| | |
| | | Dictionary<int, AlchemyDrugUseLimit> m_AlchemyDrugUseLimits = new Dictionary<int, AlchemyDrugUseLimit>();
|
| | | List<int> m_AlchemyDrugs = new List<int>();
|
| | | List<int> m_AlchemyDrugQualitys = new List<int>();
|
| | | List<int> m_AssociationItems = new List<int>();
|
| | |
|
| | | public readonly Redpoint redpoint = new Redpoint(MainRedDot.RedPoint_key, 110);
|
| | | public readonly Redpoint alchemyDrugRedpoint1 = new Redpoint(110, 11001);
|
| | | public readonly Redpoint alchemyDrugRedpoint2 = new Redpoint(110, 11002);
|
| | | Dictionary<int, Dictionary<int, Redpoint>> alchemyQualityRedpoints = new Dictionary<int, Dictionary<int, Redpoint>>();
|
| | | Dictionary<int, AlchemyRedpoint> alchemyRedpoints = new Dictionary<int, AlchemyRedpoint>();
|
| | |
|
| | | public static int redpointIndex = 110010000;
|
| | |
|
| | | int m_SelectQuality = 0;
|
| | | public int selectQuality
|
| | |
| | |
|
| | | public bool isServerPrepare { get; private set; }
|
| | |
|
| | | Clock m_AlchemingClock = null;
|
| | |
|
| | | public event Action selectQualityRefresh;
|
| | | public event Action selectAlchemyRefresh;
|
| | | public event Action alchemyStateRefresh;
|
| | |
| | |
|
| | | public override void Init()
|
| | | {
|
| | | FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
|
| | | PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefreshEvent;
|
| | | packModel.refreshItemCountEvent += RefreshItemCountEvent;
|
| | |
|
| | | ParseConfig();
|
| | | }
|
| | |
|
| | |
| | | public void OnPlayerLoginOk()
|
| | | {
|
| | | isServerPrepare = true;
|
| | | CheckRedpoint();
|
| | | }
|
| | |
|
| | | public override void UnInit()
|
| | | {
|
| | | FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
|
| | | PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefreshEvent;
|
| | | packModel.refreshItemCountEvent -= RefreshItemCountEvent;
|
| | | }
|
| | |
|
| | | private void RefreshItemCountEvent(PackType packType, int arg2, int itemId)
|
| | | {
|
| | | if (m_AssociationItems.Contains(itemId))
|
| | | {
|
| | | CheckRedpoint();
|
| | | }
|
| | | }
|
| | |
|
| | | private void PlayerDataRefreshEvent(PlayerDataType dataType)
|
| | | {
|
| | | if (dataType == PlayerDataType.LuckValue)
|
| | | {
|
| | | CheckRedpoint();
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnFuncStateChangeEvent(int id)
|
| | | {
|
| | | if (id == (int)FuncOpenEnum.BlastFurnace)
|
| | | {
|
| | | CheckRedpoint();
|
| | | }
|
| | | }
|
| | |
|
| | | void ParseConfig()
|
| | |
| | | id = key,
|
| | | count = dict[key],
|
| | | });
|
| | |
|
| | | if (!m_AssociationItems.Contains(key))
|
| | | {
|
| | | m_AssociationItems.Add(key);
|
| | | }
|
| | | }
|
| | |
|
| | | if (!m_AssociationItems.Contains(config.LearnNeedItemID))
|
| | | {
|
| | | m_AssociationItems.Add(config.LearnNeedItemID);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | m_AlchemyDrugQualitys.Sort();
|
| | | }
|
| | |
|
| | | var qualitys = AlchemyConfig.GetAlchemyQualities((int)AlchemyType.Normal);
|
| | | alchemyQualityRedpoints.Add((int)AlchemyType.Normal, new Dictionary<int, Redpoint>());
|
| | | foreach (var quality in qualitys)
|
| | | {
|
| | | var qualityRedpoint = new Redpoint(alchemyDrugRedpoint1.id, redpointIndex++); ;
|
| | | alchemyQualityRedpoints[(int)AlchemyType.Normal].Add(quality, qualityRedpoint);
|
| | | var alchemys = AlchemyConfig.GetAlchemies((int)AlchemyType.Normal, quality);
|
| | | foreach (var id in alchemys)
|
| | | {
|
| | | alchemyRedpoints.Add(id, new AlchemyRedpoint(qualityRedpoint.id));
|
| | | }
|
| | | }
|
| | |
|
| | | qualitys = AlchemyConfig.GetAlchemyQualities((int)AlchemyType.Fairy);
|
| | | alchemyQualityRedpoints.Add((int)AlchemyType.Fairy, new Dictionary<int, Redpoint>());
|
| | | foreach (var quality in qualitys)
|
| | | {
|
| | | var qualityRedpoint = new Redpoint(alchemyDrugRedpoint2.id, redpointIndex++); ;
|
| | | alchemyQualityRedpoints[(int)AlchemyType.Fairy].Add(quality, qualityRedpoint);
|
| | | var alchemys = AlchemyConfig.GetAlchemies((int)AlchemyType.Fairy, quality);
|
| | | foreach (var id in alchemys)
|
| | | {
|
| | | alchemyRedpoints.Add(id, new AlchemyRedpoint(qualityRedpoint.id));
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | public bool TryGetAlchemyUseLimit(int id,out AlchemyDrugUseLimit drugUseLimit)
|
| | | {
|
| | | return m_AlchemyDrugUseLimits.TryGetValue(id, out drugUseLimit);
|
| | | }
|
| | |
|
| | | public int GetAlchemyRedpointId(int id)
|
| | | {
|
| | | return alchemyRedpoints.ContainsKey(id) ? alchemyRedpoints[id].redpoint.id : 0;
|
| | | }
|
| | |
|
| | | public int GetQualityRedpointId(int alchemyType, int quality)
|
| | | {
|
| | | if (alchemyQualityRedpoints.ContainsKey(alchemyType))
|
| | | {
|
| | | if (alchemyQualityRedpoints[alchemyType].ContainsKey(quality))
|
| | | {
|
| | | return alchemyQualityRedpoints[alchemyType][quality].id;
|
| | | }
|
| | | }
|
| | | return 0;
|
| | | }
|
| | |
|
| | | public float GetAlchemySuccRate(int alchemyId)
|
| | |
| | | return true;
|
| | | }
|
| | |
|
| | | public bool IsStoveAlcheming(AlchemyType alchemyType)
|
| | | public bool IsStoveAlcheming(AlchemyType alchemyType, out Int2 alchemyPosition)
|
| | | {
|
| | | alchemyPosition = default(Int2);
|
| | | var qualities = AlchemyConfig.GetAlchemyQualities((int)alchemyType);
|
| | | foreach (var quality in qualities)
|
| | | {
|
| | |
| | | var state = GetStoveState(alchemyId);
|
| | | if (state != 0)
|
| | | {
|
| | | alchemyPosition.x = quality;
|
| | | alchemyPosition.y = alchemyId;
|
| | | return true;
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | public void ReceivePackage(HA3BF_tagMCPlayerStoveMsg package)
|
| | | {
|
| | | var seconds = 0;
|
| | |
|
| | | for (int i = 0; i < package.StoveCnt; i++)
|
| | | {
|
| | | var data = package.InfoList[i];
|
| | | m_AlchemyTimes[(int)data.AlchemyID] = data.StartTime;
|
| | |
|
| | | if (data.StartTime > 0)
|
| | | {
|
| | | var config = AlchemyConfig.Get((int)data.AlchemyID);
|
| | | var time = TimeUtility.GetTime(data.StartTime);
|
| | | var _seconds = (int)(TimeUtility.ServerNow - time).TotalSeconds;
|
| | | if (_seconds < config.NeedTime && config.NeedTime - _seconds > seconds)
|
| | | {
|
| | | seconds = config.NeedTime - _seconds;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (m_AlchemingClock != null)
|
| | | {
|
| | | Clock.Stop(m_AlchemingClock);
|
| | | m_AlchemingClock = null;
|
| | | }
|
| | | if (seconds > 0)
|
| | | {
|
| | | m_AlchemingClock = Clock.AlarmAfter(seconds, CheckRedpoint);
|
| | | }
|
| | |
|
| | | stoveLevel = package.StoveLV;
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | CheckRedpoint();
|
| | |
|
| | | if (alchemyStateRefresh != null)
|
| | | {
|
| | |
| | | if (alchemyDrugUseRefresh != null)
|
| | | {
|
| | | alchemyDrugUseRefresh();
|
| | | }
|
| | | }
|
| | |
|
| | | static List<int> s_Endables = new List<int>();
|
| | | static List<int> s_Studyables = new List<int>();
|
| | | static List<int> s_Alchemyables = new List<int>();
|
| | |
|
| | | static Dictionary<AlchemyType, List<int>> s_SortQualitys = new Dictionary<AlchemyType, List<int>>();
|
| | |
|
| | | public List<int> GetSortQualitys(AlchemyType alchemyType)
|
| | | {
|
| | | if (!s_SortQualitys.ContainsKey(alchemyType))
|
| | | {
|
| | | s_SortQualitys.Add(alchemyType, new List<int>(AlchemyConfig.GetAlchemyQualities((int)alchemyType)));
|
| | | s_SortQualitys[alchemyType].Sort(QualityCompare);
|
| | | }
|
| | | return s_SortQualitys[alchemyType];
|
| | | }
|
| | |
|
| | | private int QualityCompare(int x, int y)
|
| | | {
|
| | | return -x.CompareTo(y);
|
| | | }
|
| | |
|
| | | void CheckRedpoint()
|
| | | {
|
| | | s_Endables.Clear();
|
| | | s_Studyables.Clear();
|
| | | s_Alchemyables.Clear();
|
| | |
|
| | | if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.BlastFurnace))
|
| | | {
|
| | | RefreshRedpoint();
|
| | | return;
|
| | | }
|
| | |
|
| | | CheckRedpoint(AlchemyType.Normal);
|
| | | CheckRedpoint(AlchemyType.Fairy);
|
| | |
|
| | | RefreshRedpoint();
|
| | | }
|
| | |
|
| | | void CheckRedpoint(AlchemyType alchemyType)
|
| | | {
|
| | | Int2 position;
|
| | | if (IsStoveAlcheming(alchemyType, out position))
|
| | | {
|
| | | var state = GetStoveState(position.y);
|
| | | if (state == 2)
|
| | | {
|
| | | s_Endables.Add(position.y);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | var qualitys = AlchemyConfig.GetAlchemyQualities((int)alchemyType);
|
| | | foreach (var quality in qualitys)
|
| | | {
|
| | | var alchemys = AlchemyConfig.GetAlchemies((int)alchemyType, quality);
|
| | | foreach (var id in alchemys)
|
| | | {
|
| | | if (!IsGraspRecipe(id))
|
| | | {
|
| | | var config = AlchemyConfig.Get(id);
|
| | | var count = packModel.GetItemCountByID(PackType.Item, config.LearnNeedItemID);
|
| | | if (count <= 0 || stoveLevel < config.LearnNeedAlchemLV
|
| | | || PlayerDatas.Instance.extersion.luckValue < config.LearnNeedLuck)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | s_Studyables.Add(id);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | qualitys = GetSortQualitys(alchemyType);
|
| | | foreach (var quality in qualitys)
|
| | | {
|
| | | var alchemyable = false;
|
| | | var alchemys = AlchemyConfig.GetAlchemies((int)alchemyType, quality);
|
| | | foreach (var id in alchemys)
|
| | | {
|
| | | if (!IsGraspRecipe(id))
|
| | | {
|
| | | continue;
|
| | | }
|
| | | Item item;
|
| | | if (IsAlchemyEnoughMaterial(id, out item))
|
| | | {
|
| | | s_Alchemyables.Add(id);
|
| | | alchemyable = true;
|
| | | }
|
| | | }
|
| | |
|
| | | if (alchemyable)
|
| | | {
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | void RefreshRedpoint()
|
| | | {
|
| | | var qualitys = AlchemyConfig.GetAlchemyQualities((int)AlchemyType.Normal);
|
| | | foreach (var quality in qualitys)
|
| | | {
|
| | | var alchemys = AlchemyConfig.GetAlchemies((int)AlchemyType.Normal, quality);
|
| | | foreach (var id in alchemys)
|
| | | {
|
| | | var redpoint = alchemyRedpoints[id];
|
| | | redpoint.studyRedpoint.state = s_Studyables.Contains(id) ? RedPointState.Simple : RedPointState.None;
|
| | | redpoint.endRedpoint.state = s_Endables.Contains(id) ? RedPointState.Simple : RedPointState.None;
|
| | | redpoint.alchemyRedpoint.state = s_Alchemyables.Contains(id) ? RedPointState.Simple : RedPointState.None;
|
| | | }
|
| | | }
|
| | |
|
| | | qualitys = AlchemyConfig.GetAlchemyQualities((int)AlchemyType.Fairy);
|
| | | foreach (var quality in qualitys)
|
| | | {
|
| | | var alchemys = AlchemyConfig.GetAlchemies((int)AlchemyType.Fairy, quality);
|
| | | foreach (var id in alchemys)
|
| | | {
|
| | | var redpoint = alchemyRedpoints[id];
|
| | | redpoint.studyRedpoint.state = s_Studyables.Contains(id) ? RedPointState.Simple : RedPointState.None;
|
| | | redpoint.endRedpoint.state = s_Endables.Contains(id) ? RedPointState.Simple : RedPointState.None;
|
| | | redpoint.alchemyRedpoint.state = s_Alchemyables.Contains(id) ? RedPointState.Simple : RedPointState.None;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | return 0;
|
| | | }
|
| | | }
|
| | |
|
| | | public class AlchemyRedpoint
|
| | | {
|
| | | public readonly Redpoint redpoint;
|
| | | public readonly Redpoint studyRedpoint;
|
| | | public readonly Redpoint endRedpoint;
|
| | | public readonly Redpoint alchemyRedpoint;
|
| | |
|
| | | public AlchemyRedpoint(int baseId)
|
| | | {
|
| | | redpoint = new Redpoint(baseId, AlchemyModel.redpointIndex++);
|
| | | studyRedpoint = new Redpoint(redpoint.id, AlchemyModel.redpointIndex++);
|
| | | endRedpoint = new Redpoint(redpoint.id, AlchemyModel.redpointIndex++);
|
| | | alchemyRedpoint = new Redpoint(redpoint.id, AlchemyModel.redpointIndex++);
|
| | | }
|
| | | }
|
| | | } |
| | | |