Exemple #1
0
 private IEnumerator LoseRoutine()
 {
     GameOverUI.SetActive(true);
     GameOverTextLose.SetActive(true);
     result = EBattleResult.Loss;
     yield return(new WaitForEndOfFrame());            //HACK
 }
Exemple #2
0
        private IEnumerator WinRoutine()
        {
            GameOverUI.SetActive(true);
            result = EBattleResult.Win;

            // Do experience stuff
            Dictionary <Character, XPEvent> xpEvents = new Dictionary <Character, XPEvent>();

            foreach (Character player in characters)
            {
                // maybe check character is alive?
                if (player.experience != null)
                {
                    XPEvent xpEvent = player.experience.AddXp(xpEarned);
                    xpEvents.Add(player, xpEvent);
                }
            }
            GameOverTextWin.SetActive(true);
            Quit.gameObject.SetActive(false);
            GameOverNext.gameObject.SetActive(true);
            GameOverInfo.gameObject.SetActive(true);

            // have Next button control when coroutine proceeds
            bool wait = true;

            UnityEngine.Events.UnityAction continueAction = () => wait = false;
            System.Func <bool>             waitP          = () => { return(wait); };
            GameOverNext.onClick.AddListener(continueAction);

            GameOverInfo.text = string.Format("You gained {0} XP", xpEarned);
            //TODO more juicy XP gain UI
            foreach (KeyValuePair <Character, XPEvent> eventPair in xpEvents)
            {
                foreach (LevelUpEvent levelUp in eventPair.Value.levelUps)
                {
                    yield return(new WaitWhile(waitP));

                    wait = true;
                    GameOverInfo.text = LevelUpInfo(eventPair.Key, levelUp);
                }
            }

            GameOverNext.onClick.RemoveListener(continueAction);
            GameOverNext.gameObject.SetActive(false);
            Quit.gameObject.SetActive(true);
            yield return(new WaitForEndOfFrame());            //HACK
        }
Exemple #3
0
    protected override void DoFinishDuel(string playerId, string loginToken, string session, EBattleResult battleResult, int totalDamage, int deadCharacters, UnityAction <FinishDuelResult> onFinish)
    {
        var dict = new Dictionary <string, object>();

        dict.Add("session", session);
        dict.Add("battleResult", battleResult);
        dict.Add("totalDamage", totalDamage);
        dict.Add("deadCharacters", deadCharacters);
        PostAsDecodedJSON <FinishDuelResult>("finish-duel", (www, result) =>
        {
            onFinish(result);
        }, dict, loginToken);
    }
Exemple #4
0
        // Use this for initialization
        void Start()
        {
            //turn on feedback scripts
            FloatingTextController.DamageEnemy();
            FloatingTextController.DamageAlly();
            FloatingTextController.Miss();
            FloatingTextController.HealEnemy();
            FloatingTextController.HealAlly();

            RPG.BattleManager battleManager = RPG.BattleManager.Instance;
            battleManager.stateManager = this;
            turnBehaviour = GetComponent <TurnBehaviour>();
            decalUI       = GetComponent <DecalUI>();
            confirmMenu   = GetComponent <MoveConfirmMenu>();

            camMovement  = GetComponent <CameraMovement>();
            storeTargets = new List <Character>();

            if (camera == null)
            {
                camera = Camera.main;
            }


            characters           = new List <Character>();
            enemies              = new List <Character>();
            deadCharactersREVIVE = new List <Character>();

            // Activate own and enemy team from battleManager, and move enemy team into this scene
            battleManager.playerTeam.gameObject.SetActive(true);
            battleManager.enemyTeam.gameObject.SetActive(true);
            SceneManager.MoveGameObjectToScene(battleManager.enemyTeam.gameObject, gameObject.scene);

            enemyBehav = battleManager.enemyTeam.GetComponentsInChildren <EnemyBehaviour>(true);

            GameObject go = Instantiate(selector);

            selector = go;
            selector.SetActive(false);

            // move Selector into this scene
            SceneManager.MoveGameObjectToScene(selector, this.gameObject.scene);


            //game over menu stuff
            GameOverUI = GameObject.Find("GameOverMenu");

            GameOverTextLose = GameObject.Find("LoseText");
            GameOverTextWin  = GameObject.Find("WinText");

            GameOverUI.SetActive(false);
            GameOverNext.gameObject.SetActive(false);
            GameOverInfo.gameObject.SetActive(false);
            GameOverTextLose.SetActive(false);
            GameOverTextWin.SetActive(false);
            descriptionUI.gameObject.SetActive(false);

            //grabbing players/enemies from the scene to fill lists
            characters.AddRange(battleManager.playerTeam.GetComponentsInChildren <Character>(true));


            //sort player list based on their choiceOrder number(so you can make it that the closest one to the screen picks first ect)
            List <Character> sortedList = characters.OrderBy(o => o.ChoiceOrder).ToList();

            characters         = sortedList;
            battleUIController = GetComponent <BattleUIController>();
            battleUIController.UISetup(characters);

            //setting all characters to be inactive
            foreach (Character chara in characters)
            {
                chara.ActivePlayer = false;
            }

            //TODO place characters in scene positions based on this order (ie List<Transform> playerPositions and List<Transform> enemyPositions)

            enemies.AddRange(battleManager.enemyTeam.GetComponentsInChildren <Character>(true));

            //////PLACES CHARACTERS TO PRE-SET LOCATIONS
            foreach (Character chara in characters)
            {
                //chara.GetComponent<ButtonBehaviour>().Setup(buttonBehaviourObjects);
                chara.GetComponent <TargetSelection>().Init(this.gameObject, camera);
            }

            // place player team in set positions
            for (int i = 0; i < playerPositions.Count && i < characters.Count; ++i)
            {
                characters[i].transform.position = playerPositions[i].position;
                characters[i].transform.rotation = playerPositions[i].rotation;
            }
            //////

            List <Character> tmp = new List <Character>();

            //when battle reentered, forces any dead characters to act like it
            foreach (Character chara in characters)
            {
                if (chara.Hp <= 0)
                {
                    tmp.Add(chara);
                    Death(chara, tmp);
                }
            }

            //moving enemies into position
            for (int i = 0; i < enemyPositions.Count && i < enemies.Count; ++i)
            {
                enemies[i].transform.position = enemyPositions[i].position;
                enemies[i].transform.rotation = enemyPositions[i].rotation;
            }

            //shows enemy ui
            foreach (Character enemy in enemies)
            {
                enemy.GetComponent <EnemyUI>().enemyUISetup(uiCanvas);
            }
            foreach (Character enemy in enemies)
            {
                enemy.GetComponent <EnemyUI>().ShowUI();
            }

            turnBehaviour.Setup(characters, enemies);

            result = EBattleResult.Flee;

            // initialize XP to 0
            xpEarned = 0;

            //starting game loops
            StartCoroutine(GameLoop());
        }
    protected override void DoFinishDuel(string playerId, string loginToken, string session, EBattleResult battleResult, int deadCharacters, UnityAction <FinishDuelResult> onFinish)
    {
        var dict = new Dictionary <string, object>();

        dict.Add("session", session);
        dict.Add("battleResult", battleResult);
        dict.Add("deadCharacters", deadCharacters);
        PostAsDecodedJSON <FinishDuelResult>("/finish-duel", (www, result) =>
        {
            onFinish(result);
        }, JsonConvert.SerializeObject(dict), loginToken);
    }
