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); }
void Start() { totalNumberOfShotsFired++; typeOfBullet = GetComponent <TypeOfBullet>(); typeOfBullet.SetSpeed(speed); typeOfBullet.SetTarget(Camera.main.ScreenToWorldPoint(Input.mousePosition)); }
public void SetDamage(int bulletDamage) { damageToDealtToEnemy = bulletDamage; if (typeOfBullet == null) { typeOfBullet = GetComponent <TypeOfBullet>(); } typeOfBullet.SetDamage(damageToDealtToEnemy); }
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); } }
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); }
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); }
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); } }
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); } }
void Awake() { bulletType = GetComponent <TypeOfBullet>(); bulletType.SetSpeed(speed); }
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"))); }
public abstract void Fire(Vector2 origin, Vector2 target, TypeOfBullet typeOfBullet, GameTime gameTime);
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)); }