コード例 #1
0
        public override void init()
        {
            base.init();

            entities.Clear();
            entities.Add("solid", new List<bEntity>());
            entities.Add("nodes", new List<bEntity>());

            map = new WorldMap(parameters.mapfile);
            _add(map, "solid");

            foreach (LevelNode n in map.nodes)
            {
                _add(n, "nodes");
            }

            foreach (LevelNode n in entities["nodes"])
                n.setData();

            currentNode = entities["nodes"][data.state.currentNode] as LevelNode;
            nextNode = null;
            nextNodePosition = 0;

            bgColor = Color.Black;

            playerMaker = new PlayerLocationMarker(0, 0);
            _add(playerMaker, "nodes");
            playerMaker.placeAt(currentNode);

            camera = new bCamera2d(game.GraphicsDevice);
            camera.Pos = new Vector2(128, 120);

            (game as KoM).dataManager.state.currentWorld = 0;
            (game as KoM).dataManager.state.currentNode = currentNode.id;
        }
コード例 #2
0
 public void placeAt(LevelNode node)
 {
     this.x = node.x + (node.graphic.width / 2) - graphic.spriteWidth / 2;
     this.y = node.y + (node.graphic.height / 2) - graphic.spriteHeight / 2;
 }
コード例 #3
0
        public override void update(GameTime dt)
        {
            base.update(dt);

            List<LevelNode> available = currentNode.links;
            nextNode = available[nextNodePosition];
            playerMaker.placeAt(currentNode);
            if (KoM.input.pressed(Microsoft.Xna.Framework.Input.Buttons.B))
                nextNodePosition = (nextNodePosition + 1) % available.Count;
            else if (KoM.input.pressed(Microsoft.Xna.Framework.Input.Buttons.A))
            {
                currentNode = nextNode;
                nextNodePosition = 0;
                (game as KoM).dataManager.state.currentNode = currentNode.id;
            }
            else if (KoM.input.pressed(Microsoft.Xna.Framework.Input.Buttons.Start))
            {
                (game as KoM).goToLevel(0, currentNode.level, currentNode.entrance);
            }

            if (KoM.input.pressed(Microsoft.Xna.Framework.Input.Keys.S))
                data.saveGame();

            foreach (bEntity ge in entities["solid"])
                ge.update();
            foreach (bEntity ge in entities["nodes"])
                ge.update();
        }
コード例 #4
0
        protected LevelNode parseNode(XmlReader element)
        {
            LevelNode node = null;

            // Fetch common attributes
            int id, x, y;
            id = int.Parse(element.GetAttribute("id"));
            x = int.Parse(element.GetAttribute("x"));
            y = int.Parse(element.GetAttribute("y"));

            // Create entitiy by element name
            switch (element.Name)
            {
                case "LevelNode":
                    node = new LevelNode(x, y, element.GetAttribute("links"), element.GetAttribute("level"));
                    node.id = id;
                    break;
            }

            return node;
        }