Наследование: BaseTargetBehaviour
Пример #1
0
    void spawnDrones()
    {
        GameObject redDrone = PhotonNetwork.Instantiate("Drone", redSpawn.transform.position, this.transform.rotation, 0);
        redDroneSettings = redDrone.GetComponent<Drone>();
        redDroneSettings.team = "Red";
        redDroneSettings.lane = "N";
        redDroneSettings.enabled = true;
        GameObject redDrone2 = PhotonNetwork.Instantiate("Drone", redSpawn.transform.position, this.transform.rotation, 0);
        redDroneSettings = redDrone2.GetComponent<Drone>();
        redDroneSettings.team = "Red";
        redDroneSettings.lane = "C";
        redDroneSettings.enabled = true;
        GameObject redDrone3 = PhotonNetwork.Instantiate("Drone", redSpawn.transform.position, this.transform.rotation, 0);
        redDroneSettings = redDrone3.GetComponent<Drone>();
        redDroneSettings.team = "Red";
        redDroneSettings.lane = "S";
        redDroneSettings.enabled = true;

        GameObject blueDrone = PhotonNetwork.Instantiate("Drone", blueSpawn.transform.position, this.transform.rotation, 0);
        blueDroneSettings = blueDrone.GetComponent<Drone>();
        blueDroneSettings.team = "Blue";
        blueDroneSettings.lane = "N";
        blueDroneSettings.enabled = true;
        GameObject blueDrone2 = PhotonNetwork.Instantiate("Drone", blueSpawn.transform.position, this.transform.rotation, 0);
        blueDroneSettings = blueDrone2.GetComponent<Drone>();
        blueDroneSettings.team = "Blue";
        blueDroneSettings.lane = "C";
        blueDroneSettings.enabled = true;
        GameObject blueDrone3 = PhotonNetwork.Instantiate("Drone", blueSpawn.transform.position, this.transform.rotation, 0);
        blueDroneSettings = blueDrone3.GetComponent<Drone>();
        blueDroneSettings.team = "Blue";
        blueDroneSettings.lane = "S";
        blueDroneSettings.enabled = true;
    }
Пример #2
0
        public virtual void Setup()
        {
            this.arena = new Mock<IArena>();
            this.arena.SetupGet(a => a.UpperLatitude).Returns(upperCoordinate);
            this.arena.SetupGet(a => a.UpperLongitude).Returns(upperCoordinate);

            this.drone = new Drone();
        }
Пример #3
0
    private void OnExitPortal(int portalId, Drone d)
    {
        if (activated) {
            Debug.Log ("Exit portal " + portalId);

            portals[portalId].cleared = true;
        }
    }
    public override void SetDrone(Drone drone)
    {
        base.SetDrone(drone);

        rb = _drone.GetComponent<Rigidbody>();

        //Enable Gravity
        rb.useGravity = true;
    }
Пример #5
0
    public override void Setup(FlightCourse fc, Drone playerDrone)
    {
        base.Setup(fc, playerDrone);

        _drone = playerDrone;
        //transform.SetParent(playerDrone.transform);

        // CalculateTarget
        SetTarget();

        // Snap to target
        transform.position = _targetPosition;
        transform.rotation = _targetRotation;
    }
Пример #6
0
    // Hier wird eine gegebene Drone in die Tabelle DRONEN eingefüllt
    public void addDrone(Drone drone)
    {
        IDbConnection _connection = new SqliteConnection(_strDBName);
        IDbCommand _command = _connection .CreateCommand();
        string sql;

        _connection .Open();

        sql = "INSERT INTO DRONEN (DRONENNAME,AKTUELLERKNOTEN,HOMEPUNKTID, STATUS,CARTOSHOW) Values ('"+ drone.getName()+"','2','2','0','ef')";
        _command.CommandText = sql;
        _command.ExecuteNonQuery();

        _command.Dispose();
        _command = null;
        _connection .Close();
        _connection.Dispose ();
        _connection = null;
        sql = null;
    }
