예제 #1
0
        public static void ApplyImage()
        {
            if (editor.selectedTiles.Count < 1)
            {
                return;
            }

            int x = game.selectedX;
            int y = game.selectedY;

            foreach (SelectedTile s in editor.selectedTiles)
            {
                //first tile in list is under the mouse
                int currX = x + s.PositionX - editor.selectedTiles[0].PositionX;
                int currY = y + s.PositionY - editor.selectedTiles[0].PositionY;
                if (currX >= 0 && currX < game.world.currentArea.mapWidth &&
                    currY >= 0 && currY < game.world.currentArea.mapHeight &&
                    !String.IsNullOrWhiteSpace(s.TileType))
                {
                    //apply the changes to the properties of the tile
                    game.world.currentArea.tile[currX, currY].setAccessible(editor.northBox.Checked, editor.eastBox.Checked, editor.southBox.Checked, editor.westBox.Checked);
                    game.world.currentArea.tile[currX, currY].setRamp(editor.rampBox.Checked);
                    game.world.currentArea.tile[currX, currY].setJumpable(editor.jumpBox.Checked);
                    game.world.currentArea.tile[currX, currY].setRandomEncounter(editor.randomEncounterBox.Checked);
                    game.world.currentArea.tile[currX, currY].setWater(editor.waterBox.Checked);
                    game.world.currentArea.tile[currX, currY].tileType = s.TileType;
                }
            }
            //check if the tile is already of the selected type
            //if not then change it
            game.world.changeZone(game.world.currentArea);
            GameDraw.MakeAdjBuffers(game.world);
        }
예제 #2
0
        public static void PlaceNPC()
        {
            int selX = game.selectedX;
            int selY = game.selectedY;

            if (game.world.currentArea.GetNPCAtLocation(selX, selY) != null)
            {
                //do not place if there is already a NPC there
            }
            else
            {
                NPC tempNPC = editor.CreateNPC();
                //check if the sprite is already there
                if (File.Exists(Directory.GetCurrentDirectory() + "\\Content\\Sprites\\NPCs\\Overworlds\\" + tempNPC.spriteSheet))
                {
                    tempNPC.tileCoords = new Microsoft.Xna.Framework.Point(selX, selY);
                    game.world.currentArea.tile[selX, selY].setOccupied(true);

                    game.world.currentArea.trainerList.Add(tempNPC);

                    tempNPC = null;

                    GameDraw.UpdateNPCSpritesheets(game.world);
                    editor.ResetNPCTab();
                }
            }
        }
예제 #3
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);
            font         = Content.Load <SpriteFont>("font");
            simpleEffect = Content.Load <Effect>("simpleEffect");

            // initialize the screenhandler. need to do it here for the font.
            // ScreenHandler.Initialize(graphics, Content, font);

            if (!Directory.Exists(Application.StartupPath + "\\TileSets"))
            {
                downloadTileSets();
            }

            ScreenHandler.Initialize(graphics, Content, font);
            ScreenHandler.SwitchScreen(new GameScreen(graphics, Content, font));

            world = new World();
            Zone zone = new Zone(2, 2);

            world.addZone(zone);
            world.changeZone(zone);


            GameDraw.Initialize(graphics, Content, font);
            GameDraw.drawAdjObjects = true;
            GameDraw.MakeAdjBuffers(world);

            BaseStatsList.initialize(); //  We need this so we can edit trainer pokemon in the map maker

            // TODO: use this.Content to load your game content here
        }
예제 #4
0
        private void makeNewZone()
        {
            //read all the boxes to get the information necessary
            int x, y;
            int width, height;

            try
            {
                x      = Convert.ToInt32(zoneXBox.Text);
                y      = Convert.ToInt32(zoneYBox.Text);
                width  = Convert.ToInt32(zoneWidthBox.Text);
                height = Convert.ToInt32(zoneHeightBox.Text);

                //make the zone
                Zone zone = new Zone(width, height, x, y);
                zone.zoneName = nameTextBox.Text;
                zone.isRoom   = isRoomBox.Checked;

                game.world.addZone(zone);

                game.world.changeZone(zone);
                GameDraw.MakeAdjBuffers(game.world);
                EditorScreen.lookAtPosition = new Vector3(x, y, 0);

                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                //close the form
                Close();
            }
            catch (FormatException) { /*do nothing*/ }
            catch (ArgumentException)
            {
                MessageBox.Show("Zone with same name already exists");
            }
        }
