Exemplo n.º 1
0
    void VisitGateUpdate()
    {
        // if the boarding process has started, skip ahead past benches
        if (startedBoardingInterrupt && (state_passenger_building != STATE_GATE_GOTO_ENTER &&
                   state_passenger_building != STATE_GATE_GOTO_SEAT &&
                   state_passenger_building != STATE_GATE_SEAT_ROTATE)) {

            // if already entering benches, wait to get to seating part
            if (state_passenger_building == STATE_GATE_SEAT) {
                StartBoarding();
            } else {
                state_passenger_building = STATE_GATE_GOTO_QUEUE;
                finalDestination = new Vector2(this.transform.position.x, this.transform.position.z);
            }
            startedBoardingInterrupt = false;
        }

        if (state_passenger_building == STATE_GATE_GOTO) {
            finalDestination = gate.GetEnterBenchesPosition();
            steering.Visit(finalDestination);
            state_passenger_building = STATE_GATE_GOTO_ENTER;
        } else if (state_passenger_building == STATE_GATE_GOTO_ENTER) {
            if (HasArrived(GridHelper.GetGridCellSize() / 5)) {
                bench = gate.AddToBench(this);
                if (bench != null) {
                    Vector2[] exitPath = bench.GetBenchEnterPath(this);
                    steering.Visit(exitPath);
                    finalDestination = exitPath[0];
                    state_passenger_building = STATE_GATE_GOTO_SEAT;
                }
            }
        } else if (state_passenger_building == STATE_GATE_GOTO_SEAT) {
            if (HasArrived(GridHelper.GetGridCellSize() / 10f)) {
                steering.FullStop ();
                finalDestination = new Vector2 (99999f, 99999f);
                state_passenger_building = STATE_GATE_SEAT_ROTATE;
            }
        } else if (state_passenger_building == STATE_GATE_SEAT_ROTATE) {
             iTween.RotateTo(gameObject,iTween.Hash(
             	"rotation", bench.GetSeatRotation(this),
             	"easetype", iTween.EaseType.easeInOutQuad,
             	"time",1.0f));
            state_passenger_building = STATE_GATE_SEAT;
        } else if (state_passenger_building == STATE_GATE_SEAT) {
         		// on seat, waiting for boarding
         	} else if (state_passenger_building == STATE_GATE_GOTO_QUEUE) {
         		if (HasArrived(GridHelper.GetGridCellSize())) {
         			// go to enter queue position
         			//finalDestination = gate.GetEnterQueuePosition(); DISABLED FOR PASSENGER BUILDING
                steering.Seek(finalDestination);

         			state_passenger_building = STATE_GATE_GOTO_QUEUE_ENTER;
         		}
         	} else if (state_passenger_building == STATE_GATE_GOTO_QUEUE_ENTER) {

         		hasArrivedCounter++;

         		if (hasArrivedCounter > 200) {
         			print("stuck on has arrived (" + GetID() + ")");
         			print("this position = " + this.position + " | targetPos = " + targetPos + " | finalDestination = " + finalDestination);
         			finalDestination = this.position;
         		}

         		if (HasArrived(GridHelper.GetGridCellSize())) {
         			//print("has arrived");
                // send back to visitPassengerUpdate() because that will do the whole queue thing (except for exit path?)
         			visitBuilding = gate;
         			exit_state = STATE_GATE_EXIT;

         			//finalDestination = visitBuilding.EnterQueueAndGetPosition(this); DISABLED FOR PASSENGER BUILDING
                steering.Arrive(finalDestination);

                state_passenger_building = STATE_PASSENGER_BUILDING_QUEUE_ENTER;
                state = STATE_GATE_BOARDING_QUEUE;
         		}

         	}
    }
Exemplo n.º 2
0
    void VisitGateUpdate()
    {
        // if the boarding process has started, skip ahead past benches
        if (startedBoardingInterrupt && (state_passenger_building != STATE_GATE_GOTO_ENTER &&
                                         state_passenger_building != STATE_GATE_GOTO_SEAT &&
                                         state_passenger_building != STATE_GATE_SEAT_ROTATE))
        {
            // if already entering benches, wait to get to seating part
            if (state_passenger_building == STATE_GATE_SEAT)
            {
                StartBoarding();
            }
            else
            {
                state_passenger_building = STATE_GATE_GOTO_QUEUE;
                finalDestination         = new Vector2(this.transform.position.x, this.transform.position.z);
            }
            startedBoardingInterrupt = false;
        }

        if (state_passenger_building == STATE_GATE_GOTO)
        {
            finalDestination = gate.GetEnterBenchesPosition();
            steering.Visit(finalDestination);
            state_passenger_building = STATE_GATE_GOTO_ENTER;
        }
        else if (state_passenger_building == STATE_GATE_GOTO_ENTER)
        {
            if (HasArrived(GridHelper.GetGridCellSize() / 5))
            {
                bench = gate.AddToBench(this);
                if (bench != null)
                {
                    Vector2[] exitPath = bench.GetBenchEnterPath(this);
                    steering.Visit(exitPath);
                    finalDestination         = exitPath[0];
                    state_passenger_building = STATE_GATE_GOTO_SEAT;
                }
            }
        }
        else if (state_passenger_building == STATE_GATE_GOTO_SEAT)
        {
            if (HasArrived(GridHelper.GetGridCellSize() / 10f))
            {
                steering.FullStop();
                finalDestination         = new Vector2(99999f, 99999f);
                state_passenger_building = STATE_GATE_SEAT_ROTATE;
            }
        }
        else if (state_passenger_building == STATE_GATE_SEAT_ROTATE)
        {
            iTween.RotateTo(gameObject, iTween.Hash(
                                "rotation", bench.GetSeatRotation(this),
                                "easetype", iTween.EaseType.easeInOutQuad,
                                "time", 1.0f));
            state_passenger_building = STATE_GATE_SEAT;
        }
        else if (state_passenger_building == STATE_GATE_SEAT)
        {
            // on seat, waiting for boarding
        }
        else if (state_passenger_building == STATE_GATE_GOTO_QUEUE)
        {
            if (HasArrived(GridHelper.GetGridCellSize()))
            {
                // go to enter queue position
                //finalDestination = gate.GetEnterQueuePosition(); DISABLED FOR PASSENGER BUILDING
                steering.Seek(finalDestination);

                state_passenger_building = STATE_GATE_GOTO_QUEUE_ENTER;
            }
        }
        else if (state_passenger_building == STATE_GATE_GOTO_QUEUE_ENTER)
        {
            hasArrivedCounter++;

            if (hasArrivedCounter > 200)
            {
                print("stuck on has arrived (" + GetID() + ")");
                print("this position = " + this.position + " | targetPos = " + targetPos + " | finalDestination = " + finalDestination);
                finalDestination = this.position;
            }

            if (HasArrived(GridHelper.GetGridCellSize()))
            {
                //print("has arrived");
                // send back to visitPassengerUpdate() because that will do the whole queue thing (except for exit path?)
                visitBuilding = gate;
                exit_state    = STATE_GATE_EXIT;

                //finalDestination = visitBuilding.EnterQueueAndGetPosition(this); DISABLED FOR PASSENGER BUILDING
                steering.Arrive(finalDestination);

                state_passenger_building = STATE_PASSENGER_BUILDING_QUEUE_ENTER;
                state = STATE_GATE_BOARDING_QUEUE;
            }
        }
    }