public Transform getOpenElevatorAtFloor(int floorNr)
 {
     foreach (Transform el in elevators)
     {
         ElevatorTest elscript = el.gameObject.GetComponent <ElevatorTest>();
         if ((/*elscript.currFloor == floorNr || */ elscript.thisFloor == floorNr + 1) && !elscript.movingDown && !elscript.movingUp && elscript.doorOpen)
         {
             return(el);
         }
     }
     return(null);
 }
    public void elevatorDeparting(GameObject elevator)
    {
        int elFloor = elevator.GetComponent <ElevatorTest> ().thisFloor;

        foreach (Transform e in elevators)
        {
            ElevatorTest elScript = e.GetComponent <ElevatorTest> ();
            if (e.gameObject != elevator && (/*elScript.currFloor == elFloor || */ elScript.thisFloor == elFloor) && !elScript.movingDown && !elScript.movingUp)
            {
                e.GetComponent <ElevatorTest> ().arrivedAtFloor();
                break;
            }
        }
    }
    // ------------------------------------------------------------------------------
    //                              Elevator functions
    // ------------------------------------------------------------------------------

    public bool isElevatorAtFloor(int floorNr)
    {
        foreach (Transform el in elevators)
        {
            ElevatorTest elscript = el.gameObject.GetComponent <ElevatorTest>();
            Debug.Log(elscript);
            Debug.Log(floorNr);
            Debug.Log(elscript.thisFloor);
            if ((/*elscript.currFloor == floorNr || */ elscript.thisFloor == floorNr + 1) && !elscript.movingDown && !elscript.movingUp)
            {
                Debug.Log("I got this far");
                return(true);
            }
        }
        return(false);
    }
Beispiel #4
0
    void Mover(string elevator)
    {
        ele      = GameObject.Find(elevator);
        elScript = ele.gameObject.GetComponent <ElevatorTest>();
        iTween.EaseType easing = iTween.EaseType.easeInOutSine;

        if (this.arriveTime > Time.time)
        {
            this.arriveTime += speed;
            easing           = iTween.EaseType.easeOutSine;
        }
        else
        {
            gameController.removeBubble(ele);
            elScript.checkFloorIndicator();
            elScript.closeDoor();
            this.arriveTime = speed + Time.time;
            gameController.elevatorDeparting(ele);
        }

        destSpeed = arriveTime - Time.time;
        iTween.MoveTo(ele, iTween.Hash("position", TransformElevator(ele), "easetype", easing, "time", destSpeed, "oncomplete", "arrivedAtFloor"));
        elScript.thisFloor = destFloor;
    }