/// <summary> /// Checks if player can controls selected group. If the group is new so the function remove /// all object from their current groups and recount them. Finally call Select (count bonuses, etc.) /// </summary> /// <param name="clickedPoint">The mouse position.</param> /// <param name="hitObject">The result of a HitTest.</param> /// <param name="isFriendly">The information if the hitted object is friendly.</param> /// <param name="isMovableGameObject">The information if the hitted object is movable.</param> /// <returns>Returns group answer collected from each member of group</returns> public ActionAnswer SelectInfoGroup(Mogre.Vector3 clickedPoint, MovableObject hitObject, bool isFriendly, bool isMovableGameObject) { if (targetedMgr.TargetedIsMovable) { GroupMovables group = targetedMgr.GetActiveMovableGroup(); if (group.Team.Name == Game.PlayerName) { // All members of group can die so movable group is deactive. if (group.Count == 0) { targetedMgr.Clear(); return(ActionAnswer.None); } // Check if actual group is selectedGroupM if (!(imgoGroupDict.ContainsKey(group[0]) && group == imgoGroupDict[group[0]])) { // Group is unselect var toRecount = new List <GroupMovables>(); foreach (IMovableGameObject imgo in group) { if (imgoGroupDict.ContainsKey(imgo)) { // Add object to toRecount if (!toRecount.Contains(imgoGroupDict[imgo])) { toRecount.Add(imgoGroupDict[imgo]); } // Remove from old group and set new oneto Dict imgoGroupDict[imgo].RemoveMember(imgo); imgoGroupDict[imgo] = group; } else { imgoGroupDict.Add(imgo, group); } } // Recount all modified groups foreach (var groupRec in toRecount) { // Recount just basic bonuses, others are removed when the source of them is removed. groupRec.CountBasicBonuses(); } group.Select(); } return(group.OnMouseAction(clickedPoint, hitObject, isFriendly, isMovableGameObject)); } } return(ActionAnswer.None); }
/// <summary> /// Removes objects from their group and creates new one. /// The list can contains some IStaticGameObjects so they must be removed. /// New created group is selected (Select - bonuses are counted and are setted). /// </summary> /// <param name="igoList">The List with IStaticGameObjects and IMovableGameObjects</param> /// <returns>Returns created group with IMovableGameObjects from the igoList</returns> public GroupMovables CreateSelectedGroupMovable(List <IGameObject> igoList) { var toRecount = new List <GroupMovables>(); var group = new GroupMovables(igoList[0].Team); foreach (var igo in igoList) { var imgo = igo as IMovableGameObject; if (imgo != null) { group.InsertMemeber(imgo); if (imgoGroupDict.ContainsKey(imgo)) { // Add object to toRecount if (!toRecount.Contains(imgoGroupDict[imgo])) { toRecount.Add(imgoGroupDict[imgo]); } // Remove from old group and set new one to Dict imgoGroupDict[imgo].RemoveMember(imgo); imgoGroupDict[imgo] = group; } else { imgoGroupDict.Add(imgo, group); } } } // Recount all modified groups foreach (var groupRec in toRecount) { // Recount just basic bonuses, others are removed when the source of them is removed. groupRec.CountBasicBonuses(); } group.Select(); return(group); }