Exemple #6
0
            private static void Prefix(Campaign.Battle battle, EBattleResult result)
            {
                RewardSettings rewardSettings = null;

                switch (result)
                {
                case EBattleResult.Victory:
                    rewardSettings = battle.battleSettings.victoryRewards;
                    break;

                case EBattleResult.Draw:
                    rewardSettings = battle.battleSettings.drawRewards;
                    break;

                case EBattleResult.Defeat:
                    rewardSettings = battle.battleSettings.defeatRewards;
                    break;

                case EBattleResult.Passed:
                    rewardSettings = battle.battleSettings.passedRewards;
                    break;
                }
                if (rewardSettings == null)
                {
                    return;
                }
                RewardSettings.BattleReward[] rewards = rewardSettings.rewards;
                for (int i = 0; i < rewards.Length; i++)
                {
                    RewardSettings.BattleReward battleReward = rewards[i];
                    if (battleReward.item.Type == ERewardType.Gold || battleReward.item.Type == ERewardType.Reputation || battleReward.item.Type == ERewardType.CareerPoints)
                    {
                        if (battleReward.item.Type == ERewardType.Gold)
                        {
                            battleReward.count *= (Main._settings.CashRewMult - 1);
                        }
                        if (battleReward.item.Type == ERewardType.Reputation)
                        {
                            battleReward.count *= (Main._settings.ReputationRewMult - 1);
                        }
                        if (battleReward.item.Type == ERewardType.Medal)
                        {
                            battleReward.count *= (Main._settings.CareerPointsRewMult - 1);
                        }

                        battleReward.Transfer(false, battle.NavalDifficulty);
                    }
                }
                if (battle.HasBonusReward)
                {
                    rewardSettings = battle.battleSettings.bonusRewards;
                    if (rewardSettings != null)
                    {
                        rewards = rewardSettings.rewards;
                        for (int j = 0; j < rewards.Length; j++)
                        {
                            RewardSettings.BattleReward battleReward2 = rewards[j];
                            if (battleReward2.item.Type == ERewardType.Gold || battleReward2.item.Type == ERewardType.Reputation || battleReward2.item.Type == ERewardType.Medal)
                            {
                                if (battleReward2.item.Type == ERewardType.Gold)
                                {
                                    battleReward2.count *= (Main._settings.CashRewMult - 1);
                                }
                                if (battleReward2.item.Type == ERewardType.Reputation)
                                {
                                    battleReward2.count *= (Main._settings.ReputationRewMult - 1);
                                }
                                if (battleReward2.item.Type == ERewardType.Medal)
                                {
                                    battleReward2.count *= (Main._settings.CareerPointsRewMult - 1);
                                }

                                battleReward2.Transfer(false, EDifficulty.None);
                            }
                        }
                    }
                }
            }