Пример #1
0
        public CombatSystem loadCombat(XmlNode combatSystemNode, string combatReferenceName)
        {
            this.progress.updateProgress("Loading Combat " + combatReferenceName, "Loading Combat System", 10);

            CombatSystem combatSystem = new CombatSystem(lhg);

            // Find level and combat
            string  xpath      = "/combatsystem/combat[@referenceName='" + combatReferenceName + "']";
            XmlNode combatNode = combatSystemNode.SelectSingleNode(xpath);

            if (combatNode != null)
            {
                XmlNodeList combatChildren = combatNode.ChildNodes;
                foreach (XmlNode childNode in combatChildren)
                {
                    switch (childNode.Name)
                    {
                    case "board":
                        progress.updateProgress("Loading Board Assets", "Loading Board Assets", 20);
                        combatSystem.MyBoard = loadBoard(childNode);
                        break;

                    case "screen":
                        progress.updateProgress("Loading Screen Assets", "Loading Screen Assets", 30);
                        combatSystem.MyScreen = loadScreen(childNode);
                        break;

                    case "audio":
                        break;
                    }
                }
            }

            // Now that the combat board has all the components loaded.  Initialilze all the components so the board and screen know how to
            // work with each other.
            // Tell our children about each other and this system
            combatSystem.MyBoard.MyCombatScreen = combatSystem.MyScreen;
            combatSystem.MyBoard.MyCombatSystem = combatSystem;

            combatSystem.MyScreen.MyCombatBoard  = combatSystem.MyBoard;
            combatSystem.MyScreen.MyCombatSystem = combatSystem;

            foreach (Player player in combatSystem.MyBoard.MyGameEntities.MyPlayers)
            {
                player.Location.screen = combatSystem.MyBoard.MyCombatScreen;
            }

            foreach (Obstacle obstacle in combatSystem.MyBoard.MyGameEntities.MyObstacles)
            {
                obstacle.Location.screen = combatSystem.MyBoard.MyCombatScreen;
            }

            progress.updateProgress("Finished Loading Combat System", "Loading", 100);

            return(combatSystem);
        }
Пример #2
0
        // Loads the obstacle from obstacle.xml which is the main definition file for all obstacles
        public Obstacle createObstacleFromTemplate(string referenceName)
        {
            Obstacle obstacle = null;

            if (obstacleDocument == null)
            {
                this.obstacleDocument = new XmlDocument();
                obstacleDocument.Load("Content/Xml/obstacles.xml");
            }

            // Check to see if the obstacle template is in our cache already.
            Obstacle cachedObstacle = lhg.Assets.findObstacleTemplateInCache(referenceName);

            if (cachedObstacle != null)
            {
                progress.updateProgress("Loading obstacle template " + referenceName + " from cache", "Loading", 0);
                obstacle = createQuickCopy(cachedObstacle);
            }
            else
            {
                // We have to load this from our xml template
                string  xpath        = "/obstacles/obstacleGroup/obstacle[@referenceName='" + referenceName + "']";
                XmlNode obstacleNode = obstacleDocument.SelectSingleNode(xpath);
                if (obstacleNode != null)
                {
                    XmlNode         groupNode = obstacleNode.ParentNode;
                    List <Obstacle> obstacles = loadObstacleGroup(groupNode);
                    lhg.Assets.addObstacleTemplates(obstacles);

                    cachedObstacle = lhg.Assets.findObstacleTemplateInCache(referenceName);
                    if (cachedObstacle != null)
                    {
                        progress.updateProgress("Loading obstacle template " + referenceName + " from cache", "Loading", 0);
                        obstacle = createQuickCopy(cachedObstacle);
                    }
                }
            }

            return(obstacle);
        }
Пример #3
0
        public Player createPlayerForCombat(CombatBoard combatBoard, XmlNode playerNode)
        {
            string referenceName = playerNode.Attributes["referenceName"].Value;
            string name          = playerNode.Attributes["name"].Value;

            progress.updateProgress("Creating player " + name + " for combat", "Loading", 0);

            Player player = createPlayerFromTemplate(referenceName);

            player.MyName  = name;
            player.IsAlive = true;

            PrimaryStatistics stats    = null;
            CombatLocation    location = null;

            XmlNodeList childNodes = playerNode.ChildNodes;

            foreach (XmlNode childNode in childNodes)
            {
                switch (childNode.Name)
                {
                case "stats":
                    progress.updateProgress("Loading " + name + " stats", "Loading", 0);
                    stats = loadStats(childNode);
                    break;

                case "location":
                    progress.updateProgress("Loading " + name + " location", "Loading", 0);
                    location = loadCombatLocation(combatBoard, player, childNode);
                    break;
                }
            }

            player.Location = location;
            return(player);
        }