/// <summary>
 /// Creates group (without calling Select) from given List with IStaticGameObjects.
 /// Objects from 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>
 /// Clears the TargetedGroupManager. Unsets static and movable group
 /// and destroys TargetPointers.
 /// </summary>
 public void Clear()
 {
     DestroyPointers();
     groupMovables = null;
     groupStatics = null;
     targetedIsMovalbe = false;
 }
Beispiel #3
0
        /// <summary>
        /// Creates instance of the Fight. Also selects both (attacker and deffender) group and start fight.
        /// </summary>
        /// <param name="attackers">The attacking group (complete)</param>
        /// <param name="deffendersM">The deffending movable group (complete)</param>
        /// <param name="deffendersS">The deffending staic group (complete)</param>
        public Fight(GroupMovables attackers, GroupMovables deffendersM, GroupStatics deffendersS)
        {
            groupAttackers = attackers;
            movingDict = new Dictionary<IMovableGameObject, IGameObject>();
            damageCounter = new DamageCounter();

            imgoDeffenders = deffendersM;
            isgoDeffenders = deffendersS;

            attackerTarget = new Property<IGameObject>(deffendersM[0]);
            deffenderTarget = new Property<IGameObject>(attackers[0]);

            StartFight();
        }
Beispiel #4
0
        /// <summary>
        /// Creates instance of the Fight. Also selects both (attacker and deffender) group and starts the fight.
        /// </summary>
        /// <param name="attackers">The attacking group (complete)</param>
        /// <param name="deffendersM">The deffending movable group (complete)</param>
        /// <param name="deffendersS">The deffending staic group (complete)</param>
        public Fight(GroupMovables attackers, GroupMovables deffendersM, GroupStatics deffendersS)
        {
            groupAttackers = attackers;
            movingDict     = new Dictionary <IMovableGameObject, IGameObject>();
            damageCounter  = new DamageCounter();

            imgoDeffenders = deffendersM;
            isgoDeffenders = deffendersS;

            attackerTarget  = new Property <IGameObject>(deffendersM[0]);
            deffenderTarget = new Property <IGameObject>(attackers[0]);

            StartFight();
        }
Beispiel #5
0
        /// <summary>
        /// Creates instance of the Fight and collect all defenders on shout distance. Also selects both (attacker
        /// and deffender) group and start fight.
        /// </summary>
        /// <param name="attackers">The attacking group (complete)</param>
        /// <param name="deffender">The deffending group (uncomplete - Shout)</param>
        public Fight(GroupMovables attackers, IGameObject deffender)
        {
            groupAttackers = attackers;
            movingDict = new Dictionary<IMovableGameObject, IGameObject>();
            damageCounter = new DamageCounter();

            var objectsInShoutDistance = new List<IGameObject>();
            objectsInShoutDistance.Add(deffender);
            deffender.Shout(objectsInShoutDistance);
            imgoDeffenders = Game.GroupManager.CreateSelectedGroupMovable(objectsInShoutDistance);
            isgoDeffenders = Game.GroupManager.CreateSelectedGroupStatic(objectsInShoutDistance);

            attackerTarget = new Property<IGameObject>(deffender);
            deffenderTarget = new Property<IGameObject>(attackers[0]);

            StartFight();
        }
Beispiel #6
0
        /// <summary>
        /// Creates instance of the Fight and collects all defenders at a shout distance. Also selects both (attacker
        /// and deffender) group and starts the fight.
        /// </summary>
        /// <param name="attackers">The attacking group (complete)</param>
        /// <param name="deffender">The deffending group (uncomplete - Shout)</param>
        public Fight(GroupMovables attackers, IGameObject deffender)
        {
            groupAttackers = attackers;
            movingDict     = new Dictionary <IMovableGameObject, IGameObject>();
            damageCounter  = new DamageCounter();

            var objectsInShoutDistance = new List <IGameObject>();

            objectsInShoutDistance.Add(deffender);
            deffender.Shout(objectsInShoutDistance);
            imgoDeffenders = Game.GroupManager.CreateSelectedGroupMovable(objectsInShoutDistance);
            isgoDeffenders = Game.GroupManager.CreateSelectedGroupStatic(objectsInShoutDistance);

            attackerTarget  = new Property <IGameObject>(deffender);
            deffenderTarget = new Property <IGameObject>(attackers[0]);

            StartFight();
        }
