示例#1
0
    private void OnGetRewardCompleted(MissionEnums.MissionId id, int level)
    {
        ClearData(id);
        RefreshData();

        this.PostActionEvent(ActionEnums.ActionID.RefreshLayoutMission, (int)id);
    }
示例#2
0
    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;
            }
        }
    }
示例#3
0
    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));

        ;
    }
示例#5
0
    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);
    }
示例#6
0
    public Mission GetMissionData(MissionEnums.MissionId id)
    {
        for (int i = 0; i < _Missions.Count; i++)
        {
            if (_Missions[i].MissionId == id)
            {
                return(_Missions[i]);
            }
        }

        return(null);
    }
示例#7
0
    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);
    }
示例#8
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);
    }
示例#9
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);
    }
示例#10
0
    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);
    }
示例#14
0
    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);
    }
示例#16
0
    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;
            }
        }
    }
示例#17
0
 public static int GetMissionLevel(MissionEnums.MissionId id)
 {
     return(MissionLevel[(int)id]);
 }
示例#18
0
 public static void SaveMissionLevel(MissionEnums.MissionId id, int level)
 {
     MissionLevel[(int)id] = level;
     SavePref(string.Format(KeyMissionLevel, ((int)id).ToString()), level);
 }
示例#19
0
 public static void SaveMissionValue(MissionEnums.MissionId id, int value)
 {
     MissionId[(int)id] = value;
     SavePref(string.Format(KeyMissionId, ((int)id).ToString()), value);
 }
示例#20
0
    public MissionItems SetId(MissionEnums.MissionId missionId)
    {
        _MissionId = missionId;

        return(this);
    }
示例#21
0
 public static int GetMissionValue(MissionEnums.MissionId id)
 {
     return(MissionId[(int)id]);
 }