Exemple #1
0
        void IncrementDestinationIfOnCurrentDestinationTile()
        {
            TDTile currentTile     = map.GetTileForWorldPosition(transform.position);
            TDTile destinationTile = map.GetTileForWorldPosition(destination);

            if (currentTile.Equals(destinationTile))
            {
                SetDestination(GetNextDestination());
            }
        }
Exemple #2
0
        // Update is called once per frame
        void Update()
        {
            //Sort through trucks so that they are kept in the right sets, active and idle
            List <EGFiretruck> toMoveToIdle = new List <EGFiretruck> ();

            for (int i = 0; i < _dispatcher.GetActiveTrucks().Count; i++)
            {
                EGFiretruck truck = _dispatcher.GetActiveTruckAtIndex(i);

                if (!truck.IsActive() && !truck.IsPuttingOutFire())
                {
                    //Don't remove them while iterating, remove afterwards
                    toMoveToIdle.Add(truck);
                }
            }

            //Set the trucks that need setting
            for (int i = 0; i < toMoveToIdle.Count; i++)
            {
                EGFiretruck truck = toMoveToIdle[i];
                SetTruckIdle(truck);
            }

            //Identify trucks that need to be removed
            List <EGFiretruck> toDestroy = new List <EGFiretruck> ();

            for (int i = 0; i < _dispatcher.GetIdleTrucks().Count; i++)
            {
                EGFiretruck truck = _dispatcher.GetIdleTruckAtIndex(i);

                TDTile truckTile = _map.GetTileForWorldPosition(truck.transform.position);
                //Trucks that are idle at the firehouse need to be removed
                if (truckTile.type == TDTile.Type.FIREHOUSE)
                {
                    toDestroy.Add(truck);
                }
            }

            //Remove trucks that need to be removed
            for (int i = 0; i < toDestroy.Count; i++)
            {
                EGFiretruck truck = toDestroy[i];
                _dispatcher.RemoveIdleTruck(truck);
                _firehouse.DecreaseTruckCount();
                Destroy(truck.gameObject);
            }
        }