Example #1
0
 public virtual void Move(int X, int Y, Map map)
 {
     if(!map.Entities.Any(x => x.PositionX == PositionX + X && x.PositionY == PositionY + Y && x.Intersectable == false))
     {
         PositionX += X;
         PositionY += Y;
     }
 }
Example #2
0
        public override void Move(int X, int Y, Map map)
        {
            Goal goal = (Goal)map.Entities.First(x => x is Goal);

            if(goal.PositionX == PositionX + X && goal.PositionY == PositionY + Y)
            {
                map.Interface = "You win!";
            }

            List<Entity> doors = map.Entities.Where(x => x is Door).ToList();
            Door door;
            if((door = (Door)doors.FirstOrDefault(x => x.PositionX == PositionX + X && x.PositionY == PositionY + Y && ((Door)x).Locked)) != null)
            {
                Key key;
                if((key = (Key)Inventory.FirstOrDefault(x => x is Key)) != null)
                {
                    door.Locked = false;
                    Inventory.Remove(key);
                }
                else
                {
                    System.Media.SoundPlayer player = new System.Media.SoundPlayer(Environment.CurrentDirectory + @"\..\..\Content\Sound\LockedDoor.wav");
                    player.Play();
                    return;
                }
            }
            Item item;
            if((item = (Item)map.Entities.FirstOrDefault(x => x is Item && x.PositionX == PositionX + X && x.PositionY == PositionY + Y)) != null)
            {
                System.Media.SoundPlayer player = new System.Media.SoundPlayer(Environment.CurrentDirectory + @"\..\..\Content\Sound\PickupKeys.wav");
                player.Play();
                Inventory.Add(item);
                map.Entities.Remove(item);
            }
            base.Move(X, Y, map);
        }
Example #3
0
 public Game()
 {
     renderer = new Renderer();
     renderer.Entities = new List<Entity>();
     map = new Map();
 }