public static void CreateAmmo(AmmoState state) { SpriteInfo si = ammoSpriteInfo[state.ammoInfo.type]; // Realsize Point realSize = new Point(); switch (state.ammoInfo.type) { case AmmoType.Basic: realSize.X = 5; realSize.Y = 16; break; case AmmoType.Rocket: realSize.X = 16; realSize.Y = 50; break; case AmmoType.FireBall: realSize.X = 40; realSize.Y = 40; break; case AmmoType.PhiTieu: realSize.X = 50; realSize.Y = 50; break; } // Calculate ammo position Vector2 ammoPosition = state.gunPosition; state.ammoInfo.realSize = realSize; switch (state.direction) { case Direction.Up: ammoPosition.Y -= realSize.Y / 2; break; case Direction.Down: ammoPosition.Y += realSize.Y / 2; break; case Direction.Left: ammoPosition.X -= realSize.Y / 2; break; case Direction.Right: ammoPosition.X += realSize.Y / 2; break; } Ammo a = new Ammo(si, state, ammoPosition); created(a); }
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>(); }