示例#1
0
        /// <summary>
        /// Initializes the HitTest. Sorts game objects to ISGO and IMGO dictionaries (isgoDict, imgoDict).
        /// </summary>
        /// <param Name="solarSystems">The list with all solarSystems.</param>
        public void CreateHitTestMap(List <SolarSystem> solarSystems)
        {
            objectIsMovable = new Dictionary <string, bool>();
            isgoDict        = new Dictionary <string, IStaticGameObject>();
            imgoDict        = new Dictionary <string, IMovableGameObject>();
            foreach (SolarSystem ss in solarSystems)
            {
                IStaticGameObject s = ss.Sun;
                if (s != null)
                {
                    objectIsMovable.Add(s.Name, false);
                    isgoDict.Add(s.Name, s);
                }

                foreach (var isgoPair in ss.GetISGOs())
                {
                    objectIsMovable.Add(isgoPair.Key, false);
                    isgoDict.Add(isgoPair.Key, isgoPair.Value);
                }

                foreach (var imgoPair in ss.GetIMGOs())
                {
                    objectIsMovable.Add(imgoPair.Key, true);
                    imgoDict.Add(imgoPair.Key, imgoPair.Value);
                }
            }
        }
示例#2
0
 /// <summary>
 /// Removes the IStaticGameObject from the SolarSystem.
 /// </summary>
 /// <param name="isgo">The removing object.</param>
 public void RemoveISGO(IStaticGameObject isgo)
 {
     if (isgoObjectDict.ContainsKey(isgo.Name))
     {
         isgoObjectDict.Remove(isgo.Name);
     }
 }
示例#3
0
 /// <summary>
 /// Removes the given static object from the team.
 /// </summary>
 /// <param name="isgo">The removing static object.</param>
 public void RemoveISGO(IStaticGameObject isgo)
 {
     if (isgoObjects.Contains(isgo))
     {
         isgoObjects.Remove(isgo);
     }
 }
示例#4
0
 /// <summary>
 /// Inserts the given static object to the team and sets its the team.
 /// </summary>
 /// <param name="isgo">The inserting static object.</param>
 public void AddISGO(IStaticGameObject isgo)
 {
     if (!isgoObjects.Contains(isgo)) {
         isgoObjects.Add(isgo);
         isgo.Team = this;
     }
 }
示例#5
0
 /// <summary>
 /// Removes given object from attackes targets. If the removing object is the current
 /// target then selects a new one.
 /// </summary>
 /// <param name="igo">The removing target.</param>
 private void RemoveFromAttackerTarget(IStaticGameObject igo)
 {
     isgoDeffenders.RemoveMember(igo);
     if (attackerTarget.Value == igo)
     {
         SelectAttackerTarget();
     }
 }
        /// <summary>
        /// Creates IStaticGameObject by given typeName and argument. Inserts the object to given SolarSystem and registers it in HitTest.
        /// </summary>
        /// <param name="typeName">The type of the creating object.</param>
        /// <param name="args">The arguments of the creating object.</param>
        /// <param name="solSyst">The creating object SolarSystem.</param>
        /// <returns>Returns created IStaticGameObject.</returns>
        public IStaticGameObject CreateIsgo(string typeName, object[] args, SolarSystem solSyst)                // prepared...never used
        {
            IStaticGameObject isgo = xmlLoader.CreateISGO(typeName, args);

            solSyst.AddISGO(isgo);
            Game.HitTest.RegisterISGO(isgo);
            return(isgo);
        }
示例#7
0
 /// <summary>
 /// Inserts the given static object to the team and sets its the team.
 /// </summary>
 /// <param name="isgo">The inserting static object.</param>
 public void AddISGO(IStaticGameObject isgo)
 {
     if (!isgoObjects.Contains(isgo))
     {
         isgoObjects.Add(isgo);
         isgo.Team = this;
     }
 }
示例#8
0
        /// <summary>
        /// Creates a new SolarSystem with given unique name, position, and members.
        /// </summary>
        /// <param name="name">The unique name.</param>
        /// <param name="position">The position of the SolarSystem.</param>
        /// <param name="isgoObjects">The static members.</param>
        /// <param name="imgoObjects">The movable members.</param>
        /// <param name="sun">The sun of the SolarSystem (could be null).</param>
        /// <returns>Returns created SolarSystem.</returns>
        private SolarSystem CreateSolarSystem(string name, Vector3 position, List <IStaticGameObject> isgoObjects, List <IMovableGameObject> imgoObjects,
                                              IStaticGameObject sun = null)
        {
            SolarSystem sSys = new SolarSystem(name, position);

            sSys.AddISGO(isgoObjects);
            sSys.AddIMGO(imgoObjects);
            sSys.Sun = sun;
            return(sSys);
        }
