Esempio n. 1
0
        /// <summary>
        /// Constructor for Team Information
        /// </summary>
        /// <param name="teamId">Instance of Team class, indicating the identifier for the TeamInformation instance (red/blue)</param>
        /// <param name="fullyAIControlled">Indicates whether the team is human controlled or not</param>
        /// <param name="ownedTurrets">Owned turrets at the start of the game</param>
        /// <param name="teamStartingCredits">Initial credits</param>
        /// <param name="teamPlayer">Team player object</param>
        /// <param name="ownedNodes">Team's patrol nodes</param>
        /// <param name="ownedSpawnPoints">Team's owned spawn points</param>
        /// <param name="maxFighters">Maximum number of fighters</param>
        /// <param name="maxDestroyers">Maximum number of destroyers</param>
        /// <param name="teamHomeBase">Team base instance</param>
        /// <param name="playerSpawnPt">Team's player's spawn point</param>
        public TeamInformation(Team teamId, bool fullyAIControlled, List<Turret> ownedTurrets,
            int teamStartingCredits, playerObject teamPlayer, List<Node> ownedNodes, List<SpawnPoint> ownedSpawnPoints,
            uint maxFighters, uint maxDestroyers, Base teamHomeBase, PlayerSpawnPoint playerSpawnPt)
        {
            this.teamId = teamId;
            this.fullyAIControlled = fullyAIControlled;
            this.ownedTurrets = ownedTurrets;
            this.teamCredits = teamStartingCredits;
            this.teamPlayer = teamPlayer;
            this.teamOwnedNodes = ownedNodes;
            this.teamSpawnPoints = ownedSpawnPoints;
            this.maxDestroyers = maxDestroyers;
            this.maxFighters = maxFighters;
            this.teamFighters = new List<Fighter>((int)maxFighters);
            this.teamDestroyers = new List<Destroyer>((int)maxDestroyers);
            this.teamBase = teamHomeBase;

            scrambleQueue = new PowerDataStructures.PriorityQueue<int, StaticObject>(true);
            fighterBattleList = new Dictionary<Fighter, StaticObject>();
            destroyerBattleList = new Dictionary<Destroyer, StaticObject>();
            turretBattleList = new Dictionary<Turret, StaticObject>();
            gunsCoolDown = new Dictionary<StaticObject, int>();
            spawnQueue = new List<DynamicObject>(ownedSpawnPoints.Count);
            playerTarget = null;
            playerObjective = null;
        }
Esempio n. 2
0
        /// <summary>
        /// Method to load a map
        /// </summary>
        /// <param name="filename">file name of map</param>
        /// <param name="contentMgr">content manager instance</param>
        /// <param name="gfxDevice">graphics device instance</param>
        public static void loadMap(String filename, ContentManager contentMgr, GraphicsDevice gfxDevice)
        {
            XmlReader reader = XmlReader.Create(filename);
            XPathDocument docNav = new XPathDocument(reader);
            XPathNavigator nav = docNav.CreateNavigator();
            XmlNamespaceManager nsmanager = new XmlNamespaceManager(nav.NameTable);
            XPathNodeIterator iter;
            XPathNavigator mapIter = nav.SelectSingleNode("/Map");
            mapRadius = Convert.ToSingle(mapIter.GetAttribute("mapRadius", nsmanager.DefaultNamespace));

            XPathNavigator skyboxIter = nav.SelectSingleNode("/Map/Skybox");
            String texName = skyboxIter.GetAttribute("texture", nsmanager.DefaultNamespace);
            skyBoxRepeat = Convert.ToSingle(skyboxIter.GetAttribute("repeat", nsmanager.DefaultNamespace));
            SetUpSkyBox(gfxDevice, contentMgr, texName, Convert.ToString(skyBoxRepeat));
            //Now read in path nodes:
            iter = nav.Select("/Map/Marker[@className!='SpawnPoint' and @className!='PlayerSpawnPoint']");
            while (iter.MoveNext())
            {
                Node n = new Node();
                readMarkerData(contentMgr, reader, docNav, nav, nsmanager, iter, n);
                content.Add(n.id, n);
            }
            //Read spawnpoints:
            iter = nav.Select("/Map/Marker[@className='SpawnPoint']");
            while (iter.MoveNext())
            {
                SpawnPoint n = new SpawnPoint();
                readMarkerData(contentMgr, reader, docNav, nav, nsmanager, iter, n);
                content.Add(n.id, n);
            }
            //Read player spawnpoints:
            iter = nav.Select("/Map/Marker[@className='PlayerSpawnPoint']");
            while (iter.MoveNext())
            {
                SpawnPoint n = new PlayerSpawnPoint();
                readMarkerData(contentMgr, reader, docNav, nav, nsmanager, iter, n);
                content.Add(n.id, n);
            }
            //Now read other content:
            iter = nav.Select("/Map/ContentItem");
            while (iter.MoveNext())
            {
                Drawer n = new Drawer(false);
                n.contentLoader = contentMgr;
                readObjectData(contentMgr, reader, docNav, nav, nsmanager, iter, n);
            }
            List<Edge> edgeList = new List<Edge>();
            List<float> edgeDistances = new List<float>();
            iter = nav.Select("/Map/PathEdge");
            while (iter.MoveNext())
            {
                float weight = Convert.ToSingle(iter.Current.GetAttribute("weight", nsmanager.DefaultNamespace));
                float distance = Convert.ToSingle(iter.Current.GetAttribute("distance", nsmanager.DefaultNamespace));
                String firstId = iter.Current.SelectSingleNode("firstNodeId").Value;
                String secondId = iter.Current.SelectSingleNode("secondNodeId").Value;
                Node first = null, second = null;
                foreach (Object item in content.Values)
                    if (item is Node)
                    {
                        if ((item as Marker).id == firstId)
                            first = item as Node;
                        else if ((item as Marker).id == secondId)
                            second = item as Node;
                        if (first != null && second != null)
                            break;
                    }
                edgeList.Add(new Edge(first, second, weight));
                edgeDistances.Add(distance);
            }
            //Connect nodes:
            for (int i = 0; i < edgeList.Count; i++)
            {
                Edge item = edgeList.ElementAt(i);
                float distance = edgeDistances.ElementAt(i);
                item.node1.connectToNode(item.node2, item.weight, distance);
            }
            reader.Close();
        }
