Ejemplo n.º 1
0
        public Pathfinder(PlaygroundScene map)
        {
            levelWidth  = map.Width;
            levelHeight = map.Height;

            InitializeSearchNodes(map);
        }
Ejemplo n.º 2
0
        public Pathfinder(PlaygroundScene map)
        {
            levelWidth = map.Width;
            levelHeight = map.Height;

            InitializeSearchNodes(map);
        }
Ejemplo n.º 3
0
        public SpriteManager(ContentManager cm, GraphicsDevice gd, SpriteBatch sb, int [,] md)
        {
            contentManager = cm;
            graphicsDevice = gd;
            spriteBatch = sb;
            movedata = md;
=======
        PlaygroundScene scene = new PlaygroundScene();
        Human player;
        ComputerAI enemy;
Ejemplo n.º 4
0
 protected override void Initialize()
 {
     graphics.PreferredBackBufferWidth = 240 * 3;
     graphics.ApplyChanges();
     scenemanager = new SceneManager(Content, graphics.GraphicsDevice);
     //scenemanager.addScene(new PlaygroundScene(0,0,320,480,Content, graphics.GraphicsDevice));
     string[] menuText = { "New Game", "Continue", "Settings", "End Game" };
     Scene[]  menuDest = new Scene[1];
     menuDest[0] = new PlaygroundScene(0, 0, 320, 480, Content, graphics.GraphicsDevice, scenemanager);
     scenemanager.addScene(new MainMenu(0, 0, 320, 480, Content, graphics.GraphicsDevice, scenemanager, menuText, menuDest));
     //add Menu screen here
 }
Ejemplo n.º 5
0
 protected override void Initialize()
 {
     graphics.PreferredBackBufferWidth = 240 * 3;
     graphics.ApplyChanges();
     scenemanager = new SceneManager(Content, graphics.GraphicsDevice);
     //scenemanager.addScene(new PlaygroundScene(0,0,320,480,Content, graphics.GraphicsDevice));
     string[] menuText = {"New Game","Continue","Settings","End Game"};
     Scene[] menuDest = new Scene[1];
     menuDest[0] = new PlaygroundScene(0,0,320,480,Content, graphics.GraphicsDevice,scenemanager);
     scenemanager.addScene(new MainMenu(0, 0, 320, 480, Content, graphics.GraphicsDevice,scenemanager,menuText,menuDest));
     //add Menu screen here
 }
Ejemplo n.º 6
0
 protected override void Initialize()
 {
     spritebatch = new SpriteBatch(GraphicsDevice);
     graphics.PreferredBackBufferWidth = 240 * 3;
     graphics.ApplyChanges();
     scenemanager = new SceneManager(Content, graphics.GraphicsDevice);
     //scenemanager.addScene(new PlaygroundScene(0,0,320,480,Content, graphics.GraphicsDevice));
     string[] menuText = { "New Game", "Continue", "Settings", "End Game" };
     Scene[] menuDest = new Scene[1];
     menuDest[0] = new PlaygroundScene(0, 0, 320, 480, Content, graphics.GraphicsDevice, scenemanager);
     scenemanager.addScene(new MainMenu(0, 0, 320, 480, Content, graphics.GraphicsDevice, scenemanager, menuText, menuDest));
     //add Menu screen here
     player = new VideoPlayer();
     video = Content.Load<Video>("Video/Intro");
     //player.Play(video);
 }
Ejemplo n.º 7
0
 protected override void Initialize()
 {
     spritebatch = new SpriteBatch(GraphicsDevice);
     graphics.PreferredBackBufferWidth = 240 * 3;
     graphics.ApplyChanges();
     scenemanager = new SceneManager(Content, graphics.GraphicsDevice);
     //scenemanager.addScene(new PlaygroundScene(0,0,320,480,Content, graphics.GraphicsDevice));
     string[] menuText = { "New Game", "Continue", "Settings", "End Game" };
     Scene[]  menuDest = new Scene[1];
     menuDest[0] = new PlaygroundScene(0, 0, 320, 480, Content, graphics.GraphicsDevice, scenemanager);
     scenemanager.addScene(new MainMenu(0, 0, 320, 480, Content, graphics.GraphicsDevice, scenemanager, menuText, menuDest));
     //add Menu screen here
     player = new VideoPlayer();
     video  = Content.Load <Video>("Video/Intro");
     //player.Play(video);
 }
Ejemplo n.º 8
0
        // Splits our level up into a grid of nodes.
        private void InitializeSearchNodes(PlaygroundScene map)
        {
            searchNodes = new SearchNode[levelWidth, levelHeight];

            // creates a search node for each of the tiles in our map
            for (int x = 0; x < levelWidth; x++)
            {
                for (int y = 0; y < levelHeight; y++)
                {
                    //Create a search node to represent this tile.
                    SearchNode node = new SearchNode();
                    node.Position = new Point(x, y);

                    // Player can only walk on grass tiles.
                    //node.Walkable = map.movedata[y, x] == 0;
                    node.Walkable = map.GetIndex(x, y) == 0;
                    // only store nodes that can be walked on.
                    if (node.Walkable == true)
                    {
                        node.Neighbors = new SearchNode[4];
                        searchNodes[x, y] = node;
                    }
                }
            }

            // for each of the search nodes connects it to each of its neighbours.
            for (int x = 0; x < levelWidth; x++)
            {
                for (int y = 0; y < levelHeight; y++)
                {
                    SearchNode node = searchNodes[x, y];

                    //only want to look at the nodes that are walkable
                    if (node == null || node.Walkable == false)
                    {
                        continue;
                    }

                    // An array of all of the possible neighbors this node could have.
                    Point[] neighbors = new Point[]
                    {
                        new Point (x, y - 1), // The node above the current node
                        new Point (x, y + 1), // The node below the current node.
                        new Point (x - 1, y), // The node left of the current node.
                        new Point (x + 1, y), // The node right of the current node
                    };

                    // loop through each of the possible neighbors
                    for (int i = 0; i < neighbors.Length; i++)
                    {
                        Point position = neighbors[i];

                        // Check if neighbor is part of the level.
                        if (position.X < 0 || position.X > levelWidth - 1 ||
                            position.Y < 0 || position.Y > levelHeight - 1)
                        {
                            continue;
                        }

                        SearchNode neighbor = searchNodes[position.X, position.Y];

                        // Keeps a reference to the nodes that can be walked on.
                        if (neighbor == null || neighbor.Walkable == false)
                        {
                            continue;
                        }

                        // Store a reference to the neighbor.
                        node.Neighbors[i] = neighbor;
                    }
                }
            }
        }
Ejemplo n.º 9
0
        // Splits our level up into a grid of nodes.
        private void InitializeSearchNodes(PlaygroundScene map)
        {
            searchNodes = new SearchNode[levelWidth, levelHeight];

            // creates a search node for each of the tiles in our map
            for (int x = 0; x < levelWidth; x++)
            {
                for (int y = 0; y < levelHeight; y++)
                {
                    //Create a search node to represent this tile.
                    SearchNode node = new SearchNode();
                    node.Position = new Point(x, y);

                    // Player can only walk on grass tiles.
                    node.Walkable = map.GetIndex(x, y) == 0;

                    // only store nodes that can be walked on.
                    if (node.Walkable == true)
                    {
                        node.Neighbors    = new SearchNode[4];
                        searchNodes[x, y] = node;
                    }
                }
            }

            // for each of the search nodes connects it to each of its neighbours.
            for (int x = 0; x < levelWidth; x++)
            {
                for (int y = 0; y < levelHeight; y++)
                {
                    SearchNode node = searchNodes[x, y];

                    //only want to look at the nodes that are walkable
                    if (node == null || node.Walkable == false)
                    {
                        continue;
                    }

                    // An array of all of the possible neighbors this node could have.
                    Point[] neighbors = new Point[]
                    {
                        new Point(x, y - 1),  // The node above the current node
                        new Point(x, y + 1),  // The node below the current node.
                        new Point(x - 1, y),  // The node left of the current node.
                        new Point(x + 1, y),  // The node right of the current node
                    };

                    // loop through each of the possible neighbors
                    for (int i = 0; i < neighbors.Length; i++)
                    {
                        Point position = neighbors[i];

                        // Check if neighbor is part of the level.
                        if (position.X < 0 || position.X > levelWidth - 1 ||
                            position.Y < 0 || position.Y > levelHeight - 1)
                        {
                            continue;
                        }

                        SearchNode neighbor = searchNodes[position.X, position.Y];

                        // Keeps a reference to the nodes that can be walked on.
                        if (neighbor == null || neighbor.Walkable == false)
                        {
                            continue;
                        }

                        // Store a reference to the neighbor.
                        node.Neighbors[i] = neighbor;
                    }
                }
            }
        }