Ejemplo n.º 1
0
        public MainGame(LevelFactory aLevelFactory, int level)
        {
            myLevelFactory           = aLevelFactory;
            aLevelFactory.AccessGame = this;
            AccessCurrentLevel       = level;

            myGraphics = new GraphicsDeviceManager(this)
            {
                PreferredBackBufferWidth  = 1920, // set this value to the desired width of your window, 1280 is better on lower resolution screen
                PreferredBackBufferHeight = 1080  // set this value to the desired height of your window, 1024 is better on lower resolution screen
            };
            myGraphics.ApplyChanges();

            Content.RootDirectory = "Content";

            AccessCurrentLevelInstance = myLevelFactory.GetLevelInstance(AccessCurrentLevel);
        }
Ejemplo n.º 2
0
    private void Awake()
    {
        if (ins == null)
        {
            ins = this;
        }
        else
        {
            Destroy(this.gameObject);
            Debug.Log("Deleted existing GameManager");
        }

        DontDestroyOnLoad(this.gameObject);
        Debug.Log(SimpleSerializer.IsFirstLoad());

        if (Environment.GetFlag("--demo"))
        {
            List <LevelAsset> OLDdemoLevels = LevelFactory.ConstructFromFolderCONFIG(Environment.GetPath("demo"));
            for (int i = 0; i < OLDdemoLevels.Count; i++)
            {
                levels.Insert(0, OLDdemoLevels[i]);
            }

            List <LevelAsset> demoLevels = LevelFactory.ConstructFromFolder(Environment.GetPath("demo"));
            for (int i = 0; i < demoLevels.Count; i++)
            {
                levels.Insert(0, demoLevels[i]);
            }
        }

        foreach (LevelAsset level in levels)
        {
            level.LevelData = ConstructSaveData(level.SaveKey);
        }


        if (File.Exists(Environment.GetPath("save") + "/UsernameSTR.sav"))
        {
            m_username = SimpleSerializer.LoadString("Username");
        }
        else
        {
            m_username = "******";
        }
    }
Ejemplo n.º 3
0
        public KeyValuePair <CharClass, int> Convert(ICharClass icc)
        {
            CharClass cc = new CharClass();

            cc.classType         = LEGACY_CLASS_TYPE.Single(kv => kv.Value.Equals(icc.CharClassType)).Key;
            cc.coinBonus         = icc.CoinBonus;
            cc.itemFind          = icc.ItemFind;
            cc.myPets            = new List <Pet>(icc.MyPets);
            cc.prestige          = icc.Prestige;
            cc.preventDeathBonus = icc.PreventDeathBonus;
            cc.successChance     = icc.SuccessChance;
            cc.xpBonus           = icc.XpBonus;

            LevelFactory lf = new LevelFactory();

            return(new KeyValuePair <CharClass, int>(cc,
                                                     lf.createFromLevel(levelCap, icc.Level).XP));
        }
Ejemplo n.º 4
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();
        }
Ejemplo n.º 5
0
        private void NextLevelInit()
        {
            _gameData.WriteToConsole.Invoke(new[] { "\rInitialising...\r" });
            _keyboardInput = new KeyboardInput(new PlayKeyManager());
            _keyboardInput.KBPreviewEventInitialise();
            _gameEngine    = new GameEngine(_renderer);
            IsLevelRunning = false;
            IsNewGame      = true;
            UserReady      = false;
            IsNewGame      = false;
            SetupGameData();
            _weaponEnemy = new List <IAGameObject>();
            GameObjectLoader gol = new GameObjectLoader("Assets//Scripts//Gamedat.xml");

            _levelFactory     = new LevelFactory(gol.GetLevelParser(), gol.GetAiParser(), _gameData);
            _munitionsFactory = new MunitionsFactory(_gameData);
            _weaponPlayer     = new List <IAGameObject>();
            _player           = new Player(_gameData, _keyboardInput, _weaponPlayer);
        }
