Exemplo n.º 1
0
    public override void _Process(float delta)
    {
        if (_currentlyPlacingBuilding == null)
        {
            return;
        }

        var canPlace = CanPlace(_currentlyPlacingBuilding);

        if (canPlace)
        {
            _placementMarker.SetAllow();
        }
        else
        {
            _placementMarker.SetDeny();
        }

        if (Input.IsActionJustPressed("accept_build") && canPlace)
        {
            _placementMarker.QueueFree();
            _placementMarker = null;
            AddBuilding(_currentlyPlacingBuilding);
            _currentlyPlacingBuilding.Build();
            SetBuildPlaceHolder(_currentlyPlacingBuilding.BuildingType);
        }
    }
Exemplo n.º 2
0
    public void StopPlaceBuildings()
    {
        _placementMarker.QueueFree();
        _placementMarker = null;

        ((Node)_currentlyPlacingBuilding).QueueFree();
        _currentlyPlacingBuilding = null;
    }
Exemplo n.º 3
0
    private void SetBuildPlaceHolder(BuildingType buildingType)
    {
        _currentlyPlacingBuilding = (IBuilding)FarmerHouseScene.Instance();
        _placementMarker          = (PlacementMarker)PlacementMarkerScene.Instance();
        _placementMarker.AttachTo(_currentlyPlacingBuilding);

        var asNode = (Node)_currentlyPlacingBuilding;

        asNode.AddChild(_placementMarker);
        _buildingsParent.AddChild(asNode);
    }