Ejemplo n.º 1
0
        private DroneStateManager AddDroneData(GameObject drone)
        {
            do
            {
                _lastId++;
            } while (Drones.ContainsKey(_lastId));

            var droneData = drone.AddComponent <DroneStateManager>();

            droneData.Initialize(_lastId, this);
            Drones[_lastId] = droneData;
            return(droneData);
        }
Ejemplo n.º 2
0
        //Loops through each drone to update their position and remove them from the world if necessary
        private async Task NavigateDrones()
        {
            var toRemove = new List <int>();

            foreach (var drone in Drones.ToList())
            {
                toRemove.Add(await NavigateToNexPoint(drone));
            }
            foreach (var key in toRemove.Where(x => x != 0))
            {
                var drone = Drones.ContainsKey(key) ? Drones[key] : null;
                SceneSystem.SceneInstance.RootScene.Entities.Remove(drone);
                Drones.Remove(key);
                DistanceTravelled.Remove(key);
                _routes.Remove(key);
                _waypointIndexes.Remove(key);
                Speeds.Remove(key);
                DroneLogic.SetDroneNotLive(key);
            }
        }