Ejemplo n.º 6
0
    static void CreateLevel()
    {
        Print.Reset();

        LevelAssetBINARY level = new LevelAssetBINARY
        {
            name       = Print.Prompt("Level name:"),
            difficulty = int.Parse(Print.Prompt(difficultylevel, "Enter a number:")),
            PublicKey  = Print.Prompt("Public Key: "),
            PrivateKey = Print.Prompt("Private Key: "),
            Savekey    = Print.Prompt("Save Key: ")
        };

        string PATH = WD + "/Textures/" + Print.Prompt("Name of image (include the file extension):");

        level.image = LevelFactory.GetImageBytes(PATH);
        string saveName = Print.Prompt("file name:");

        LevelFactory.WriteLevel(WD + saveName + ".level", level);
    }
Ejemplo n.º 7
0
        public Game(Board board, int difficulty)
        {
            this.moveFlag = true;
            this.board    = board;
            this.elements = new List <Drawable>();
            this.player   = new Player(8, 19, this.obstacles);

            LevelFactory factory = new LevelFactory(this.board, this.player);
            Level        lvl     = factory.GetLevel(difficulty);

            this.obstacles = lvl.GetObstacles();
            this.enemies   = lvl.GetEnemies();
            this.attackers = lvl.GetAttackers();
            this.elements.AddRange(this.enemies);
            this.elements.AddRange(this.obstacles);
            this.elements.Add(this.player);
            this.player.SetObstacles(this.obstacles);

            this.scoreIndicator  = new ScoreIndicator(10, 0, this.player);
            this.healthIndicator = new HealthIndicator(30, 0, this.player);
        }
Ejemplo n.º 8
0
        public void TestLumpData()
        {
            var hogFile    = new HOGFile(TestUtils.GetResourceStream("standard.hog"));
            var lumpHeader = hogFile.Lumps[2];

            var lumpData = hogFile.GetLumpData(2);

            Assert.NotNull(lumpData);
            Assert.AreEqual(lumpHeader.Size, lumpData.Length);

            var lumpStream = hogFile.GetLumpAsStream(2);

            Assert.NotNull(lumpStream);
            Assert.AreEqual(lumpHeader.Size, lumpStream.Length);

            // One last thing... try reading the stream
            var level = LevelFactory.CreateFromStream(lumpStream);

            Assert.NotNull(level);
            Assert.AreEqual(20, level.Segments.Count);
        }
Ejemplo n.º 9
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            LevelFactory    levelFactory    = new LevelFactory();
            LevelRepository levelRepository = new LevelRepository();

            string error;

            if (!levelFactory.validate(txtName.Text, txtCode.Text, out error))
            {
                lbErrorMsg.Text = error;
                return;
            }

            Level theLevel = levelFactory.Create(txtName.Text, txtCode.Text, txtDescription.Text);

            if (theLevel != null)
            {
                levelRepository.CreatLevel(theLevel);

                Response.Redirect("View.aspx");
            }
        }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 11
0
        IEnumerator LoadGame()
        {
#if _CALC_LOAD_TIME
            var watch = System.Diagnostics.Stopwatch.StartNew();
            watch.Start();
#endif

            yield return(StartCoroutine(LoadMaze()));

#if _CALC_LOAD_TIME
            watch.Stop();
            Debug.Log("Labyrinth generation time: " + watch.ElapsedMilliseconds / 1000f);
#endif
            Dweller.Map = maze.Map;

            LevelSettings level = LevelFactory.Create(PlayerPrefs.GetInt("level", 1));
            player = DwellerFactory.Create(playerPrefab, maze.Size.GetCenter);
            coins  = DwellerFactory.CreateSet(coinPrefab, level, transform, player);
            yield return(new WaitForEndOfFrame());

#if _CALC_LOAD_TIME
            watch = System.Diagnostics.Stopwatch.StartNew();
            watch.Start();
#endif
            enemies = DwellerFactory.CreateSet(enemyPrefab, level, transform, player);
#if _CALC_LOAD_TIME
            watch.Stop();
            Debug.Log("Enemies spawn time: " + watch.ElapsedMilliseconds / 1000f);
#endif
            yield return(new WaitForEndOfFrame());

            Coin.OnCollect += OnCoinCollect;
            ControllButtons.PressedButton += player.Move;
            Enemy.Gotcha += OnCaughtByEnemy;
            CounterText.Update?.Invoke(TextType.Points, Points = 0);
        }