예제 #5
0
        internal static void SetAll(String tileType)
        {
            //shift undo history down by one
            for (int i = editor.historySize - 1; i > 0; i--)
            {
                editor.zoneHistory[i] = editor.zoneHistory[i - 1];
            }
            //save current state as last change

            for (int x = 0; x < game.world.currentArea.mapWidth; x++)
            {
                for (int y = 0; y < game.world.currentArea.mapHeight; y++)
                {
                    //apply properties
                    game.world.currentArea.tile[x, y].setAccessible(editor.northBox.Checked, editor.eastBox.Checked, editor.southBox.Checked, editor.westBox.Checked);
                    game.world.currentArea.tile[x, y].setRamp(editor.rampBox.Checked);
                    game.world.currentArea.tile[x, y].setJumpable(editor.jumpBox.Checked);
                    game.world.currentArea.tile[x, y].setRandomEncounter(editor.jumpBox.Checked);
                    game.world.currentArea.tile[x, y].setWater(editor.waterBox.Checked);

                    //apply tile image
                    game.world.currentArea.tile[x, y].tileType = tileType;
                    game.world.changeZone(game.world.currentArea);
                }
            }

            //save current zone for undo history
            editor.zoneHistory[0] = new Zone(game.world.currentArea);

            //then update buffers all in one fell swoop
            GameDraw.MakeAdjBuffers(game.world);
        }
예제 #6
0
 protected virtual void OnDraw([CanBeNull] GameTime gameTime)
 {
     if (gameTime != null)
     {
         GameDraw?.Invoke(this, new TimedEventArgs(gameTime));
     }
 }
예제 #7
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.SynchronizeWithVerticalRetrace = true;
            var screen = Screen.AllScreens.First(e => e.Primary);
            Window.IsBorderless = true;
            Window.Position = new Point(screen.Bounds.X, screen.Bounds.Y);
            graphics.PreferredBackBufferWidth = screen.Bounds.Width;
            graphics.PreferredBackBufferHeight = screen.Bounds.Height;
            graphics.IsFullScreen = true;
            //graphics.ToggleFullScreen();
            //graphics.ApplyChanges();

            Content.RootDirectory = "Content";
            gameDrawStack = new Stack<GameDraw>();
            gameUpdateStack = new Stack<GameUpdate>();
            gameDrawStack.Push(StartMenuUpdate);
            gameUpdateStack.Push(StartMenuDraw);
            //gameDrawStack.Enqueue(MainGameUpdate);
            //gameUpdateStack.Enqueue(MainGameDraw);
            gameUpdate = gameUpdateStack.Peek();
            gameDraw = gameDrawStack.Peek();
            Actor.Spawn += new EventHandler<SpawnEventArgs>(Actor_Spawn);
            Actor.Use += new EventHandler<EventArgs>(Actor_Use);
            
        }
예제 #8
0
        internal static void SetAll(String tileType)
        {
            EditorScreen.updateHistory();

            for (int x = 0; x < game.world.currentArea.mapWidth; x++)
            {
                for (int y = 0; y < game.world.currentArea.mapHeight; y++)
                {
                    //apply properties
                    game.world.currentArea.tile[x, y].setAccessible(editor.northBox.Checked, editor.eastBox.Checked, editor.southBox.Checked, editor.westBox.Checked);
                    game.world.currentArea.tile[x, y].setRamp(editor.rampBox.Checked);
                    game.world.currentArea.tile[x, y].setJumpable(editor.jumpBox.Checked);
                    game.world.currentArea.tile[x, y].setRandomEncounter(editor.randomEncounterBox.Checked);
                    game.world.currentArea.tile[x, y].setWater(editor.waterBox.Checked);

                    //apply tile image
                    game.world.currentArea.tile[x, y].tileType = tileType;
                    //game.world.changeZone(game.world.currentArea);
                }
            }

            //if the history index is zero we want to save the current zone
            if (editor.historyIndex == 0)
            {
                editor.zoneHistory[0] = new Zone(game.world.currentArea);
            }

            //then update buffers all in one fell swoop
            GameDraw.MakeAdjBuffers(game.world);
        }
