/// <summary> /// Returns an exact copy of the object. /// </summary> public override GameObj Clone() { //Sets common variables. MazeTurretBullet newBlock = new MazeTurretBullet(game, X, Y, Layer); newBlock.ActionIndex = ActionIndex; newBlock.ActionIndex2 = ActionIndex2; newBlock.ActionType = ActionType; newBlock.CustInt1 = CustInt1; newBlock.CustInt2 = CustInt2; newBlock.CustStr = CustStr; newBlock.BlockDir = BlockDir; newBlock.IsActivated = IsActivated; newBlock.IsEnabled = IsEnabled; newBlock.IsVisible = IsVisible; newBlock.mirrors = mirrors; return(newBlock); }
/// <summary> /// Updates the atlas. Behavior handled by MngrLvl.cs. /// </summary> public override void Update() { #region Determines sprite by dir and isEnabled. if (BlockDir == Dir.Right) { spriteAtlas.frame = 0; } else if (BlockDir == Dir.Down) { spriteAtlas.frame = 1; } else if (BlockDir == Dir.Left) { spriteAtlas.frame = 2; } else if (BlockDir == Dir.Up) { spriteAtlas.frame = 3; } if (!IsEnabled) { spriteAtlas.frame += 4; } #endregion //Manages turret bullet spawning. if (IsEnabled) { msDelay -= 1; if (msDelay <= 0) { msDelay = CustInt1; MazeTurretBullet bullet = new MazeTurretBullet(game, X * 32 + 16, Y * 32 + 16, Layer); //Updates the bullet position after adjusting it. bullet.X += (int)((Utils.DirVector(BlockDir)).X * 16 - 4); bullet.Y += (int)((Utils.DirVector(BlockDir)).Y * 16 - 4); bullet.BlockSprite.rectDest.X = bullet.X; bullet.BlockSprite.rectDest.Y = bullet.Y; bullet.BlockDir = BlockDir; bullet.CustInt2 = CustInt2; //Provides the bullet speed. game.mngrLvl.AddItem(bullet); } //Fires a bullet when activated. if (IsActivated && ActionType == 5) { IsActivated = false; MazeTurretBullet bullet = new MazeTurretBullet(game, X * 32 + 16, Y * 32 + 16, Layer); //Updates the bullet position after adjusting it. bullet.X += (int)((Utils.DirVector(BlockDir)).X * 16 - 4); bullet.Y += (int)((Utils.DirVector(BlockDir)).Y * 16 - 4); bullet.BlockSprite.rectDest.X = bullet.X; bullet.BlockSprite.rectDest.Y = bullet.Y; bullet.BlockDir = BlockDir; game.mngrLvl.AddItem(bullet); } } spriteAtlas.Update(true); base.Update(); }
///<summary> ///Loads relevant graphics into memory. /// /// Dependencies: MainLoop.cs, maze block textures. /// </summary> public void LoadContent(ContentManager Content) { //Loads relevant assets. sndCheckpoint = Content.Load <SoundEffect>("Content/Sounds/sndCheckpoint"); sndFinish = Content.Load <SoundEffect>("Content/Sounds/sndFinish"); sndHit = Content.Load <SoundEffect>("Content/Sounds/sndHit"); sndWin = Content.Load <SoundEffect>("Content/Sounds/sndWin"); TexPixel = new Texture2D(game.GraphicsDevice, 1, 1); TexPixel.SetData(new Color[] { Color.White }); TexMenuHud = game.Content.Load <Texture2D>("Content/Sprites/Gui/sprMenuHud"); //Sets up hud sprites. sprHudOverlay = new Sprite(true, TexPixel); sprHudOverlay.color = Color.Gray; sprHudOverlay.alpha = 0.5f; sprHudOverlay.rectDest = new SmoothRect (0, game.GetScreenSize().Y - 32, game.GetScreenSize().X, 32); sprMenuHud = new Sprite(true, TexMenuHud); sprMenuHud.rectDest = new SmoothRect (0, game.GetScreenSize().Y - 32, 64, 32); //Loads all maze block textures. GameObj._LoadContent(game.Content); //base class. MazeActor.LoadContent(game.Content); MazeBelt.LoadContent(game.Content); MazeCoin.LoadContent(game.Content); MazeCoinLock.LoadContent(game.Content); MazeCrate.LoadContent(game.Content); MazeCrateHole.LoadContent(game.Content); MazeEnemy.LoadContent(game.Content); MazeFilter.LoadContent(game.Content); MazeFloor.LoadContent(game.Content); MazeFreeze.LoadContent(game.Content); MazeGate.LoadContent(game.Content); MazeHealth.LoadContent(game.Content); MazeIce.LoadContent(game.Content); MazeKey.LoadContent(game.Content); MazeLaserActuator.LoadContent(game.Content); MazeLock.LoadContent(game.Content); MazeMultiWay.LoadContent(game.Content); MazePanel.LoadContent(game.Content); MazeSpawner.LoadContent(game.Content); MazeSpike.LoadContent(game.Content); MazeStairs.LoadContent(game.Content); MazeTeleporter.LoadContent(game.Content); MazeThaw.LoadContent(game.Content); MazeWall.LoadContent(game.Content); MazeCheckpoint.LoadContent(game.Content); MazeEPusher.LoadContent(game.Content); MazeELight.LoadContent(game.Content); MazeEAuto.LoadContent(game.Content); MazeGoal.LoadContent(game.Content); MazeFinish.LoadContent(game.Content); MazeMessage.LoadContent(game.Content); MazeClick.LoadContent(game.Content); MazeRotate.LoadContent(game.Content); MazeTurret.LoadContent(game.Content); MazeTurretBullet.LoadContent(game.Content); MazeMirror.LoadContent(game.Content); }