Esempio n. 1
0
        private void DecideBattle()
        {
            VisualDebug.WriteLine($"Original input: {string.Join(",", pattern)}");
            VisualDebug.WriteLine($"Player input:   {string.Join(",", playerSelection)}");
            currentScreen = 2;

            int    energyRank     = GetEnergyRank();
            int    rewardCategory = GetRewardCategory();
            Reward reward         = GetRandomReward(rewardCategory);

            //To prevent abusing jackpot to level up fast, level up/down is restricted to certain conditions.
            //If those conditions aren't met, they are replaced with increase/reduce distance.
            if (reward == Reward.LevelDown && gm.logicMgr.GetPlayerLevelProgression() > 0.5f ||
                reward == Reward.ForceLevelDown && gm.logicMgr.GetPlayerLevelProgression() == 0f)
            {
                reward = Reward.IncreaseDistance500;
            }
            else if (reward == Reward.LevelUp && gm.logicMgr.GetPlayerLevelProgression() < 0.5f ||
                     reward == Reward.ForceLevelUp && gm.logicMgr.GetPlayerLevelProgression() == 0f)
            {
                reward = Reward.ReduceDistance500;
            }

            Sprite[] friendlySprites = gm.spriteDB.GetAllDigimonBattleSprites(friendlyDigimon, energyRank);

            //Play animations of the battle against the box.
            gm.EnqueueAnimation(Animations.LaunchAttack(friendlySprites, 0, false, false));
            gm.EnqueueAnimation(Animations.AttackCollision(0, friendlySprites, 3, null, 0));

            if (rewardCategory < 2)
            {
                gm.EnqueueAnimation(Animations.BoxResists(friendlyDigimon));
            }
            else
            {
                gm.EnqueueAnimation(Animations.DestroyBox());
                if (Random.Range(0, 20) > gm.JackpotValue)
                {
                    reward = Reward.Empty;
                }
            }

            //Apply the reward and play its animation.
            if (reward == Reward.Empty)
            {
                gm.EnqueueRewardAnimation(reward, null, null, null);
            }
            else if (reward == Reward.PunishDigimon)
            {
                gm.logicMgr.ApplyReward(reward, friendlyDigimon, out object resultBefore, out object resultAfter);
                gm.EnqueueRewardAnimation(reward, friendlyDigimon, resultBefore, resultAfter);
            }
            else if (reward == Reward.RewardDigimon)
            {
                gm.logicMgr.ApplyReward(reward, null, out object resultBefore, out object resultAfter);
                gm.EnqueueRewardAnimation(reward, null, resultBefore, resultAfter);
            }
            else if (reward == Reward.UnlockDigicodeOwned)
            {
                gm.logicMgr.ApplyReward(reward, null, out object resultBefore, out object resultAfter);
                gm.EnqueueRewardAnimation(reward, null, resultBefore, resultAfter);
            }
            else if (reward == Reward.UnlockDigicodeNotOwned)
            {
                gm.logicMgr.ApplyReward(reward, null, out object resultBefore, out object resultAfter);
                gm.EnqueueRewardAnimation(reward, null, resultBefore, resultAfter);
            }
            else if (reward == Reward.TriggerBattle)
            {
                gm.EnqueueAnimation(TriggerBattle());
                return;
            }
            else
            {
                gm.logicMgr.ApplyReward(reward, null, out object resultBefore, out object resultAfter);
                gm.EnqueueRewardAnimation(reward, null, resultBefore, resultAfter);
            }

            CloseApp(Screen.GamesRewardMenu);
        }