/// <summary> /// Selectes the targeted group and finds out info about object where the mouse clicked. /// After that calls OnRightMouseClick on group and depending on the response is called /// the appropriate action. /// </summary> /// <param Name="clickedPoint">The mouse position.</param> /// <param Name="selectedObjects">The objects in clicked area.</param> public void OnRightClick(Mogre.Vector3 clickedPoint, List<Mogre.MovableObject> selectedObjects) { Mogre.MovableObject hitObject; bool isFriendly = true; bool isIMGO = true; if (selectedObjects.Count == 0) { // Nothing at clicked area. hitObject = null; } else { hitObject = selectedObjects[0]; Team targetTeam; // The clicked object is not controllable. if (!hitTest.IsObjectControllable(hitObject.Name)) return; if (hitTest.IsObjectMovable(hitObject.Name)) { // The clicked object is movable. targetTeam = hitTest.GetIMGO(hitObject.Name).Team; } else { // The clicked object is static. targetTeam = hitTest.GetISGO(hitObject.Name).Team; isIMGO = false; } // Checks if the object is friendly. isFriendly = teamMgr.AreFriendly(groupMgr.ActiveTeam, targetTeam); } // Gets the selected group answer on mouse action (clicked position). var answer = groupMgr.SelectInfoGroup(clickedPoint, hitObject, isFriendly, isIMGO); Game.IEffectPlayer.PlayEffect(groupSelectedSound); // Plays effect // Chooses the next action by the group reply. switch (answer) { case ActionAnswer.Move: Game.PrintToGameConsole("Group from team " + groupMgr.GetActiveMovableGroup().Team.Name + " moving to " + clickedPoint.ToString()); moveMgr.GoToLocation(groupMgr.GetActiveMovableGroup(), clickedPoint); break; case ActionAnswer.MoveTo: moveMgr.GoToTarget(groupMgr.GetActiveMovableGroup(), hitTest.GetGameObject(hitObject.Name)); break; case ActionAnswer.Attack: fightMgr.Attack(groupMgr.GetActiveMovableGroup(), hitTest.GetGameObject(hitObject.Name)); break; case ActionAnswer.Occupy: fightMgr.Occupy(groupMgr.GetActiveMovableGroup(), hitTest.GetGameObject(hitObject.Name)); break; } }