public void TogglePatrolMode() { foreach (Squad.Core c in SelectedCores) { AI.WaypointType t = c.waypointType; if (t == WaypointType.Patrol_Conteniusly) { c.waypointType = WaypointType.Patrol_FromTo; } else { c.waypointType = WaypointType.Patrol_Conteniusly; } } }
private void CreateNewWaypoint() { if (SelectedCores.Count != 0) { RaycastHit hit; Ray ray = cam.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, Mathf.Infinity, detectionMask)) { if (Vector3.Angle(Vector3.up, hit.normal) <= 70) { GameObject obj = Instantiate(Waypoint); obj.transform.position = hit.point; obj.transform.parent = waypointParent; foreach (Squad.Core c in SelectedCores) { if (!setToPatrol) { c.ReceiveNewWaypoint(obj.transform.position, AI.WaypointType.One_Way, Input.GetKey(KeyCode.LeftShift)); obj.GetComponent <Waypoint>().Add(); } else { AI.WaypointType t = c.waypointType; if (t == AI.WaypointType.One_Way) { t = AI.WaypointType.Patrol_FromTo; } c.ReceiveNewWaypoint(obj.transform.position, t, Input.GetKey(KeyCode.LeftShift)); obj.GetComponent <Waypoint>().Add(); } } } } } if (!checkShiftCount) { checkShiftCount = true; } }
public void UpdateInteraction() { if (checkShiftCount) { if (!Input.GetKey(KeyCode.LeftShift)) { Type = AI.WaypointType.One_Way; checkShiftCount = false; setToPatrol = false; } } if (Input.GetKeyDown(CreateWaypointTrigger)) { CreateNewWaypoint(); } #region Selection Detection if (Input.GetKeyDown(SelectionTrigger)) { uiMousePos[0] = Input.mousePosition; } if (Input.GetKey(SelectionTrigger)) { uiMousePos[1] = Input.mousePosition; } if (Input.GetKeyUp(SelectionTrigger) && Vector2.Distance(uiMousePos[0], uiMousePos[1]) >= 10) { Vector2[] corners = GetBoundingBox(uiMousePos[0], uiMousePos[1]); if (!Input.GetKey(KeepOldTrigger)) { SelectedCores.Clear(); } currentDetectionMesh = GenerateSelectionMesh(corners); col.sharedMesh = currentDetectionMesh; } #endregion if (Type != AI.WaypointType.One_Way) { if (Input.GetKeyDown(KeyCode.Escape)) { Type = AI.WaypointType.One_Way; } } if (currentDetectionMesh != null) { time += Time.deltaTime; if (time >= maxTime) { currentDetectionMesh = null; col.sharedMesh = null; time = 0; uiMousePos = new Vector2[2]; } } }