Ejemplo n.º 1
0
    private void InstantiateNewTower(Waypointer spaceToPlace)
    {
        TowerController newTower        = Instantiate(placeableTower, spaceToPlace.transform.position, Quaternion.identity);
        TowerRingBuffer hierarchyTidier = FindObjectOfType <TowerRingBuffer>();

        newTower.transform.parent        = hierarchyTidier.transform;
        newTower.blockThatTowerOccupies  = spaceToPlace;
        spaceToPlace.isPlayerInteractive = false;
        ringBuffer.Enqueue(newTower);
    }
Ejemplo n.º 2
0
    private void ProcessPossibleMovement()
    {
        waypointQueue.Enqueue(startWaypoint);

        while (waypointQueue.Count > 0 && isRunning)
        {
            originSearch = waypointQueue.Dequeue();
            originSearch.blockHasBeenExplored = true;
            PathValidator();
        }
    }
Ejemplo n.º 3
0
    public void PlaceTower(Waypointer spaceToPlace)
    {
        int towerPlacedCount = ringBuffer.Count;

        if (towerPlacedCount >= placeableTowerLimit)
        {
            RequeueExistingTower(spaceToPlace);
        }
        else
        {
            InstantiateNewTower(spaceToPlace);
        }
    }
Ejemplo n.º 4
0
    private void RequeueExistingTower(Waypointer newSpaceToPlace)
    {
        //initializing logic preparing to move tower that has been placed
        TowerController oldestTower = ringBuffer.Dequeue();

        oldestTower.blockThatTowerOccupies.isPlayerInteractive = true;
        newSpaceToPlace.isPlayerInteractive = false;

        //now that the tower is ready to move, we initialize values/properties
        oldestTower.blockThatTowerOccupies = newSpaceToPlace;
        oldestTower.transform.position     = newSpaceToPlace.transform.position;
        ringBuffer.Enqueue(oldestTower);
        print("henlo darkness my old fren");
    }
Ejemplo n.º 5
0
    private void CreatePath()
    {
        //setting our path so that towers can't be placed
        //to block our enemies, same in the loop below
        endWaypoint.isPlayerInteractive   = false;
        startWaypoint.isPlayerInteractive = false;
        path.Add(endWaypoint);

        Waypointer previousPoint = endWaypoint.previouslyAccessedWaypoint;

        while (previousPoint != startWaypoint)
        {
            path.Add(previousPoint);
            previousPoint.isPlayerInteractive = false;
            previousPoint = previousPoint.previouslyAccessedWaypoint;
        }
        path.Add(startWaypoint);
        path.Reverse();
    }
Ejemplo n.º 6
0
    private void PathValidator()
    {
        if (!isRunning)
        {
            return;
        }
        if (originSearch == endWaypoint)
        {
            isRunning = false;
        }

        foreach (Vector2Int possibleMove in cardinalMovements)
        {
            //looping and taking the StartWaypoint and setting it so it's grabbing
            //the actual coordinates instead of the integer values that represent the
            //arithmetic responsible (0,1) -> (3,4)
            Vector2Int explorationCoordinates = originSearch.GetGridPosition() + possibleMove;

            //using bracket notation, we can reference these coordinates in our dictionary
            try
            {
                Waypointer neighbor = grid[explorationCoordinates];
                if (neighbor.blockHasBeenExplored || waypointQueue.Contains(neighbor)) /**/ } {
Ejemplo n.º 7
0
 private void Awake()
 {
     waypointer = GetComponent <Waypointer>();
 }