예제 #9
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            var screen = Screen.AllScreens.First(e => e.Primary);

            Window.IsBorderless = true;
            Window.Position     = new Point(screen.Bounds.X, screen.Bounds.Y);
            graphics.PreferredBackBufferWidth  = screen.Bounds.Width;
            graphics.PreferredBackBufferHeight = screen.Bounds.Height;
            graphics.IsFullScreen = true;
            //graphics.ToggleFullScreen();
            //graphics.ApplyChanges();

            Content.RootDirectory = "Content";
            gameDrawStack         = new Stack <GameDraw>();
            gameUpdateStack       = new Stack <GameUpdate>();
            gameDrawStack.Push(StartMenuUpdate);
            gameUpdateStack.Push(StartMenuDraw);
            //gameDrawStack.Enqueue(MainGameUpdate);
            //gameUpdateStack.Enqueue(MainGameDraw);
            gameUpdate   = gameUpdateStack.Peek();
            gameDraw     = gameDrawStack.Peek();
            Actor.Spawn += new EventHandler <SpawnEventArgs>(Actor_Spawn);
            Actor.Use   += new EventHandler <EventArgs>(Actor_Use);
        }
예제 #10
0
        private void ImportTileFolder(string tileDirectory)
        {
            try
            {
                string[] tiles = Directory.GetFiles(tileDirectory);

                lbox_Tiles.Items.Clear();

                //Clear the directory before using
                foreach (string file in Directory.GetFiles(Directory.GetCurrentDirectory() + "\\Content\\Tiles\\"))
                {
                    File.Delete(file);
                }

                foreach (string tile in tiles)
                {
                    if (tile.EndsWith(".png") || tile.EndsWith(".jpg"))
                    {
                        string s = tile.Split('\\')[tile.Split('\\').Length - 1];
                        File.Copy(tile, Directory.GetCurrentDirectory() + "\\Content\\Tiles\\" + s, true);


                        lbox_Tiles.Items.Add(s);
                    }
                }

                lbox_Tiles.Enabled = true;

                //clear our display box
                tilesPanel.Controls.Clear();

                //then display the tiles in our tile display box
                int x = 0;
                int y = 0;

                foreach (String s in lbox_Tiles.Items)
                {
                    TileSelector ts = new TileSelector(x, y, this);
                    ts.Load(tileDirectory + "\\" + s);
                    ts.Parent = tilesPanel;
                    ts.Tag    = s;
                    ts.Click += new EventHandler(tileClick);

                    //increment location counters
                    x += 32;
                    if (x >= 256)
                    {
                        x  = 0;
                        y += 32;
                    }
                }
            }
            catch (ArgumentException)
            {
            }

            //update the tiles used by gamedraw
            GameDraw.LoadTileTextures();
        }
예제 #11
0
 public Brick(Field field, GameDraw draw)
 {
     this.field = field;
     this.draw  = draw;
     shapeID    = rnd.Next(0, 3);
     //shapeID = 0; //fixme
     coordinate = new Coordinate(4, -4);
 }
예제 #12
0
        public void TutorialSelected(Object sender, EventArgs eventArgs)
        {
            cam.menuEnabled = false;
            startTutorial();

            gameUpdateStack.Push(MainGameUpdate);
            gameDrawStack.Push(MainGameDraw);
            gameUpdate = gameUpdateStack.Peek();
            gameDraw   = gameDrawStack.Peek();
        }
예제 #13
0
 public Game1()
 {
     graphics = new GraphicsDeviceManager(this);
     graphics.PreferredBackBufferWidth = 800;
     graphics.PreferredBackBufferHeight = 800;
     graphics.IsFullScreen = false;
     graphics.ApplyChanges();
     Content.RootDirectory = "Content";
     gameUpdate = MainGameUpdate;
     gameDraw = MainGameDraw;
 }
