Esempio n. 1
0
        /// <summary>
        /// Initializes Mogre properties, runtime Properties (Speed, Rotate - speed of rotation,
        /// PickUp - pick up distance). Needs 3 arguments and fourth is optional (name of a mesh,
        /// string with position - Vector2 converted to Vector3, distance from center and health).
        /// </summary>
        /// <param name="name">The name of the planet.</param>
        /// <param name="myTeam">The planet team.</param>
        /// <param name="args">The array with arguments (3 required + 1 optional)</param>
        public Planet(string name, Team myTeam, object[] args)
        {
            this.name = name;
            this.mesh = (string)args[1];
            this.team = myTeam;

            this.position = new Property<Vector3>(Vector3.ZERO);

            SetProperty(PropertyEnum.Position, this.position);
            base.SetProperty(PropertyEnum.Speed, Game.PropertyManager.GetProperty<float>("speed3"));
            base.SetProperty(PropertyEnum.Position, position);
            base.SetProperty(PropertyEnum.Rotate, Game.PropertyManager.GetProperty<float>("planetRotateSpeed"));
            base.SetProperty(PropertyEnum.PickUp, Game.PropertyManager.GetProperty<float>("planetPickUpDistance"));

            if (args.Count() == 4) {
                setHp(Convert.ToInt32(args[3]));
            }

            var planetPosition = ParseStringToVector3((string)args[0]);
            centerPosition = ParseStringToVector3((string)args[2]);

            // Prepare list of positions
            circularPositions = CalculatePositions(circularNum, CalculateDistance(planetPosition, centerPosition), centerPosition);

            // Sets start position
            SetStartPosition(circularNum, planetPosition);

            position.Value = circularPositions.First();

            // Mogre inicialization of object
            entity = Game.SceneManager.CreateEntity(name, mesh);
        }
