///////////////////////////////////////////////////////////////////////////////////////// // Main use is to get the vector3 point where the player clicked their mouse // But if the player clicks on an enemy, sets CommandManagement's target to this enemy public static Vector3 GetClickPoint() { RaycastHit hit; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, Mathf.Infinity)) { if (hit.transform.gameObject.tag == "Enemy") { CommandManagement.target = hit.transform.gameObject; } else if (hit.transform.gameObject.tag == "Weapon") { CommandManagement.SetItemTarget(hit.transform.gameObject.GetComponent <Weapon>()); } else { // this clears the last selected target CommandManagement.target = null; CommandManagement.itemTarget = null; } return(hit.point); } Debug.LogError("Map collider not found!"); Application.Quit(); return(hit.point); }
// Use this for initialization private void Awake() { if (instance == null) { instance = this; } }
void Start() { SetMap(); commandManager = GetComponent <CommandManagement>(); cam = gameObject.GetComponentInChildren <Camera>(); if (!isLocalPlayer) { cam.enabled = false; } }
private void SysTrayShowCommands(object sender, EventArgs e) { if (!AssistantHelper.IsWindowOpen <CommandManagement>()) { var commandManagement = new CommandManagement(); commandManagement.Show(); } else { MessageBox.Show(Properties.Resources.FormIsAlreadyOpen, Properties.Resources.Information, MessageBoxButton.OK, MessageBoxImage.Information); } }
void EndSelect() { selectedEndPoint = ProgUtils.GetClickPoint(); RaycastHit hit; Vector3 pos = gameObject.transform.position; if (Physics.Raycast(pos, selectedEndPoint - pos, out hit, Mathf.Infinity)) { if (hit.collider.gameObject.tag == "Friendly") { CommandManagement.AddTroop(hit.collider.gameObject.GetComponent <TroopClass>()); } } CommandManagement.SelectTroops(); }
public void DefaultSpeechRecognized(object sender, SpeechRecognizedEventArgs e) { recognizedCommand = AssistantHelper.GetRecognizedCommand(commands.Command, e.Result.Text); if (recognizedCommand.CommandText == Properties.Resources.AddNewCommand) { if (!AssistantHelper.IsWindowOpen <AddNewCommand>()) { var addNewCommand = new AddNewCommand(_assistantService); addNewCommand.Show(); Sara.SpeakAsync(recognizedCommand.Answer); } else { Sara.SpeakAsync(Properties.Resources.FormIsAlreadyOpen); } } else if (recognizedCommand.CommandText == Properties.Resources.ShowCommands) { if (!AssistantHelper.IsWindowOpen <CommandManagement>()) { var commandManagement = new CommandManagement(); commandManagement.Show(); Sara.SpeakAsync(recognizedCommand.Answer); } else { Sara.SpeakAsync(Properties.Resources.FormIsAlreadyOpen); } } else if (recognizedCommand.CommandText == Properties.Resources.TimeForBreak) { Sara.SpeakAsync(recognizedCommand.Answer); CancelRecognize(); contextMenu.MenuItems[0].Enabled = true; contextMenu.MenuItems[1].Enabled = false; } else if (recognizedCommand.NeedsConfirmation) { Sara.SpeakAsync(Properties.Resources.ConfirmOperation); StopRecognize(); recognizer = new SpeechRecognitionEngine(); _speechRecognizerService.CreateNewSynthesizer(commands.Command.Where(x => x.IsConfimation).Select(x => x.CommandText).ToArray(), recognizer, Sara, listener, ConfirmationSpeechRecognized, RecognizerSpeechRecognized, ListenerSpeechRecognize); } else { _speechRecognizerService.ExecuteRecognizedAction(Sara, recognizedCommand); } }
void SetTarget() { CommandManagement.target = null; CommandManagement.pointSelected = ProgUtils.GetClickPoint(); //Get Click Point also sets CommandManagement.target to //what it clicked on, if it clicked on an enemy if (CommandManagement.target != null) { //if the target is not null, it means GetClickPoint found an enemy so attack it //the Combat class handles movement towards enemies so it isn't done here CommandManagement.SetAttackTargets(); } else { //There was no enemy so just move to the pointSelected as usual CommandManagement.MoveTroops(); } }
void Update() { CameraMovement(); // Left clicks are used for selection while... if (Input.GetMouseButtonDown(0)) { BeginSelect(); CommandManagement.ClearSelection(); } if (Input.GetMouseButtonUp(0)) { EndSelect(); } // ...right clicks are used for targeting and movement if (Input.GetMouseButtonDown(1)) { SetTarget(); } }