示例#1
0
        public void SendTruckToTile(EGFiretruck truckToSend, int x, int y)
        {
            TDPath truckPath = new TDPath();
            TDMap  dataMap   = _map.Map;

            truckPath.BuildPath(dataMap,
                                dataMap.GetTile(Mathf.FloorToInt(truckToSend.GetPosition().x), Mathf.FloorToInt(-truckToSend.GetPosition().z)),
                                dataMap.GetTile(x, y));
            truckToSend.SetPath(truckPath);
            truckToSend.SetIdle(false);

            _dispatcher.AddActiveTruck(truckToSend);
        }
示例#2
0
        public void SetTruckIdle(EGFiretruck truck)
        {
            if (truck != null)
            {
                _dispatcher.RemoveActiveTruck(truck);
                _dispatcher.AddIdleTruck(truck);

                if (truck.returnWhenIdle)
                {
                    Vector2 fireHouseTilePos = new Vector2();
                    _map.Map.GetFireHouseCoordinates(out fireHouseTilePos);

                    TDTile start           = _map.GetTileForWorldPosition(truck.transform.position);
                    TDTile end             = _map.Map.GetTile(Mathf.FloorToInt(fireHouseTilePos.x), Mathf.FloorToInt(fireHouseTilePos.y));
                    TDPath pathToFirehouse = new TDPath();
                    pathToFirehouse.BuildPath(_map.Map, start, end);

                    truck.SetPath(pathToFirehouse);
                }

                truck.SetIdle(true);
            }
        }