예제 #14
0
 public void CreditsSelected(Object sender, EventArgs eventArgs)
 {
     cam.menuEnabled    = false;
     cam.creditsEnabled = true;
     cam.rollCredits();
     gameUpdateStack.Push(CreditsUpdate);
     gameDrawStack.Push(CreditsDraw);
     gameUpdate = gameUpdateStack.Peek();
     gameDraw   = gameDrawStack.Peek();
     SoundManager.Instance.playSong("creditsTheme");
 }
예제 #15
0
        public void NewGameSelected(Object sender, EventArgs eventArgs)
        {
            //Console.Write("new game selected");
            cam.menuEnabled = false;
            startNewGame();
            //SoundManager.Instance.stopAllSounds();

            gameUpdateStack.Push(MainGameUpdate);
            gameDrawStack.Push(MainGameDraw);
            gameUpdate = gameUpdateStack.Peek();
            gameDraw   = gameDrawStack.Peek();
        }
예제 #16
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferWidth  = 800;
            graphics.PreferredBackBufferHeight = 800;
            graphics.IsFullScreen = false;
            graphics.ApplyChanges();
            Content.RootDirectory = "Content";
            gameUpdate            = MainGameUpdate;
            gameDraw = MainGameDraw;

            Actor.Spawn += new EventHandler <SpawnEventArgs>(Actor_Spawn);
        }
예제 #17
0
 public void CreditsExited(Object sender, EventArgs eventArgs)
 {
     cam.creditsEnabled = false;
     SoundManager.Instance.stopAllSounds();
     cam.enterStartMenu();
     cam.drawSpace.X = 0;
     cam.drawSpace.Y = 0;
     gameUpdateStack.Pop();
     gameDrawStack.Pop();
     gameUpdate = gameUpdateStack.Peek();
     gameDraw   = gameDrawStack.Peek();
     SoundManager.Instance.stopSong("creditsTheme");
 }
예제 #18
0
        public void LoadWorldUpdate(GameTime gameTime)
        {
            while (isLoadingWorld)
            {
                float dt = (gameTime.ElapsedGameTime.Seconds) + (gameTime.ElapsedGameTime.Milliseconds / 1000f);
                //UpdateInput();
                //actorManager.update(dt);
                //UpdateCamera(cam, player);

                base.Update(gameTime);
            }
            gameUpdate = MainGameUpdate;
            gameDraw   = MainGameDraw;
        }
예제 #19
0
        public static void SetMap(String mapName, int xCoord, int yCoord)
        {
            //the while loop makes sure the dialog box is closed before it changes the map

            //disable drawing while transitioning, cause this is in a separate thread
            GameScreen.StopDrawing = true;
            GameScreen.world.changeZone(mapName);
            GameScreen.world.currentArea.scenery = new List <Map.Scenery>();
            GameScreen.player.tileCoords         = new Microsoft.Xna.Framework.Point(xCoord, yCoord);
            GameDraw.MakeAdjBuffers(GameScreen.world);
            GameDraw.UpdateNPCSpritesheets(GameScreen.world);
            //reenable drawing
            GameScreen.StopDrawing = false;
        }
예제 #20
0
        private void editCurrentZone()
        {
            //read all the boxes to get the information necessary
            int x, y;
            int width, height;

            try
            {
                x      = Convert.ToInt32(zoneXBox.Text);
                y      = Convert.ToInt32(zoneYBox.Text);
                width  = Convert.ToInt32(zoneWidthBox.Text);
                height = Convert.ToInt32(zoneHeightBox.Text);

                //make the zone
                Zone zone = new Zone(width, height, x, y);
                zone.zoneName          = nameTextBox.Text;
                zone.isRoom            = isRoomBox.Checked;
                zone.scenery           = game.world.currentArea.scenery;
                zone.tileSheetLocation = game.world.currentArea.tileSheetLocation;
                zone.trainerList       = game.world.currentArea.trainerList;
                zone.randomPokemon     = game.world.currentArea.randomPokemon;

                for (int i = 0; i < Math.Min(zone.mapWidth, game.world.currentArea.mapWidth); i++)
                {
                    for (int j = 0; j < Math.Min(zone.mapHeight, game.world.currentArea.mapHeight); j++)
                    {
                        zone.tile[i, j] = new Tile(game.world.currentArea.tile[i, j]);
                    }
                }

                game.world.addZone(zone);

                game.world.changeZone(zone);
                GameDraw.MakeAdjBuffers(game.world);
                EditorScreen.lookAtPosition = new Vector3(x, y, 0);

                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                //close the form
                Close();
            }
            catch (FormatException) { /*do nothing*/ }
            catch (ArgumentException)
            {
                MessageBox.Show("Zone with same name already exists");
            }
        }
