Пример #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            hero       = new Hero(Content, new Vector2(178, 100));
            hero.input = new BedieningPijltjes();


            myBackground = Content.Load <Texture2D>("png/BG");
            mainFrame    = new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);

            menuImage     = Content.Load <Texture2D>("png/BGMenu");
            wonImage      = Content.Load <Texture2D>("png/BGWON");
            diedImage     = Content.Load <Texture2D>("png/BGDead");
            controlsImage = Content.Load <Texture2D>("png/BGControls");
            infoImage     = Content.Load <Texture2D>("png/BGInfo");

            level1 = new Level1(Content, hero);
            level1.CreateLevel(Content);

            level2 = new Level2(Content, hero);
            level2.CreateLevel(Content);

            levelBeginner = new BeginnerLevel1(Content, hero);
            levelBeginner.CreateLevel(Content);

            camera = new Camera();

            backgroundMusic = Content.Load <Song>("Background");
            MediaPlayer.Play(backgroundMusic);
            MediaPlayer.IsRepeating = true;
        }
Пример #2
0
        public void TestEasy()
        {
            var   easy = new Easy();
            Level level;

            level = LevelFactory.CreateLevel("Easy");
            Assert.Equal(easy.levelType, level.levelType);
        }
Пример #3
0
        public void TestHard()
        {
            var   hard = new Hard();
            Level level2;

            level2 = LevelFactory.CreateLevel("Hard");
            Assert.Equal(hard.levelType, level2.levelType);
        }
Пример #4
0
        public void TestMedium()
        {
            var   medium = new Medium();
            Level level1;

            level1 = LevelFactory.CreateLevel("Medium");
            Assert.Equal(medium.levelType, level1.levelType);
        }
Пример #5
0
 protected Level(int level, ContentManager content)
 {
     this.Enemies                  = new List <Enemy>();
     this.Decor                    = new List <Sprite>();
     this.QuestGivers              = new List <QuestGiver>();
     this.Interactives             = new List <IInteractable>();
     this.ItemsOnTheField          = new List <IItem>();
     this.LastCharacterCoordinates = new Point2D(Constant.StartingPlayerXPosition, Constant.StartingPlayerYPosition);
     LevelFactory.CreateLevel(this, level, content);
 }
Пример #6
0
 public Map()
 {
     Obstacles = new List <Obstacle>();
     PowerUps  = new PowerUpCollection();
     Width     = 1000;
     Height    = 969;
     Level     = LevelFactory.CreateLevel();
     Snakes    = new List <SnakeBody>();
     Scores    = new List <Score>();
     gameState = new NotStarted();
     ClearMap();
 }
Пример #7
0
 protected override void LoadContent()
 {
     randomNumberGenerator = new RandomNumberClass();
     Textures.Load(Content);
     camera       = new Camera(ScreenWidth, ScreenHeight);
     keyBoard     = (IKeyboard)Activator.CreateInstance(Type.GetType($"GameEngine1.Input.KeyboardInput"), new object[] { });
     mouse        = new MouseInput();
     _spriteBatch = new SpriteBatch(GraphicsDevice);
     levelFactory = new LevelFactory();
     currentLevel = levelFactory.CreateLevel("LevelOne");
     currentLevel.Load();
 }
Пример #8
0
        public void CreateLevel_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            var    factory = this.CreateFactory();
            string level   = "Easy";

            // Act
            Level result = LevelFactory.CreateLevel(level);

            // Assert
            Assert.True(result.levelType == level);
            this.mockRepository.VerifyAll();
        }
Пример #9
0
        public Spel(System.Windows.Controls.Image tekenBlad)
        {
            _tekenBlad = tekenBlad;

            _monster_timer = new DispatcherTimer {
                Interval = new TimeSpan(0, 0, 0, 0, 100)
            };
            _monster_timer.Tick += MonsterTimerElapsed;

            _projectiel_timer = new DispatcherTimer {
                Interval = new TimeSpan(0, 0, 0, 0, 5)
            };
            _projectiel_timer.Tick += ProjectielTimerElapsed;

            _huidigeLevel = 1;
            HuidigeLevel  = LevelFactory.CreateLevel(_huidigeLevel, this);

            StartLevel();
        }
Пример #10
0
        private void Level_gedaan()
        {
            _monster_timer.Stop();

            if (Is_gewonnen)
            {
                HuidigeLevel = LevelFactory.CreateLevel(++_huidigeLevel, this);

                if (HuidigeLevel == null)
                {
                    Gewonnen();
                }
                else
                {
                    StartLevel();
                }
            }
            else
            {
                GameOver();
            }
        }
Пример #11
0
        public void WaitForMessage(Socket listener)
        {
            Socket      clientSocket = listener.Accept();
            MapObserver mapObserver  = new MapObserver(clientSocket, map);

            mapObservable.Register(mapObserver);
            Collegue me = new Collegue(snakeId.ToString(), clientSocket);

            mediator.Register(me);
            clients.Add(clientSocket);

            Thread t = new Thread(new ThreadStart(() => WaitForMessage(listener)));

            threads.Add(t);
            t.Start();
            JObject server = new JObject();

            server["serverAddress"] = clientSocket.LocalEndPoint.ToString();
            server["snakeId"]       = snakeId++;
            SendClientMessage(clientSocket, server.ToString());

            Console.WriteLine(String.Format("ClientConnected -> snakeId: {0}, ip: {1}", snakeId - 1, clientSocket.RemoteEndPoint));

            byte[] bytes = new Byte[1024];

            while (true)
            {
                try
                {
                    NetworkStream ns  = new NetworkStream(clientSocket);
                    StreamReader  sw  = new StreamReader(ns);
                    string        dat = sw.ReadLine();

                    JObject dataPairs = JObject.Parse(dat);

                    if (dataPairs.ContainsKey("generatePowerUp"))
                    {
                        map.PowerUps.Add(map.Level.generatePowerUp(map.Height, map.Width));
                    }
                    if (dataPairs.ContainsKey("addSnake"))
                    {
                        map.Snakes.Add(JsonSerializer.Deserialize <SnakeBody>(dataPairs["addSnake"].ToString()));
                    }
                    if (dataPairs.ContainsKey("gameStart"))
                    {
                        map.Level  = LevelFactory.CreateLevel(dataPairs["level"].ToString());
                        map.Width  = map.Width > int.Parse(dataPairs["mapWidth"].ToString()) ? int.Parse(dataPairs["mapWidth"].ToString()) : map.Width;
                        map.Height = map.Height > int.Parse(dataPairs["mapHeight"].ToString()) ? int.Parse(dataPairs["mapHeight"].ToString()) : map.Height;
                    }
                    if (dataPairs.ContainsKey("sayCommand"))
                    {
                        mediator.Send(me.Name, dataPairs["sayCommand"]["to"].ToString(), dataPairs["sayCommand"]["msg"].ToString());
                        Console.WriteLine(dataPairs["sayCommand"]);
                    }
                    else
                    {
                        ProcessData(dataPairs);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                    break;
                }
            }
        }