Esempio n. 3
0
        /// <summary>
        /// Constructor for Team Information
        /// </summary>
        /// <param name="teamId">Instance of Team class, indicating the identifier for the TeamInformation instance (red/blue)</param>
        /// <param name="fullyAIControlled">Indicates whether the team is human controlled or not</param>
        /// <param name="ownedTurrets">Owned turrets at the start of the game</param>
        /// <param name="teamStartingCredits">Initial credits</param>
        /// <param name="teamPlayer">Team player object</param>
        /// <param name="ownedNodes">Team's patrol nodes</param>
        /// <param name="ownedSpawnPoints">Team's owned spawn points</param>
        /// <param name="maxFighters">Maximum number of fighters</param>
        /// <param name="maxDestroyers">Maximum number of destroyers</param>
        /// <param name="teamHomeBase">Team base instance</param>
        /// <param name="playerSpawnPt">Team's player's spawn point</param>
        public TeamInformation(Team teamId, bool fullyAIControlled, List <Turret> ownedTurrets,
                               int teamStartingCredits, playerObject teamPlayer, List <Node> ownedNodes, List <SpawnPoint> ownedSpawnPoints,
                               uint maxFighters, uint maxDestroyers, Base teamHomeBase, PlayerSpawnPoint playerSpawnPt)
        {
            this.teamId            = teamId;
            this.fullyAIControlled = fullyAIControlled;
            this.ownedTurrets      = ownedTurrets;
            this.teamCredits       = teamStartingCredits;
            this.teamPlayer        = teamPlayer;
            this.teamOwnedNodes    = ownedNodes;
            this.teamSpawnPoints   = ownedSpawnPoints;
            this.maxDestroyers     = maxDestroyers;
            this.maxFighters       = maxFighters;
            this.teamFighters      = new List <Fighter>((int)maxFighters);
            this.teamDestroyers    = new List <Destroyer>((int)maxDestroyers);
            this.teamBase          = teamHomeBase;

            scrambleQueue       = new PowerDataStructures.PriorityQueue <int, StaticObject>(true);
            fighterBattleList   = new Dictionary <Fighter, StaticObject>();
            destroyerBattleList = new Dictionary <Destroyer, StaticObject>();
            turretBattleList    = new Dictionary <Turret, StaticObject>();
            gunsCoolDown        = new Dictionary <StaticObject, int>();
            spawnQueue          = new List <DynamicObject>(ownedSpawnPoints.Count);
            playerTarget        = null;
            playerObjective     = null;
        }