예제 #21
0
        private void btn_LoadNPCSprites_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            //use default zone path if one exists
            if (Directory.Exists(DefaultFileLocations.npcSpriteLocation))
            {
                ofd.InitialDirectory = DefaultFileLocations.npcSpriteLocation;
            }
            ofd.Multiselect = false;
            ofd.ShowDialog();

            Image     tempImage     = null;
            ImageList tempImageList = new ImageList();

            tempImageList.ImageSize = new System.Drawing.Size(116, 153);

            try
            {
                NPCImageToUse     = ofd.FileName;
                tempImage         = Bitmap.FromFile(ofd.FileName);
                NPCImageBox.Image = tempImage;

                //save selected directory as default
                String[] temp = ofd.FileName.Split('\\');
                DefaultFileLocations.npcSpriteLocation = ofd.FileName.Substring(0, ofd.FileName.Length - temp[temp.Length - 1].Length);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            //only fires when we are editing an existing NPC
            if (NPCEditRadio.Checked && activeNPCEdit != null)
            {
                //copy the sprite over to the content folder
                if (!String.IsNullOrWhiteSpace(NPCImageToUse))
                {
                    String destination = Directory.GetCurrentDirectory() + "\\Content\\Sprites\\NPCs\\Overworlds\\" + Path.GetFileName(NPCImageToUse);
                    File.Copy(NPCImageToUse, destination, true);
                }
                activeNPCEdit.spriteSheet = Path.GetFileName(NPCImageToUse);
                GameDraw.UpdateNPCSpritesheets(game.world);
            }
        }
예제 #22
0
        private void Actor_Use(Object sender, EventArgs eventArgs)
        {
            Actor deadActor = (Actor)sender;

            if (deadActor.className == "player" && deadActor.health <= 0 && gameUpdateStack.Count > 1)
            {
                player = null;
                SoundManager.Instance.stopAllSounds();

                cam.enterStartMenu();
                cam.drawSpace.X = 0;
                cam.drawSpace.Y = 0;
                worldManager.restart();
                gameUpdateStack.Pop();
                gameDrawStack.Pop();
                gameUpdate = gameUpdateStack.Peek();
                gameDraw   = gameDrawStack.Peek();
            }
        }
예제 #23
0
        private void WorldManager_worldChange(Object sender, EventArgs eventArgs)
        {
            WorldManager worldManager = (WorldManager)sender;

            if (worldManager.curWorld != null && worldManager.curWorld.isTutorial && gameUpdateStack.Count > 1)
            {
                player = null;
                SoundManager.Instance.stopAllSounds();

                cam.enterStartMenu();
                cam.drawSpace.X = 0;
                cam.drawSpace.Y = 0;
                worldManager.restart();
                gameUpdateStack.Pop();
                gameDrawStack.Pop();
                gameUpdate = gameUpdateStack.Peek();
                gameDraw   = gameDrawStack.Peek();
            }
        }
예제 #24
0
        static public void draw(World world)
        {
            //draw tiles
            GameDraw.DrawAdjacentGround(world, lookAtPosition);
            //draw scenery/models
            GameDraw.DrawScenery(world);
            //draw npc's
            //GameDraw.updateNPCSpritesheets(world);
            GameDraw.DrawNPCs(world);

            //draw the temporary NPC if we are setting a path
            if (editor.toolTab.SelectedTab == editor.NPCTab)
            {
                NPCTool.Draw();
            }
            else if (editor.toolTab.SelectedTab == editor.SceneryTab)
            {
                ModelTool.Draw(currentKeyState);
            }
        }
