Esempio n. 1
0
    public InternalBuildingNode GetEntrance(Person person, PassengerBehaviour behaviour)
    {
        InternalBuildingNode return_entrance = null;

        if (entrances.Count == 1)
        {
            return(entrances[0]);
        }

        for (int i = 0; i < entrances.Count; i++)
        {
            if (behaviour.CanVisit(entrances[i]))
            {
                // can visit this entrance, return it.
//				print("returning entrance = " + i);
                return(entrances[i]);
                // otherwise continue
            }
        }

        if (return_entrance == null)
        {
            print("do not know what entrance to get");
        }

        return(return_entrance);
    }
Esempio n. 2
0
        public static void SetNeighborsPassengers(Passenger[][] passengers, PassengerBehaviour behaviour)
        {
            var rowCount    = passengers.Length;
            var columnCount = passengers.First().Length;

            for (var i = 0; i < rowCount; i++)
            {
                for (var j = 0; j < columnCount; j++)
                {
                    if (i > 0)
                    {
                        passengers[i][j].AddNeighbor(passengers[i - 1][j]);
                    }
                    if (j > 0)
                    {
                        passengers[i][j].AddNeighbor(passengers[i][j - 1]);
                    }
                    if (i < rowCount - 1)
                    {
                        passengers[i][j].AddNeighbor(passengers[i + 1][j]);
                    }
                    if (j < columnCount - 1)
                    {
                        passengers[i][j].AddNeighbor(passengers[i][j + 1]);
                    }
                    passengers[i][j].PassengerBehaviour = behaviour;
                }
            }
        }
Esempio n. 3
0
    // --------------------------------- FOR PASSENGERS ---------------------------------

    public PassengerBehaviour VisitBuilding(Person person)
    {
        PassengerBehaviour   behaviour    = new PassengerBehaviour(this, person, passengerBehaviour);
        InternalBuildingNode entranceNode = GetEntrance(person, behaviour);

//		print("entrance node = " + entranceNode.position2);
        behaviour.SetEntrance(entranceNode);
        return(behaviour);
    }
Esempio n. 4
0
    /*
     * public void AssignWorkBuilding(BuildingEmployee building_employee)
     * {
     *      work_building = building_employee;
     *
     *      finalDestination = new Vector2(work_building.GetWorkDestination (this).x, work_building.GetWorkDestination (this).z);
     *      steering.Visit (finalDestination);
     *
     *      state = STATE_MOVING_TO_WORK;
     * }*/

    public void AssignWorkBuilding(BuildingPassenger building_employee)
    {
        building  = building_employee;
        behaviour = building.VisitBuilding(this);

        finalDestination = behaviour.GetEntrancePosition();
        steering.Visit(finalDestination);

        state = STATE_MOVING_TO_WORK;
    }
Esempio n. 5
0
    /*
    public void AssignWorkBuilding(BuildingEmployee building_employee)
    {
        work_building = building_employee;

        finalDestination = new Vector2(work_building.GetWorkDestination (this).x, work_building.GetWorkDestination (this).z);
        steering.Visit (finalDestination);

        state = STATE_MOVING_TO_WORK;
    }*/
    public void AssignWorkBuilding(BuildingPassenger building_employee)
    {
        building = building_employee;
        behaviour = building.VisitBuilding(this);

        finalDestination = behaviour.GetEntrancePosition();
        steering.Visit(finalDestination);

        state = STATE_MOVING_TO_WORK;
    }
Esempio n. 6
0
        public static Passenger CreatePassenger(PassengerBehaviour passengerBehaviour, int number,
                                                TransmissionType transmissionType)
        {
            var rnd          = new Random();
            var transport    = GetRandomtransportType();
            var quality      = Math.Round(rnd.NextDouble(), 2);
            var satisfaction = Math.Round(rnd.NextDouble(), 2);

            return(new Passenger(passengerBehaviour, transport, transmissionType, quality, satisfaction, number));
        }
Esempio n. 7
0
    bool VisitBuilding(string type_name, int _exit_state)
    {
        // get building
        buildingPassenger = (BuildingPassenger)BuildingList.GetPassengerBuilding(this, type_name);

        if (buildingPassenger == null)
        {
            print("could not find building)");
            return(false);
        }
        else
        {
            behaviour        = buildingPassenger.VisitBuilding(this);
            finalDestination = behaviour.GetEntrancePosition();
            steering.Visit(finalDestination);
            state_passenger   = STATE_BUILDING_GOTO;
            buildingExitState = _exit_state;

            // don't forget to remove eventual message
            speechBubbleController.RemoveMessageImmediate(this);
            return(true);
        }
    }
    public InternalBuildingNode GetEntrance(Person person, PassengerBehaviour behaviour)
    {
        InternalBuildingNode return_entrance = null;

        if (entrances.Count == 1)
            return entrances[0];

        for (int i = 0; i < entrances.Count; i++) {
            if (behaviour.CanVisit(entrances[i])) {
                // can visit this entrance, return it.
        //				print("returning entrance = " + i);
                return entrances[i];
                // otherwise continue
            }
        }

        if (return_entrance == null)
            print("do not know what entrance to get");

        return return_entrance;
    }
 // --------------------------------- FOR PASSENGERS ---------------------------------
 public PassengerBehaviour VisitBuilding(Person person)
 {
     PassengerBehaviour behaviour = new PassengerBehaviour(this, person, passengerBehaviour);
     InternalBuildingNode entranceNode = GetEntrance(person, behaviour);
     //		print("entrance node = " + entranceNode.position2);
     behaviour.SetEntrance(entranceNode);
     return behaviour;
 }
Esempio n. 10
0
    bool VisitBuilding(string type_name, int _exit_state)
    {
        // get building
        buildingPassenger = (BuildingPassenger) BuildingList.GetPassengerBuilding (this, type_name);

        if (buildingPassenger == null) {
            print("could not find building)");
            return false;
        } else  {
            behaviour = buildingPassenger.VisitBuilding(this);
            finalDestination = behaviour.GetEntrancePosition();
            steering.Visit(finalDestination);
            state_passenger = STATE_BUILDING_GOTO;
            buildingExitState = _exit_state;

            // don't forget to remove eventual message
            speechBubbleController.RemoveMessageImmediate(this);
            return true;
        }
    }
Esempio n. 11
0
 public HomeController(PassengerBehaviour passengerBehaviour)
 {
     this.passengerBehaviour = passengerBehaviour;
 }