Пример #1
0
    private void _on_Map_finished_updating()
    {
        var currentSelectedNode = _map.GetSelectedNode();

        if (currentSelectedNode is Player player)
        {
            var gridPosition   = player.GetGridPosition();
            var direction      = player.GetDirection();
            var targetPosition = GridHelper.GetTargetPosition(gridPosition.Column, gridPosition.Row, direction);
            var playerNumber   = player.GetPlayerNumber();
            var isHumanPlayer  = playerNumber != (int)PlayerNumber.Zombie;
            var isZombiePlayer = playerNumber == (int)PlayerNumber.Zombie;

            if (isZombiePlayer || _gameManager.HasBarricade(targetPosition.Column, targetPosition.Row))
            {
                ChangeToDestroy();
            }
            else
            {
                ChangeToSet();
            }

            if (_isSetMode)
            {
                if (GridHelper.CanSetBarricade(_map, gridPosition.Column, gridPosition.Row, direction, playerNumber) &&
                    !player.IsDisabledToWalk() &&
                    player.AP > 0 &&
                    isHumanPlayer)
                {
                    this.Modulate = new Color("ffffff");
                    _disabled     = false;
                }
                else
                {
                    this.Modulate = new Color("4affffff");
                    _disabled     = true;
                }
            }
            else
            {
                if (GridHelper.HasFourPileFriendlies(_gameManager, gridPosition, direction, playerNumber) && isZombiePlayer && player.AP > 0)
                {
                    this.Modulate = new Color("ffffff");
                    _disabled     = false;
                }
                else if (_gameManager.HasBarricade(targetPosition.Column, targetPosition.Row) && isHumanPlayer && player.AP >= 4)
                {
                    this.Modulate = new Color("ffffff");
                    _disabled     = false;
                }
                else
                {
                    this.Modulate = new Color("4affffff");
                    _disabled     = true;
                }
            }
        }
    }