예제 #25
0
        private void loadZone()
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Pokemon Zone File (*.zon)|*.zon";
            //use default zone path if one exists
            if (Directory.Exists(DefaultFileLocations.zoneLocation))
            {
                ofd.InitialDirectory = DefaultFileLocations.zoneLocation;
            }
            ofd.ShowDialog();
            Zone zone = null;

            try
            {
                using (FileStream stream = new FileStream(ofd.FileName, FileMode.Open))
                {
                    using (BinaryReader reader = new BinaryReader(stream))
                    {
                        zone = SaveLoad.LoadZone(reader);
                    }
                }

                ImportTileFolder(zone.tileSheetLocation); //for now its just the location of where the tiles are

                game.world.getBounds();
                game.world.addZone(zone);

                game.world.changeZone(zone);
                GameDraw.MakeAdjBuffers(game.world);
                GameDraw.UpdateNPCSpritesheets(game.world);
                EditorScreen.lookAtPosition = new Vector3(zone.globalX * 32, zone.globalY * 32, 0);

                toolTab.Enabled = true;

                //save selected directory as default
                String[] temp = ofd.FileName.Split('\\');
                DefaultFileLocations.zoneLocation = ofd.FileName.Substring(0, ofd.FileName.Length - temp[temp.Length - 1].Length);
            }
            catch (ArgumentException) { }
        }
예제 #26
0
        public static void ApplyImage()
        {
            int x = game.selectedX;
            int y = game.selectedY;

            //apply the changes to the properties of the tile
            game.world.currentArea.tile[x, y].setAccessible(editor.northBox.Checked, editor.eastBox.Checked, editor.southBox.Checked, editor.westBox.Checked);
            game.world.currentArea.tile[x, y].setRamp(editor.rampBox.Checked);
            game.world.currentArea.tile[x, y].setJumpable(editor.jumpBox.Checked);
            game.world.currentArea.tile[x, y].setRandomEncounter(editor.randomEncounterBox.Checked);
            game.world.currentArea.tile[x, y].setWater(editor.waterBox.Checked);

            //check if the tile is already of the selected type
            if (game.world.currentArea.tile[x, y].tileType != (String)editor.pbox_TilePreview.Tag &&
                x != -1 && y != -1)
            {
                //if not then change it
                game.world.currentArea.tile[x, y].tileType = (String)editor.pbox_TilePreview.Tag;
                game.world.changeZone(game.world.currentArea);
                GameDraw.MakeAdjBuffers(game.world);
            }
        }
예제 #27
0
        public void TutorialSelected(Object sender, EventArgs eventArgs)
        {
            cam.menuEnabled = false;
            startTutorial();

            gameUpdateStack.Push(MainGameUpdate);
            gameDrawStack.Push(MainGameDraw);
            gameUpdate = gameUpdateStack.Peek();
            gameDraw = gameDrawStack.Peek();
        }
예제 #28
0
 public void CreditsSelected(Object sender, EventArgs eventArgs)
 {
     cam.menuEnabled = false;
     cam.creditsEnabled = true;
     cam.rollCredits();
     gameUpdateStack.Push(CreditsUpdate);
     gameDrawStack.Push(CreditsDraw);
     gameUpdate = gameUpdateStack.Peek();
     gameDraw = gameDrawStack.Peek();
     SoundManager.Instance.playSong("creditsTheme");
 }
예제 #29
0
 public void CreditsExited(Object sender, EventArgs eventArgs)
 {
     cam.creditsEnabled = false;
     SoundManager.Instance.stopAllSounds();
     cam.enterStartMenu();
     cam.drawSpace.X = 0;
     cam.drawSpace.Y = 0;
     gameUpdateStack.Pop();
     gameDrawStack.Pop();
     gameUpdate = gameUpdateStack.Peek();
     gameDraw = gameDrawStack.Peek();
     SoundManager.Instance.stopSong("creditsTheme");
 }
예제 #30
0
        private void Actor_Use(Object sender, EventArgs eventArgs)
        {
            Actor deadActor = (Actor)sender;
            if (deadActor.className == "player" && deadActor.health <= 0 && gameUpdateStack.Count > 1)
            {
                player = null;
                SoundManager.Instance.stopAllSounds();

                cam.enterStartMenu();
                cam.drawSpace.X = 0;
                cam.drawSpace.Y = 0;
                worldManager.restart();
                gameUpdateStack.Pop();
                gameDrawStack.Pop();
                gameUpdate = gameUpdateStack.Peek();
                gameDraw = gameDrawStack.Peek();
            }
        }
