/*
         * Grid simulation setup:
         * G = Grass, W = Water
         * |G|G|G|
         * |G|G|G|
         * |G|G|G|
         */
        public KeyDoor()
        {
            // Initialize world
            this.w = new World(Size, Size);
            // Fill world with tiles of grass
            w.FillWorld(TERRAIN.grass, new Size(Size, Size));

            // Initialize player
            w.InitPlayer(new PointF(0, 0));
            this.p = w.getPlayer();
            p.CurrentDirection = (int)Player.Direction.Down;

            // Initialize door and key
            this.d = new Door(new PointF(1, 0));
            w.addEntity(d);
            this.k = new Key(new PointF(0, 0));
            w.addEntity(k);
        }
Exemple #2
0
 /// <summary>
 /// Unlocks door with matching key
 /// </summary>
 /// <param name="key"></param>
 public void UnlockDoor(Key key)
 {
     foreach (Entity e in objects)
     {
         if (e is Door && key.getKeyid() == ((Door) e).getDoorid())
         {
             ((Door)e).UnlockDoor();
             return;
         }
     }
 }