// 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 Factory(ContentManager contentManager, SpriteCreatedHandler created, SpriteDestroyedHandler destroyed) { Factory.created = created; Factory.destroyed = destroyed; // Clear Factory.tankSpriteInfo.Clear(); Factory.gunTextures.Clear(); Factory.ammoSpriteInfo.Clear(); Factory.blockSpriteSI.Clear(); Factory.effectSpriteInfo.Clear(); Factory.itemSpriteInfo.Clear(); gunSound.Clear(); InitializeTankFactory(contentManager); InitializeAmmoFactory(contentManager); InitializeBlockSpriteFactory(contentManager); InitializeEffectFactory(contentManager); InitializeItemFactory(contentManager); tankHealthBar = contentManager.Load<Texture2D>(@"Images/GamePlay/Tank/hp_bar_overtank"); tankMainHealthBar = contentManager.Load<Texture2D>(@"Images/GamePlay/Tank/main_hp_bar"); tankHPbackground = contentManager.Load<Texture2D>(@"Images/GamePlay/Tank/hpbg"); healthFont = contentManager.Load<SpriteFont>(@"Fonts/HealthFont"); itemInfoFont = contentManager.Load<SpriteFont>(@"Fonts/ItemInfo"); myselfColor = contentManager.Load<Texture2D>(@"Images/GamePlay/Tank/me"); teamColor = contentManager.Load<Texture2D>(@"Images/GamePlay/Tank/team"); enemyColor = contentManager.Load<Texture2D>(@"Images/GamePlay/Tank/enemy"); statHeader = contentManager.Load<Texture2D>(@"Images/GamePlay/Stat_header"); statBlue = contentManager.Load<Texture2D>(@"Images/GamePlay/Stat_blue"); statTeam = contentManager.Load<Texture2D>(@"Images/GamePlay/stat_team"); statFooter = contentManager.Load<Texture2D>(@"Images/GamePlay/Stat_footer"); explosion = contentManager.Load<SoundEffect>(@"Sound/explosion2"); SoundEffect gun = contentManager.Load<SoundEffect>(@"Sound/basic"); gunSound.Add(AmmoType.Basic, gun); gun = contentManager.Load<SoundEffect>(@"Sound/fireball"); gunSound.Add(AmmoType.FireBall, gun); gun = contentManager.Load<SoundEffect>(@"Sound/phitieu"); gunSound.Add(AmmoType.PhiTieu, gun); gun = contentManager.Load<SoundEffect>(@"Sound/rocket"); gunSound.Add(AmmoType.Rocket, gun); }
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 UserTank(SpriteInfo si, Texture2D gunTexture, TankState ts, SpriteDestroyedHandler handler) : base(si, ts, handler) { this.gunTexture = gunTexture; this.playerIndex = ts.playerIndex; }
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; }