/// <summary>
 /// handles shooting
 /// </summary>
 /// <param name="vector2"></param>
 /// <param name="alignment"></param>
 /// <param name="rotation"></param>
 public virtual void Shoot(Alignment alignment, float rotation)
 {
     PlayShootSoundEffect();
     BulletPool.CreateBullet(go, alignment,
                             bulletType, rotation + (GameWorld.Instance.Rnd.Next(-weaponSpread, weaponSpread)));
     Ammo--;
 }
Exemple #2
0
 /// <summary>
 /// Shoots an amount of  pellets, with a wide spread
 /// </summary>
 /// <param name="vector2"></param>
 /// <param name="alignment"></param>
 /// <param name="rotation"></param>
 public override void Shoot(Alignment alignment, float rotation)
 {
     PlayShootSoundEffect();
     for (int i = 0; i < Constant.shotgunPelletAmount; i++)
     {
         BulletPool.CreateBullet(go, alignment, bulletType, rotation + (GameWorld.Instance.Rnd.Next(-weaponSpread, weaponSpread)));
     }
     Ammo--;
     vehicle.Stats.ShotgunFired++;
 }
        /// <summary>
        /// Standard shooting behaviour for all towers
        /// </summary>
        protected virtual void Shoot()
        {
            if (shootTimeStamp + attackRate <= GameWorld.Instance.TotalGameTime)
            {
                Collider target;
                target = FindEnemiesInRange();
                if (target != null)
                {
                    Vector2 direction = new Vector2(target.CollisionBox.Center.X - GameObject.Transform.Position.X, target.CollisionBox.Center.Y - GameObject.Transform.Position.Y);
                    direction.Normalize();

                    float rotation = GetDegreesFromDestination(direction);
                    BulletPool.CreateBullet(GameObject, Alignment.Friendly, bulletType, rotation + (GameWorld.Instance.Rnd.Next(-spread, spread)));
                    shootTimeStamp = GameWorld.Instance.TotalGameTime;
                    PlayShootSoundEffect();
                }
            }
        }
        protected virtual void Shoot()
        {
            if (attackTimeStamp + attackRate <= GameWorld.Instance.TotalGameTime)
            {
                Collider target;
                target = FindTargetInRange();
                if (target != null)
                {
                    Vector2 direction = new Vector2(target.CollisionBox.Center.X - GameObject.Transform.Position.X, target.CollisionBox.Center.Y - GameObject.Transform.Position.Y);

                    direction.Normalize();

                    float rotation = GetDegreesFromDestination(direction);

                    RotateToMatchDirection(direction);

                    BulletPool.CreateBullet(GameObject, Alignment.Enemy,
                                            bulletType, rotation + (GameWorld.Instance.Rnd.Next(-spread, spread)));

                    if (attackVariation > 2)//Adds animation variation
                    {
                        attackVariation = 1;
                    }
                    animator.PlayAnimation("Attack" + attackVariation);
                    attackVariation++;

                    attackTimeStamp = GameWorld.Instance.TotalGameTime;

                    isAttacking = true;
                }
                else
                {
                    isAttacking = false;
                }
            }
        }