protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); AllScenes = new SceneCollection(); LevelClasses.lMenu menu = new CoreClasses.LevelClasses.lMenu(Content, spriteBatch); CurScene = menu.MakeScene(); AllScenes.AddScene(CurScene); fnt = Content.Load<SpriteFont>("fnt"); // TODO: use this.Content to load your game content here }
public bool AddScene(GameScene Scene) { bool SceneIs = false; if (Collection.Count > 0) { foreach (GameScene gs in Collection) { if (gs.GameSceneName == Scene.GameSceneName) SceneIs = true; } if (!SceneIs) { Collection.Add(Scene); return true; } } else { Collection.Add(Scene); return true; } return false; }
public void Update() { current = MainGame.ThisClass.CurScene; if (Keyboard.GetState().IsKeyDown(Keys.F)) { if (MainGame.ThisClass.CurScene.AvZone.Count > 0) foreach (GameScene.Zone z in MainGame.ThisClass.CurScene.AvZone) { if (MainGame.Man.position.X > z.Area.X && MainGame.Man.position.X < z.Area.X + z.Area.Width && MainGame.Man.position.Y > z.Area.Y && MainGame.Man.position.Y < z.Area.Y + z.Area.Height) MainGame.ThisClass.CurScene = MainGame.ThisClass.CurScene.SubSceneCollection.FindByName(z.DestenationSubLevel); } } if (CanWalk(position)) { prev_pos = position; if (Keyboard.GetState().IsKeyDown(Keys.Left)) { if (Schetchik < 10) { Schetchik += 1; return; } Schetchik = 0; position.X -= 20; /*if (position.X <= 0) { position = new Vector2(0, position.Y); CurTex = Collection[0]; }*/ if (CurTex == Collection[4]) CurTex = Collection[3]; else CurTex = Collection[4]; } if (Keyboard.GetState().IsKeyDown(Keys.Right)) { if (Schetchik < 10) { Schetchik += 1; return; } Schetchik = 0; position.X += 20; if (position.X >= 1180) { position = new Vector2(1180, position.Y); CurTex = Collection[0]; } if (CurTex == Collection[6]) CurTex = Collection[5]; else CurTex = Collection[6]; } if (Keyboard.GetState().IsKeyDown(Keys.Down)) { if (Schetchik < 10) { Schetchik += 1; return; } Schetchik = 0; position.Y += 15; if (position.Y >= 430) { position = new Vector2(position.X, 430); CurTex = Collection[0]; } if (CurTex == Collection[2]) CurTex = Collection[1]; else CurTex = Collection[2]; } if (Keyboard.GetState().IsKeyDown(Keys.Up)) { if (Schetchik < 10) { Schetchik += 1; return; } Schetchik = 0; position.Y -= 15; if (position.Y <= 0) { position = new Vector2(position.X, 0); CurTex = Collection[0]; } if (CurTex == Collection[9]) CurTex = Collection[8]; else CurTex = Collection[9]; } } else position = prev_pos; }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Allows the game to exit if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { GameScene sc = AllScenes.FindByName("lMenu"); CurScene = sc; } //if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) //this.Exit(); CurScene.Update(); if (!CurScene.IsSceneStatic) Man.Update(); // TODO: Add your update logic here base.Update(gameTime); }