Esempio n. 2
0
 /// <summary>
 /// Checks if given Teams are friendly.
 /// </summary>
 /// <param name="t1">The firtst Team.</param>
 /// <param name="t2">The second Team.</param>
 /// <returns>Returns if the Teams are friendly.</returns>
 public bool AreFriendly(Team t1, Team t2)
 {
     if (friendlyTeamDict[t1].Contains(t2)) {
         return true;
     } else {
         return false;
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Initializes Mogre properties and sets base animation (animationStay);
        /// </summary>
        /// <param name="name">The name of the gate.</param>
        /// <param name="team">The gate team, it should be None team.</param>
        public Gate(string name, Team team)
        {
            this.name = name;
            this.team = team;
            position = new Property<Vector3>(gatePosition);
            entity = Game.SceneManager.CreateEntity(name, meshConst);

            SetProperty(PropertyEnum.Position, position);

            animationState = entity.GetAnimationState(animationPort);
            animationState.Loop = true;
            animationState.Enabled = true;
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes the object from given arguments (1-2 members second argument is the Hp).
        /// Loads runtime properties from PropertyManager (Speed, Deffence). 
        /// </summary>
        /// <param name="name">The name of the creating object.</param>
        /// <param name="myTeam">The object team.</param>
        /// <param name="args">The argouments should contains one or two members (second is Hp).</param>
        public SpaceShip(string name, Team myTeam, object[] args)
        {
            this.name = name;
            this.mesh = meshConst;
            this.team = myTeam;

            this.position = new Property<Vector3>(ParseStringToVector3((string)args[0]));
            if (args.Count() > 1) {
                setHp(Convert.ToInt32(args[args.Length - 1]));
            }
            base.SetProperty(PropertyEnum.Position, this.position);
            base.SetProperty(PropertyEnum.Speed, Game.PropertyManager.GetProperty<float>("speed"));
            base.SetProperty(PropertyEnum.Deffence, Game.PropertyManager.GetProperty<int>("basicDeff"));

            //Mogre inicialization of object
            entity = Game.SceneManager.CreateEntity(name, mesh);
        }
 /// <summary>
 /// Creates special type Gate (is not runtime compiled). 
 /// </summary>
 /// <param Name="solarSystName">The name of SolarSystem where the Gate will be.</param>
 /// <returns>Returns instance of Gate</returns>
 public Gate CreateGate(string solarSystName, Team teamNone)
 {
     var gate = new Gate("Gate " + solarSystName,
         teamNone);
     gate.Team.AddISGO(gate);
     return gate;
 }
 /// <summary>
 /// Serializes materials of the given Team (name, team and quantity).
 /// </summary>
 /// <param name="rootElement">The parent element.</param>
 /// <param name="team">The serializing materials of the given Team.</param>
 private void SerializeTeamMaterials(XElement rootElement, Team team)
 {
     foreach (var material in team.GetMaterials()) {
         var element = new XElement("material",
             new XAttribute("name", material.Value.Name),
             new XAttribute("team", team.Name));
         SerializeArgument(element, material.Value.State.ToString());
         rootElement.Add(element);
     }
 }
Esempio n. 7
0
 /// <summary>
 /// Changes the game object Team (sets the given Team).
 /// </summary>
 /// <param name="gameObject">The object which will have the changed Team.</param>
 /// <param name="newTeam">The new Team for the object.</param>
 public static void ChangeObjectsTeam(IGameObject gameObject, Team newTeam)
 {
     gameObjectMgr.ChangeObjectsTeam(gameObject, newTeam);
 }
Esempio n. 8
0
        /// <summary>
        /// Loads names of teams and creates the relations.
        /// </summary>
        /// <param Name="teamsNode">XML node with teams and frienships</param>
        private void LoadTeams(XmlNode teamsNode)
        {
            // Add None team for suns and gates
            var t = new Team("None");
            var noneList = new List<Team>();
            noneList.Add(t);
            teamRealationDict.Add(t, noneList);
            teamDict.Add(t.Name, t);
            foreach (XmlNode node in teamsNode.ChildNodes) {
                List<Team> friends = new List<Team>();
                // Teams in same node are friendly
                foreach (XmlNode teamName in node.ChildNodes) {
                    foreach (XmlNode att in teamName.Attributes) {
                        if (att.Name == "name") {
                            t = new Team(att.Value);
                            teamDict.Add(t.Name, t);
                            friends.Add(t);
                        }
                    }
                }
                var listWithNone = new List<Team>(friends);
                listWithNone.Add(teamDict["None"]);
                foreach (var team in friends) {

                    teamRealationDict.Add(team, listWithNone);
                }
            }
        }
Esempio n. 9
0
 /// <summary>
 /// Removes the object from the old Team and inserts it to the given Team.
 /// </summary>
 /// <param name="imgo">The removing movable object.</param>
 /// <param name="newTeam">The new Team of the movable object.</param>
 public void ChangeTeam(IMovableGameObject imgo, Team newTeam)
 {
     RemoveFromOwnTeam(imgo);
     newTeam.AddIMGO(imgo);
 }
Esempio n. 10
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);
 }
Esempio n. 11
0
 /// <summary>
 /// Initializes the TeamManager. Sets the friendly relations between teams and sets the teams to the manager.
 /// </summary>
 /// <param name="settingTeam">The dictionary with teams (name of the team,team).</param>
 /// <param name="friendlyDict">The relations between teams.</param>
 public void Initialize(Dictionary<string,Team> settingTeam, Dictionary<Team, List<Team>> friendlyDict)
 {
     friendlyTeamDict = friendlyDict;
     teamDict = settingTeam;
     playerTeam = teamDict[Game.PlayerName];
 }
 /// <summary>
 /// Changes the team of the given gameObject. Sets the newTeam as the objects team (ChangeTeam) and 
 /// removes it from actual group (has new owner). 
 /// </summary>
 /// <param name="gameObject">The object which is changing team.</param>
 /// <param name="newTeam">The new team of the object.</param>
 public void ChangeObjectsTeam(IGameObject gameObject, Team newTeam)
 {
     var castedImgo = gameObject as IMovableGameObject;
     if (castedImgo != null) {
         groupMgr.RemoveFromGroup(castedImgo);
         teamMgr.ChangeTeam(castedImgo, newTeam);
     } else {
         var castedIsgo = gameObject as IStaticGameObject;
         groupMgr.RemoveFromGroup(castedIsgo);
         teamMgr.ChangeTeam(castedIsgo, newTeam);
     }
 }