Exemplo n.º 1
0
        public override void Load()
        {
            //Mouse
            oldMouseState = Mouse.GetState();

            //Button
            Vector2 buttonPosition = new Vector2(MainGame.ScreenWidth / 2 - buttonWidth / 2,
                                                 MainGame.ScreenHeight / 1.6f - buttonHeight / 2);

            lstButton = new List <Button>();

            newGameButton = new Button(new AnimatedSprite(mainGame.Content.Load <Texture2D>("button"),
                                                          570, 48, 190, 48, 0, buttonScale), "New Game", buttonPosition);
            newGameButton.onClick = onClickNewGame;
            lstButton.Add(newGameButton);

            buttonPosition = new Vector2(buttonPosition.X, buttonPosition.Y + buttonHeight + buttonSpace);
            loadGameButton = new Button(new AnimatedSprite(mainGame.Content.Load <Texture2D>("button"),
                                                           570, 48, 190, 48, 0, buttonScale), "Load Save", buttonPosition);
            loadGameButton.onClick = onClickLoadGame;
            lstButton.Add(loadGameButton);

            buttonPosition = new Vector2(buttonPosition.X, buttonPosition.Y + buttonHeight + buttonSpace);
            quitGameButton = new Button(new AnimatedSprite(mainGame.Content.Load <Texture2D>("button"),
                                                           570, 48, 190, 48, 0, buttonScale), "Quit", buttonPosition);
            quitGameButton.onClick = onClickQuit;
            lstButton.Add(quitGameButton);

            //Title
            title      = "FARMING AND FIGHT";
            titleScale = 2;
            SpriteFont font = AssetManager.MainFont;

            titleStringSize = font.MeasureString(title);

            titlePosition = new Vector2(MainGame.ScreenWidth / 2 - titleStringSize.X * titleScale / 2,
                                        (MainGame.ScreenHeight / 2.9f) - titleStringSize.Y * titleScale / 2);

            //save
            LoadSaves = false;

            //Test particle Engine
            particleEngine = new ParticleEngine(mainGame, new Vector2(MainGame.ScreenWidth / 2,
                                                                      MainGame.ScreenHeight / 2), null);

            base.Load();
        }
Exemplo n.º 2
0
        public override void Load()
        {
            Rectangle Screen = mainGame.Window.ClientBounds;

            //GameFile
            gameFile = new GameFile(this);
            gameFile.ImportingGameData();

            //Hero set
            myCharacter = new Hero(mainGame.Content.Load <Texture2D>("Player/HeroWalk_down"),
                                   mainGame.Content.Load <Texture2D>("PlayerSelector"),
                                   16, 48, 16, 16, 0.4f, GameplayScale, this,
                                   mainGame.Content.Load <Texture2D>("Player/MageBaton"));
            myCharacter.Position = gameFile.HeroPosition;

            myCharacter.Animation["walk_left"]  = mainGame.Content.Load <Texture2D>("Player/HeroWalk_left");
            myCharacter.Animation["walk_up"]    = mainGame.Content.Load <Texture2D>("Player/HeroWalk_up");
            myCharacter.Animation["walk_right"] = mainGame.Content.Load <Texture2D>("Player/HeroWalk_right");
            myCharacter.Animation["walk_down"]  = mainGame.Content.Load <Texture2D>("Player/HeroWalk_down");
            //Baton
            myCharacter.Animation["walk_left_baton"]  = mainGame.Content.Load <Texture2D>("Player/HeroWalk_left_baton");
            myCharacter.Animation["walk_up_baton"]    = mainGame.Content.Load <Texture2D>("Player/HeroWalk_up_baton");
            myCharacter.Animation["walk_right_baton"] = mainGame.Content.Load <Texture2D>("Player/HeroWalk_right_baton");
            myCharacter.Animation["walk_down_baton"]  = mainGame.Content.Load <Texture2D>("Player/HeroWalk_down_baton");

            //TimeManager
            timeManager = new TimeManager(13);
            timeManager.SetHour(gameFile.CurrentTime);

            //Camera
            camera = new Camera(mainGame.GraphicsDevice.Viewport, myCharacter.Position);

            //Crop
            map = new TileMap(mainGame, "PlayerLevel");
            map.LoadMap();
            CropData.PopulateData();
            CropList = new List <Crop>();
            CropRecup();
            map = null;

            //Spell
            spellManager = new SpellManager();
            PassivSpellData.PopulateData(mainGame.Content);
            OffensiveSpellData.PopulateData(mainGame.Content);

            //Enemie
            EnemieData.PopulateData(mainGame.Content);
            enemieOutput = new EnemieOutput();

            //mapFile loading
            mapFile = new MapFile();

            //GUI
            gameplayOutput = new GameplayOutput(new Vector2(Screen.Width / 2, Screen.Height / 2), mainGame, mapFile, myCharacter, this);

            //ChangeMap
            mapManager = new MapManager(mainGame, this);
            mapManager.ChangeMap(gameFile.CurrentMap);
            Console.WriteLine(timeManager);
            if (SceneMenu.LoadSaves)
            {
                mapFile.LoadingMap();
                mapFile.SetMapFile();

                map = new TileMap(mainGame, mapManager.CurrentMap.FileName);
                //map loading
                map.LoadMap();
                mapSaving = false;

                myCharacter.Position = gameFile.HeroPosition;
                //Camera
                camera.CameraFix = mapManager.CurrentMap.CameraFix;
                camera.Position  = new Vector2(-MainGame.ScreenWidth, -MainGame.ScreenHeight);

                if (camera.CameraFix)
                {
                    camera.Position = mapManager.CurrentMap.CameraPosition;
                }
                else
                {
                    if (myCharacter.Position.Y >= (TileMap.MapHeight * TileMap.TileHeight) - MainGame.ScreenHeight / 2)
                    {
                        camera.Position = new Vector2(camera.Position.X, -(TileMap.MapHeight * TileMap.TileHeight -
                                                                           MainGame.ScreenHeight) - MainGame.ScreenHeight);
                    }
                    if (myCharacter.Position.X >= (TileMap.MapWidth * TileMap.TileWidth) - MainGame.ScreenWidth / 2)
                    {
                        camera.Position = new Vector2(-(TileMap.MapWidth * TileMap.TileWidth -
                                                        MainGame.ScreenWidth) - MainGame.ScreenWidth, camera.Position.Y);
                    }
                }
                //Inventory + time
                timeManager.SetHour(gameFile.CurrentTime);
                gameFile.GetInventory(gameplayOutput.InventoryManager);
                gameplayOutput.overlayInventory.Populate();
            }
            else
            {
                //Create + save the map
                map = new TileMap(mainGame, "level1");
                map.LoadMap();
                mapFile.SavingMap();
                mapFile.SetMapFile();
                mapFile.LoadingMap();
                gameFile.SavingGameData();
                gameFile.ImportingGameData();
                mapManager.ChangeMap("level1");
                mapSaving = false;
            }

            //Keyboard
            oldKeyboardState = Keyboard.GetState();
            //Mouse
            oldMouseState = Mouse.GetState();

            //buildMode set
            buildMode = new BuildMode(mainGame.Content.Load <Texture2D>("Selector"),
                                      mainGame.Content.Load <Texture2D>("tileset"), this);

            //ParticleEngine
            particleEngine = new ParticleEngine(mainGame, myCharacter.Position, myCharacter);
            //particleEngine.PlayerFootPrint = true;

            //Layer
            layerManager = new LayerManager(this);

            base.Load();
        }