示例#1
0
 void VisitBuildingUpdate(float deltaTime)
 {
     if (state_passenger == STATE_BUILDING_GOTO)
     {
         // test one last time if there is no better building to go to
         //if (HasArrived(GridHelper.GetGridCellSize() * 10)) {
         //	VisitBuilding(buildingPassenger.GetType(), buildingExitState);
         state_passenger = STATE_BUILDING_GOTO_FINAL;
         //}
     }
     else if (state_passenger == STATE_BUILDING_GOTO_FINAL)
     {
         if (HasArrived())
         {
             state_passenger = STATE_BUILDING_GET_MOVE;
             //behaviour = buildingPassenger.VisitBuilding(this);
         }
     }
     else if (state_passenger == STATE_BUILDING_GET_MOVE)
     {
         if (behaviour.ExecuteBehaviour())
         {
             state_passenger = STATE_BUILDING_MOVE;
         }
         else             // it's finished
         {
             state = buildingExitState;
         }
     }
     else if (state_passenger == STATE_BUILDING_MOVE)
     {
         if (behaviour.BehaviorCompleted(deltaTime))
         {
             state_passenger = STATE_BUILDING_GET_MOVE;
         }
     }
 }
示例#2
0
    protected override void DefaultBehaviour(float deltaTime)
    {
        if (state == 0)
        {
            print("something has gone wrong, not supposed to have state = 0");
        }
        else if (state == STATE_AVAILABLE)
        {
            // wait for employeeController to assign work
            Wandering(STATE_AVAILABLE);
            speechBubbleController.SendMessageContinuous(speechBubble_NoWorkBuilding, this, SpeechBubbleController.EMPLOYEE_NO_WORK_BUILDING);
        }
        else if (state == STATE_MOVING_TO_WORK)
        {
            speechBubbleController.RemoveMessageImmediate(this);

            /*
             * if (Vector2.Distance(finalDestination, position) < GridHelper.GetGridCellSize() / 3) {
             *      finalDestination = new Vector2(work_building.GetFinalWorkDestination(this).x, work_building.GetFinalWorkDestination(this).z);
             *      steering.Arrive (finalDestination);
             *      state = STATE_MOVING_TO_FINAL;
             * }*/

            if (HasArrived())
            {
                state = STATE_MOVE_INSIDE_BUILDING;
            }
        }
        else if (state == STATE_MOVING_TO_FINAL)
        {
            if (HasArrived())
            {
                steering.FullStop();
                state = STATE_WORKING;
            }
        }
        else if (state == STATE_WORKING)
        {
            if (passenger == null)
            {
                //passenger = work_building.AssistPassenger(this);
                //passengerAssistPercentage = 0;
            }
            else
            {
                if (HelpPassenger(deltaTime))
                {
                    // reset passenger and delete panel
                    passenger = null;
                    Object.Destroy(progressPanel.gameObject);

                    // tell work buliding all about it
                    work_building.AssistPassengerComplete();
                }
            }
        }
        else if (state == STATE_MOVE_INSIDE_BUILDING)
        {
            //behaviour = building.VisitBuilding(this);
            state = STATE_BUILDING_GET_MOVE;
        }
        else if (state == STATE_BUILDING_GET_MOVE)
        {
            if (behaviour.ExecuteBehaviour())
            {
                state = STATE_BUILDING_MOVE;
            }
            else             // it's finished
            {
                state = 0;   // TEMPORARY
            }
        }
        else if (state == STATE_BUILDING_MOVE)
        {
            if (behaviour.BehaviorCompleted(deltaTime))
            {
                state = STATE_BUILDING_GET_MOVE;
            }
        }

        if (state == STATE_SERVICE_PASSENGER)
        {
            if (HelpPassenger(deltaTime))
            {
                // reset passenger and delete panel
                passenger = null;
                Object.Destroy(progressPanel.gameObject);

                // tell work buliding all about it
                work_building.AssistPassengerComplete();
            }
        }
    }