public void PawnControllerStart()
    {
        this.body           = GameObject.FindWithTag(this.tag).GetComponentInChildren <CreateCombination>();
        this.playerAnimator = GetComponentInChildren <PlayerMoveAnim>().gameObject.GetComponent <Animator>();
        this.inBattle       = false;
        this.posController  = this.gameObject.GetComponent <PlayerPositionController>();
        // initialize weapon if player is supposed to have one
        CallSetWeapon("Sword");
        if (!spawnWithWeapon)
        {                                    //
            this.weaponComboScript.AllOff(); // Creates a weapon, sets it to the player's hand and makes it invisible.
            this.weaponComboScript.SwapNow();
        }

        if (spawnWithArmor)
        {
            int randomNum = Random.Range(0, 3);
            switch (randomNum)
            {
            case 0: CallSetArmor("HeavyArmor");
                break;

            case 1: CallSetArmor("MediumArmor");
                break;

            case 2: CallSetArmor("LightArmor");
                break;
            }
        }
        else
        {
            CallSetArmor("BlankArmor");
            this.playerArmor.gameObject.GetComponentInChildren <SpriteRenderer>().enabled = false;
        }
    }
Beispiel #2
0
    private void RemoveGoal()
    {
        foreach (var playerAndGoals in playerAndItsGoalsList)
        {
            var player = playerAndGoals.player;
            if (player == null)
            {
                continue;
            }

            if (playerAndGoals.goals.Count == 0)
            {
                continue;
            }

            var goal = playerAndGoals.goals[0];

            bool isArrive = PlayerPositionController.IsArrive(player.transform, goal.position);
            if (isArrive && goal.encountedEnemy == null)
            {
                playerAndGoals.goals.RemoveAt(0);
            }
        }
    }
Beispiel #3
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;
            }
        }
    }