public override void Initialize() { MyInputManager = new InputManager(); MyInputManager.AddAction("Back"); MyInputManager["Back"].Add(Keys.Escape); spriteBatch = new SpriteBatch(Game.GraphicsDevice); base.Initialize(); }
/// <summary> /// Odpalane przed wyrysowaniem czegokolwiek /// </summary> public override void Initialize() { /* * Dodawanie informacji o inpucie do managera * * */ MenuInputManager = new InputManager(); MenuInputManager.AddAction("Play"); MenuInputManager.AddAction("Help"); MenuInputManager.AddAction("Highscores"); MenuInputManager.AddAction("Close"); MenuInputManager["Play"].Add(Keys.Enter); MenuInputManager["Close"].Add(Keys.Q); MenuInputManager["Help"].Add(Keys.W); MenuInputManager["Highscores"].Add(Keys.E); base.Initialize(); }
/// <summary> /// Initialization /// </summary> public override void Initialize() { base.Initialize(); /** * * TUTAJ ODBYWA SIE PRZYPISANIE CONTROLSOW * * */ GameInputManager = new InputManager(); GameInputManager.AddAction("BackToMenu"); GameInputManager.AddAction("RepeatLevel"); GameInputManager.AddAction("Pause"); GameInputManager.AddAction("CCW"); GameInputManager.AddAction("CW"); GameInputManager.AddAction("Left"); GameInputManager.AddAction("Right"); GameInputManager["RepeatLevel"].Add(Keys.Enter); GameInputManager["BackToMenu"].Add(Keys.Escape); GameInputManager["Pause"].Add(Keys.P); GameInputManager["CCW"].Add(Keys.Up); GameInputManager["CW"].Add(Keys.Down); GameInputManager["Left"].Add(Keys.Left); GameInputManager["Right"].Add(Keys.Right); // Wysokosci podlogi i platformy floorHeight = 15; platformHeight = 40; highestBodyPosition = 1000; // Ustawienie flag zwyciestwa lub przegranej failFlag = false; lineReached = false; winFlag = false; countDownStarted = false; notStableFlag = false; afterWinProcedureDone = false; pauseFlag = false; // Utworzenie timera ktory bedzie zliczał w doł w przypadku osiagniecia wysokosci, // Czas odliczania to 3 - arg. sec TimeSpan'a CountDownTimer = new TimerGtt(TimerGttModes.COUNTDOWN, new TimeSpan(0, 0, 0, 3, 0)); // Ustawienie defaultowych danych, w calej grze dane są z tej zmiennej brane Settings = new GameSettings(OptionsHandler.blocksFriction, OptionsHandler.blocksBounciness, 0.12f, new Vector2(0.0f, 1.0f), new Vector2(this.GraphicsDevice.Viewport.Width / 2, 40)); // Standardowy "Efekt" do rysowania prymitywów w XNA basicEffect = new BasicEffect(GraphicsDevice); basicEffect.VertexColorEnabled = true; basicEffect.Projection = Matrix.CreateOrthographicOffCenter (0, GraphicsDevice.Viewport.Width, // left, right GraphicsDevice.Viewport.Height, 0, // bottom, top 0, 1); // near, far plane // Stworzenie batchy do rysowania spriteBatch = new SpriteBatch(GraphicsDevice); hudBatch = new SpriteBatch(GraphicsDevice); endingBatch = new SpriteBatch(GraphicsDevice); // Stworzenie kontenera na linie levelu LevelLines = new List<LevelLine>(); // Dodanie linii levelu. LevelLines.Add(new LevelLine(TargetHeight, GraphicsDevice)); // Inicjalizacja świata if (world == null) { world = new World(Settings.gravity); } else { world.Clear(); } if (debugView == null) { debugView = new DebugViewXNA(world); debugView.RemoveFlags(FarseerPhysics.DebugViewFlags.Controllers); debugView.RemoveFlags(FarseerPhysics.DebugViewFlags.Joint); debugView.LoadContent(GraphicsDevice, Game.Content); } // Tworzenie podlogi _floor = BodyFactory.CreateRectangle(world, ConvertUnits.ToSimUnits(GraphicsDevice.Viewport.Width), ConvertUnits.ToSimUnits(floorHeight), 10f); //_floor.Position = ConvertUnits.ToSimUnits(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height - 50); Vector2 posi = new Vector2(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height - floorHeight/2); _floor.Position = ConvertUnits.ToSimUnits(posi); _floor.BodyType = BodyType.Static; _floor.IsStatic = true; _floor.Restitution = 0.1f; _floor.Friction = 2.5f; _floor.OnCollision += new OnCollisionEventHandler(CheckFloorCollision); // Tworzenie platformy _platform = BodyFactory.CreateRectangle(world, ConvertUnits.ToSimUnits(platformWidth), ConvertUnits.ToSimUnits(platformHeight), 10f); //_platform.Position = ConvertUnits.ToSimUnits(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height - 100); Vector2 posi2 = new Vector2(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height - platformHeight/2 - floorHeight); _platform.Position = ConvertUnits.ToSimUnits(posi2); _platform.BodyType = BodyType.Static; _platform.IsStatic = true; _platform.Restitution = 0.1f; _platform.Friction = 5.0f; // Żaden blok nie spada blockOnHisWay = false; // lista bloków leżących na platformie yOfBlocksOnPlatform = new List<float>(); timer = new Timer(1000); timer.Elapsed += new System.Timers.ElapsedEventHandler(timerCallback); timer.Start(); }
public InputAction(InputManager p, string n) { parent = p; name = n; }
/// <summary> /// Inicjalizacja /// </summary> public override void Initialize() { /* * Tutaj odbywa się dodanie poziomów do gry * */ LevelsList = new LinkedList<Level>(); //LevelsList.AddLast(new Level(3, 200)); for (float x = 0; x < 10; x++) { // Wysoksc linii do osiagniecia w danym levelu float a = (float)Math.Round((5 - (x*0.1f)),2); // Szer platformy float b = (float)Math.Round((200 - 5 * x),2); if (Game1.player.IsLevelUnlocked((int)(x + 1))) LevelsList.AddLast(new Level(a,b,false)); else LevelsList.AddLast(new Level(a, b)); } // Ustawienie currenta na pierwszy lewel currentChosenLevel = LevelsList.First; MyInputManager = new InputManager(); // Przesunięcie w lewo MyInputManager.AddAction("Left"); // W prawo MyInputManager.AddAction("Right"); // Wybranie danego levelu MyInputManager.AddAction("EnterLevel"); // Powrót do mainMenu MyInputManager.AddAction("Back"); MyInputManager["Back"].Add(Keys.Escape); MyInputManager["EnterLevel"].Add(Keys.Enter); MyInputManager["Left"].Add(Keys.Left); MyInputManager["Right"].Add(Keys.Right); // Ohydny sposób na BUG, który łapie entera z poprzedniego komponentu System.Threading.Thread.Sleep(700); base.Initialize(); }