Ejemplo n.º 1
0
        public void Initialize(OpenTK.GameWindow window)
        {
            Window = window;
            //window.ClientSize = new Size(room1Layout[0].Length * tileSize, room1Layout.Length * tileSize);
            //Window.ClientSize = new Size(8 * tileSize, 6 * tileSize);
            Window.ClientSize = new Size(990, 550);
            projectiles = new List<Bullet>();
            Sprite = TextureManager.Instance.LoadTexture(spriteSheets);
            TextureManager.Instance.UseNearestFiltering = true;

            GraphicsManager.Instance.SetDepthRange(0, 21 * 21);

            hero = new PlayerCharacter(heroSheet, new Point(spawnTile.X * TILE_W, spawnTile.Y * TILE_H), 20);
            room1 = new Map(room1Layout, spriteSheets, spriteSources, 2, 0);
            room2 = new Map(room2Layout, spriteSheets, spriteSources, 0, 2);
            room1[4][7].MakeDoor(room2, new Point(1, 1));
            room2[1][0].MakeDoor(room1, new Point(6, 4));
            currentMap = room1;

            room1.AddEnemy(npcSheet, new Point(6 * TILE_W, 1 * TILE_H), true);
            room2.AddEnemy(npcSheet, new Point(1 * TILE_W, 4 * TILE_H), false);
            room1.AddItem(spriteSheets, new Rectangle(20, 198, 44, 49), 10, new Point(3 * TILE_W, 2 * TILE_H + 7));
            room1.AddItem(spriteSheets, new Rectangle(20, 198, 44, 49), 20, new Point(5 * TILE_W, 4 * TILE_H + 7));
            room2.AddItem(spriteSheets, new Rectangle(20, 198, 44, 49), 30, new Point(4 * TILE_W, 2 * TILE_H + 7));
        }
Ejemplo n.º 2
0
 public void MakeDoor(Map target, Point location)
 {
     DoorTarget = target;
     DoorLocation = location;
     IsDoor = true;
 }
Ejemplo n.º 3
0
 public void Update(float dt)
 {
     if (InputManager.Instance.KeyPressed(OpenTK.Input.Key.U)) {
         if (ViewWorldSpace == false) {
             ViewWorldSpace = true;
         }
         else {
             ViewWorldSpace = false;
         }
     }
     if (!GameOver) {
         currentMap = currentMap.ResolveDoors(hero);
         hero.Update(dt);
         if (InputManager.Instance.KeyPressed(OpenTK.Input.Key.Space)) {
             PointF velocity = new PointF(0.0f, 0.0f);
             if (hero.currentSprite == "up") {
                 velocity.Y = -100.0f;
             }
             else if (hero.currentSprite == "down") {
                 velocity.Y = 100.0f;
             }
             if (hero.currentSprite == "left") {
                 velocity.X = -100.0f;
             }
             else if (hero.currentSprite == "right") {
                 velocity.X = 100.0f;
             }
             projectiles.Add(new Bullet(hero.Center, velocity,Sprite));
         }
         for (int i = projectiles.Count - 1; i >= 0; i--) {
             projectiles[i].Update(dt);
         }
         currentMap.Update(dt, hero, projectiles);
     }
     else {
         if (InputManager.Instance.KeyPressed(OpenTK.Input.Key.Space)) {
             currentMap = room1;
             hero.Position = new Point(spawnTile.X * TILE_W, spawnTile.Y * TILE_H);
             GameOver = false;
         }
     }
 }