// Constructors public BlockSprite(SpriteInfo spriteInfo, BlockSpriteState state, SpriteDestroyedHandler handlers) : base(spriteInfo) { this.position = new Vector2(state.mapPoint.X * Map.CellSize, state.mapPoint.Y * Map.CellSize); this.type = state.type; this.maxHealth = state.maxHealth; this.Health = state.health; layer = Map.Layer1 - 0.0001f * state.mapPoint.Y + 0.01f; if (type != BlockSpriteType.Invisible) blockAmmo = true; hasBeenDestroyed = handlers; }
// Constructors public MovingSprite(SpriteInfo si, Point realSize, Vector2 position, byte speed) : base(si) { this.position = position; this.speed = speed; this.movingDirection = Direction.None; this.realSize = realSize; this.horizontal = false; this.tPerMovement = 19; origin.X = (int)(si.frameSize.X / 2); origin.Y = (int)(si.frameSize.Y / 2); }
public Effect(SpriteInfo si, EffectState state, SpriteDestroyedHandler handler) : base(si) { this.type = state.type; this.position = state.position; this.startFrame = state.startFrame; this.endFrame = state.endFrame; this.attachedTankIndex = state.attachedTankIndex; scale = 1; if (!normalScale.Contains(type)) scale = 0.6f; origin.X = (int)(si.frameSize.X / 2); origin.Y = (int)(si.frameSize.Y / 2); lastingTime = state.lastingTime; if (lastingTime == 0) oneTimeEffect = true; if (!state.oldEffect) SetFrame(state.startFrame); else SetFrame(state.currentFrame); hasBeenDestroyed = handler; }
// Constructors public Sprite(SpriteInfo spriteInfo) { this.spriteInfo = spriteInfo; }
// Constructors public UserTank(SpriteInfo si, Texture2D gunTexture, TankState ts, SpriteDestroyedHandler handler) : base(si, ts, handler) { this.gunTexture = gunTexture; this.playerIndex = ts.playerIndex; }
void InitializeBackgroundAndForeground(ContentManager content) { // Background textures SpriteInfo si = new SpriteInfo(content.Load<Texture2D>(@"Images/GamePlay/Background/BGsnow"), new Point(1000, 750), null); Sprite snowBG = new Sprite(si); charToSprite.Add('A', snowBG); si.texture = content.Load<Texture2D>(@"Images/GamePlay/Background/BGfire"); Sprite fireBG = new Sprite(si); charToSprite.Add('B', fireBG); si.texture = content.Load<Texture2D>(@"Images/GamePlay/Background/BG"); Sprite bg = new Sprite(si); charToSprite.Add('C', bg); // Foreground textures SpriteInfo fSI = new SpriteInfo(content.Load<Texture2D>(@"Images/GamePlay/Foreground/tree3"), new Point(100, 100), null); Sprite tree = new Sprite(fSI); charToSprite.Add('a', tree); }
public Item(SpriteInfo si, ItemState state, SpriteDestroyedHandler handler) : base(si) { this.position = state.position; this.activeTime = state.activeTime; this.waitingTime = state.waitingTime; this.type = state.type; this.hasBeenDestroyed = handler; this.affectedTankIndex = state.affectedTankIndex; this.oldValue = state.oldValue; this.itemIndex = state.itemIndex; if (waitingTime <= 0) activated = true; occupiedArea.X = (int)position.X; occupiedArea.Y = (int)position.Y; occupiedArea.Width = FrameWidth; occupiedArea.Height = FrameHeight; }
// Private methods. static void InitializeTankFactory(ContentManager contentManager) { // Populate tankSpriteInfo dic. SpriteInfo spriteInfo = new SpriteInfo { texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Tank/bodytank"), frameSize = new Point(50, 50), isAnimated = false, currentFrame = new Point(0, 0), sheetSize = new Point(1, 4), timePerFrame = 0, health = null }; tankSpriteInfo.Add(TankType.Body1, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Tank/bot"); tankSpriteInfo.Add(TankType.Bot1, spriteInfo); // Populate gunTextures dic. gunTextures.Add(GunType.Gun1, contentManager.Load<Texture2D>(@"Images/GamePlay/Tank/hattank")); }
static void InitializeItemFactory(ContentManager contentManager) { // ItemSpriteInfo. SpriteInfo spriteInfo = new SpriteInfo { texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_MaxTankSpeed"), frameSize = new Point(64, 64), isAnimated = true, currentFrame = new Point(0, 0), sheetSize = new Point(2, 1), timePerFrame = 200, health = null }; itemSpriteInfo.Add(ItemType.MaxTankSpeed, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_nitro_speedup"); itemSpriteInfo.Add(ItemType.IncreaseTankSpeed, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_MinTankSpeed"); itemSpriteInfo.Add(ItemType.MinTankSpeed, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_MinimizeEnemiesTanksSpeed"); itemSpriteInfo.Add(ItemType.MinimizeEnemiesTanksSpeed, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_MaxAmmoSpeed"); itemSpriteInfo.Add(ItemType.MaxAmmoSpeed, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_speedup_ammo"); itemSpriteInfo.Add(ItemType.IncreaseAmmoSpeed, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_MinAmmoSpeed"); itemSpriteInfo.Add(ItemType.MinAmmoSpeed, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_MinimizeEnemiesAmmoSpeed"); itemSpriteInfo.Add(ItemType.MinimizeEnemiesTanksAmmoSpeed, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_MaxArmor"); itemSpriteInfo.Add(ItemType.MaxArmor, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_IncreaseArmor"); itemSpriteInfo.Add(ItemType.IncreaseArmor, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_MinArmor"); itemSpriteInfo.Add(ItemType.MinArmor, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_MinimizeEnemiesTanksArmor"); itemSpriteInfo.Add(ItemType.MinimizeEnemiesTanksArmor, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_MinTBF"); itemSpriteInfo.Add(ItemType.MinTBF, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_speedup_cooldown"); itemSpriteInfo.Add(ItemType.DecreaseTBF, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_MaxTBF"); itemSpriteInfo.Add(ItemType.MaxTBF, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_MaximizeEnemiesTBF"); itemSpriteInfo.Add(ItemType.MaximizeEnemiesTBF, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_add50health"); itemSpriteInfo.Add(ItemType.Add50Health, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_invul"); itemSpriteInfo.Add(ItemType.MakeTankInvulnerable, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_rocket_ammo"); itemSpriteInfo.Add(ItemType.ChangeAmmoToRocket, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_FireballAmmo"); itemSpriteInfo.Add(ItemType.ChangeAmmoToFireBall, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_phitieu"); itemSpriteInfo.Add(ItemType.ChangeAmmoToPhiTieu, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_FreezeAllEnemiesTank"); itemSpriteInfo.Add(ItemType.FreezeAllEnemiesTanks, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_unidentify_item"); itemSpriteInfo.Add(ItemType.Random, spriteInfo); }
static void InitializeEffectFactory(ContentManager contentManager) { // EffectSpriteInfo. SpriteInfo spriteInfo = new SpriteInfo { texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Effects/fireovergun"), frameSize = new Point(100, 100), isAnimated = true, currentFrame = new Point(0, 0), sheetSize = new Point(2, 4), timePerFrame = 25, health = null }; effectSpriteInfo.Add(EffectType.TankFire, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Effects/tank-ex2"); spriteInfo.frameSize = new Point(400, 400); spriteInfo.sheetSize = new Point(5, 5); effectSpriteInfo.Add(EffectType.TankDestroyed, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Effects/tank_invul"); spriteInfo.frameSize = new Point(100, 100); spriteInfo.sheetSize = new Point(2, 1); spriteInfo.timePerFrame = 200; effectSpriteInfo.Add(EffectType.TankInvulnerable, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_nitro_speedup"); spriteInfo.frameSize = new Point(64, 64); spriteInfo.sheetSize = new Point(2, 1); effectSpriteInfo.Add(EffectType.II_IncreaseTankSpeed, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_speedup_ammo"); effectSpriteInfo.Add(EffectType.II_IncreaseAmmoSpeed, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_IncreaseArmor"); effectSpriteInfo.Add(EffectType.II_IncreaseArmor, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Items/it_speedup_cooldown"); effectSpriteInfo.Add(EffectType.II_DecreaseTBF, spriteInfo); }
static void InitializeBlockSpriteFactory(ContentManager contentManager) { // Populate blockSpriteSI dic. SpriteInfo spriteInfo = new SpriteInfo { texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Onground/transperant"), frameSize = new Point(25, 25), isAnimated = false, currentFrame = new Point(0, 0), sheetSize = new Point(1, 1), timePerFrame = 0, health = null }; blockSpriteSI.Add(BlockSpriteType.Invulnerable, spriteInfo); blockSpriteSI.Add(BlockSpriteType.Invisible, spriteInfo); spriteInfo.health = 100; spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Onground/snowwallfinal"); spriteInfo.frameSize = new Point(25, 40); spriteInfo.sheetSize = new Point(1, 3); blockSpriteSI.Add(BlockSpriteType.Wall, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Onground/firewall"); blockSpriteSI.Add(BlockSpriteType.FireWall, spriteInfo); }
static void InitializeAmmoFactory(ContentManager contentManager) { // Populate ammoSpriteInfo dic. SpriteInfo spriteInfo = new SpriteInfo { texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Ammo/basicammo"), frameSize = new Point(50, 50), isAnimated = false, currentFrame = new Point(0, 0), sheetSize = new Point(1, 4), timePerFrame = 0, health = 1 }; ammoSpriteInfo.Add(AmmoType.Basic, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Ammo/rocketammo"); spriteInfo.frameSize = new Point(50, 50); spriteInfo.isAnimated = true; spriteInfo.sheetSize = new Point(4, 4); spriteInfo.timePerFrame = 100; ammoSpriteInfo.Add(AmmoType.Rocket, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Ammo/phitieuammo"); ammoSpriteInfo.Add(AmmoType.PhiTieu, spriteInfo); spriteInfo.texture = contentManager.Load<Texture2D>(@"Images/GamePlay/Ammo/fireballammo"); spriteInfo.isAnimated = false; spriteInfo.sheetSize = new Point(1, 4); ammoSpriteInfo.Add(AmmoType.FireBall, spriteInfo); }
public Ammo(SpriteInfo spriteInfo, AmmoState ammoState, Vector2 position) : base(spriteInfo, ammoState.ammoInfo.realSize, position, ammoState.ammoInfo.speed) { this.team = ammoState.team; this.tankIndex = ammoState.tankIndex; this.needCheckForCollision = true; switch (ammoState.direction) { case Direction.Up: SetSheetRow(0); break; case Direction.Down: SetSheetRow(1); break; case Direction.Left: SetSheetRow(2); break; case Direction.Right: SetSheetRow(3); break; } this.ammoType = ammoState.ammoInfo.type; this.damage = ammoState.ammoInfo.damage; MovingDirection = ammoState.direction; this.range = ammoState.ammoInfo.range; this.damagedSprites = new List<Sprite>(); }