示例#9
0
 /// <summary>
 /// Finds IStaticGameObject at SolarSystems and removes it from the one.
 /// </summary>
 /// <param name="isgo">The removing object.</param>
 public void RemoveObjectFromSolarSystem(IStaticGameObject isgo)
 {
     foreach (var solSysPair in solarSystemDict)
     {
         if (solSysPair.Value.HasISGO(isgo))
         {
             solSysPair.Value.RemoveISGO(isgo);
             break;
         }
     }
 }
示例#10
0
        /// <summary>
        /// Serializes the given Sun (name and type).
        /// </summary>
        /// <param name="rootElement">The parent element.</param>
        /// <param name="sun">The serializing Sun.</param>
        private void SerializeSun(XElement rootElement, IStaticGameObject sun)
        {
            var element = new XElement("isgo",
                                       new XAttribute("name", sun.Name),
                                       new XAttribute("type", "Sun"));

            rootElement.Add(element);
            foreach (var item in GetSortedArgsToSerialization(sun))
            {
                SerializeArgument(element, item.Value);
            }
        }
示例#11
0
 /// <summary>
 /// Inserts the IStaticGameObject to the SolarSystem and sets SolarSystem visibility
 /// to the object. Also checks if the inserting item is Gate, if the object is so sets
 /// the indicator.
 /// </summary>
 /// <param name="isgo">The inserting object.</param>
 public void AddISGO(IStaticGameObject isgo)
 {
     if (!isgoObjectDict.ContainsKey(isgo.Name))
     {
         var gate = isgo as Gate;
         if (gate != null)
         {
             hasGate = true;
         }
         isgoObjectDict.Add(isgo.Name, isgo);
         isgo.ChangeVisible(active);
     }
 }
示例#12
0
        /// <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();
                    }
                }
            }
        }
示例#13
0
 /// <summary>
 /// Adds new object to the isgoDict and also adds to the objectIsMovable as a non-movable (false).
 /// </summary>
 /// <param name="isgo">The inserting object.</param>
 public void RegisterISGO(IStaticGameObject isgo)
 {
     objectIsMovable.Add(isgo.Name, false);
     isgoDict.Add(isgo.Name, isgo);
 }
 /// <summary>
 /// Finds IStaticGameObject at SolarSystems and removes it from the one.
 /// </summary>
 /// <param name="isgo">The removing object.</param>
 public void RemoveObjectFromSolarSystem(IStaticGameObject isgo)
 {
     foreach (var solSysPair in solarSystemDict) {
         if (solSysPair.Value.HasISGO(isgo)) {
             solSysPair.Value.RemoveISGO(isgo);
             break;
         }
     }
 }
示例#15
0
        /// <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();
                    }
                }
            }
        }
示例#16
0
 /// <summary>
 /// Removes static game object from group, from solar system and calls Destroy to remove object from the game.
 /// </summary>
 /// <param Name="isgo">IStaticGameObject to remove from the game.</param>
 public void DestroyGameObject(IStaticGameObject isgo)
 {
     RemoveFromGroup(isgo);
     isgo.Destroy();
     Game.SolarSystemManager.RemoveObjectFromSolarSystem(isgo);
 }
示例#17
0
 /// <summary>
 /// Check if SolarSystem contains the IStaticGameObject.
 /// </summary>
 /// <param name="isgo">The checking object.</param>
 /// <returns>Returns if the SolarSystem contains the object.</returns>
 public bool HasISGO(IStaticGameObject isgo)
 {
     return(isgoObjectDict.ContainsKey(isgo.Name));
 }
示例#18
0
 /// <summary>
 /// Serializes the given Sun (name and type).
 /// </summary>
 /// <param name="rootElement">The parent element.</param>
 /// <param name="sun">The serializing Sun.</param>
 private void SerializeSun(XElement rootElement, IStaticGameObject sun)
 {
     var element = new XElement("isgo",
         new XAttribute("name", sun.Name),
         new XAttribute("type", "Sun"));
     rootElement.Add(element);
     foreach (var item in GetSortedArgsToSerialization(sun)) {
         SerializeArgument(element, item.Value);
     }
 }