Beispiel #7
0
        /// <summary>
        /// Initializes the FightManager from two given lists (occupation and fights).
        /// </summary>
        /// <param name="loadedOcc">The list with occupations.</param>
        /// <param name="loadedFights">The list with fights.</param>
        public void Initialize(List <Tuple <List <string>, string, int> > loadedOcc, List <Tuple <List <string>, List <string> > > loadedFights)
        {
            // Occupations
            if (loadedOcc != null)
            {
                foreach (var occupation in loadedOcc)
                {
                    IMovableGameObject firstObj = null;
                    foreach (var gameObject in occupation.Item1)
                    {
                        if (Game.HitTest.IsObjectControllable(gameObject) && Game.HitTest.IsObjectMovable(gameObject))
                        {
                            firstObj = Game.HitTest.GetIMGO(gameObject);
                            break;
                        }
                    }
                    if (firstObj == null)
                    {
                        // Invalid data
                        continue;
                    }
                    GroupMovables group = Game.GroupManager.GetGroup(firstObj);

                    // Creates group
                    for (int i = 1; i < occupation.Item1.Count; i++)
                    {
                        if (Game.HitTest.IsObjectControllable(occupation.Item1[i]) && Game.HitTest.IsObjectMovable(occupation.Item1[i]))
                        {
                            Game.GroupManager.AddToGroup(group, Game.HitTest.GetIMGO(occupation.Item1[i]));
                        }
                    }

                    if (group.Count == 0)
                    {
                        // Invalid data
                        continue;
                    }
                    IGameObject target;
                    if (Game.HitTest.IsObjectControllable(occupation.Item2))
                    {
                        target = Game.HitTest.GetGameObject(occupation.Item2);
                    }
                    else
                    {
                        // Invalid data
                        continue;
                    }

                    if (target.OccupyTime == occupation.Item3)
                    {
                        Occupy(group, target);
                    }
                    else
                    {
                        // Create Occupation
                        occupationList.Add(new Occupation(group, target, TimeSpan.FromSeconds(occupation.Item3)));
                    }
                }
            }

            // Fights
            if (loadedFights != null)
            {
                foreach (var fight in loadedFights)
                {
                    var           firstObj = Game.HitTest.GetIMGO(fight.Item1[0]);
                    GroupMovables group1   = Game.GroupManager.GetGroup(firstObj);
                    // Creates group1
                    for (int i = 1; i < fight.Item1.Count; i++)
                    {
                        if (Game.HitTest.IsObjectControllable(fight.Item1[i]) && Game.HitTest.IsObjectMovable(fight.Item1[i]))
                        {
                            Game.GroupManager.AddToGroup(group1, Game.HitTest.GetIMGO(fight.Item1[i]));
                        }
                    }

                    if (group1.Count == 0)
                    {
                        continue;
                    }

                    // Second group can contains the static members
                    IGameObject   firstObj1 = null;
                    GroupMovables group2    = null;
                    foreach (var gameObject in fight.Item2)
                    {
                        if (Game.HitTest.IsObjectControllable(gameObject))
                        {
                            firstObj1 = Game.HitTest.GetGameObject(gameObject);
                            group2    = new GroupMovables(firstObj1.Team);
                            break;
                        }
                    }
                    GroupStatics group3 = new GroupStatics();

                    if (Game.HitTest.IsObjectControllable(fight.Item2[0]))
                    {
                        if (Game.HitTest.IsObjectMovable(fight.Item2[0]))
                        {
                            var firstObj2 = Game.HitTest.GetIMGO(fight.Item2[0]);
                            group2 = Game.GroupManager.GetGroup(firstObj2);
                        }
                        else
                        {
                            var firstObj3 = Game.HitTest.GetISGO(fight.Item2[0]);
                            group3 = new GroupStatics(firstObj3.Team);
                            group3.InsertMemeber(firstObj3);
                        }
                    }

                    if (group2 == null || group3 == null || group2.Count == 0 && group3.Count == 0)
                    {
                        // Invalid data
                        continue;
                    }

                    for (int i = 1; i < fight.Item2.Count; i++)
                    {
                        if (Game.HitTest.IsObjectMovable(fight.Item2[i]))
                        {
                            Game.GroupManager.AddToGroup(group2, Game.HitTest.GetIMGO(fight.Item2[i]));
                        }
                        else
                        {
                            group3.InsertMemeber(Game.HitTest.GetISGO(fight.Item2[i]));
                        }
                    }
                    fightList.Add(new Fight(group1, group2, group3));
                }
            }
        }
        /// <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();
                    }
                }
            }
        }
 /// <summary>
 /// Removes objects from their group and creates new one.
 /// 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>
        /// 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));
            }
        }
