コード例 #1
0
    private void ShootWeapon()
    {
        nextShotAvailable = false;
        PlayShotSoundFX();
        TypeOfBullet bullet = Instantiate(weaponBeingHeld.GetBulletPrefab(), tipOfTheGun.position, Quaternion.identity, null);

        if (!(bullet is AOEBullet))
        {
            bullet.gameObject.layer = (int)DefinedLayers.PlayerBullets;
            var playerBullet = bullet.gameObject.AddComponent <PlayerBullet>();
            playerBullet.SetDamage(weaponBeingHeld.GetBulletDamage());
        }
        else
        {
            var typeOfBullet = bullet.GetComponent <TypeOfBullet>();
            typeOfBullet.SetDamage(weaponBeingHeld.GetBulletDamage());
            typeOfBullet.SetSpeed(20);
            typeOfBullet.SetTarget(Camera.main.ScreenToWorldPoint(Input.mousePosition));
        }
        currentBulletManager.BulletFired();
        OnBulletFired(currentBulletManager.AvailableBulletsCount());
        shootingPS.Play();
        StartCoroutine(CanShootAgain());
        animator.SetTrigger(RECOIL_TRIGGER);
    }
コード例 #2
0
 void Start()
 {
     totalNumberOfShotsFired++;
     typeOfBullet = GetComponent <TypeOfBullet>();
     typeOfBullet.SetSpeed(speed);
     typeOfBullet.SetTarget(Camera.main.ScreenToWorldPoint(Input.mousePosition));
 }
コード例 #3
0
 public void SetDamage(int bulletDamage)
 {
     damageToDealtToEnemy = bulletDamage;
     if (typeOfBullet == null)
     {
         typeOfBullet = GetComponent <TypeOfBullet>();
     }
     typeOfBullet.SetDamage(damageToDealtToEnemy);
 }
コード例 #4
0
        public override void Fire(Vector2 center, Vector2 target, TypeOfBullet type, GameTime gameTime)
        {
            if (fireTimer.IsDone(gameTime))
            {
                EntityManager.CreateBullet(type, center, target, damagePerShot);

                fireTimer.Reset(gameTime);
            }
        }
コード例 #5
0
ファイル: Bullet.cs プロジェクト: Pfizerr/G01_Perseus
 public Bullet(Vector2 position, Vector2 targetPosition, Vector2 maxVelocity, Vector2 scale, TypeOfBullet type, float damage, float timeToLive, Texture2D texture)
     : base(maxVelocity, position, scale, texture)
 {
     Type = type;
     SetTexture();
     this.damage     = damage;
     this.timeToLive = timeToLive;
     Center          = position;
     rotation        = 0f;
     layerDepth      = 0.8f;
     direction       = Vector2.Normalize(targetPosition - position);
 }
コード例 #6
0
ファイル: Bullet.cs プロジェクト: Pfizerr/G01_Perseus
 public Bullet(Vector2 position, Vector2 targetPosition, Vector2 maxVelocity, Vector2 scale, TypeOfBullet type, float damage, float timeToLive)
     : base(maxVelocity, position, scale)
 {
     Type            = type;
     this.damage     = damage;
     this.timeToLive = timeToLive;
     Center          = position;
     Origin          = Size / 2;
     rotation        = 0f;
     layerDepth      = 0.8f;
     source          = null;
     direction       = Vector2.Normalize(targetPosition - position);
 }
コード例 #7
0
        public override void Fire(Vector2 center, Vector2 target, TypeOfBullet type, GameTime gameTime)
        {
            if (fireTimer.IsDone(gameTime))
            {
                if (type == TypeOfBullet.Enemy)
                {
                    laserType = TypeOfLaser.Enemy;
                }
                else
                {
                    laserType = TypeOfLaser.Player;
                }

                EntityManager.CreateLaser(laserType, center, target, damagePerShot);

                fireTimer.Reset(gameTime);
            }
        }
コード例 #8
0
        public override void Fire(Vector2 center, Vector2 target, TypeOfBullet type, GameTime gameTime)
        {
            if (fireTimer.IsDone(gameTime))
            {
                Vector2 dPos     = (center) - target;
                float   rotation = (float)Math.Atan2(dPos.Y, dPos.X) - MathHelper.ToRadians(90);
                // Calculates angles based on the
                secondBulletTarget.X = (float)Math.Cos(rotation + (float)Math.PI * 1.3) + center.X;
                secondBulletTarget.Y = (float)Math.Sin(rotation + (float)Math.PI * 1.3) + center.Y;
                thirdBulletTarget.X  = (float)Math.Cos(rotation + (float)Math.PI * 1.7) + center.X;
                thirdBulletTarget.Y  = (float)Math.Sin(rotation + (float)Math.PI * 1.7) + center.Y;

                EntityManager.CreateBullet(type, center, target, damagePerShot);
                EntityManager.CreateBullet(type, center, secondBulletTarget, damagePerShot);
                EntityManager.CreateBullet(type, center, thirdBulletTarget, damagePerShot);
                fireTimer.Reset(gameTime);
            }
        }
コード例 #9
0
 void Awake()
 {
     bulletType = GetComponent <TypeOfBullet>();
     bulletType.SetSpeed(speed);
 }
コード例 #10
0
ファイル: EntityManager.cs プロジェクト: Pfizerr/G01_Perseus
 public static void CreateBullet(TypeOfBullet type, Vector2 start, Vector2 target, float damage)
 {
     AddBullet(new Bullet(start, target, new Vector2(7, 7), new Vector2(0.1f, 0.1f), type, damage, 10, AssetManager.TextureAsset("projectile_green")));
 }
コード例 #11
0
ファイル: Weapon.cs プロジェクト: Pfizerr/G01_Perseus
 public abstract void Fire(Vector2 origin, Vector2 target, TypeOfBullet typeOfBullet, GameTime gameTime);
コード例 #12
0
ファイル: EntityManager.cs プロジェクト: Pfizerr/G01_Perseus
 public static void CreateBullet(TypeOfBullet type, Vector2 start, Vector2 target, bool isLaser, float damage)
 {
     AddBullet(new Bullet(start, target, new Vector2(7, 7), new Vector2(0.1f, 0.1f), type, damage, 10));
 }