Example #1
0
 //returns true if there is no elevator in the way
 public bool checkForElevatorInTheWay(int x, int low, int high)
 {
     low  = FloorSpaceManager.convertPositionToFloor(low);
     high = FloorSpaceManager.convertPositionToFloor(high);
     // Debug.Log("x low high " + x + " " + (low) + " " + (high));
     foreach (Elevator e in elevatorList)
     {
         if (e.transform.position.x == x)
         {
             // Debug.Log("x lowest highest " + x + " " + (e.lowestFloor) + " " + (e.highestFloor));
             if (e.lowestFloor <= high && e.highestFloor >= low)
             {
                 if (e.lowestFloor <= high)
                 {
                     Debug.Log("The lowest floor, " + e.lowestFloor + " is less than or equal to the high, " + high);
                 }
                 else if (e.highestFloor >= low)
                 {
                     Debug.Log("The highest floor, " + e.highestFloor + " is greater than or equal to the low, " + low);
                 }
                 return(true);
             }
         }
     }
     return(false);
 }
    public static Stack <Vector2> findRouteToGoal(Vector2 finalGoal, int currentFloor, Stack <Vector2> goals)
    {
        int finalGoalFloor = FloorSpaceManager.convertPositionToFloor(finalGoal.y);
        int count          = goals.Count;

        foreach (Elevator elevator in TowerMap.elevatorList)
        {
            if (elevator.checkForAccess(currentFloor, finalGoalFloor))
            {
                goals.Push(elevator.transform.position);
                return(goals);
            }
            else if (elevator.checkForAccess(finalGoalFloor) && (elevator.lowestFloor < FloorSpaceManager.convertPositionToFloor(goals.Peek().y) || elevator.highestFloor > FloorSpaceManager.convertPositionToFloor(goals.Peek().y)))
            {
                goals.Push(elevator.transform.position);
                if (currentFloor < finalGoalFloor)
                {
                    goals = findRouteToGoal(finalGoal, elevator.lowestFloor, goals);
                }
                else
                {
                    goals = findRouteToGoal(finalGoal, elevator.highestFloor, goals);
                }
            }
        }
        return(goals);
    }
Example #3
0
 public void updateFloors()
 {
     highestFloor = FloorSpaceManager.convertPositionToFloor(upDragRect.transform.position.y);
     lowestFloor  = FloorSpaceManager.convertPositionToFloor(downDragRect.transform.position.y);
     foreach (ElevatorCar c in cars)
     {
         c.setFloorMinMax(lowestFloor, highestFloor);
     }
 }
Example #4
0
 public void pickUp(GameObject g)
 {
     contents.Add(g);
     if (g.GetComponent <Character>())
     {
         g.GetComponent <Character>().updateToNextGoal();
         addFloorToQueue(FloorSpaceManager.convertPositionToFloor(g.GetComponent <Character>().currentGoal.y));
     }
     g.SetActive(false);
 }
Example #5
0
 public void goToFloor(int floor)
 {
     if (currentFloor != floor)
     {
         transform.position = new Vector2(transform.position.x, Mathf.MoveTowards(transform.position.y, FloorSpaceManager.convertFloorToPosition(floor), speed));
         if (Mathf.Approximately(transform.position.y, Mathf.Round(transform.position.y)))
         {
             currentFloor = FloorSpaceManager.convertPositionToFloor(transform.position.y);
         }
     }
     else
     {
         floorQueue.Dequeue();
     }
 }
Example #6
0
 public void tick()
 {
     if (floorQueue.Count > 0)
     {
         waiting = false;
         goToFloor(floorQueue.Peek());
         checkForDropOffs();
     }
     else if (contents.Count > 0)
     {
         waiting = false;
         addFloorToQueue(FloorSpaceManager.convertPositionToFloor(contents[0].GetComponent <Character>().currentGoal.y));
     }
     else
     {
         floorQueue.ClearHash();
         waiting = true;
     }
 }
Example #7
0
 void OnEnable()
 {
     currentFloor = FloorSpaceManager.convertPositionToFloor(transform.position.y);
     GetComponent <SpriteRenderer>().sortingOrder = 50;
 }