Exemple #1
0
    public IEnumerator RunMoveTurn() //목표지점으로 이동하는 함수
    {
        Dictionary <PlayerAndGoals, bool> arriveDic = new Dictionary <PlayerAndGoals, bool>();
        Skill skill;

        foreach (PlayerAndGoals playerAndItsGoals in playerAndItsGoalsList)
        {
            Player player = playerAndItsGoals.player.gameObject.GetComponent <Player>();
            if (player.characterName == Player.CharacterName.Hesmen)
            {
                skill = new HpRecovery();
                if (skill.activated)
                {
                    skill.Use(player);
                }
            }

            arriveDic[playerAndItsGoals] = false;
        }

        while (true)
        {
            foreach (PlayerAndGoals playerAndItsGoals in playerAndItsGoalsList)
            {
                if (playerAndItsGoals.player == null || playerAndItsGoals.goals.Count == 0)
                {
                    arriveDic[playerAndItsGoals] = true;
                    continue;
                }

                Goal currentGoal = playerAndItsGoals.goals[0];

                if (arriveDic[playerAndItsGoals] == true)
                {
                    continue;
                }

                Transform playerTransform = playerAndItsGoals.player.transform;
                Vector2   goalPosition    = currentGoal.position;
                if (PlayerPositionController.IsArrive(playerTransform, goalPosition) == false)
                {
                    LineController linecont = LineController.FindLineWithNum(playerAndItsGoals.player.GetComponent <Player>(), playerAndItsGoals.player.GetComponent <Player>().lineNum);
                    linecont.PlayerMove();
                    PlayerPositionController.Move1Frame(playerTransform, goalPosition, 5.0f);
                }
                else
                {
                    LineController linecont = LineController.FindLineWithNum(playerAndItsGoals.player.GetComponent <Player>(), playerAndItsGoals.player.GetComponent <Player>().lineNum);
                    linecont.PlayerAfterMove();
                    arriveDic[playerAndItsGoals] = true;
                }
            }
            yield return(null);

            bool allArrive = true;
            foreach (PlayerAndGoals playerAndItsGoals in playerAndItsGoalsList)
            {
                if (arriveDic[playerAndItsGoals] == false)
                {
                    allArrive = false;
                }
            }

            if (allArrive)
            {
                yield break;
            }
        }
    }