private void Start() { // get the drone controller m_Drone = GetComponent <DroneController>(); friends = GameObject.FindGameObjectsWithTag("Drone"); myIndex = -1; for (int idx = 0; idx < friends.Length; idx++) { if (friends[idx].transform == m_Drone.transform) { myIndex = idx; break; } } terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>(); tInfo = terrain_manager.myInfo; Vector3 start_pos = m_Drone.transform.position; Vector3 goal_pos = my_goal_object.transform.position; mHighResMap = new HighResMap(ref tInfo, 1); AStar aster = new AStar(ref mHighResMap); int i = mHighResMap.get_i_index(transform.position.x); int j = mHighResMap.get_j_index(transform.position.z); int iEnd = mHighResMap.get_i_index(goal_pos.x); int jEnd = mHighResMap.get_j_index(goal_pos.z); tPath = aster.ComputePath(i, j, iEnd, jEnd); mDecision = new DroneDecisionSimple(ref m_Drone, ref friends, ref mHighResMap, tPath); //status init ifMoveable = false; ifFinished = false; }
//Button method to spawn the given drone public void SpawnDrone(GameObject droneGO) { if (droneGO == null) { return; } //Close the spawnable sub-menues showDrones.SetActive(false); showForms.SetActive(false); if (startupAnimationIndex == 0) { CheckVisibilityOfMenuParts(); } //Destroy the current drone (and everything else that shouldn't exist as a child) foreach (Transform child in transform) { Destroy(child.gameObject); } //Instantiate and setup the drone drone = Instantiate(droneGO, transform).GetComponent <DroneController>(); drone.transform.position = spawnPosition; drone.transform.rotation = Quaternion.Euler(spawnRotation); droneStatusText.text = "Drone status: stationary"; //If the editor button isn't interable, make it so (as there is a drone to edit now) if (!droneEditorBtn.interactable) { droneEditorBtn.interactable = true; } }
void Start() { controller = GetComponent <DroneController>(); // Velocity = 3f; }
private void OnBestDroneChanged(DroneController bestDrone) { var drones = GameObject.FindObjectsOfType <DroneController>(); if (UIController != null) { UIController.SetDisplayTarget(bestDrone); } if (bestDrone == null || drones == null || CameraAir.useAirCam) { return; } foreach (var drone in drones) { var camera = drone.GetComponentInChildren <CameraFollow>(true); if (camera.gameObject.transform.parent.gameObject != bestDrone.gameObject) { camera.gameObject.SetActive(false); } else { camera.gameObject.SetActive(true); } } }
public static Role Build(string roleName, MyIni config, Program program = null) { Role builtRole; switch (roleName) { case "miner": builtRole = new Miner(config); break; case "drone_controller": builtRole = new DroneController(config); break; case "tester": builtRole = new Tester(config); break; case "network_tester": builtRole = new NetworkTester(config); break; case "surveyor": builtRole = new Surveyor(config); break; default: throw new Exception($"Unable to build role: {roleName}"); break; } return(builtRole); }
private void Awake() { if (drone == null) { drone = this; } }
public TakePictureCommand(DroneController controller, int id) { _controller = controller; _id = id; _subDestPath = "images/" + _id + "/"; _websitePath = "../../../../../Website/"; }
private void Start() { // get the car controller m_Drone = GetComponent <DroneController>(); terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>(); // note that both arrays will have holes when objects are destroyed // but for initial planning they should work friend_tag = gameObject.tag; if (friend_tag == "Blue") { enemy_tag = "Red"; } else { enemy_tag = "Blue"; } friends = GameObject.FindGameObjectsWithTag(friend_tag); enemies = GameObject.FindGameObjectsWithTag(enemy_tag); ball = GameObject.FindGameObjectWithTag("Ball"); // Plan your path here // ... }
void Start() { ds = GetComponent <DroneSensors>(); dm = GetComponent <DroneMotors>(); dc = GetComponent <DroneController>(); rigidbody = GetComponent <Rigidbody>(); }
public void SetDroneAmount(int amount) { if (amount < 0) { throw new ArgumentException("Amount may not be less than zero."); } if (amount == DroneCount) { return; } if (amount > drones.Count) { for (int toBeAdded = amount - drones.Count; toBeAdded > 0; toBeAdded--) { GameObject droneCopy = Instantiate(PrototypeDrone.gameObject); droneCopy.transform.position = startPosition; droneCopy.transform.rotation = startRotation; DroneController controllerCopy = droneCopy.GetComponent <DroneController>(); drones.Add(new MarsDrone(controllerCopy, 1)); droneCopy.SetActive(true); } } else if (amount < drones.Count) { for (int toBeRemoved = drones.Count - amount; toBeRemoved > 0; toBeRemoved--) { MarsDrone last = drones[drones.Count - 1]; drones.RemoveAt(drones.Count - 1); Destroy(last.Drone.gameObject); } } }
private void Start() { // get the car controller m_Drone = GetComponent <DroneController>(); terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>(); pbTree = GetComponent <PandaBehaviour>(); // note that both arrays will have holes when objects are destroyed // but for initial planning they should work friend_tag = gameObject.tag; if (friend_tag == "Blue") { enemy_tag = "Red"; attackDirection = Vector3.right; } else { enemy_tag = "Blue"; attackDirection = Vector3.left; } friends = GameObject.FindGameObjectsWithTag(friend_tag); enemies = GameObject.FindGameObjectsWithTag(enemy_tag); initAcc(); ball = GameObject.FindGameObjectWithTag("Ball"); myDefencePoint = new Vector3(120f, 0f, 100f); for (playerNum = 0; friends[playerNum].transform != m_Drone.transform; playerNum++) { } time = Time.fixedDeltaTime * 50f; //FixedUpdate(); }
public void Restart() { GameObject newDrone = Instantiate(originalDrone.gameObject); newDrone.SetActive(true); newDrone.transform.SetParent(this.transform); newDrone.transform.position = this.transform.position; if (currentDrone != null) { currentDrone.Stop(newDrone); oldDrones.Add(currentDrone); int fadecount = 0; foreach (DroneController droneController in oldDrones) { droneController.SetDeadAlpha(Mathf.Clamp(1.0f - oldDrones.Count * 0.09f + fadecount * 0.10f, 0.0f, 1.0f)); if (droneController != null) { Physics2D.IgnoreCollision(newDrone.GetComponent <Collider2D>(), droneController.gameObject.GetComponent <Collider2D>()); } fadecount += 1; } if (oldDrones.Count > 10) { Destroy(oldDrones[0].gameObject); oldDrones.RemoveAt(0); } } currentDrone = newDrone.GetComponent <DroneController>(); currentDrone.GetComponent <Rigidbody2D>().velocity += initialVelocity; lostDrones += 1; AudioController.instance.JustBeep(); }
public void Update(DroneController drone) { position = drone.transform.position; direction = drone.velocity.normalized; velocity = drone.velocity.magnitude; UpdateController(); }
bool attack = true; //se sto perdendo o pareggiando private void Start() { // get the car controller m_Drone = GetComponent <DroneController>(); terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>(); // note that both arrays will have holes when objects are destroyed // but for initial planning they should work friend_tag = gameObject.tag; if (own_goal.CompareTag("blue")) { enemy_tag = "red"; friend_tag = "blue"; } else { enemy_tag = "blue"; friend_tag = "red"; } friends = GameObject.FindGameObjectsWithTag(friend_tag); enemies = GameObject.FindGameObjectsWithTag(enemy_tag); ball = GameObject.FindGameObjectWithTag("Ball"); Debug.Log("own goal" + own_goal); }
public void AddDrone(DroneController drone, float target_velocity, Vector3 goal) { Drone d = new Drone(drone, drone_radius, goal); d.SetTargetVelocity(target_velocity); drone_population.Add(drone.GetInstanceID(), d); }
public Vector3 NextMove(DroneController drone, Vector3 goal) { float dt = Time.deltaTime; Drone info_drone = drone_population[drone.GetInstanceID()]; info_drone.Update(drone); float v = info_drone.GetEstimatedVelocityInput(); Vector3 move = (goal - drone.transform.position).normalized; move = AdjustFormation(info_drone, move); move = AdjustIntercept(info_drone, move); move = AdjustWallRepulsion(info_drone, move); //move = AdjustGoalCollision(info_drone, move); //AdjustGoalSpeed(info_drone, goal); /* * if (Vector3.Angle(info_drone.direction, move) >= 45f) * { * info_drone.SetTargetVelocity(Mathf.Clamp(info_drone.target_velocity - 0.5f, 3, 15)); * }*/ return(move * v); }
private void Start() { // get the drone controller m_Drone = GetComponent <DroneController>(); terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>(); Vector3 start_pos = terrain_manager.myInfo.start_pos; Vector3 goal_pos = terrain_manager.myInfo.goal_pos; drone_pos = start_pos; RRTSD rrt = new RRTSD(terrain_manager_game_object); my_path = rrt.Run(); // initialize the starting position for the model x = start_pos[0]; z = start_pos[2]; // set the next node in the path to be the one after the start node next = 1; // plot the path in the scene window Vector3 old_wp = start_pos; foreach (var wp in my_path) { UnityEngine.Debug.DrawLine(old_wp, wp.pos, Color.red, 100f); old_wp = wp.pos; } }
/* ajouté */ // Calculates the completion percentage of given car with given completed last checkpoint. // This method will update the given checkpoint index accordingly to the current position. private float GetCompletePerc(DroneController drone, ref uint curCheckpointIndex) { //Already all checkpoints captured if (curCheckpointIndex >= checkpoints.Length) { return(1); } //Calculate distance to next checkpoint float checkPointDistance = Vector3.Distance(drone.transform.position, checkpoints[curCheckpointIndex].transform.position); /* a revoir */ //Check if checkpoint can be captured if (checkpoints[curCheckpointIndex].GetComponent <Renderer>().bounds.Contains(drone.transform.position)) { Debug.Log("Checkpoint completed !!!"); curCheckpointIndex++; drone.CheckpointCaptured(); //Inform car that it captured a checkpoint return(GetCompletePerc(drone, ref curCheckpointIndex)); //Recursively check next checkpoint } else { //Return accumulated reward of last checkpoint + reward of distance to next checkpoint return(checkpoints[curCheckpointIndex - 1].AccumulatedReward + checkpoints[curCheckpointIndex].GetRewardValue(checkPointDistance)); } }
// Start is called before the first frame update void Start() { m_Drone = GetComponent <DroneController>(); team_tag = "Red"; ball = GameObject.FindGameObjectWithTag("Ball"); state = 0; }
private EnemyController CreateController() { EnemyController controller; switch (this.enemyType) { case EnemyType.Mine: controller = new MineController(this); break; case EnemyType.Drone: controller = new DroneController(this); break; case EnemyType.MineLayer: controller = new MineLayerController(this); break; case EnemyType.Warrior: controller = new WarriorController(this); break; case EnemyType.Warlord: controller = new WarriorController(this); break; default: controller = new MineController(this); break; } return(controller); }
void Awake() { if (!enemyController) { enemyController = GetComponent <EnemyController>(); } if (!droneController) { droneController = GetComponentInChildren <DroneController>(); } if (!rb) { rb = GetComponent <Rigidbody>(); } enemyController.GivesExperienceWhenKilled = false; enemyController.HandleFightBack = false; if (!attackRadiusCollider || !activateRadiusCollider) { var colliders = GetComponents <SphereCollider>(); if (colliders.Length == 2) { attackRadiusCollider = colliders[0]; activateRadiusCollider = colliders[1]; } else { Debug.LogError("Blerp"); } } name = "___RAID__BOSS___"; EnsureRaidManager(); }
public bool GetControllerConnectedStatus() { DroneController dc = new DroneController(); dc.Update(); return(dc.IsConnected); }
void Update() { attachedObject = spawnedDrones; // for destroying when tower is destroyed if (!spawning) { if (spawnedDrones == null) { StartCoroutine(WaitForSpawn()); } } if (Input.GetMouseButtonDown(0)) { if (spawnedDrones != null) { DroneController dC = spawnedDrones.GetComponent <DroneController>(); newPosition = SelectTarget(dC.xMin, dC.xMax, dC.yMin, dC.yMax); } } if (moving) { MoveToNewPos(newPosition); } }
private void Start() { pandaBT = GetComponent <PandaBehaviour>(); rb = GetComponent <Rigidbody>(); // get the drone controller m_Drone = GetComponent <DroneController>(); terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>(); friend_tag = gameObject.tag; if (friend_tag == "Blue") { enemy_tag = "Red"; } else { enemy_tag = "Blue"; } friends = GameObject.FindGameObjectsWithTag(friend_tag); enemies = GameObject.FindGameObjectsWithTag(enemy_tag); ball = GameObject.FindGameObjectWithTag("Ball"); goalie = friends[0]; }
private void Start() { m_DroneController = GetComponent <DroneController>(); Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (!drone) { drone = animator.GetComponent <DroneController>(); } }
private void Start() { // get the drone controller m_Drone = GetComponent <DroneController>(); terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>(); Vector3 start_pos = terrain_manager.myInfo.start_pos; Vector3 goal_pos = terrain_manager.myInfo.goal_pos; List <Vector3> my_path = new List <Vector3>(); // Plan your path here // ... my_path.Add(start_pos); for (int i = 0; i < 3; i++) { Vector3 waypoint = start_pos + new Vector3(UnityEngine.Random.Range(-50.0f, 50.0f), 0, UnityEngine.Random.Range(-30.0f, 30.0f)); my_path.Add(waypoint); } my_path.Add(goal_pos); // Plot your path to see if it makes sense Vector3 old_wp = start_pos; foreach (var wp in my_path) { Debug.DrawLine(old_wp, wp, Color.red, 100f); old_wp = wp; } }
private void Awake() { drone = GetComponent<DroneController>(); client = new TcpClient(Hostname, Port); dataStream = client.GetStream(); updatePacket = new TcpUpdatePacket(); first = true; }
public void DroneShotDown(EnemyMoveAction.DroneType droneType, DroneController drone) { Destroy(drone.gameObject, 0.5f); //ドローン撃墜 Observable.Timer(System.TimeSpan.FromSeconds(1)) .Subscribe(_ => droneshodown(droneType)); }
/// <summary> /// Awake Function, initialize propreties. /// </summary> void Awake() { drone = this; rigidbody = GetComponentInChildren <Rigidbody>(); currentLocalVelocity = Vector3.zero; turnOn(isRunning); }
//#region Methods //// Callback method for when the best car has changed. private void OnDroneChanged(DroneController newDrone) { Camera.SetTarget(newDrone.gameObject); if (UIController != null) { UIController.SetDisplayTarget(newDrone); } }
private void Awake() { model = transform.Find("model").gameObject; myCollider = GetComponent<SphereCollider>(); randomRotation = new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f), Random.Range(-1f, 1f)); Active = false; drone = FindObjectOfType<DroneController>(); }
private void Awake() { Transform = transform; navAgent = GetComponent<NavMeshAgent>(); drone = FindObjectOfType<DroneController>(); flightView = FindObjectOfType<FlightView>(); flightView.Keepers.Add(this); distortion = transform.Find("vfx/distortion"); }
private void Awake() { drone = GetComponent<DroneController>(); client = new TcpClient(Hostname, Port); dataStream = client.GetStream(); }
void OnTriggerEnter(Collider other) { droneController = droneControllerGO.GetComponent<DroneController>(); droneController.DroneTriggerEntered (other); }
void OnCollisionEnter(Collision collisionInfo) { droneController = droneControllerGO.GetComponent<DroneController>(); droneController.DroneCollisionEntered (collisionInfo); }
void Start() { originalPosition = transform.position; instance = this; droneLight = GameObject.Find ("targetLight"); }
/// <summary> /// Execute startup tasks /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void WindowLoaded(object sender, RoutedEventArgs e) { // Create the drawing group we'll use for drawing this.drawingGroup = new DrawingGroup(); // Create an image source that we can use in our image control this.imageSource = new DrawingImage(this.drawingGroup); // Display the drawing using our image control Image.Source = this.imageSource; // Look through all sensors and start the first connected one. // This requires that a Kinect is connected at the time of app startup. // To make your app robust against plug/unplug, // it is recommended to use KinectSensorChooser provided in Microsoft.Kinect.Toolkit (See components in Toolkit Browser). foreach (var potentialSensor in KinectSensor.KinectSensors) { if (potentialSensor.Status == KinectStatus.Connected) { this.sensor = potentialSensor; break; } } if (null != this.sensor) { // Connect to the drone droneController = new DroneController(); droneController.SubscribeToGestures(); droneController.DroneCommandChanged += droneController_DroneCommandChanged; // Turn on the skeleton stream to receive skeleton frames this.sensor.SkeletonStream.Enable(); // Add an event handler to be called whenever there is new color frame data this.sensor.SkeletonFrameReady += this.SensorSkeletonFrameReady; // Start the sensor! try { this.sensor.Start(); } catch (IOException) { this.sensor = null; } } if (null == this.sensor) { CommandTextBlock.Text = "Connect Kinect before sending commands!"; StartButton.IsEnabled = false; EmergencyButton.IsEnabled = false; ResetEmergencyButton.IsEnabled = false; this.statusBarText.Text = Properties.Resources.NoKinectReady; } GestureDetection.RightHandUpDownChanged += OnRightHandUpDownChanged; GestureDetection.RightHandLeftRightChanged += OnRightHandLeftRightChanged; GestureDetection.RightHandBackForwardsChanged += OnRightHandBackFordwardChanged; GestureDetection.LeftHandUpDownChanged += OnLeftHandUpDownChanged; GestureDetection.LeftHandLeftRightChanged += OnLeftHandLeftRightChanged; GestureDetection.LeftHandBackForwardsChanged += OnLeftHandBackFordwardChanged; }
public static ControllerBase CreateController(string server, int port, string username, string password) { PostToConsole($"Connecting to server {server}:{port}"); var networkConnection = new TcpClient(server, port); var authRequest = new Message { MessageType = "auth-request", Authentication = new Authentication { Username = username, Password = password } }; var stream = networkConnection.GetStream(); var serializer = new XmlSerializer(typeof(Message)); var writer = new StreamWriter(stream); var reader = new StreamReader(stream); SendMessage(writer, authRequest); var authResponse = GetMessage(reader); if (authResponse.MessageType != "auth-response") { PostToConsole($"Bad message from server : {authResponse.MessageType}"); return null; } if (authResponse.Authentication.Result.ToLowerInvariant() != "ok") { PostToConsole($"Authentication Failed"); return null; } PostToConsole($"Authenticated as {username}"); PostToConsole("Waiting for Sim Start"); var simStart = GetMessage(reader); while (simStart.MessageType != "sim-start") { PostToConsole($"Unexpected message from server : {simStart.MessageType}"); } var sim = simStart.Simulation; ControllerBase result; switch (sim.Role.Name.ToLower()) { case "car": result = new CarController(); break; case "drone": result = new DroneController(); break; case "motorcycle": result = new MotorcycleController(); break; case "truck": result = new TruckController(); break; default: PostToConsole($"Bad role from server : {simStart.Simulation.Role.Name}"); return null; } result.SimulationId = sim.Id; result.TotalSteps = sim.Steps; result.Team = sim.Team; result.MaxBattery = sim.Role.MaxBattery; result.MaxLoad = sim.Role.MaxLoad; result.Speed = sim.Role.Speed; result.Tools = new List<Tool>(sim.Role.Tools); result.Products = new List<Product>(sim.Products); result.reader = reader; result.writer = writer; return result; }
// Use this for initialization private void Start() { this.droneController = this.gameObject.GetComponent<DroneController>(); this.cameraController = GameObject.Find("Dummy").GetComponent<CameraController>(); this.inGameUI = GameObject.Find("IngameUI").GetComponent<Canvas>(); this.routeUI = GameObject.Find("RouteUI").GetComponent<Canvas>(); //this.inputField = GameObject.Find("InputField"); this.coordinatePanel = this.routeUI.transform.FindChild("CoordinateInputPanel"); this.lineRenderer = this.gameObject.GetComponent<LineRenderer>(); this.lineRenderer.material = new Material(Shader.Find("Particles/Additive")); this.lineRenderer.SetColors(Color.red, Color.red); this.lineRenderer.SetWidth(0.05f, 0.05f); this.routingPoints = new Queue<GameObject>(); }
void droneController_DroneCommandChanged(object sender, DroneController.DroneCommandChangedEventArgs args) { if (isDroneOn) CommandTextBlock.Text = args.CommandText; }