Example #1
0
    public void StoreInfo()
    {
        GameObject data = GameObject.FindGameObjectWithTag("GameData");

        if (data != null)
        {
            PlayerStateStorage store = data.GetComponent <PlayerStateStorage>();
            string             ret   = "null";
            System.Type        t;
            if (weapon != null)
            {
                t = weapon.GetType();
                if (t == typeof(DaggerWeapon))
                {
                    ret = "dagger";
                }
                else if (t == typeof(LongswordWeapon))
                {
                    ret = "longsword";
                }
                else if (t == typeof(GunWeapon))
                {
                    ret = "gun";
                }
            }
            int coins  = pcc.Coins();
            int health = GetComponent <PlayerHealthController>().GetHealth();

            Debug.Log("Stored some game info: " + coins + " " + health + " " + ret);

            store.StoreInfo(coins, ret, health);
        }
    }
Example #2
0
        public static List <SkillListItemView.Item> GetItems(
            SkillStorage skillStorage,
            PlayerStateStorage playerStateStorage,
            SkillHelperStorage skillHelperStorage,
            Translator translator)
        {
            itemsBuffer.Clear();
            currentSkillsBuffer.Clear();
            BaseSkill[] baseSkills      = skillStorage.GetAllBase();
            PlayerState playerState     = playerStateStorage.Get();
            List <int>  currentSkillIds = playerState.SkillIds;

            for (int i = 0; i < currentSkillIds.Count; ++i)
            {
                Skill currentSkill = skillStorage.Get(currentSkillIds[i]);
                currentSkillsBuffer.Add(currentSkill.BaseId, currentSkill);
            }

            for (int i = 0; i < baseSkills.Length; ++i)
            {
                itemsBuffer.Add(GetItem(
                                    baseSkills[i],
                                    currentSkillsBuffer,
                                    playerState,
                                    skillStorage,
                                    skillHelperStorage,
                                    translator
                                    ));
            }

            return(itemsBuffer);
        }
Example #3
0
        private void OnServerConnectSuccess()
        {
            if (Server.IsLoggedIn)
            {
                PlayerStateStorage.Sync(Server, OnPlayerSync, OnPlayerSync);
                return;
            }

            ShowMainScreen();
        }
Example #4
0
        public void OnResurrectBtnClick()
        {
            PlayerState playerState = PlayerStateStorage.Get();

            --playerState.AvailableResurrectionsCount;
            PlayerStateStorage.Save(playerState);
            player.IsHealthFreezed = false;
            player.IsScoreFreezed  = false;
            player.Resurrect();
            GameOverScreen.GetComponent <ShowableView>().Hide();
        }
Example #5
0
        private void RewardPlayer(PlayerState playerState)
        {
            int addResurrectionsCount = RewardManager.Give(playerState);

            PlayerStateStorage.Save(playerState);
            var popup = (ScreenSpacePopupView)PopupManager.Get(
                CommonPopupType);

            popup.Msg.text = Translator.Translate(
                "Notification.RewardEarn", addResurrectionsCount);
            PopupManager.Show(popup);
        }
Example #6
0
        public void OnStart(Evt evt)
        {
            // DebugUtils.Log("AppController.OnStart()");
            PlayerState playerState = PlayerStateStorage.Get();

            if (playerState == null)
            {
                playerState = new PlayerState();
                PlayerStateStorage.Save(playerState);
            }

            Server.Connect(OnServerConnectSuccess, OnServerConnectFail);
        }
Example #7
0
        public void OnConstruct()
        {
            GameOverScreen.ResurrectTextTemplate =
                Translator.Translate("GameOverMenu.Resurrect");
            GameOverScreen.RewardTextTemplate =
                Translator.Translate("GameOverMenu.Reward");
            PlayerState playerState = PlayerStateStorage.Get();

            if (playerState != null)
            {
                UpdateScreen(playerState);
            }
        }
Example #8
0
        private void ShowMainScreen()
        {
            PlayerState playerState = PlayerStateStorage.Get();

            if (RewardManager.IsTimeToUnlock(playerState))
            {
                int unlockedRewardsCount = RewardManager.Unlock(playerState);
                var popup = (ScreenSpacePopupView)PopupManager.Get(
                    CommonPopupType);
                popup.Msg.text = Translator.Translate(
                    "Notification.RewardUnlock", unlockedRewardsCount);
                PopupManager.Show(popup);
            }

            playerState.LastSeenDate = DateTime.UtcNow;
            PlayerStateStorage.Save(playerState);
            MainScreen.GetComponent <ShowableView>().Show();
        }
Example #9
0
    void Start()
    {
        if (smu == null)
        {
            Debug.Log("Updater Isn't configured correctly.");
        }

        GameObject data = GameObject.FindGameObjectWithTag("GameData");

        if (data != null)
        {
            PlayerStateStorage store = data.GetComponent <PlayerStateStorage>();

            pcc.AddCoins(store.GetCoins());
            GetComponent <PlayerHealthController>().SetHealth(store.GetHealth());
            string w = store.GetWeapon();

            if (w == "dagger")
            {
                SetWeapon <DaggerWeapon>();
            }
            else if (w == "longsword")
            {
                SetWeapon <LongswordWeapon>();
            }
            else if (w == "gun")
            {
                SetWeapon <GunWeapon>();
            }
            else
            {
                SetWeapon <DaggerWeapon>();
            }

            // SetWeapon();
        }
        else
        {
            SetWeapon <DaggerWeapon>();
        }
    }
        public override void InitBindings(DiContainer container)
        {
            PlayerStateStorage finalPlayerStateStorage = playerStateStorage;

            if (Debug.isDebugBuild && isPlayerStateStorageStubbed)
            {
                finalPlayerStateStorage = playerStateStorageStub;
            }

            container.Bind <PlayerStateStorage>()
            .ToSingleMethod((InjectContext context) => {
                context.Container.Inject(finalPlayerStateStorage);
                return(finalPlayerStateStorage);
            });
            container.Bind <GiftManager>()
            .ToSingleMethod((InjectContext context) => {
                context.Container.Inject(giftManager);
                return(giftManager);
            });
            container.Bind <RewardManager>()
            .ToSingleMethod((InjectContext context) => {
                context.Container.Inject(rewardManager);
                return(rewardManager);
            });
            container.Bind <GameObject>("HUDWrapper").ToInstance(hudWrapper);
            container.Bind <int>("ScoreWorldPopupType")
            .ToInstance(scoreWorldPopupType);
            container.Bind <int>("ResurrectionWorldPopupType")
            .ToInstance(resurrectionWorldPopupType);
            container.Bind <int>("RewardWorldPopupType")
            .ToInstance(rewardWorldPopupType);
            container.Bind <int>("SpeechWorldPopupType")
            .ToInstance(speechWorldPopupType);
            container.Bind <int>("DamageWorldPopupType")
            .ToInstance(damageWorldPopupType);
            container.Bind <HUDScoreController>().ToSingle();
            container.Bind <HUDHealthController>().ToSingle();
            container.Bind <HUDNotificationsController>().ToSingle();
            container.Bind <PlayerManager>().ToSingle();
        }
Example #11
0
 private void OnAdView(Ad ad)
 {
     ad.OnView -= OnAdView;
     RewardPlayer(PlayerStateStorage.Get());
 }