Example #1
0
    void UsePowerUp()
    {
        if (!powerUpEquipped)
        {
            return;
        }

        switch (activePowerUp)
        {
        case PowerUps.BLOCK:
            int x, y;
            var field = lastField.GetComponent <Field>();
            CoordsInDirection(field.x, field.y, direction, out x, out y);

            var newField = board.GetField(x, y);
            if (newField == null || newField.GetComponent <Field>().HasVisitors())
            {
                return;
            }

            if (!board.AddWall(y, x, '!'))
            {
                return;
            }

            break;

        case PowerUps.RAGING:
            game.SetRaging();
            break;

        default:
            return;
        }

        powerUpEquipped = false;
        status.GetComponent <Text>().text = "";
    }