예제 #31
0
        public void LoadWorldUpdate(GameTime gameTime)
        {
            while (isLoadingWorld)
            {
                // Allows the game to exit
                if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                    this.Exit();

                float dt = (gameTime.ElapsedGameTime.Seconds) + (gameTime.ElapsedGameTime.Milliseconds / 1000f);
                //UpdateInput();
                //actorManager.update(dt);
                //UpdateCamera(cam, player);

                base.Update(gameTime);
            }
            gameUpdate = MainGameUpdate;
            gameDraw = MainGameDraw;
        }
예제 #32
0
        private void WorldManager_worldChange(Object sender, EventArgs eventArgs)
        {
            WorldManager worldManager = (WorldManager)sender;
            if (worldManager.curWorld != null && worldManager.curWorld.isTutorial && gameUpdateStack.Count > 1)
            {
                player = null;
                SoundManager.Instance.stopAllSounds();

                cam.enterStartMenu();
                cam.drawSpace.X = 0;
                cam.drawSpace.Y = 0;
                worldManager.restart();
                gameUpdateStack.Pop();
                gameDrawStack.Pop();
                gameUpdate = gameUpdateStack.Peek();
                gameDraw = gameDrawStack.Peek();
            }
        }
예제 #33
0
파일: Runtime.cs 프로젝트: Pelsen85/OOP
 public void OnGameDraw(object sender, EventArgs e)
 {
     GameDraw.Invoke(sender, e);
 }
예제 #34
0
        public void LoadWorldUpdate(GameTime gameTime)
        {
            while (isLoadingWorld)
            {
                float dt = (gameTime.ElapsedGameTime.Seconds) + (gameTime.ElapsedGameTime.Milliseconds / 1000f);
                //UpdateInput();
                //actorManager.update(dt);
                //UpdateCamera(cam, player);

                base.Update(gameTime);
            }
            gameUpdate = MainGameUpdate;
            gameDraw = MainGameDraw;
        }
예제 #35
0
 public BrickO(Field field, GameDraw draw)
     : base(field, draw)
 {
     shapes = shapesBrick;
     color  = Color.Blue;
 }
예제 #36
0
        public void NewGameSelected(Object sender, EventArgs eventArgs)
        {
            //Console.Write("new game selected");
            cam.menuEnabled = false;
            startNewGame();
            //SoundManager.Instance.stopAllSounds();

            gameUpdateStack.Push(MainGameUpdate);
            gameDrawStack.Push(MainGameDraw);
            gameUpdate = gameUpdateStack.Peek();
            gameDraw = gameDrawStack.Peek();
        }
예제 #37
0
 internal static void Draw()
 {
     GameDraw.DrawUncontroledPlayer(tempNPC, game.world);
     game.spriteBatch.Draw(hud, hudLocation, Color.White);
 }
예제 #38
0
 public BrickS(Field field, GameDraw draw)
     : base(field, draw)
 {
     shapes = shapesBrick;
     color  = Color.Green;
 }
예제 #39
0
 public BrickT(Field field, GameDraw draw)
     : base(field, draw)
 {
     shapes = shapesBrick;
     color  = Color.Brown;
 }
예제 #40
0
 public void MainGameExited(Object sender, EventArgs eventArgs){
     if(gameUpdateStack.Count > 1)
     {
         paused = false;
         player = null;
         cam.tutorialGui.Clear();
         SoundManager.Instance.stopAllSounds();
         cam.enterStartMenu();
         cam.drawSpace.X = 0;
         cam.drawSpace.Y = 0;
         gameUpdateStack.Pop();
         gameDrawStack.Pop();
         gameUpdate = gameUpdateStack.Peek();
         gameDraw = gameDrawStack.Peek();
         SoundManager.Instance.stopSong("creditsTheme");
     }
     
 }