Ejemplo n.º 12
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);

            var viewPort = _graphics.GraphicsDevice.Viewport;

            var screenConfiguration = new GameScreenConfiguration(viewPort.Height, viewPort.Width);
            var levelConfiguration  = new LevelConfiguration(12, Color.Black, 12, 52, Color.Black, 12, 64, Color.Black, 8, Color.Black, 42, 12, 8);
            var textConfiguration   = new TextConfiguration(Color.Black, 2);

            var textTexture = GetPlain2DTexture(textConfiguration.TextSize);
            var texture     = GetPlain2DTexture(1);

            _eventAggregator = new EventAggregator();
            _randomizer      = new Randomizer.Randomizer();
            _keyboardManager = new KeyboardManager(_eventAggregator, TimeSpan.Zero);
            _playerInput     = new PlayerInput(_eventAggregator);
            var collisionManager = new CollisionManager(_eventAggregator);
            var drawer           = new Drawer(_spriteBatch, texture);
            var textDrawer       = new Drawer(_spriteBatch, textTexture);
            var pixelTextDrawer  = new PixelTextDrawer(textDrawer);
            var particleManager  = new ParticleManager(_eventAggregator, drawer, _randomizer);


            var startScreen  = new StartScreen(_eventAggregator, pixelTextDrawer, screenConfiguration, textConfiguration);
            var levelFactory = new LevelFactory(_eventAggregator, screenConfiguration, levelConfiguration);
            var levelManager = new LevelManager(_eventAggregator, levelFactory, collisionManager, particleManager, drawer);
            var gameScreen   = new GameScreen(_eventAggregator, levelManager);

            _screenManager = new ScreenManager(_eventAggregator, startScreen, gameScreen);

            _keyboardManager.Load();
            _playerInput.Load();
            _screenManager.Load();
        }
Ejemplo n.º 13
0
 public void Expert_Gallery3()
 {
     Levels = LevelFactory.ExpertGallery3();
     Assert.AreEqual(20, Levels.Count);
     Run();
 }
Ejemplo n.º 14
0
 public void AddLevel(string level, Vector2 respawnPosition, PowerUpEnum powerUp, bool appearing)
 {
     AddLevel(LevelFactory.LoadLevel(this, level, respawnPosition, powerUp), appearing);
 }
Ejemplo n.º 15
0
    public override void OnClick(dfControl control, dfMouseEventArgs args)
    {
        LevelFactory factory = new LevelFactory(levelName, loadingBar, switchPanelBehaviour);

        factory.LoadLevel();
    }
Ejemplo n.º 16
0
 public void SpecificLevelTest()
 {
     Levels = LevelFactory.Get_Specific();
     Assert.AreEqual(1, Levels.Count);
     Run(doubleSolve: true);
 }
Ejemplo n.º 17
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;
                }
            }
        }
Ejemplo n.º 18
0
        public static void PlayerReaction(ICharacter character, Keys key)
        {
            IEnumerable <IGameObject> collisionItems = character.Level.Assets.Concat(character.Level.Enemies).ToList();

            var collider = Collide(character, collisionItems);

            if (collider != null)
            {
                Vector2 temp = new Vector2(character.Position.X, character.Position.Y);

                // movement reactions
                if (collider is ICollidable && !(collider is IKillable))
                {
                    if (key == Keys.D)
                    {
                        temp.X            -= character.Speed;
                        character.Position = temp;
                    }

                    if (key == Keys.W)
                    {
                        temp.Y            += character.Speed;
                        character.Position = temp;
                    }

                    if (key == Keys.S)
                    {
                        temp.Y            -= character.Speed;
                        character.Position = temp;
                    }

                    if (key == Keys.A)
                    {
                        temp.X            += character.Speed;
                        character.Position = temp;
                    }
                }

                if (collider is IPickable)
                {
                    var item = (IPickable)collider;

                    // legit cool gold-pickup sound

                    if ((character as Player).TryToPick(item))
                    {
                        item.PickedUpBy(character);
                        Console.Beep(8000, 50);
                    }

                    var healingItem = item as IHeals;
                    healingItem?.HealCharacter(character);

                    var weaponItem = item as IWeapon;
                    weaponItem?.EquipCharacter(character);
                }
            }


            IGameObject door = character.Level.Assets.Find(a => a.Type.Contains("Door"));

            if (door != null)
            {
                Rectangle doorBox = GfxHandler.GetBBox(door);

                Rectangle characterBox = GfxHandler.GetBBox(character);

                if (doorBox.Intersects(characterBox))
                {
                    character.Level = LevelFactory.MakeLevel(character);
                    GfxHandler.ClearEffects();
                }
            }
        }