Beispiel #11
0
        /// <summary>
        /// Initializes the FightManager from two given lists (occupation and fights).
        /// </summary>
        /// <param name="loadedOcc">The list with occupations.</param>
        /// <param name="loadedFights">The list with fights.</param>
        public void Initialize(List<Tuple<List<string>, string, int>> loadedOcc, List<Tuple<List<string>, List<string>>> loadedFights)
        {
            // Occupations
            if (loadedOcc != null) {
                foreach (var occupation in loadedOcc) {
                    IMovableGameObject firstObj = null;
                    foreach (var gameObject in occupation.Item1) {
                        if (Game.HitTest.IsObjectControllable(gameObject) && Game.HitTest.IsObjectMovable(gameObject)) {
                            firstObj = Game.HitTest.GetIMGO(gameObject);
                            break;
                        }
                    }
                    if (firstObj == null) {
                        // Invalid data
                        continue;
                    }
                    GroupMovables group = Game.GroupManager.GetGroup(firstObj);

                    // Creates group
                    for (int i = 1; i < occupation.Item1.Count; i++) {
                        if (Game.HitTest.IsObjectControllable(occupation.Item1[i]) && Game.HitTest.IsObjectMovable(occupation.Item1[i])) {
                            Game.GroupManager.AddToGroup(group, Game.HitTest.GetIMGO(occupation.Item1[i]));
                        }
                    }

                    if (group.Count == 0) {
                        // Invalid data
                        continue;
                    }
                    IGameObject target;
                    if (Game.HitTest.IsObjectControllable(occupation.Item2)) {
                        target = Game.HitTest.GetGameObject(occupation.Item2);
                    } else {
                        // Invalid data
                        continue;
                    }

                    if (target.OccupyTime == occupation.Item3) {
                        Occupy(group, target);
                    } else {
                        // Create Occupation
                        occupationList.Add(new Occupation(group, target, TimeSpan.FromSeconds(occupation.Item3)));
                    }

                }
            }

            // Fights
            if (loadedFights != null) {
                foreach (var fight in loadedFights) {
                    var firstObj = Game.HitTest.GetIMGO(fight.Item1[0]);
                    GroupMovables group1 = Game.GroupManager.GetGroup(firstObj);
                    // Creates group1
                    for (int i = 1; i < fight.Item1.Count; i++) {
                        if (Game.HitTest.IsObjectControllable(fight.Item1[i]) && Game.HitTest.IsObjectMovable(fight.Item1[i])) {
                            Game.GroupManager.AddToGroup(group1, Game.HitTest.GetIMGO(fight.Item1[i]));
                        }
                    }

                    if (group1.Count == 0) {
                        continue;
                    }

                    // Second group can contains the static members
                    IGameObject firstObj1 = null;
                    GroupMovables group2 = null;
                    foreach (var gameObject in fight.Item2) {
                        if (Game.HitTest.IsObjectControllable(gameObject)) {
                            firstObj1 = Game.HitTest.GetGameObject(gameObject);
                            group2 = new GroupMovables(firstObj1.Team);
                            break;
                        }
                    }
                    GroupStatics group3 = new GroupStatics();

                    if (Game.HitTest.IsObjectControllable(fight.Item2[0])) {
                        if (Game.HitTest.IsObjectMovable(fight.Item2[0])) {
                            var firstObj2 = Game.HitTest.GetIMGO(fight.Item2[0]);
                            group2 = Game.GroupManager.GetGroup(firstObj2);
                        } else {
                            var firstObj3 = Game.HitTest.GetISGO(fight.Item2[0]);
                            group3 = new GroupStatics(firstObj3.Team);
                            group3.InsertMemeber(firstObj3);
                        }
                    }

                    if (group2 == null || group3 == null || group2.Count == 0 && group3.Count == 0) {
                        // Invalid data
                        continue;
                    }

                    for (int i = 1; i < fight.Item2.Count; i++) {
                        if (Game.HitTest.IsObjectMovable(fight.Item2[i])) {
                            Game.GroupManager.AddToGroup(group2, Game.HitTest.GetIMGO(fight.Item2[i]));
                        } else {
                            group3.InsertMemeber(Game.HitTest.GetISGO(fight.Item2[i]));
                        }
                    }
                    fightList.Add(new Fight(group1, group2, group3));
                }
            }
        }