예제 #1
0
    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);
    }
예제 #2
0
    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);
    }
예제 #3
0
    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);
    }
예제 #4
0
    public static void Load()
    {
        // =============================== Start coins with 0 ================================ //
        //  Coins = double.Parse (LoadPref (KeyCoins, "0"));

        // =============================== Start with coins unit 0 ================================ //
        //  CoinUnit = LoadPref (KeyCoinsUnit, 0);

        // =============================== Start food with 0 ================================ //
        Food = double.Parse(LoadPref(KeyFood, "0"));

        // =============================== Start with food unit 0 ================================ //
        FoodUnit = LoadPref(KeyFoodUnit, 0);

        // =============================== Start with level unlocked is 1 ================================ //
        //LastLevelUnlocked = LoadPref (KeyLevelUnlocked, 1);

        // =============================== Start with number diamonds is zero ================================ //
        Diamonds = LoadPref(KeyDiamonds, 0);

        // =============================== Start with number of coca is zero ================================ //
        Coca = double.Parse(LoadPref(KeyCoca, "0"));

        // =============================== Get the unit of coca ================================ //
        CocaUnit = LoadPref(KeyCocaUnit, 0);

        // =============================== Start with level is 1 ================================ //
        Level = LoadPref(KeyLevel, 1);

        // =============================== Start with round 1 ================================ //
        LevelRound = LoadPref(KeyLevelRound, 1);

        // =============================== Get High level round ================================ //
        HighLevelRound = LoadPref(KeyHighLevelRound, 1);

        // =============================== Save Time Speed Up ================================ //
        TotalTimeSpeedUp = LoadPref(KeyTimeTotalSpeedUp, 0);

        // =============================== Save time for more cash ================================ //
        TotalTimeMoreCash = LoadPref(KeyTimeTotalMoreCash, 0);

        // =============================== Save Time Multi Reward Coins ================================ //
        TotalTimeMultiRewardCoins = LoadPref(KeyTotalTimeMultiRewardCoins, 0);

        // =============================== Start Exp With 0 ================================ //
        Exp = LoadPref(KeyExp, 0);

        // =============================== Add Shop Profit item ================================ //
        ShopItemProfitPercent = new List <int> ();

        var total = GameConfig.TotalItem;

        for (int i = 0; i < total; i++)
        {
            ShopItemProfitPercent.Add(LoadPref(string.Format(KeyNumberBuyItem, i.ToString()), 0));
        }

        // =============================== Add shop upgrade profit item ================================ //

        ShopItemUpgradeProfitPercent = new List <int> ();

        total = GameConfig.TotalItem;

        for (int i = 0; i < total; i++)
        {
            ShopItemUpgradeProfitPercent.Add(LoadPref(string.Format(KeyNumberUpgradeItem, i.ToString()), 0));
        }

        _LastCocaSaved     = Coca;
        _LastCocaUnitSaved = CocaUnit;

        // _LastCoinSaved     = Coins;
        // _LastCoinUnitSaved = CoinUnit;

        // =============================== Load Last Time Online ================================ //
        _LastTimeOnline = LoadPref(KeyTimeOnline, Helper.GetUtcTimeString());

        // =============================== Load Last Time Spin ================================ //
        _LastTimeSpinLucky = LoadPref(KeyTimeSpinLucky, Helper.GetDefaultUTCTimeString());

        // =============================== Get the number turn spin of player ================================ //
        _LastNumberTurnSpin = LoadPref(KeyNumberTurnSpin, GameConfig.MaxNumberTurnForSpin);

        // =============================== Time Watch Ads For Free Diamonds ================================ //
        _LastTimeWatchAdsForFreeDiamonds = LoadPref(KeyWatchAdsForFreeDiamonds, Helper.GetDefaultUTCTimeString());

        // =============================== Time appear bonus reward ================================ //
        _LastTimeAppearBonusReward = LoadPref(KeyLastTimeAppearBonusReward, Helper.GetDefaultUTCTimeString());

        // =============================== Time appear multi reward coins ================================ //
        _LastTimeMultiRewardCoins = LoadPref(KeyLastTimeMultiRewardCoins, Helper.GetDefaultUTCTimeString());

        // =============================== Time appear new quest ================================ //
        _LastTimeDailyQuest = LoadPref(KeyTimeDailyQuest, Helper.GetDefaultUTCTimeString());

        // =============================== Time appear bonus currency ================================ //
        _LastTimeAppearBonusCurrency = LoadPref(KeyLastTimeAppearBonusCurrency, Helper.GetDefaultUTCTimeString());

        // =============================== Time for speed up ================================ //
        _LastTimeForSpeedUp = LoadPref(KeyTimeForSpeedUp, Helper.GetDefaultUTCTimeString());

        // =============================== Time for watch ads ================================ //
        _LastTimeForMoreCash = LoadPref(KeyTimeForMoreCash, Helper.GetDefaultUTCTimeString());

        // =============================== Add the tutorials ================================ //

        TutorialId = new List <int> ();

        var size = TutorialEnums.GetSizeTutorial();

        for (int i = 0; i < size; i++)
        {
            TutorialId.Add(LoadPref(string.Format(KeyTutorialId, i.ToString()), 0));
        }

        // =============================== Load The default language ================================ //
        DefaultLanguage = LoadPref(KeyDefaultLanguage, LanguageEnums.GetLanguageSupportDefault());

        // =============================== Add the mission value ================================ //

        MissionId = new List <int> ();

        size = MissionEnums.GetSize();

        for (int i = 0; i < size; i++)
        {
            MissionId.Add(LoadPref(string.Format(KeyMissionId, i.ToString()), 0));
        }

        // =============================== Add the mission level ================================ //

        MissionLevel = new List <int> ();

        size = MissionEnums.GetSize();

        for (int i = 0; i < size; i++)
        {
            MissionLevel.Add(LoadPref(string.Format(KeyMissionLevel, i.ToString()), 0));
        }

        // =============================== Load the equipment upgrade ================================ //

        EquipmentUpgrade = new List <int> ();

        size = EquipmentEnums.GetLength();

        for (int i = 0; i < size; i++)
        {
            EquipmentUpgrade.Add(LoadPref(string.Format(KeyEquipmentUpgrade, i.ToString()), 0));
        }

        // =============================== Load Unlock Node Grids ================================ //

        UnlockGrid = new List <int> ();

        length_unlock_grid = LoadPref(KeyLengthUnlockGrid, 0);

        for (int i = 0; i < length_unlock_grid; i++)
        {
            UnlockGrid.Add(LoadPref(string.Format(KeyUnlockGrid, i), 0));
        }

        // =============================== Get the last the state watch ads for spin ================================ //

        IsWatchAdsForSpin = LoadPref(KeyWatchAdsForSpin, 0) == 1;
    }