Ejemplo n.º 19
0
 public void Medium_Gallery4()
 {
     Levels = LevelFactory.MediumGallery4();
     Assert.AreEqual(20, Levels.Count);
     Run();
 }
Ejemplo n.º 20
0
 protected override void SetLevelMetrics(LevelFactory levelFactory)
 {
     _levelData.LapsToComplete = levelFactory.RaceLapCount;
 }
Ejemplo n.º 21
0
 public void Bonus1_Gallery_All()
 {
     Levels = LevelFactory.Bonus1Gallery_All();
     Assert.AreEqual(80, Levels.Count);
     Run();
 }
Ejemplo n.º 22
0
 public void NextLevel()
 {
     LevelFactory.NextLevel();
 }
Ejemplo n.º 23
0
 public void getAction()
 {
     Game.getCurrent().CurrentLevel = LevelFactory.LoadLevel(_nextLevel);
 }
Ejemplo n.º 24
0
 public void Easy_Gallery4()
 {
     Levels = LevelFactory.EasyGallery4();
     Assert.AreEqual(20, Levels.Count);
     Run();
 }
Ejemplo n.º 25
0
        protected override void Update(GameTime gameTime)
        {
            GlobalVariables.GlobalTimer += gameTime.ElapsedGameTime.Milliseconds;

            MouseState mouse = Mouse.GetState();

            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }

            if (this.stage == GameStages.Start_Stage)
            {
                string characterClass = this.startScreen.IsClicked();

                if (characterClass != null)
                {
                    if (characterClass == "Redhead")
                    {
                        this.player = PlayerFacory.MakePlayer(PlayerChars.Redhead);
                    }
                    else if (characterClass == "Guy")
                    {
                        this.player = PlayerFacory.MakePlayer(PlayerChars.TheGuy);
                    }
                    else if (characterClass == "Blondie")
                    {
                        this.player = PlayerFacory.MakePlayer(PlayerChars.Blondy);
                    }

                    this.startScreen.UnloadButtons();
                    this.stage = GameStages.GameStage;

                    this.player.Level = LevelFactory.MakeLevel(this.player, Maps.HouseMap);
                }

                this.startScreen.Update(mouse);
            }

            if (this.stage == GameStages.DeathStage)
            {
                this.player.Level = null;
                string death = this.deathScreen.IsClicked();
                if (death != null)
                {
                    this.startScreen.UnloadButtons();
                    this.stage = GameStages.Start_Stage;
                }

                this.deathScreen.Update(mouse);
            }

            if (this.stage == GameStages.GameStage)
            {
                GfxHandler.UpdateLevel(gameTime, this.player.Level);

                if (this.player.CurrentHealth <= 0)
                {
                    this.stage        = GameStages.DeathStage;
                    this.player.Level = null;
                }
            }

            base.Update(gameTime);
        }
 protected abstract void SetLevelMetrics(LevelFactory levelFactory);
Ejemplo n.º 27
0
 public void All_Seaons_Combined()
 {
     Levels = LevelFactory.GetAll_Seasons_Combined();
     Assert.AreEqual(ImagesPerYear * WholeYearsAdded, Levels.Count);
     Run();
 }
Ejemplo n.º 28
0
 public void All_Seaons()
 {
     Levels = LevelFactory.GetAll_Seasons();
     Assert.AreEqual(ImagesPerYear * ImagesPerWeek * WholeYearsAdded + ExtraWeeksAdded * ImagesPerWeek, Levels.Count);
     Run();
 }
Ejemplo n.º 29
0
 public void All_Test()
 {
     Levels = LevelFactory.GetAll_Test();
     Run();
 }
Ejemplo n.º 30
0
 public void Bonus2_Gallery4()
 {
     Levels = LevelFactory.Bonus2Gallery4();
     Assert.AreEqual(20, Levels.Count);
     Run();
 }