예제 #41
0
파일: NPC.cs 프로젝트: luodua/PokemonAzure
        /// <summary>
        /// Returns false if the tile we are trying to move to is not accessable, or occupied
        /// </summary>
        /// <param name="direction"></param>
        /// <returns></returns>
        public bool tryToMove(String direction)
        {
            bool canMove = true;
            bool npcTest = true; //false means an npc is occupying the next tile, thus halting movement

            try
            {
                switch (direction)
                {
                case "Up":
                    nextTile = new Point(tileCoords.X, tileCoords.Y - 1);
                    if (GameScreen.Map.tile[tileCoords.X, tileCoords.Y - 1].isAccessibleFrom(Map.Direction.South))
                    {
                        if (standCoolDown <= 0)
                        {
                            startMove("Up");
                        }
                    }
                    else if (standCoolDown <= 0)
                    {
                        canMove = false;
                        changeFacingDirection("Up");
                    }
                    break;

                case "Down":
                    nextTile = new Point(tileCoords.X, tileCoords.Y + 1);
                    if (GameScreen.Map.tile[tileCoords.X, tileCoords.Y + 1].isAccessibleFrom(Map.Direction.North))
                    {
                        if (standCoolDown <= 0)
                        {
                            startMove("Down");
                        }
                    }
                    else if (standCoolDown <= 0)
                    {
                        canMove = false;
                        changeFacingDirection("Down");
                    }
                    break;

                case "Left":
                    nextTile = new Point(tileCoords.X - 1, tileCoords.Y);
                    if (GameScreen.Map.tile[tileCoords.X - 1, tileCoords.Y].isAccessibleFrom(Map.Direction.East))
                    {
                        if (standCoolDown <= 0)
                        {
                            startMove("Left");
                        }
                    }
                    else if (standCoolDown <= 0)
                    {
                        canMove = false;
                        changeFacingDirection("Left");
                    }
                    break;

                case "Right":
                    nextTile = new Point(tileCoords.X + 1, tileCoords.Y);
                    if (GameScreen.Map.tile[tileCoords.X + 1, tileCoords.Y].isAccessibleFrom(Map.Direction.West))
                    {
                        if (standCoolDown <= 0)
                        {
                            startMove("Right");
                        }
                    }
                    else if (standCoolDown <= 0)
                    {
                        canMove = false;
                        changeFacingDirection("Right");
                    }
                    break;

                default:
                    break;
                }
            }//end try
            catch (IndexOutOfRangeException)
            {
                //check whether you can swap to an adjacent map
                if (GameScreen.world.isAdjacentTile(GameScreen.world.currentArea.globalX + nextTile.X, GameScreen.world.currentArea.globalY + nextTile.Y))
                {
                    //unoccupy current tile
                    GameScreen.world.currentArea.tile[tileCoords.X, tileCoords.Y].setOccupied(false);

                    //find global coords
                    nextTile.X   += GameScreen.world.currentArea.globalX;
                    nextTile.Y   += GameScreen.world.currentArea.globalY;
                    tileCoords.X += GameScreen.world.currentArea.globalX;
                    tileCoords.Y += GameScreen.world.currentArea.globalY;
                    //change zone
                    GameScreen.world.moveToAdjZone(nextTile.X, nextTile.Y);
                    GameDraw.MakeAdjBuffers(GameScreen.world);
                    GameDraw.UpdateNPCSpritesheets(GameScreen.world);

                    //convert back to local coords in new zone
                    nextTile.X   -= GameScreen.world.currentArea.globalX;
                    nextTile.Y   -= GameScreen.world.currentArea.globalY;
                    tileCoords.X -= GameScreen.world.currentArea.globalX;
                    tileCoords.Y -= GameScreen.world.currentArea.globalY;

                    isMoving = true;
                    startMove(direction);
                }
                else
                {
                    nextTile = tileCoords;
                    switch (direction)
                    {
                    case "Up": changeFacingDirection("Up"); break;

                    case "Down": changeFacingDirection("Down"); break;

                    case "Left": changeFacingDirection("Left"); break;

                    case "Right": changeFacingDirection("Right"); break;

                    default: break;
                    }
                }
            }

            return(canMove);
        }
예제 #42
0
 public GameSettings(double fps, double renderFPS, GameUpdate update, GameDraw draw)
 {
     FPS = fps;
     RenderFPS = renderFPS;
     OnGameDraw = draw;
     OnGameUpdate = update;
 }