/// <summary> /// Clears the TargetedGroupManager. Unsets static and movable group /// and destroys TargetPointers. /// </summary> public void Clear() { DestroyPointers(); groupMovables = null; groupStatics = null; targetedIsMovalbe = false; }
/// <summary> /// Creates group (without calling Select) from given list with IStaticGameObjects. /// Objects from the player team has greater priority then others, so if list contains /// any so the others will not be selected. /// </summary> /// <param Name="isgoList">The List with IStaticGameObjects</param> public void CreateInfoGroup(List <IStaticGameObject> isgoList) { if (isgoList.Count > 0) { var group = new GroupStatics(isgoList[0].Team); group.InsertMemeber(isgoList[0]); // Insert first var inGroup = isgoList[0]; if (isgoList.Count > 1) // Check if there is more object { for (int i = 1; i < isgoList.Count; i++) { if (inGroup.Team == isgoList[i].Team) { group.InsertMemeber(isgoList[i]); // Insert player isgo } else { if (isgoList[i].Team.Name == Game.PlayerName) // In some of elements in isgoList is players -> has greater priority { group = new GroupStatics(isgoList[i].Team); group.InsertMemeber(isgoList[i]); // Insert firt inGroup = isgoList[i]; } } } } targetedMgr.TargetGroup(group); } else { targetedMgr.TargetGroup(new GroupStatics()); } targetedMgr.ShowTargetedGroup(); }
/// <summary> /// Creates a TargetPointer for each member of the group and destroys old pointers. /// Also indicates that the static group is targeted. /// </summary> /// <param name="group">The targeted group.</param> public void TargetGroup(GroupStatics group) { targetedIsMovalbe = false; groupStatics = group; DestroyPointers(); foreach (IGameObject item in group) { pointerList.Add(new TargetPointer(item)); } }
/// <summary> /// Removes objects from their group and creates new one. /// The list can contains some IMovableGameObjects so they must be removed. /// </summary> /// <param name="igoList">The list with IStaticGameObjects and IMovableGameObjects</param> /// <returns>Returns created group with IStaticGameObjects from the igoList</returns> public GroupStatics CreateSelectedGroupStatic(List <IGameObject> igoList) { var group = new GroupStatics(igoList[0].Team); foreach (var igo in igoList) { var imgo = igo as IStaticGameObject; if (imgo != null) { group.InsertMemeber(imgo); } } return(group); }
/// <summary> /// Attempts to remove IStaticGameObject from the targeted group. /// </summary> /// <param Name="isgo">IStaticGameObject to remove from the targeted group.</param> public void RemoveFromGroup(IStaticGameObject isgo) { if (!targetedMgr.TargetedIsMovable) { GroupStatics group = targetedMgr.GetAtctiveStaticGroup(); if (group.HasMember(isgo)) { group.RemoveMember(isgo); if (group.Count == 0) { group = new GroupStatics(); } } } }