Example #1
0
    public bool CheckIfPlacingPossible(Vector3 snappedPosition)
    {
        bool isPossible = true;

        //1 first check if we have the ressources
        if (!PlayerManager.Instance.HasRessources(currentBuildingPlacer.buildingData.cost))
        {
            isPossible = false;
        }

        //2. check if this building is not too far
        if (Vector3.Distance(playersBaseLocation.position, snappedPosition) > playerBase.buildingDistance)
        {
            isPossible = false;
        }

        // 3 . check if there is room
        if ((currentBuildingPlacer.buildingPlacementTrigger.Collides()))
        {
            isPossible = false;
        }

        if (isPossible)
        {
            currentBuildingPlacer.SetPlaningPossible();
            return(true);
        }
        else
        {
            currentBuildingPlacer.SetPlaningImpossible();
            return(false);
        }
    }