コード例 #1
0
ファイル: Unit.cs プロジェクト: PatrikSjolin/Grrrrrr
 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;
     }
 }
コード例 #2
0
ファイル: Player.cs プロジェクト: PatrikSjolin/Grrrrrr
        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);
        }
コード例 #3
0
ファイル: Game.cs プロジェクト: PatrikSjolin/Grrrrrr
 public Game()
 {
     renderer = new Renderer();
     renderer.Entities = new List<Entity>();
     map = new Map();
 }