示例#19
0
        /// <summary>
        /// Loads mission from selected file and creates all game objects from the mission file.
        /// Also load materials, mission targets and state (fughts, movements ...).
        /// </summary>
        /// <exception cref="XmlLoadException">Thrown when XML document has a wrong format.</exception>
        public void LoadMission()
        {
            bool hasSun           = false;
            IStaticGameObject sun = null;

            // Load mission (first of given Name)
            missionNode = root.SelectNodes("/mission[1]")[0];

            Game.PropertyManager.LoadPropertyToMission(missionNode.Attributes["propertyFilePath"].InnerText);

            LoadTeams(missionNode.SelectNodes("teams[1]")[0]);

            CompileUsedObjects(missionNode.SelectNodes("usedObjects[1]")[0]);

            // Load every IGameObject
            XmlNode missionSolarSystemNode = missionNode.SelectNodes("solarSystems[1]")[0];

            foreach (XmlNode solarSystem in missionSolarSystemNode)
            {
                List <IStaticGameObject>  isgos = new List <IStaticGameObject>();
                List <IMovableGameObject> imgos = new List <IMovableGameObject>();
                string gameObjectType;
                string solarSystemName = "";
                foreach (XmlNode chldNode in solarSystem.Attributes)
                {
                    switch (chldNode.Name)
                    {
                    case "gate":
                        var gate = runtimeCtor.CreateGate(solarSystemName, teamDict["None"]);
                        isgos.Add(gate);
                        break;

                    case "name":
                        solarSystemName = chldNode.InnerText;
                        break;
                    }
                }

                foreach (XmlNode gameObject in solarSystem.ChildNodes)
                {
                    switch (gameObject.Name)
                    {
                    case "isgo":
                        IsgoType t;
                        gameObjectType = gameObject.Attributes["type"].InnerText;
                        if (gameObjectType == "Sun")
                        {
                            hasSun = true;
                            t      = IsgoType.Sun;
                            sun    = CreateISGO(gameObject, t);
                        }
                        else
                        {
                            t = IsgoType.StaticObject;
                            IStaticGameObject isgo = CreateISGO(gameObject, t);
                            isgo.Team.AddISGO(isgo);
                            isgos.Add(isgo);

                            // Create IGameAction for created object
                            CreateGameActions(gameObject.SelectNodes("gameAction"), isgo);
                            break;
                        }
                        break;

                    case "imgo":
                        gameObjectType = gameObject.Attributes["type"].InnerText;
                        IMovableGameObject imgo = CreateIMGO(gameObject);
                        imgo.Team.AddIMGO(imgo);
                        imgos.Add(imgo);
                        CreateGameActions(gameObject.SelectNodes("gameAction"), imgo);
                        break;

                    default:
                        throw new XmlLoadException("Wrong XML format. In SolarSystem cannot be node " + gameObject.Name);
                    }
                }

                if (hasSun)
                {
                    this.solarSystemList.Add(CreateSolarSystem(solarSystemName,
                                                               ParseStringToVector3(solarSystem.Attributes["position"].Value), isgos, imgos, sun));
                    hasSun = false;
                }
                else
                {
                    this.solarSystemList.Add(CreateSolarSystem(solarSystemName,
                                                               ParseStringToVector3(solarSystem.Attributes["position"].Value), isgos, imgos));
                }
            }

            // Finally load mission targets and materials
            LoadMissionTargets(missionNode.SelectNodes("missionTargets[1]")[0]);
            LoadMaterials(missionNode.SelectNodes("materials[1]")[0]);
            LoadGameState(missionNode.SelectNodes("startState[1]")[0]);
        }
示例#20
0
        /// <summary>
        /// Creates a new SolarSystem with given unique name, position, and members.
        /// </summary>
        /// <param name="name">The unique name.</param>
        /// <param name="position">The position of the SolarSystem.</param>
        /// <param name="isgoObjects">The static members.</param>
        /// <param name="imgoObjects">The movable members.</param>
        /// <param name="sun">The sun of the SolarSystem (could be null).</param>
        /// <returns>Returns created SolarSystem.</returns>
        private SolarSystem CreateSolarSystem(string name, Vector3 position, List<IStaticGameObject> isgoObjects, List<IMovableGameObject> imgoObjects,
			IStaticGameObject sun = null)
        {
            SolarSystem sSys = new SolarSystem(name, position);
            sSys.AddISGO(isgoObjects);
            sSys.AddIMGO(imgoObjects);
            sSys.Sun = sun;
            return sSys;
        }
示例#21
0
 /// <summary>
 /// Removes the object from the old Team and inserts it to the given Team.
 /// </summary>
 /// <param name="isgo">The removing static object.</param>
 /// <param name="newTeam">The new Team of the static object.</param>
 public void ChangeTeam(IStaticGameObject isgo, Team newTeam)
 {
     RemoveFromOwnTeam(isgo);
     newTeam.AddISGO(isgo);
 }
