private void OnGetRewardCompleted(MissionEnums.MissionId id, int level) { ClearData(id); RefreshData(); this.PostActionEvent(ActionEnums.ActionID.RefreshLayoutMission, (int)id); }
private void SetQuantity(MissionEnums.MissionId id, int quantity) { for (int i = 0; i < _Missions.Count; i++) { var item = _Missions[i]; if (item.MissionId == id) { if (item.IsMax) { return; } item.Quantity += quantity; if (item.Quantity >= item.MissionProperty.QuantityTarget) { item.IsMax = true; item.Quantity = item.MissionProperty.QuantityTarget; } PlayerData.SaveMissionValue(item.MissionId, item.Quantity); break; } } }
public string GetDescription(MissionEnums.MissionId id, MissionData.MissionProperty data) { switch (id) { case MissionEnums.MissionId.None: return(string.Empty); case MissionEnums.MissionId.Merge: return(string.Format(ApplicationLanguage.Text_description_mission_merge, data.QuantityTarget.ToString())); case MissionEnums.MissionId.GetBonus: return(string.Format(ApplicationLanguage.Text_description_mission_get_bonus, data.QuantityTarget.ToString())); case MissionEnums.MissionId.UpgradeItem: return(string.Format(ApplicationLanguage.Text_description_mission_upgrade_item, data.QuantityTarget.ToString())); case MissionEnums.MissionId.BuyItem: return(string.Format(ApplicationLanguage.Text_description_mission_buy_item, data.QuantityTarget.ToString())); case MissionEnums.MissionId.TapOnItem: return(string.Format(ApplicationLanguage.Text_description_mission_tap_item, data.QuantityTarget.ToString())); case MissionEnums.MissionId.TapOnBox: return(string.Format(ApplicationLanguage.Text_description_mission_tap_box, data.QuantityTarget.ToString())); default: return(string.Empty); } }
public static MissionEventDispatcher RemoveMissionEvent(this MonoBehaviour mono, MissionEnums.MissionId missionId, System.Action <object> callback) { if (ReferenceEquals(MissionEventDispatcher.InstanceAwake(), null)) { LogGame.Error("[Mission Event] Mission Event Dispatcher Is Null!"); return(null); } return(MissionEventDispatcher.Instance.RemoveEvent(missionId, callback)); ; }
public Sprite GetIcon(MissionEnums.MissionId missionId) { for (int i = 0; i < _MissionIconProperties.Length; i++) { if (_MissionIconProperties[i].MissionId == missionId) { return(_MissionIconProperties[i].Icon); } } return(null); }
public Mission GetMissionData(MissionEnums.MissionId id) { for (int i = 0; i < _Missions.Count; i++) { if (_Missions[i].MissionId == id) { return(_Missions[i]); } } return(null); }
public int GetQuantityTarget(MissionEnums.MissionId id) { for (int i = 0; i < _Missions.Count; i++) { if (_Missions[i].MissionId == id) { return(_Missions[i].MissionProperty.QuantityTarget); } } return(0); }
public int GetQuantity(MissionEnums.MissionId id) { for (int i = 0; i < _Missions.Count; i++) { if (_Missions[i].MissionId == id) { return(_Missions[i].Quantity); } } return(0); }
public bool IsSameLevelTarget(MissionEnums.MissionId id, int level) { for (int i = 0; i < _Missions.Count; i++) { var item = _Missions[i]; if (item.MissionId == id && item.MissionProperty.LevelTarget == level) { return(true); } } return(false); }
public void OnGetReward(MissionEnums.MissionId id) { var level = 0; for (int i = 0; i < _Missions.Count; i++) { var item = _Missions[i]; if (item.MissionId == id) { level = item.MissionProperty.Level; var rewards = item.MissionProperty._MissionReward; for (int j = 0; j < rewards.Length; j++) { var reward = rewards[j]; switch (reward.RewardId) { case RewardEnums.RewardId.X5RewardCoins: OnGetX5RewardCoins(reward.Value); break; case RewardEnums.RewardId.Diamonds: OnGetDiamonds(reward.Value); break; case RewardEnums.RewardId.SpeedUp: OnGetSpeedUp(reward.Value); break; case RewardEnums.RewardId.Box: OnGetBox(reward.Value); break; case RewardEnums.RewardId.Cash: OnGetCash(reward.Value, reward.Unit); break; default: throw new ArgumentOutOfRangeException(); } } } } OnGetRewardCompleted(id, level); }
public static MissionEventDispatcher PostMissionEvent(this MonoBehaviour mono, MissionEnums.MissionId missionId, object param = null) { if (PlayerData.Level < GameConfig.UnlockMissionLevel) { return(null); } if (ReferenceEquals(MissionEventDispatcher.InstanceAwake(), null)) { LogGame.Error("[Mission Event] Mission Event Dispatcher Is Null!"); return(null); } return(MissionEventDispatcher.Instance.PostEvent(missionId, param)); ; }
public MissionEventDispatcher PostEvent(MissionEnums.MissionId missionId, object param) { if (!_PoolEvent.TryGetValue(MissionEnums.GetKey(missionId), out paramOut)) { return(this); } if (ReferenceEquals(paramOut, null)) { _PoolEvent.Remove(MissionEnums.GetKey(missionId)); return(this); } paramOut(param); LogGame.Log(string.Format("[Action Manager] Post the event with ID: {0}", MissionEnums.GetKey(missionId))); return(this); }
public MissionEventDispatcher RemoveEvent(MissionEnums.MissionId missionId, System.Action <object> action) { if (_PoolEvent.TryGetValue(MissionEnums.GetKey(missionId), out paramOut)) { paramOut -= action; _PoolEvent[MissionEnums.GetKey(missionId)] = paramOut; LogGame.Log(string.Format("[Mission Manager] Remove the event with ID: {0}", MissionEnums.GetKey(missionId))); } else { LogGame.Log(string.Format("[Mission Manager] Not Found the event with ID: {0}", MissionEnums.GetKey(missionId))); } return(this); }
public bool IsMaxMission(MissionEnums.MissionId id, int level) { for (int i = 0; i < DailyQuest.Length; i++) { if (DailyQuest[i].GetId() == id && !DailyQuest[i].IsMaxLevel(level)) { return(false); } } for (int i = 0; i < MissionData.Length; i++) { if (MissionData[i].GetId() == id && !MissionData[i].IsMaxLevel(level)) { return(false); } } return(true); }
public MissionEventDispatcher RegisterEvent(MissionEnums.MissionId missionId, System.Action <object> action) { if (_PoolEvent.TryGetValue(MissionEnums.GetKey(missionId), out paramOut)) { paramOut += action; _PoolEvent[MissionEnums.GetKey(missionId)] = paramOut; } else { paramOut += action; _PoolEvent.Add(MissionEnums.GetKey(missionId), paramOut); } LogGame.Log(string.Format("[Mission Manager] Register the new event with ID: {0}", MissionEnums.GetKey(missionId))); return(this); }
private void ClearData(MissionEnums.MissionId id) { for (int j = 0; j < _Missions.Count(); j++) { var mission = _Missions[j]; if (mission.IsMax && mission.MissionId == id) { var level = PlayerData.GetMissionLevel(mission.MissionId) + 1; PlayerData.SaveMissionLevel(mission.MissionId, level); if (IsMaxMission(mission.MissionId, level)) { _Missions.RemoveAt(j); j--; continue; } mission.IsRefresh = true; } } }
public static int GetMissionLevel(MissionEnums.MissionId id) { return(MissionLevel[(int)id]); }
public static void SaveMissionLevel(MissionEnums.MissionId id, int level) { MissionLevel[(int)id] = level; SavePref(string.Format(KeyMissionLevel, ((int)id).ToString()), level); }
public static void SaveMissionValue(MissionEnums.MissionId id, int value) { MissionId[(int)id] = value; SavePref(string.Format(KeyMissionId, ((int)id).ToString()), value); }
public MissionItems SetId(MissionEnums.MissionId missionId) { _MissionId = missionId; return(this); }
public static int GetMissionValue(MissionEnums.MissionId id) { return(MissionId[(int)id]); }