Exemplo n.º 1
0
        public BombExplosion(Vector2 location)
        {
            SetUp(this);
            SoundFactory.Instance.PlayBombExplosion();
            Width                 = ProjectileSpriteFactory.Instance.ExplosionWidth;
            Height                = ProjectileSpriteFactory.Instance.ExplosionHeight;
            Physics               = new Physics(new Vector2(location.X, location.Y));
            collisionHandler      = new ProjectileCollisionHandler(this);
            lifeTime              = MaxLifeTime + 1;
            IsExpired             = false;
            Physics.BoundsOffset  = new Vector2(Width, Height) / 2;
            Physics.Bounds        = new Rectangle((Physics.Location - Physics.BoundsOffset).ToPoint(), new Point(Width, Height));
            Physics.BoundsOffset *= 2;
            Physics.SetLocation();
            Damage       = GameData.Instance.ProjectileDamageConstants.BombDamage;
            Physics.Mass = GameData.Instance.ProjectileMassConstants.ExplosionMass;
            Random numGen     = new Random();
            int    selectBomb = numGen.Next(0, 5);

            switch (selectBomb)
            {
            case 0:
                Sprite = ProjectileSpriteFactory.Instance.BombExplosionOne();
                break;

            case 1:
                Sprite = ProjectileSpriteFactory.Instance.BombExplosionTwo();
                break;

            case 2:
                Sprite = ProjectileSpriteFactory.Instance.BombExplosionThree();
                break;

            case 3:
                Sprite = ProjectileSpriteFactory.Instance.BombExplosionFour();
                break;

            case 4:
                Sprite = ProjectileSpriteFactory.Instance.BombExplosionFive();
                break;

            default:
                Sprite = ProjectileSpriteFactory.Instance.BombExplosionFive();
                break;
            }

            // initialize variables for flashing screen
            flashTexture = new Texture2D(LoZGame.Instance.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            flashTexture.SetData <Color>(new Color[] { Color.White });
            flashDestination = new Rectangle(0, 0, LoZGame.Instance.ScreenWidth, LoZGame.Instance.GraphicsDevice.Viewport.Height);
        }
Exemplo n.º 2
0
 public void SetUp(IProjectile parent)
 {
     this.parent      = parent;
     Returning        = false;
     IsExpired        = false;
     StunDuration     = 0;
     Speed            = 0;
     Acceleration     = 0;
     Damage           = 0;
     Width            = 0;
     Height           = 0;
     Offset           = 0;
     Source           = new Physics(Vector2.Zero);
     Physics          = new Physics(Vector2.Zero);
     Data             = new EntityData();
     Sprite           = ProjectileSpriteFactory.Instance.Bomb();
     CollisionHandler = new ProjectileCollisionHandler(this.parent);
 }
Exemplo n.º 3
0
 public FireballProjectile(Physics physics)
 {
     Physics = new Physics(physics.Location)
     {
         MovementVelocity = new Vector2(physics.MovementVelocity.X, physics.MovementVelocity.Y)
     };
     Source                = physics;
     CollisionHandler      = new ProjectileCollisionHandler(this);
     Data                  = new EntityData();
     Width                 = ProjectileSpriteFactory.Instance.FireballWidth;
     Height                = ProjectileSpriteFactory.Instance.FireballHeight;
     Physics.BoundsOffset  = new Vector2(Width, Height) / 2;
     Physics.Bounds        = new Rectangle((Physics.Location - Physics.BoundsOffset + new Vector2(4)).ToPoint(), new Point(Width, Height) - new Point(8));
     Physics.BoundsOffset *= 2;
     Physics.BoundsOffset -= new Vector2(4);
     Physics.SetLocation();
     Sprite       = ProjectileSpriteFactory.Instance.Fireball();
     IsExpired    = false;
     Damage       = GameData.Instance.ProjectileDamageConstants.FireballDamage;
     Physics.Mass = GameData.Instance.ProjectileMassConstants.FireballMass;
 }