コード例 #1
0
    IEnumerator SwitchRound()
    {
        yield return(new WaitForSeconds(1));

        CurrentTurn++;
        currentPlayerID++;
        if (currentPlayerID == Players.Length)
        {
            currentPlayerID = 0;
        }
        // 切换回合动画
        if (currentPlayerID == 0)
        {
            NextTurnAnimation.Play("NextTurn");
            yield return(new WaitForSeconds(1.5f));
        }

        // 回合控制(每次优先计算回合数)
        if (currentPlayerID == Players.Length / 2 || currentPlayerID == 0)
        {
            CurrentHalfRound++;
        }
        if (currentPlayerID == 0)
        {
            CurrentRound++;
        }

        // 回合开始时发生的效果
        // 地图特效
        if (_MapEffect != null)
        {
            _MapEffect.InitPerRound();
        }
        //
        if (_CoinController != null)
        {
            _CoinController.InitPerRound();
        }
        //
        if (_StatueController != null)
        {
            _StatueController.InitPerRound();
        }

        // 处理角色异常状态
        foreach (var palyer in Players)
        {
            PlayerUnit u = palyer.GetComponent <PlayerUnit>();
            if (u != null && u.IsDead)
            {
                u.Resurrection();
            }
            if (u != null && u.controlled)
            {
                u.ReleaseControl();
            }
        }

        // 切换人物
        if (currentPlayer != null)
        {
            currentPlayer.GetComponent <PlayerController_>().IsControlled = false;
        }
        currentPlayer = Players[currentPlayerID];
        PlayerUnit cu = currentPlayer.GetComponent <PlayerUnit>();

        if (!cu.IsDead && !cu.controlled)
        {
            currentPlayer.GetComponent <PlayerController_>().ImpulseEnd    = false;
            currentPlayer.GetComponent <PlayerController_>().IsControlled  = true;
            currentPlayer.GetComponent <PlayerController_>().Impulse_force = 50;
            IsControlled = currentPlayer.GetComponent <PlayerController_>().IsControlled;
            ImpulseEnd   = currentPlayer.GetComponent <PlayerController_>().ImpulseEnd;
        }
        MainCamera.GetComponent <MoveCamera>().Target = currentPlayer;
        yield return(new WaitForSeconds(1.5f));

        MainCamera.GetComponent <MoveCamera>().Target = null;

        // 携程结束
        UseCoroutine = false;
    }