/// <summary> /// /// </summary> public XNArkanoidGame() { State.Game = this; mIsolatedStorage = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication(); XNArkanoidGame.mGameState = eGameState.Loading; mGraphics = new GraphicsDeviceManager(this); mSettings = Settings.Load(); mGraphics.PreferredBackBufferWidth = mSettings.ScreenWidth; mGraphics.PreferredBackBufferHeight = mSettings.ScreenHeight; // Frame rate is 30 fps by default for Windows Phone. TargetElapsedTime = TimeSpan.FromTicks(333333); mVaus = new Vaus(this); // Create dialogs mMainDialog = new UIGame.GUIMainScreen(this); mMainDialog.ControlSelected += new global::XNArkanoid.UI.UIDialog.ControlSelectedDelegate(mMainDialog_ControlSelected); mContinueDialog = new UIGame.GUIContinueScreen(this); mContinueDialog.PlayerContinues += new EventHandler(mContinueDialog_PlayerContinues); mContinueDialog.CounterReachedZero += new EventHandler(mContinueDialog_CounterReachedZero); Level.AllBallsFallen += new Level.AllBallsFallenDelegate(Level_AllBallsFallen); Level.EndLevel += new Level.EndLevelDelegate(Level_EndLevel); XNArkanoidGame.mGameState = eGameState.DialogMain; }
public PlayArena(Arkanoid game, bool twoPlayer, LevelWadSelector selector, Vaus vaus, int editLevelNumber, Level editLevel = null, string editPath = null, bool demo = false) : base(game) { TwoPlayer = twoPlayer; _editLevelNum = editLevelNumber; _editLevel = editLevel; _editPath = editPath; if (demo) { var w = Levels.Levels.Wads.Where(v => v.Levels.Count != 0).ToList(); LevelSelector = new DemoLevelWadSelector(game, w[w.Count - 1], 0, false); } else { LevelSelector = selector; } if (LevelSelector != null) { LevelSelector.Initialise(this); if (LevelMap.TopLeftEntryEnable) { EnimyEntries.Add(TopLeftEntry); } if (LevelMap.TopRightEntryEnable) { EnimyEntries.Add(TopRightEntry); } if (LevelMap.SideRightTopEntryEnable) { EnimyEntries.Add(SideRightTopEntry); } if (LevelMap.SideRightMidEntryEnable) { EnimyEntries.Add(SideRightMidEntry); } if (LevelMap.SideLeftTopEntryEnable) { EnimyEntries.Add(SideLeftTopEntry); } if (LevelMap.SideLeftMidEntryEnable) { EnimyEntries.Add(SideLeftMidEntry); } NextEnimyRelease = new TimeSpan(0, 0, Arkanoid.Random.Next(LevelMap.MinEnimyRealeaseTime, LevelMap.MaxEnimyRealeaseTime)); } NextBrickFlash = new TimeSpan(0, 0, 1); DemoMode = demo; EndDemo = new TimeSpan(0, 0, 2, 30); Vaus = vaus ?? (demo ? new DemoVaus(game, this) : new Vaus(game, this, true, TwoPlayer)); Vaus.PlayArena = this; Vaus.Reset(); }
public virtual PlayableArena WarpRight(Vaus vaus) { Map = null; IsLeft = false; Level++; if (Level >= Wad.Levels.Count) { Map = Map.GetLevel(Game, PlayArena, Lev.EmptyLevel(Lev.ClassicBricksWide, Lev.ClassicBricksHigh)); Name = "Final Round"; return(new BossArena(Game, TwoPlayer, this, vaus)); } if (Game.Settings.Unlocks[Wad.Name].LevelScores.Count > Level - 1) { Game.Settings.Unlocks[Wad.Name].LevelScores[Level - 1] = Math.Max(Game.Settings.Unlocks[Wad.Name].LevelScores[Level - 1], vaus.Score); } else { Game.Settings.Unlocks[Wad.Name].LevelScores.Add(vaus.Score); } Game.Settings.Unlocks[Wad.Name].HighScore = Game.Settings.Unlocks[Wad.Name].LevelScores.Max(); Game.Settings.Save(); if (Wad.Levels[Level].Value != null) { Map = Map.GetLevel(Game, PlayArena, Wad.Levels[Level].Value); } else { if (Wad.Levels[Level].Key != null) { Map = Map.GetLevel(Game, PlayArena, Wad.Levels[Level].Key); } else { Name = "Final Round"; return(new BossArena(Game, TwoPlayer, this, vaus)); } } Name = "Round " + (Level + 1); return(new PlayArena(Game, TwoPlayer, this, vaus, 0)); }
/// <summary> /// /// </summary> protected override void LoadContent() { mSpriteBatch = new SpriteBatch(mGraphics.GraphicsDevice); mSpriteFont = Content.Load <SpriteFont>(@"Content\SpriteFont1"); mLogoTaito = Content.Load <Texture2D>(@"Content\logoTaito"); Brick.LoadTextures(this); Prize.LoadTextures(this); Ball.LoadTextures(this); Vaus.LoadTextures(this); // Give 20 pixels of fall area height below vaus mVaus.mPosition = new Vector2(mVaus.mPosition.X, mGraphics.GraphicsDevice.Viewport.Height - 20 - Vaus.cHeight); // Load levels. Should be done after sprite creation this.LoadLevels(); base.LoadContent(); XNArkanoidGame.mGameState = eGameState.DialogMain; }
public void DeflectVaus(Vaus v) { if (Motion.Y > 0) { var relativeIntersectX = Center.X - v.X; var normalizedRelativeIntersectionX = relativeIntersectX / v.Width; var bounceAngle = MathHelper.Clamp( MathHelper.Pi + (normalizedRelativeIntersectionX + (float)(Arkanoid.Random.NextDouble() / 8f * (Arkanoid.Random.NextDouble() > .5 ? 1 : -1))) * MathHelper.Pi, MathHelper.Pi + .2f, MathHelper.TwoPi - .2f); Motion = new Vector2((float)Math.Cos(bounceAngle), (float)-Math.Abs(-Math.Sin(bounceAngle))); Motion.Normalize(); Location = new Vector2(Location.X, v.Y - Height); } else { Motion = new Vector2(Motion.X, Motion.Y * -1f); } Game.Sounds.BallMetalBounce.Play(); }
public override PlayableArena WarpRight(Vaus vaus) { return(new EditArena(Game, Level, EditPath)); }
public override void Update(GameTime gameTime) { if (DemoMode) { EndDemo -= gameTime.ElapsedGameTime; if (Game.KeyboardInput.Any()) { EndDemo = TimeSpan.Zero; } if (Game.UnifiedInput.VolatileTap != Vector2.Zero) { EndDemo = TimeSpan.Zero; } } if (Game.KeyboardInput.TypedKey(Keys.Escape) || EndDemo < TimeSpan.Zero) { if (_editLevel == null) { Game.Arena = new MenuArena(Game); } else { Game.Arena = new EditArena(Game, _editLevelNum, _editPath); } return; } if (DemoMode && Game.TouchInput.Touches.Count > 0) { EndDemo = TimeSpan.Zero; } Enimies.AddRange(_enimieQue); _enimieQue.Clear(); UpdateEnimies(gameTime); UpdateEntires(gameTime); UpdateWarps(gameTime); UpdateMap(gameTime); if (!Balls.Any(b => b.IsAlive) && Vaus.IsAlive && !IsOver) { Vaus.Die(); } else if (!Vaus.IsAlive) { if (Fade.FadeIn) { Fade.DoFadeOut(() => { Game.Arena = new MenuArena(Game); }); } } base.Update(gameTime); if (!IsOver) { return; } if (Vaus.ExitLeft()) { Vaus.ActionExitLeft = true; Game.Sounds.VausLong.Play(); } if (Vaus.ExitRight()) { Vaus.ActionExitRight = true; Game.Sounds.VausLong.Play(); } if (!Collisions.IsCollision(Vaus.Bounds, Bounds, true)) { if (Fade.Finished) { if (LeftWarp.IsOpen || LeftWarp.IsOpening) { LeftWarp.Close(() => { }); } if (RightWarp.IsOpen || RightWarp.IsOpening) { RightWarp.Close(() => { }); } if (Vaus.ActionExitRight) { Fade.DoFadeOut(() => { if (DemoMode) { Game.Arena = new MenuArena(Game); } else { Game.Arena = LevelSelector.WarpRight(Vaus); Game.Arena.Initialise(); Game.Arena.Fade.DoFadeIn(() => { }); } }); } else { Fade.DoFadeOut(() => { if (DemoMode) { Game.Arena = new MenuArena(Game); } else { Game.Arena = LevelSelector.WarpLeft(Vaus); Game.Arena.Initialise(); Game.Arena.Fade.DoFadeIn(() => { }); } }); } } return; } if (!(LeftWarp.IsOpen || LeftWarp.IsOpening)) { LeftWarp.Open(); } if (!(RightWarp.IsOpen || RightWarp.IsOpening)) { RightWarp.Open(); } }
public BossArena(Arkanoid game, bool twoPlayer, LevelWadSelector selector, Vaus vaus) : base(game, twoPlayer, selector, vaus, 0) { Doh = new Doh(Game, this); }