/// <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 a TargetPointer for each member of the group and destroys old pointers.
        /// Also indicates that the movable group is targeted.
        /// </summary>
        /// <param name="group">The targeted group.</param>
        public void TargetGroup(GroupMovables group)
        {
            targetedIsMovalbe = true;
            groupMovables     = group;
            DestroyPointers();

            foreach (IGameObject item in group)
            {
                pointerList.Add(new TargetPointer(item));
            }
        }
示例#3
0
        /// <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);
        }
示例#4
0
        /// <summary>
        /// Finds required group by the given object. If it is not exists so the new is created
        /// just with given object.
        /// </summary>
        /// <param name="imgo">The object which the group is looking for.</param>
        /// <returns>Returns the founded group or a new one</returns>
        public GroupMovables GetGroup(IMovableGameObject imgo)
        {
            GroupMovables group;

            if (imgoGroupDict.ContainsKey(imgo))
            {
                group = imgoGroupDict[imgo];
            }
            else
            {
                group = new GroupMovables(imgo.Team);
                group.InsertMemeber(imgo);
                imgoGroupDict.Add(imgo, group);
            }
            return(group);
        }
示例#5
0
        /// <summary>
        /// Inserts given IMovableGameObject to the group. Also recounts old group.
        /// </summary>
        /// <param name="group">The member which will be inserted to this group.</param>
        /// <param name="gameObject">The object which will be inesrted.</param>
        public void AddToGroup(GroupMovables group, IGameObject gameObject)
        {
            var imgo = gameObject as IMovableGameObject;

            if (imgo != null)
            {
                if (imgoGroupDict.ContainsKey(imgo))
                {
                    var removeFromGroup = imgoGroupDict[imgo];
                    removeFromGroup.RemoveMember(imgo);
                    removeFromGroup.CountBasicBonuses();
                    imgoGroupDict[imgo] = group;
                }
                else
                {
                    imgoGroupDict.Add(imgo, group);
                }
                group.InsertMemeber(imgo);
            }
        }
示例#6
0
        /// <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);
        }
示例#7
0
 /// <summary>
 /// Selects given group (counts bonuses, sets bonuses, etc.)/
 /// </summary>
 /// <param name="group">The selecting group.</param>
 public void SelectGroup(GroupMovables group)
 {
     targetedMgr.TargetGroup(group);
     targetedMgr.ShowTargetedGroup();
 }
示例#8
0
        /// <summary>
        /// Creates group (without calling Select) from given list with IMovableGameObjects.
        /// 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 IMovableGameObjects</param>
        public void CreateInfoGroup(List <IMovableGameObject> imgoList)
        {
            bool inSameGroup = true;

            imgoList = checkPlayersObjects(imgoList);

            // Tests if all imgo are in same selected group
            var firstGroup = GetGroup(imgoList.First());

            for (int i = 1; i < imgoList.Count; i++)
            {
                var memberGroup = GetGroup(imgoList[i]);
                if (firstGroup != memberGroup)
                {
                    // Different groups -> new group must be created (unselected)
                    inSameGroup = false;
                    break;
                }
            }

            if (!inSameGroup)
            {
                // Create new uselect group (selected object was not in same group)
                var group = new GroupMovables(imgoList.First().Team);
                group.InsertMemeber(imgoList[0]);

                if (imgoList.Count > 1)                                 // Check if there is more object
                {
                    for (int i = 1; i < imgoList.Count; i++)
                    {
                        if (imgoList[i].Team.Name == Game.PlayerName && group.Team.Name != Game.PlayerName)
                        {
                            group = new GroupMovables(imgoList[i].Team);
                            group.InsertMemeber(imgoList[i]);                                   // Insert first
                        }
                        else
                        {
                            if (group.Team == imgoList[i].Team)
                            {
                                group.InsertMemeber(imgoList[i]);
                            }
                        }
                    }
                }
                targetedMgr.TargetGroup(group);
            }
            else
            {
                // Objects are in same group. Now must be checked if group is complete.
                if (firstGroup.Count == imgoList.Count)
                {
                    // Absolutly same group just selected the group
                    targetedMgr.TargetGroup(firstGroup);
                }
                else
                {
                    // Subset of group => copy parameters (group is not selected, parameters will only be showed)
                    var group = new GroupMovables(imgoList.First().Team);
                    // Copy bonuses, bonuses will have actual value (changes in the original will be also in this info group)
                    group.GroupBonusDict = firstGroup.GroupBonusDict;

                    foreach (var imgo in imgoList)
                    {
                        group.InsertMemeber(imgo);
                    }
                    targetedMgr.TargetGroup(group);
                }
            }
            targetedMgr.ShowTargetedGroup();
        }