コード例 #1
0
ファイル: Level.cs プロジェクト: mbonitho/Dedale
        private void generateLevelRooms()
        {
            try
            {
                //ligne lue
                var lignes = _layout.Replace("\r", "").Split('\n');

                // Lecture du fichier ligne par ligne
                int i = 0;

                foreach (string ligne in lignes)
                {
                    var roomTab = ligne.Split(';');
                    foreach (string room in roomTab)
                    {
                        Room r = new Room(i, int.Parse(room));
                        Rooms.Add(r);
                        i++;
                    }
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
コード例 #2
0
ファイル: Controller.cs プロジェクト: mbonitho/Dedale
        public void initialisePartie()
        {
            try
            {
                SoundManager.playTitleAmbience();

                this.CurrentLevel = LevelsManager.GetAllLevels()[0];
                this.CurrentRoom = this.CurrentLevel.GetRoom(this.CurrentLevel.StartRoomIndex);
                this.CurrentLevel.GetRoom(this.CurrentRoom.Position).Echo();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
コード例 #3
0
ファイル: Controller.cs プロジェクト: mbonitho/Dedale
        public void deplaceJoueur(DIRECTIONS dir)
        {
            int direction = 0;

            switch (dir)
            {
                case DIRECTIONS.LEFT:
                    if (!CurrentRoom.WallLeft)
                        direction = -1;
                    break;

                case DIRECTIONS.UP:
                    if (!CurrentRoom.WallUp)
                        direction = -5;
                    break;

                case DIRECTIONS.RIGHT:
                    if (!CurrentRoom.WallRight)
                        direction = -1;
                    break;

                case DIRECTIONS.DOWN:
                    if (!CurrentRoom.WallDown)
                        direction = 5;
                    break;
            }

            if (direction == 0)
            {
                SoundManager.playSound(@"media\invalid.wav");
                Thread.Sleep(700);
            }
                
            CurrentRoom = CurrentLevel.Rooms[CurrentRoom.Position + direction];
            CurrentRoom.Echo();
        }