Exemple #1
0
    void Update()
    {
        if (Player.GetBattle() && !Battle)
        {
            Battle = true;
        }

        if (Battle)
        {
            if (!BattleStart)
            {
                BattleStarts();
            }
            else
            {
                if (!Player.GetMyTurn() && PlayerTurn)
                {
                    PlayerTurn = false;
                    Enemy.SetMyTurn(true);
                    waitTime = 3f;
                    Enemy.TakeHit(Player.GetAttack());
                }
                if (!Enemy.GetMyTurn() && !PlayerTurn)
                {
                    PlayerTurn = true;
                    Player.SetMyTurn(true);
                    waitTime = 3f;
                    Player.TakeHit(Enemy.GetAttack());
                }

                waitTime -= Time.deltaTime;

                if (waitTime < 0)
                {
                    if (PlayerTurn)
                    {
                        StartCoroutine(Player.Attack(Enemy.transform.position));
                    }
                    else
                    {
                        StartCoroutine(Enemy.Attack(Player.transform.position));
                    }
                }
            }

            if (Player.GetDeath())
            {
                Battle      = false;
                BattleStart = false;
                Player.LeaveBattle();
                Debug.Log("Player L0se");
            }
            if (Enemy.GetDeath())
            {
                Enemy.OnDeath += onEnemyDeath;
            }
        }
    }