Beispiel #1
0
        public IEnumerator <YieldInstruction> MakeLeader(int charIndex, ActionResult result)
        {
            if (CurrentCharacter != ActiveTeam.Leader)
            {
                GameManager.Instance.SE("Menu/Cancel");
                DungeonScene.Instance.LogMsg(Text.FormatKey("MSG_LEADER_SWAP_REQ"), false, true);
                yield return(new WaitForFrames(GameManager.Instance.ModifyBattleSpeed(10)));
            }
            else if (charIndex >= ActiveTeam.Players.Count || ActiveTeam.LeaderIndex == charIndex)
            {
                GameManager.Instance.SE("Menu/Cancel");
                yield return(new WaitForFrames(GameManager.Instance.ModifyBattleSpeed(10)));
            }
            else if (ZoneManager.Instance.CurrentMap.NoSwitching || DataManager.Instance.Save.NoSwitching)
            {
                GameManager.Instance.SE("Menu/Cancel");
                DungeonScene.Instance.LogMsg(Text.FormatKey("MSG_CANT_SWAP_LEADER", CurrentCharacter.GetDisplayName(true)), false, true);
                yield return(new WaitForFrames(GameManager.Instance.ModifyBattleSpeed(10)));
            }
            else
            {
                if (!canSwitchToChar(charIndex))
                {
                    GameManager.Instance.SE("Menu/Cancel");
                }
                else
                {
                    result.Success = ActionResult.ResultType.Success;

                    //change the leader index
                    int oldLeader = ActiveTeam.LeaderIndex;
                    ActiveTeam.LeaderIndex = charIndex;

                    //re-order map order as well
                    ZoneManager.Instance.CurrentMap.CurrentTurnMap.AdjustLeaderSwap(Faction.Player, 0, false, oldLeader, charIndex);

                    focusedPlayerIndex = ZoneManager.Instance.CurrentMap.CurrentTurnMap.GetCurrentTurnChar().Char;

                    DungeonScene.Instance.LogMsg(Text.FormatKey("MSG_LEADER_SWAP", ActiveTeam.Leader.GetDisplayName(true)));

                    GameManager.Instance.SE(GraphicsManager.LeaderSE);
                    yield return(new WaitForFrames(GameManager.Instance.ModifyBattleSpeed(10)));

                    yield return(CoroutineManager.Instance.StartCoroutine(SpecialIntro(ActiveTeam.Leader)));
                }
            }
        }