コード例 #1
0
 public override void Action()
 {
     time++;
     //This timer might be awfully ugly
     if (time > _transaction_duration)
     {
         AgentTicketOffice agent  = _stateMachine.Agent as AgentTicketOffice;
         Ticket            ticket = Environment.GetInstance().environment.RequestSeat((agent.askForTicket.Type as MessageAskForTicket).door);
         agent.receivedAskForTicket = false;
         if (ticket != null)
         {
             agent.SendMessage(agent.queue.Pop(), new MessageGiveTicket(ticket));
             agent.transactionFinished = true;
         }
         else
         {
             List <int> availableCategories =
                 Environment.GetInstance().environment.StillAvailableCategories((agent.queue.First() as AgentSpectator).side);
             agent.SendMessage(agent.queue.First(), new MessageNoTicketAvailable(availableCategories, (agent.askForTicket.Type as MessageAskForTicket).door));
             //No seat available, the transaction is finished
             if (availableCategories.Count == 0)
             {
                 agent.queue.Pop(); //Eliminate the first agent in the queue
                 agent.transactionFinished = true;
             }
         }
     }
 }
コード例 #2
0
        public StateTicketOfficeGiveTicket(StateMachine stateMachine, Agent agent) : base(stateMachine)
        {
            _transaction_duration = Environment.GetInstance().settings.timeToBuyTicket * 50; // 50 is the number of frames in 1 sec
            _agent = agent;
            AgentTicketOffice ato = _stateMachine.Agent as AgentTicketOffice;

            ato.transactionFinished = false;
        }
コード例 #3
0
 // Start is called before the first frame update
 void Awake()
 {
     //Hydrade zones position with physical location of zones
     foreach (Zone z in GameObject.FindObjectsOfType <Zone>())
     {
         Environment.GetInstance().environment.SetCategoryPosition(z.zoneNumber, z.transform.position);
         List <Vector3> places = z.GetPlacesLocations();
         Environment.GetInstance().environment.SetCategoryPlaces(z.zoneNumber, places);
     }
 }
コード例 #4
0
 public override void Action()
 {
     if (!isMoving && spectator != null)
     {
         if (Environment.GetInstance().settings.noNavMesh || (!Environment.GetInstance().settings.noNavMesh&& spectator.Body.gameObject.GetComponent <NavMeshAgent>() != null))
         {
             isMoving = true;
             spectator.Body.MoveToDestination(spectator.spawnLocation);
         }
     }
 }
コード例 #5
0
        public void Reattach()
        {
            _agentIsDead    = false;
            _rigidbody      = gameObject.AddComponent <Rigidbody>();
            _rigidbody.mass = 1;

            if (!Environment.GetInstance().settings.noNavMesh)
            {
                _navMeshAgent              = gameObject.AddComponent <NavMeshAgent>();
                _navMeshAgent.speed        = 9;
                _navMeshAgent.angularSpeed = 120;
                _navMeshAgent.acceleration = 5;
                _navMeshAgent.autoBraking  = true;
            }
        }
コード例 #6
0
 public override void ProcessMessage(Message message)
 {
     if (Environment.GetInstance().settings.showMessagesLog)
     {
         Debug.Log(this + " received " + message.Type + " from " + message.Sender);
     }
     switch (message.Type.messageObject())
     {
     case MessageObject.ASK_FOR_QUEUE:
         _queue.Add(message.Sender);
         MessageType answer = new MessageSendQueuePosition(_queue.GetPositionForAgent(message.Sender),
                                                           _queue.GetNumberInQueueForAgent(message.Sender));
         SendMessage(message.Sender, answer);
         break;
     }
     archivedMailbox.Add(message);
 }
コード例 #7
0
        public void OnClickButtonStartSimulation()
        {
            _mainCanvas.SetActive(true);

            Settings settings = new Settings(GetTicketTime());

            settings.noNavMesh = GetDontUseNavMesh();
            Environment.GetInstance().CreateBrain(GetTicketsOfficesNumber(), settings);

            GameObject.Find("Environment").AddComponent <EnvironmentUI>();
            gameObject.AddComponent <MultiAgentSystem>();

            int ticketProportion = GetTicketProportion();

            if (!GetPedestrianActivated("North"))
            {
                GameObject.Destroy(GameObject.Find("NorthStreet"));
            }
            if (!GetPedestrianActivated("South"))
            {
                GameObject.Destroy(GameObject.Find("SouthStreet"));
            }
            if (!GetPedestrianActivated("West"))
            {
                GameObject.Destroy(GameObject.Find("WestStreet"));
            }
            if (!GetPedestrianActivated("East"))
            {
                GameObject.Destroy(GameObject.Find("EastStreet"));
            }

            foreach (SpectatorSpawner sp in GameObject.FindObjectsOfType <SpectatorSpawner>())
            {
                sp.spawiningDurationInSec  = GetArrivalTime();
                sp.awaySpectatorPercentage = GetAwaySpectatorsPourcentage();
                sp.ticketPercentage        = ticketProportion;
                sp.Activate();
            }
            CreateTramSpawner();
            GameObject.Find("CanvasSettings").SetActive(false);
        }
コード例 #8
0
ファイル: Zone.cs プロジェクト: nicolasLepy/StadiumSimulator
 // Update is called once per frame
 void Update()
 {
     _textZone.text = Environment.GetInstance().environment.AvailableSeats(_zoneNumber) + "";
 }
コード例 #9
0
 public void OnClickExportData()
 {
     Environment.GetInstance().Brain.ExportData();
 }
コード例 #10
0
 // Update is called once per frame
 void FixedUpdate()
 {
     Environment.GetInstance().Brain.Loop();
 }