Exemplo n.º 1
0
    void Update()
    {
        if (!started)
        {
            Configure(Permanente.iaCount, Permanente.playerCount);
            started = true;
        }
        PlayerBase player         = players[turn].GetComponent <PlayerBase>();
        var        selectedSprite = this.Select.GetComponent <SpriteRenderer>();
        var        selectedColor  = player.color;

        if (player.selectedTerritory != null)
        {
            selectedColor.a = 1;
            var selectedPos = player.selectedTerritory.transform.position;
            this.Select.transform.position = new Vector3(
                selectedPos.x, selectedPos.y, this.Select.transform.position.z
                );
        }
        else
        {
            selectedColor.a = 0;
        }
        selectedSprite.color = selectedColor;

        var otherSprite = this.Other.GetComponent <SpriteRenderer>();
        var otherColor  = player.color;

        if (player.otherTerritory != null)
        {
            otherColor.a = 1;
            var otherPos = player.otherTerritory.transform.position;
            this.Other.transform.position = new Vector3(
                otherPos.x, otherPos.y, this.Other.transform.position.z
                );
        }
        else
        {
            otherColor.a = 0;
        }
        otherSprite.color = otherColor;

        this.nextButton.SetActive(player.showNext);


        if (state == -1 || state == 0)
        {
            player.Distribute(this, exercitos, exercitosAdd);
        }
        else if (state == 1)
        {
            if (substate == 0)
            {
                player.Attack(this);
            }
            else if (substate == 1)
            {
                player.ShowAttack(this, attackSource, attackTarget, attackDice, defenseDice, false);
            }
            else if (substate == 2)
            {
                player.ShowAttack(this, attackSource, attackTarget, attackDice, defenseDice, true);
            }
            else if (substate == 3)
            {
                player.Conquest(this, attackSource, attackTarget);
            }
        }
        else if (state == 2)
        {
            if (substate == 0)
            {
                player.Redistribute(this, redistributed);
            }
            else
            {
                player.RedistributeSelected(this, redistributed);
            }
        }

        if (Input.GetKey(KeyCode.M))
        {
            players[turn].GetComponent <PlayerBase>().EndGame();
        }
    }