Esempio n. 1
0
    public void StartGame()
    {
        StartCoroutine(Routine());

        IEnumerator Routine()
        {
            description.ChangeText("Player names are set...");

            yield return(new WaitForSeconds(2.5F));

            description.ChangeText("Selecting active player randomly...");
            int rnd     = Random.Range(0, 2);
            var player1 = GameObject.FindGameObjectWithTag("Player1").GetComponent <Player>();
            var player2 = GameObject.FindGameObjectWithTag("Player2").GetComponent <Player>();

            activePlayer   = rnd == 0 ? player1 : player2;
            opponentPlayer = activePlayer == player1 ? player2 : player1;

            yield return(new WaitForSeconds(2.5F));

            description.ChangeText($"Active player is selected. Current active player is : { activePlayer.name }");
            turnImage.SetActive(true);
            this.MoveObject(turnImage, activePlayer.gameObject.transform.position + Vector3.left * 6);

            yield return(new WaitForSeconds(2.5F));

            BeginTurn();
        }
    }