Пример #7
0
    private static void gameLoop(Zone[] zones, Drone[] drones, int me)
    {
        updateZonesFromConsole(zones);
        updateDronesFromConsole(drones);
        mapDronesToZones(drones, zones, me);

        var myDrones = drones.Where(d => d.Team == me).ToArray();

        var commands = solve(myDrones, zones);
        var solution = flatten(commands).ToDictionary(c => c.Drone.Index, c => c);

        for (int i = 0; i < myDrones.Length; i++)
        {
            var destinationZone = solution.ContainsKey(i) ? solution[i].Zone : null;
            log("Moving drone #{0} to zone #{1}", i, destinationZone == null ? "-" : destinationZone.Index.ToString());

            var destination = solution.ContainsKey(i) ? solution[i].Destination : new Point { X = 1000, Y = 500 };
            Console.WriteLine(destination);
        }
    }
        public async Task <IActionResult> PutDrone([FromRoute] int id, [FromBody] Drone drone)
        {
            dbContext.Entry(drone).State = EntityState.Modified;

            try
            {
                await dbContext.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DroneExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #9
0
        public void BroadcastCommandTestEventShouldBeRaised()
        {
            //Arrange
            var drone   = new Drone(id: 0, x: 1, y: 3, direction: 90);
            var command = new Command('*', 0);

            command.BroadcastingSignal += drone.OnBroadcastingSignal;

            List <Command> receivedEvents = new List <Command>();

            command.BroadcastingSignal += delegate(object sender, CommandEventArgs e)
            {
                receivedEvents.Add(e.Command);
            };

            //Act
            command.BroadcastCommand();

            //Assert
            Assert.AreEqual(1, receivedEvents.Count);
            Assert.AreEqual('*', receivedEvents[0].Code);
        }
Пример #10
0
    void InitalizeBridge()
    {
        droneBridge = DroneBridge.Create();
        if (droneBridge == null)
        {
            Debug.Log("No drone bridge found for " + Application.platform);
            IsPlatformSupported = false;
            return;
        }

        IsPlatformSupported           = true;
        droneBridge.OnRegistered     += () => eventQueue.Enqueue(() => OnRegisteredEvent.Invoke());
        droneBridge.OnRegisterFailed += (error) => eventQueue.Enqueue(() => OnRegisterFailedEvent.Invoke(error));
        droneBridge.OnDroneConnected += (drone) => {
            Drone = drone;
            eventQueue.Enqueue(() => OnDroneConnectedEvent.Invoke(drone));
        };
        droneBridge.OnDroneDisconnected += () => {
            Drone = null;
            eventQueue.Enqueue(() => OnDroneDisconnectedEvent.Invoke());
        };
    }
        public async Task Drone_SolicitarTodosDrones_RetornarListaDeDrones()
        {
            // Arrange
            var query = new DronesQuery();

            IEnumerable <Drone> drones = new List <Drone>
            {
                Drone.Criar(12000, 3, 35, 100, DroneStatus.Livre)
            };

            _mocker.GetMock <IUnitOfWork>()
            .Setup(p => p.Drones.ObterTodosAsync())
            .Returns(Task.FromResult(drones));


            // Act
            var result = await _handler.Handle(query, CancellationToken.None);

            // Assert
            Assert.False(result.HasFails);
            _mocker.GetMock <IUnitOfWork>().Verify(o => o.Drones.ObterTodosAsync(), Times.Once);
        }
Пример #12
0
    void OnClickEvent()
    {
        Drone selectedDrone = WorldProperties.GetSelectedDrone();
        ROSDroneConnectionInterface droneROSConnection = selectedDrone.droneProperties.droneROSConnection;

        if (startMission)
        {
            Debug.Log("Start mission button clicked");
            droneROSConnection.StartMission();
        }

        if (pauseMission)
        {
            droneROSConnection.PauseMission();
        }

        if (resumeMission)
        {
            droneROSConnection.ResumeMission();
        }


        if (clearWaypoints)
        {
            selectedDrone.DeleteAllWaypoints();
        }


        if (landDrone)
        {
            droneROSConnection.LandDrone();
        }


        if (homeDrone)
        {
            droneROSConnection.FlyHome();
        }
    }
Пример #13
0
        public void GetCurrentBranch_ShouldUseDroneBranch_InCaseOfPullRequestAndEmptyDroneSourceBranchAndInvalidFormatOfCiCommitRefSpec()
        {
            // Arrange
            const string droneBranch            = "droneBranch";
            const string droneSourceBranch      = "droneSourceBranch";
            const string droneDestinationBranch = "droneDestinationBranch";

            string ciCommitRefSpec = $"{droneSourceBranch};{droneDestinationBranch}";

            environment.SetEnvironmentVariable("DRONE_PULL_REQUEST", "1");
            environment.SetEnvironmentVariable("DRONE_SOURCE_BRANCH", "");
            environment.SetEnvironmentVariable("CI_COMMIT_REFSPEC", ciCommitRefSpec);
            environment.SetEnvironmentVariable("DRONE_BRANCH", droneBranch);

            var buildServer = new Drone(environment);

            // Act
            var result = buildServer.GetCurrentBranch(false);

            // Assert
            result.ShouldBe(droneBranch);
        }
        public void DroneFlyDownCheck()
        {
            //arrange
            Drone drone = new Drone();

            //act - takeoff procedure
            drone.Engine.Start();
            drone.TakeOff();

            //act - flyup 150 and down 50
            drone.FlyUp(150);
            drone.FlyDown(50);

            //assert - we should be at 100 alt
            Assert.AreEqual(drone.CurrentAltitude, 100);

            //act - flydown to 0
            drone.FlyDown(100);

            //assert - we should be at 0 alt
            Assert.AreEqual(drone.CurrentAltitude, 0);
        }
Пример #15
0
 public void DoSomething()
 {
     var drones = new Drone[]
     {
         new Drone()
         {
             ID = 0, Position = new Point(1, 2)
         },
         new Drone()
         {
             ID = 1, Position = new Point(3, 4)
         },
         new Drone()
         {
             ID = 2, Position = new Point(4, 2)
         },
     };
     var  myDrone = drones[0];
     bool result  = drones
                    .Where(d => d.ID != myDrone.ID)
                    .All(d => d.IsInsideSafearea(myDrone.Position));
 }
Пример #16
0
    public void SetUp(Drone _drone)
    {
        myDrone          = _drone;
        isInventorySetup = true;
        buildingInventoryUpdatedCallback?.Invoke();
        myAnim = GetComponent <DroneAnimator>();

        transform.position = myDrone.curPosition.Vector3(Position.Type.drone);
        if (!myDrone.targetPosition.isValid())
        {
            myAnim.FlyToLocation(myDrone.targetPosition);
        }
        else
        {
            myAnim.FlyToLocation(myDrone.curPosition);
        }

        myAnim.SetMiningLaser(myDrone.isLaser);
        myDrone.dronePositionUpdatedCallback       += CurrentPositionChanged;
        myDrone.droneLaserStateUpdatedCallback     += LaserStateChanged;
        myDrone.droneTargetPositionUpdatedCallback += MovementTargetChanged;
    }
Пример #17
0
        public async Task <ActionResult <Drone> > PostDrone(Drone drone)
        {
            drone.Perfomance         = (float)(drone.Autonomia / 60.0f) * drone.Velocidade;
            drone.PerfomanceRestante = drone.Perfomance;
            drone.CapacidadeRestante = drone.Capacidade;
            drone.Carga = 1;

            if (drone.Capacidade > 12000)
            {
                drone.Capacidade = 12000;
            }

            if (drone.Autonomia > 35)
            {
                drone.Autonomia = 35;
            }

            _context.Drone.Add(drone);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetDrone", new { id = drone.Id }, drone));
        }
Пример #18
0
 public void GetDataForDrone()
 {
     FirebaseDatabase.DefaultInstance
     .GetReference("USERS").Child(LogInAndRegister.Instance.UserName).Child("GAMESPACE").Child("CONTRACT" + DroneID).Child("DRONE" + DroneID)
     .GetValueAsync().ContinueWith(task =>
     {
         if (task.IsFaulted)
         {
             Debug.Log(task.IsFaulted);
         }
         else if (task.IsCompleted)
         {
             DataSnapshot snapshot = task.Result;
             Debug.Log("DRONE " + snapshot.GetRawJsonValue());
             drone = JsonUtility.FromJson <Drone>(snapshot.GetRawJsonValue());
             Debug.Log("");
             DroneLevel        = drone.DroneLevel;
             PlantsForPlanting = drone.Plants;
             ContractDroneID   = drone.ContactID;
         }
     });
 }
Пример #19
0
        public Program()
        {
            MyIni         config   = ParseIni();
            List <string> sections = new List <string>();

            config.GetSections(sections);

            List <Role> roles = new List <Role>();

            foreach (string section in sections)
            {
                Echo($"Adding Role: {section}");
                //TODO: I'm so sorry...
                if (section.StartsWith("deposit"))
                {
                    continue;
                }
                roles.Add(RoleFactory.Build(section, config, this));
            }

            this.drone = new Drone(this, roles);
        }
Пример #20
0
        private Drone CreateDrone(string droneInfo)
        {
            if (string.IsNullOrEmpty(droneInfo))
            {
                var msg = string.Format("{0}: Input text to create a drone is null or empty, application is not able to create the drone.", this.GetType().Name);
                throw new ArgumentNullException(msg);
            }

            int x;
            int y;
            int direction;
            var info = droneInfo.Split(' ');

            DoValidation(info, 3, "drone");

            int.TryParse(info[0], out x);
            int.TryParse(info[1], out y);
            direction = info[2].ToAngle();
            var drone = new Drone(incrementalDroneId++, x, y, direction);

            return(drone);
        }
Пример #21
0
        private object CanPickupEntity(BasePlayer player, Drone drone)
        {
            if (!IsDroneEligible(drone))
            {
                return(null);
            }

            var storage = GetDroneStorage(drone);

            if (storage == null)
            {
                return(null);
            }

            // Prevent drone pickup while the storage is not empty.
            if (!storage.inventory.IsEmpty())
            {
                return(false);
            }

            return(null);
        }
Пример #22
0
    void Start()
    {
        if (Static._isStart) //시작해야 하는가?
        {
            Static._isStart = false;
            return; //시작이면 아무것도 안함
        }

        _drone          = GameObject.Find("Drone_red").GetComponent <Transform>(); //드론을 담음
        _drone.position = Static._dronePosition;                                   //드론 위치 초기화
        _drone.rotation = Static._droneRotation;                                   //드론 회전 초기화

        _droneScript          = _drone.GetComponent <Drone>();                     //드론 스크립트 담음
        _droneScript._StartUp = Static._droneStartUp;                              //드론 시동 켬

        if (SceneManager.GetActiveScene().buildIndex == 1)                         //1인칭 화면인 경우에는
        {
            Player          = GameObject.Find("FirstPerson").GetComponent <Transform>();
            Player.position = Static._playerPosition; //플레이어 위치 설정
            Player.rotation = Static._playerRotation; //플레이어 회전 설정
        }
    }
Пример #23
0
    // Pre: drone is landed at controller.
    // Returns false if unreachable.
    private bool setFlightPath(Drone drone, Delivery delivery)
    {
        Vector3        destination    = delivery.GetDestination();
        float          flightAltitude = MinBuildingHeight + HeightVariation + HeightClearance;
        List <Vector3> path           = delivery.FlightPath.GetPath();

        if (path.Count == 1)
        {
            return(false);
        }

        List <WaypointInfo> waypointInfos = new List <WaypointInfo>();

        waypointInfos.Add(new WaypointInfo(WaypointType.TAKEOFF));

        foreach (var loc in path)
        {
            waypointInfos.Add(new WaypointInfo(loc));
        }


        waypointInfos.Add(new WaypointInfo(WaypointType.LAND));
        waypointInfos.Add(new WaypointInfo(WaypointType.DELIVER));
        waypointInfos.Add(new WaypointInfo(WaypointType.TAKEOFF));

        path.Reverse();

        foreach (var loc in path)
        {
            waypointInfos.Add(new WaypointInfo(loc));
        }

        waypointInfos.Add(new WaypointInfo(WaypointType.LAND));
        waypointInfos.Add(new WaypointInfo(WaypointType.END));

        droneInfoDict.Add(drone, new DroneInfo(waypointInfos));
        drone.WaypointInfo = droneInfoDict[drone].getNextWaypointInfo();
        return(true);
    }
Пример #24
0
        public static DroneDTO createDroneDTO(Drone droneObj)
        {
            DroneDTO result = new DroneDTO();

            result.id          = droneObj.id;
            result.sysid       = droneObj.connection.systemId.ToString();
            result.componentid = droneObj.connection.componentId.ToString();
            result.name        = droneObj.id.ToString();
            if (null != droneObj.connection)
            {
                result.port = droneObj.connection.portName();
                if (droneObj.connection.isOpen())
                {
                    result.state = DroneDTO.ConnectionState.CONNECTED;
                }
                else
                {
                    result.state = DroneDTO.ConnectionState.DISCONNECTED;
                }
            }
            result.heartbeat_data        = createHeartbeatDTO(droneObj.getHearbeat());
            result.sys_status_data       = createSystemStatusDTO(droneObj.getSystemStatus());
            result.sys_time_data         = createSystemTimeDTO(droneObj.getSystemTime());
            result.gps_raw_int           = createGpsRawIntDTO(droneObj.getGpsRawInt());
            result.raw_imu               = createRawImuDTO(droneObj.getRawImu());
            result.scaled_pressure       = createScaledPressureDTO(droneObj.getScaledPressure());
            result.attitude              = createAttitudeDTO(droneObj.getAttitude());
            result.global_position_int   = createGlobalPositionIntDTO(droneObj.getGlobalPositionInt());
            result.rc_channels_raw       = createRcChannelsRawDTO(droneObj.getRcChannelsRaw());
            result.server_output_raw     = createServoOutputRawDTO(droneObj.getServerOutputRaw());
            result.mission_current       = createMissionCurrentDTO(droneObj.getMissionCurrent());
            result.nav_controller_output = createNavControllerOutputDTO(droneObj.getNavControllerOutput());
            result.vfr_hud               = createVfrHudDTO(droneObj.getVfrHud());
            result.terrain_report        = createTerrainReportDTO(droneObj.getTerrainReport());
            result.scaled_imu_2          = createScaledImu2DTO(droneObj.getScaledImu2());
            result.power_status          = createPowerStatusDTO(droneObj.getPowerStatus());
            return(result);
        }
Пример #25
0
    public override void CollectObservations()
    {
        Vector3 pos = Drone.Position;

        if (IsNewGridPosition(pos))
        {
            Data.AddPoint(new Point(PointType.DronePos, pos, Time.time));
        }

        Data.AddPoint(scanPoint);
        // Number of new leaf nodes created by this scan.
        int   nodeCount  = Data.Tree.Intersect(pos, scanPoint.Position);
        float scanReward = (nodeCount * 0.1f) / Data.LookRadius;

        AddReward(scanReward);

        Data.StepUpdate(pos);

        float linger        = lingerCount / 100f; // 0 - 2
        float lingerPenalty = -linger * 0.1f;

        AddReward(lingerPenalty);

        Vector3 velocity    = Drone.VelocityNorm;
        Vector4 proximity   = Drone.GetForwardProximity();
        float   proxPenalty = (1f - 1f / Mathf.Max(proximity.w, 0.1f)) * velocity.sqrMagnitude * 0.25f;

        AddReward(proxPenalty);

        AddVectorObs(linger - 1f);                // 1
        AddVectorObs(velocity);                   // 3
        AddVectorObs((Vector3)proximity);         // 3
        AddVectorObs(proximity.w * 2f - 1f);      // 1
        AddVectorObs(Data.LookRadiusNorm);        // 1
        AddVectorObs(Data.NodeDensities);         // 8
        AddVectorObs(Data.IntersectRatios);       // 8
        AddVectorObs(Drone.ScanBuffer.ToArray()); // 30
    }
Пример #26
0
        public async Task <bool> Handle(AdicionarDroneCommand request, CancellationToken cancellationToken)
        {
            if (!request.EhValido())
            {
                return(false);
            }

            var drone = new Drone();

            drone.Capacidade        = request.Capacidade;
            drone.Velocidade        = request.Velocidade;
            drone.Autonomia         = request.Autonomia;
            drone.Carga             = request.Carga;
            drone.AutonomiaRestante = request.AutonomiaRestante;

            await _droneRepository.Adicionar(drone);

            var resultDrone = await _droneRepository.UnitOfWork.Commit();

            if (resultDrone)
            {
                var droneItinerario = new DroneItinerario
                {
                    DataHora    = request.DataHora,
                    Drone       = drone,
                    DroneId     = drone.Id,
                    StatusDrone = request.StatusDrone
                };

                await _droneItinerarioRepository.Adicionar(droneItinerario);

                return(await _droneItinerarioRepository.UnitOfWork.Commit());
            }
            else
            {
                return(false);
            }
        }
Пример #27
0
    // Update is called once per frame
    void Update()
    {
        //Reposition the screen in front our the Camera when its ready
        if (ZEDManager.Instance.IsZEDReady && !_warning)
        {
            StartCoroutine(WarningDisplay());
            _warning = true;
        }

        if (!_canSpawn)
        {
            return;
        }

        //Tick down the respawn timer if applicable
        if (_respawnCountdown > 0)
        {
            _respawnCountdown -= Time.deltaTime;
        }

        if (_readyToSpawn) //We've got no drone and the respawn timer has elapsed
        {
            //Try to spawn a drone in a random place in front of the player. We'll do once per frame for now.
            if (CheckRandomSpawnLocation(out _randomPosition))
            {
                _currentDrone = SpawnDrone(_randomPosition);
            }
        }

        //Debug Solution to spawn drone multiple times for testing.
        //On Input Down, destroy current drone.
        if (Input.GetKeyDown(KeyCode.Mouse1))
        {
            //Destroys the current Drone.
            Destroy(_currentDrone.gameObject);
            ClearDrone();
        }
    }
Пример #28
0
    public void handleDataNearby(List <CommunicationDataStructureValue> responseData)
    {
        int            id, entityType;
        long           entityId, lastSeen;
        Vector3D       position;
        string         entityName;
        Drone          myDrone = Communication.currentNode;
        DetectedEntity nearbyEntity;

        foreach (CommunicationDataStructureValue data in responseData)
        {
            if (data.getName() == "id")
            {
                id = int.Parse(data.getValue());
            }
            else if (data.getName() == "Entity")
            {
                entityName = data.getValue();
                entityType = int.Parse(data.getAdditional(0).getValue());
                entityId   = long.Parse(data.getAdditional(1).getValue());
                position   = new Vector3D(
                    double.Parse(data.getAdditional(2).getValue()),
                    double.Parse(data.getAdditional(3).getValue()),
                    double.Parse(data.getAdditional(4).getValue())
                    );
                lastSeen = long.Parse(data.getAdditional(5).getValue());

                nearbyEntity          = new DetectedEntity();
                nearbyEntity.id       = entityId;
                nearbyEntity.name     = entityName;
                nearbyEntity.distance = myDrone.navHandle.getDistanceFrom(myDrone.navHandle.getShipPosition(), position);
                nearbyEntity.type     = DetectedEntity.getEntityType(entityType);
                nearbyEntity.position = position;
                nearbyEntity.lastSeen = lastSeen;
                Communication.currentNode.navHandle.addNearbyEntity(nearbyEntity);
            }
        }
    }
Пример #29
0
        public IHttpActionResult setMode(string id, [FromBody] SetModeAction parameters)
        {
            String action = "setMode";

            logger.Debug("running command {1} on /drones/{0}", id, action);
            if (null == parameters)
            {
                return(BadRequest("Missing Required Parameters"));
            }
            Drone target = droneMgr.getById(new Guid(id));

            if (null != target)
            {
                if (!target.isConnected())
                {
                    return(BadRequest("Target system is not connected, refusing request"));
                }
                MAVLink.MAV_MODE mode = 0;
                try
                {
                    mode = (MAVLink.MAV_MODE)Enum.Parse(typeof(MAVLink.MAV_MODE), parameters.mode);
                }
                catch (Exception e)
                {
                    return(BadRequest(e.Message));
                }
                CommandAck result = target.Command.setMode(mode);
                if (null == result)
                {
                    return(new CustomResponse("Null command result.", HttpStatusCode.RequestTimeout));
                }
                return(Ok(DTOFactory.DTOFactory.createCommandAckDTO(result)));
            }
            else
            {
                return(NotFound());
            }
        }
Пример #30
0
    /// <summary>
    /// Initilize the drone sim with the required references.
    /// </summary>
    /// <param name="droneInit"></param>
    public void InitDroneSim()
    {
        // Load the drone simulated by this script.
        drone = GetComponent <DroneProperties>().droneClassPointer;

        // Compute the total mass of the quadrotor.
        totalMass = bodyMass + 4 * rotorMass;

        // Model the quadrotor's body and its rotors as spheres, and compute its moments of inertia.
        float bodyInertia  = 2.0f * bodyMass * bodyRadius * bodyRadius / 5.0f;
        float rotorInertia = rodLength * rodLength * rotorMass;

        inertia.x = bodyInertia + 2.0f * rotorInertia;
        inertia.y = bodyInertia + 4.0f * rotorInertia;
        inertia.z = bodyInertia + 2.0f * rotorInertia;

        // Store the quadrotor's staring position.
        homeLocation = drone.gameObjectPointer.transform.localPosition;

        // Initialize the flight status.
        droneStatus     = FlightStatus.ON_GROUND_STANDBY;
        droneStatusPrev = FlightStatus.NULL;
    }
        public void DroneMinAltCheck()
        {
            //arrange
            Drone drone = new Drone();

            //act - takeoff procedure
            drone.Engine.Start();
            drone.TakeOff();

            //act - flyup 500, down 1000
            drone.FlyUp(500);
            drone.FlyDown(1000);

            //assert - we are still at 500
            Assert.AreEqual(drone.CurrentAltitude, 500);

            //act - fly to 0 then down 5k, going past 0
            drone.FlyDown(500);
            drone.FlyDown(5000);

            //assert - we are at 0 right?
            Assert.AreEqual(drone.CurrentAltitude, 0);
        }
Пример #32
0
        private Queue <Drone> InitDronesWithCommands(Dictionary <OrderDto, Point> productQueue, int dronesNumber, int droneMaxWeight, List <Warehouse> warehouses, List <Order> orders)
        {
            var dronesQueue = new Queue <Drone>();

            for (var i = 0; i < dronesNumber; i++)
            {
                var drone = new Drone()
                {
                    Id        = i,
                    R         = warehouses[0].R,
                    C         = warehouses[0].C,
                    MaxWeight = droneMaxWeight,
                    Turns     = 0,
                    Commands  = new Queue <Command>()
                };

                var product = productQueue.First();
                productQueue.Remove(product.Key);
                SetDroneCommands(drone, warehouses, product, orders);
                dronesQueue.Enqueue(drone);
            }
            return(dronesQueue);
        }
Пример #33
0
        IHttpActionResult commandNoParams(string id, string action)
        {
            logger.Debug("running command {1} on /drones/{0}", id, action);
            Drone target = droneMgr.getById(new Guid(id));

            if (null != target)
            {
                if (!target.isConnected())
                {
                    return(BadRequest("Target system is not connected, refusing request"));
                }
                CommandAck result = runCommand(target, action);
                if (null == result)
                {
                    return(NotFound());
                }
                return(Ok(DTOFactory.DTOFactory.createCommandAckDTO(result)));
            }
            else
            {
                return(NotFound());
            }
        }
Пример #34
0
        public void Robots_OperatorPlus_DuplicateRobots_ShouldNotAddDuplicate()
        {
            Robots       robots1 = new Robots();
            Robots       robots2 = new Robots();
            Drone        dron    = new Drone("Drone", 10.5, 100.5);
            Mower        mower   = new Mower("Mower", 6.3, 1.2, 250);
            DrivingRobot funCar  = new DrivingRobot("FunCar", 33.5, 55.5);
            Mower        mower2  = new Mower("Mower2", 8.3, 1.2, 250);
            Drone        dron2   = new Drone("Drone", 10.5, 100.5);
            bool         ok      = robots1.AddRobot(mower);

            ok = robots1.AddRobot(dron);
            ok = robots1.AddRobot(funCar);
            ok = robots2.AddRobot(mower2);
            ok = robots2.AddRobot(dron2);
            Robots union = robots1 + robots2;

            Assert.AreEqual(4, union.Count, "Dron2 ist doppelt und wurde nicht übernommen");
            Assert.AreEqual("FunCar", union.GetAt(0).Name, "Roboter an Position 0 wurde falsch zurückgegeben");
            Assert.AreEqual("Drone", union.GetAt(1).Name, "Roboter an Position 1 wurde falsch zurückgegeben");
            Assert.AreEqual("Mower2", union.GetAt(2).Name, "Roboter an Position 2 wurde falsch zurückgegeben");
            Assert.AreEqual("Mower", union.GetAt(3).Name, "Roboter an Position 3 wurde falsch zurückgegeben");
        }
Пример #35
0
        private static bool CanPickupInternal(BasePlayer player, Drone drone)
        {
            if (!IsDroneEligible(drone))
            {
                return(true);
            }

            var turret = GetDroneTurret(drone);

            if (turret == null)
            {
                return(true);
            }

            // Prevent drone pickup while it has a turret (the turret must be removed first).
            // Ignores NPC turrets since they can't be picked up.
            if (turret != null && !(turret is NPCAutoTurret))
            {
                return(false);
            }

            return(true);
        }
Пример #36
0
            private void ProcessUnicast()
            {
                MyIGCMessage message = Drone.NetworkService.GetUnicastListener().AcceptMessage();

                if (message.Data == null)
                {
                    Drone.LogToLcd($"\nNo Message");
                }

                // TODO: This could be a switch
                if (message.Tag == DockingRequestChannel && DockingAttempt != null)
                {
                    DockingAttempt.ProcessClearance(message);
                }
                else if (message.Tag == "recall")
                {
                    this.State = 4;
                }
                else
                {
                    Drone.LogToLcd($"{message.Tag} is not a recognized message format.");
                }
            }
Пример #37
0
 void setDroneText(Drone drone, GameObject prefab)
 {
     prefab.transform.Find("hp").GetComponent <Text>().text   = "hp :" + drone.hp.ToString();
     prefab.transform.Find("Name").GetComponent <Text>().text = drone.name;
     prefab.transform.Find("kineticDmgResonnance").GetComponent <Text>().text   = "kinetic: " + drone.kineticDamageResonance.ToString();
     prefab.transform.Find("thermalDmgResonnance").GetComponent <Text>().text   = "thermal: " + drone.thermalDamageResonance.ToString();
     prefab.transform.Find("explosiveDmgResonnance").GetComponent <Text>().text = "explo: " + drone.explosiveDamageResonance.ToString();
     prefab.transform.Find("emDmgResonnance").GetComponent <Text>().text        = "em: " + drone.emDamageResonance.ToString();
     prefab.transform.Find("Shield").GetComponent <Text>().text          = "shield: " + drone.shieldCapacity.ToString();
     prefab.transform.Find("emShield").GetComponent <Text>().text        = "em: " + drone.shieldEmDamageResonance.ToString();
     prefab.transform.Find("explosiveShield").GetComponent <Text>().text = "explo: " + drone.shieldExplosiveDamageResonance.ToString();
     prefab.transform.Find("kineticShield").GetComponent <Text>().text   = "kinetic: " + drone.shieldKineticDamageResonance.ToString();
     prefab.transform.Find("thermalShield").GetComponent <Text>().text   = "thermal: " + drone.shieldThermalDamageResonance.ToString();
     prefab.transform.Find("Armor").GetComponent <Text>().text           = "armor: " + drone.armorHp.ToString();
     prefab.transform.Find("emArmor").GetComponent <Text>().text         = "em: " + drone.armorEmDamageResonance.ToString();
     prefab.transform.Find("explosiveArmor").GetComponent <Text>().text  = "explo: " + drone.armorExplosiveDamageResonance.ToString();
     prefab.transform.Find("kineticArmor").GetComponent <Text>().text    = "kinetic: " + drone.armorKineticDamageResonance.ToString();
     prefab.transform.Find("thermalArmor").GetComponent <Text>().text    = "thermal: " + drone.armorThermalDamageResonance.ToString();
     prefab.transform.Find("emDmg").GetComponent <Text>().text           = "em: " + drone.emDamage.ToString();
     prefab.transform.Find("explosiveDmg").GetComponent <Text>().text    = "explo: " + drone.explosiveDamage.ToString();
     prefab.transform.Find("kineticDmg").GetComponent <Text>().text      = "kinetic: " + drone.kineticDamage.ToString();
     prefab.transform.Find("thermalDmg").GetComponent <Text>().text      = "thermal: " + drone.thermalDamage.ToString();
 }
Пример #38
0
    protected override void Start()
    {
        base.Start ();
        //db = transform.Find("dickBat");
        eDamageT = transform.Find("eDamageGO");
        eDamage = transform.Find("eDamageGO").GetComponent<Enemy_Damage>();
        eDamage.enemyCS = this;

        eDamage.AwakeAfter(transform.Find ("damage"));
        dickT = transform.Find("dWeapon");
        dickA = dickT.GetComponent<Animator>();

        droneCS = GetComponent<Drone> ();

        //if (transform.Find ("sniperHand")) {
            //transform.Find ("sniperHand").GetComponent<SniperSight>().StartSniping();
        //}
    }
Пример #39
0
 void LoadItem(Drone drone, Warehouse warehouse, int productType, int quantity)
 {
     drone.Commands.Add(new LoadCommand(warehouse.Index, productType, quantity));
     drone.WillBeFreeAtStep += GetStepsToGo(drone.FreeLocation, warehouse.Location) + 1;
     drone.FreeLocation = warehouse.Location;
     drone.LoadedProducts.Add(new Product { ProductType = productType, Quantity = quantity });
     warehouse.Products[productType].Quantity -= quantity;
 }
Пример #40
0
        void SendDrone(Drone drone, Warehouse warehouse, Order order, Product product, int amount)
        {
            drone.Commands.Add(new LoadCommand(warehouse.Index, product.ProductType, amount));
            drone.Commands.Add(new DeliverCommand(order.Index, product.ProductType, amount));

            drone.WillBeFreeAtStep += GetStepsToDoneOrder(drone, warehouse, order);

            drone.FreeLocation = order.Location;
        }
Пример #41
0
 public virtual void Setup(FlightCourse fc, Drone playerDrone)
 {
 }
Пример #42
0
 // Set the drone that this flight controller controls
 public virtual void SetDrone(Drone drone)
 {
     _drone = drone;
 }
Пример #43
0
    private static void mapDronesToZones(Drone[] drones, Zone[] zones, int me)
    {
        foreach (var d in drones)
            d.Zone = null;

        foreach (var zone in zones)
        {
            zone.Drones = drones.Where(d => d.SquareDistanceTo(zone) < 10000).ToArray();
            foreach (var d in zone.Drones)
                d.Zone = zone;

            zone.RequiredDrones = (zone.Team == me ? 0 : 1)
                + zone.Drones
                    .Where(d => d.Team != me)
                    .GroupBy(d => d.Team)
                    .Select(grp => grp.Count())
                    .DefaultIfEmpty(0)
                    .Max();

            //log("Zone {0} has {1} drones, is controlled by {2} and requires {3} drones", zone.Index, (zone.Drones==null?0:zone.Drones.Count()), zone.Team, zone.RequiredDrones);
        }
    }
Пример #44
0
 public override void SetDrone(Drone drone)
 {
     base.SetDrone(drone);
     _forward = _drone.transform.forward;
 }
Пример #45
0
    public List<Drone> SpawnDrones()
    {
        List<Drone> drones = new List<Drone>();
        int totalDrones = 5;

        for (var i = 0; i < totalDrones; i++)
        {
            var position = new Vector3(
                Random.Range(-2000f, 2000f),
                Random.Range(0f, 200f),
                Random.Range(-2000f, 2000f)
            );
            var drone = new Drone(position, this);
            drones.Add(drone);
        }

        Debug.Log("Total drones: " + drones.Count);
        return drones;
    }
Пример #46
0
    // Update is called once per frame
    void Update()
    {
        var ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if(container == null)
        {

            RaycastHit info;
            if (Physics.Raycast (ray, out info, 12.0f))
            {
                var cM = info.collider.gameObject.GetComponent<Drone>();
                if(cM != null)
                {
                    mouseOverLabel.gameObject.SetActive(true);
                    mouseOverLabel.rectTransform.anchoredPosition = (Vector2)Input.mousePosition-30.0f*Vector2.up;
                    mouseOverLabel.text = info.collider.gameObject.name;
                    if(Input.GetMouseButtonDown(0))
                    {
                        container = cM;
                        container.Activate();
                        character.enabled = false;
                        character.gameObject.GetComponent<Rigidbody>().isKinematic = true;
                        character.gameObject.GetComponent<Collider>().enabled = false;
                        character.transform.parent = container.transform;
                        character.transform.localPosition = Vector3.zero;
                        cF.target = container.gameObject;
                        mouseOverLabel.gameObject.SetActive(false);
                    }

                } else mouseOverLabel.gameObject.SetActive(false);
            } else mouseOverLabel.gameObject.SetActive(false);
        }
        else
        {
            RaycastHit info;
            if (Physics.Raycast (ray, out info, 12.0f))
            {
                var cN = info.collider.gameObject.GetComponent<ComponentBase>();
                if(cN != null)
                {
                    if(cN.transform.parent == null)
                    {
                        if(container.CurrentIndex() != -1)
                        {
                            connectionSelector.SetActive(true);
                            connectionSelector.transform.position = container.connections[container.CurrentIndex()].pointPos;
                        }

                        if( Input.GetAxis("Mouse ScrollWheel") != 0 && connectionSelector.activeSelf)
                        {
                            if(Input.GetAxis("Mouse ScrollWheel") > 0) container.NextIndex();
                            else container.PreviousIndex();
                            if(container.CurrentIndex() != -1) connectionSelector.transform.position = container.connections[container.CurrentIndex()].pointPos;
                        }
                    }

                    mouseOverLabel.gameObject.SetActive(true);
                    mouseOverLabel.rectTransform.anchoredPosition = (Vector2)Input.mousePosition-30.0f*Vector2.up;
                    mouseOverLabel.text = info.collider.gameObject.name;
                    if(Input.GetMouseButtonDown(0))
                    {
                        if(cN.transform.parent == null)
                        {
                            container.Connect(cN);
                        }
                        else
                        {
                            container.Disconnect (cN);
                        }
                    }
                }
                else
                {
                    mouseOverLabel.gameObject.SetActive(false);
                    connectionSelector.SetActive(false);
                }
            }
            else if(mouseOverLabel.gameObject.activeSelf)
            {
                mouseOverLabel.gameObject.SetActive(false);
                connectionSelector.SetActive(false);
            }

            if(Input.GetKeyDown(KeyCode.X))
            {
                container.Deactivate ();
                character.enabled = true;
                character.transform.parent = null;
                character.transform.position = container.transform.position - container.transform.forward * 2.25f;
                character.transform.rotation = container.transform.rotation;
                character.gameObject.GetComponent<Rigidbody>().isKinematic = false;
                character.gameObject.GetComponent<Collider>().enabled = true;
                cF.target = character.gameObject;
                container = null;
                connectionSelector.SetActive(false);
            }
        }
    }
Пример #47
0
    void SetupDrones()
    {
        if (StartingPoints.Length <= 0)
            throw new System.Exception("No starting points");

        // Spawn the player drone
        GameObject playerDrone = (GameObject)GameObject.Instantiate(Globals.Drones[0].Prefab, StartingPoints[0].transform.position, StartingPoints[0].transform.rotation);
        _playerDrone = playerDrone.GetComponent<Drone>();

        // Spawn AI Drones

        // Spawn Cameras
        _cameras = new GameCamera[Globals.Cameras.Length];
        for (int i = 0; i < _cameras.Length; i++)
        {
            GameObject cam = (GameObject)Instantiate(Globals.Cameras[i].Prefab);
            GameCamera gc = cam.GetComponent<GameCamera>();
            gc.Setup(this, _playerDrone);
            cam.SetActive(false);
            _cameras[i] = gc;
        }
        _cameras[0].gameObject.SetActive(true);     // Activate the main camera

        // Assign flight controller
        Globals.FlightController.Reset();
        Globals.FlightController.SetDrone(_playerDrone);
    }
Пример #48
0
 // Use this for initialization
 void Start()
 {
     droneScr = GetComponent<Drone>();
     SetBounds();
 }
 private void Awake()
 {
     npc = GetComponentInParent<Drone>();
     detectedColliders = new List<Collider>();
 }
Пример #50
0
 private void OnEnterPortal(int portalId, Drone d)
 {
     if (activated) {
         Debug.Log ("Enter portal " + portalId);
     }
 }
Пример #51
0
 int GetStepsToDoneOrder(Drone drone, Warehouse warehouse, Order order)
 {
     return GetStepsToGo(drone.FreeLocation, warehouse.Location) + drone.LoadedProducts.Count() + 1 +
            GetStepsToGo(warehouse.Location, order.Location) + 1;
 }
Пример #52
0
        private Task FillDrone(Drone drone, ProductStock request)
        {
            Task task = default(Task);
            task.ProductType = request.ProductType;
            int avaibleCapicaity = drone.Capiciaty;
            int itemWeight = request.ProductType.Weight;

            while(avaibleCapicaity >= itemWeight)
            {
                avaibleCapicaity -= request.ProductType.Weight;
                task.Quanity += 1;
            }
            return task;
        }
Пример #53
0
        public Moves GenerateMove(Drone drone, Point startPosition, List<Target> pathes, List<Point> avoidTargets)
        {
            var moves = new List<Moves>();

            avoidTargets = avoidTargets
                .Where(at => !pathes.Select(x => x.Position).Contains(at))
                .ToList();

            if (!pathes.Any())
            {
                return Moves.Stand;
            }

            var path = pathes.First();

            var shortestPath = AStar.FindPath(
                startPosition,
                n => PathFinder.GetNeightboors(Map, n, avoidTargets),
                (src, dst) => 0,
                h => DistanceHelper.GetDistance(Map, h, path.Position).Distance,
                end => end == path.Position)
                .ToList();

            if (shortestPath.Any())
            {
                shortestPath.Reverse();

                drone.Position = shortestPath
                    .Skip(1)
                    .First();

                return MoveHelper.GetMovesFromPath(Map, shortestPath)
                    .First();
            }


            return Moves.Stand;
        }
Пример #54
0
 void UnoadItem(Drone drone, Order order, int productType, int quantity)
 {
     drone.Commands.Add(new DeliverCommand(order.Index, productType, quantity));
     drone.WillBeFreeAtStep += GetStepsToGo(drone.FreeLocation, order.Location) + 1;
     drone.FreeLocation = order.Location;
 }
Пример #55
0
    // Hier wird die Tabelle Drone gefüllt
    // Zurzeit ist es nur eine Drone
    public void fillTableDronen()
    {
        Debug.Log ("Dronen");
        IDbConnection _connection = new SqliteConnection(_strDBName);
        IDbCommand _command = _connection .CreateCommand();
        string sql;
        _connection.Open();
        sql = " Delete From DRONEN";
        _command.CommandText = sql;
        _command.ExecuteNonQuery ();

        _connection.Close ();
        _connection.Dispose ();
        _connection = null;
        _command.Dispose ();
        _command = null;

        Drone drone = new Drone ();
        drone.setName ("QuadCopter");drone.setStatus ("0");this.addDrone (drone);
        drone = null;
    }
Пример #56
0
 public DroneAI(Drone d)
     : base(d)
 {
     drone = d;
 }