示例#22
0
 /// <summary>
 /// Removes the given static object from the team.
 /// </summary>
 /// <param name="isgo">The removing static object.</param>
 public void RemoveISGO(IStaticGameObject isgo)
 {
     if (isgoObjects.Contains(isgo)) {
         isgoObjects.Remove(isgo);
     }
 }
示例#23
0
 /// <summary>
 /// Inserts the IStaticGameObject to the SolarSystem and sets SolarSystem visibility
 /// to the object. Also checks if the inserting item is Gate, if the object is so sets
 /// the indicator.
 /// </summary>
 /// <param name="isgo">The inserting object.</param>
 public void AddISGO(IStaticGameObject isgo)
 {
     if (!isgoObjectDict.ContainsKey(isgo.Name)) {
         var gate = isgo as Gate;
         if (gate != null) {
             hasGate = true;
         }
         isgoObjectDict.Add(isgo.Name, isgo);
         isgo.ChangeVisible(active);
     }
 }
示例#24
0
 /// <summary>
 /// Removes given object from attackes targets. If the removing object is the actual
 /// target then selects new one.
 /// </summary>
 /// <param name="igo">The removing target.</param>
 private void RemoveFromAttackerTarget(IStaticGameObject igo)
 {
     isgoDeffenders.RemoveMember(igo);
     if (attackerTarget.Value == igo) {
         SelectAttackerTarget();
     }
 }
示例#25
0
 /// <summary>
 /// Removes static object from its Team.
 /// </summary>
 /// <param name="isgo">The removing static object.</param>
 public void RemoveFromOwnTeam(IStaticGameObject isgo)
 {
     isgo.Team.RemoveISGO(isgo);
 }
示例#26
0
 /// <summary>
 /// Removes the object from the old Team and inserts it to the given Team.
 /// </summary>
 /// <param name="isgo">The removing static object.</param>
 /// <param name="newTeam">The new Team of the static object.</param>
 public void ChangeTeam(IStaticGameObject isgo, Team newTeam)
 {
     RemoveFromOwnTeam(isgo);
     newTeam.AddISGO(isgo);
 }
示例#27
0
 /// <summary>
 /// Check if SolarSystem contains the IStaticGameObject.
 /// </summary>
 /// <param name="isgo">The checking object.</param>
 /// <returns>Returns if the SolarSystem contains the object.</returns>
 public bool HasISGO(IStaticGameObject isgo)
 {
     return isgoObjectDict.ContainsKey(isgo.Name);
 }
示例#28
0
        /// <summary>
        /// Creates IStaticGameObject by the given type name.
        /// </summary>
        /// <param name="fullName">The name og the creating type.</param>
        /// <param name="args">The arguments of creating object.</param>
        /// <returns>Returns created IStaticGameObject.</returns>
        public IStaticGameObject CreateISGO(string fullName, object[] args)
        {
            IStaticGameObject isgo = (IStaticGameObject)CreateObject(fullName, args);

            return(isgo);
        }
示例#29
0
 /// <summary>
 /// Removes the IStaticGameObject from the SolarSystem.
 /// </summary>
 /// <param name="isgo">The removing object.</param>
 public void RemoveISGO(IStaticGameObject isgo)
 {
     if (isgoObjectDict.ContainsKey(isgo.Name)) {
         isgoObjectDict.Remove(isgo.Name);
     }
 }
示例#30
0
 /// <summary>
 /// Adds new object to isgoDict and also adds to objectIsMovable as non-movable (false).
 /// </summary>
 /// <param name="isgo">The inserting object.</param>
 public void RegisterISGO(IStaticGameObject isgo)
 {
     objectIsMovable.Add(isgo.Name, false);
     isgoDict.Add(isgo.Name, isgo);
 }
示例#31
0
 /// <summary>
 /// Removes static object from its Team.
 /// </summary>
 /// <param name="isgo">The removing static object.</param>
 public void RemoveFromOwnTeam(IStaticGameObject isgo)
 {
     isgo.Team.RemoveISGO(isgo);
 }
示例#32
0
 /// <summary>
 /// Removes the static game object from group, from a solar system and calls Destroy to remove object from the game.
 /// </summary>
 /// <param Name="isgo">IStaticGameObject to remove from the game.</param>
 public void DestroyGameObject(IStaticGameObject isgo)
 {
     RemoveFromGroup(isgo);
     isgo.Destroy();
     Game.SolarSystemManager.RemoveObjectFromSolarSystem(isgo);
 }