void Start() { _lifeTimer.Set(60 * 5); _sprite = GetComponentInChildren <BulletSprite>(); _light = GetComponentInChildren <Light>(); _hitboxes = GetComponentsInChildren <Hitbox>(); }
public override void Updata() { //BulletSprite.X += BulletSprite.SpeedX * (float)(Math.Sin(BulletSprite.Rotation)); //BulletSprite.Y += BulletSprite.SpeedY * (float)(Math.Cos(BulletSprite.Rotation)); BulletSprite.X += BulletSprite.SpeedX; BulletSprite.Y += BulletSprite.SpeedY; BulletSprite.Update(); }
private ScalableSprite <BulletAnimations> SetupAnimations(BulletSprite sprite) { var animations = new ScalableSprite <BulletAnimations>(); animations.renderLayer = Layers.Bullet; animations.addAnimation(BulletAnimations.Bullet, sprite.Bullet.ToSpriteAnimation(sprite.Source, 16, 16)); return(animations); }
public void shoot() { Vector2 shootDirection = new Vector2(Input.GetAxis("SD Horizontal Shoot"), Input.GetAxis("SD Vertical Shoot")); shootDirection.Normalize(); if (shootDirection != Vector2.zero) { BulletSprite bullet = Instantiate <BulletSprite>(bulletPrefab); bullet.Initialize(transform.position, shootDirection, bulletSpeed); audioSource.Play(); lastShot = 0; } }
private void CreateBullets() { var bulletSpriteLeft = new BulletSprite(_bulletTexture); var bulletSpriteRight = new BulletSprite(_bulletTexture); var bulletY = _playerSprite.Position.Y + 30; var bulletLeftX = _playerSprite.Position.X + _playerSprite.Width / 2 - 40; var bulletRightX = _playerSprite.Position.X + _playerSprite.Width / 2 + 10; bulletSpriteLeft.Position = new Vector2(bulletLeftX, bulletY); bulletSpriteRight.Position = new Vector2(bulletRightX, bulletY); _bulletList.Add(bulletSpriteLeft); _bulletList.Add(bulletSpriteRight); AddGameObject(bulletSpriteLeft); AddGameObject(bulletSpriteRight); }
public void OnTriggerEnter2D(Collider2D collision) { if (ISBEAR) { if (collision.tag == "FishAllyBullet") { BulletSprite bs = collision.GetComponent <BulletSprite>(); bs.Dissipate(); } else if (collision.tag == "FishAlly") { Destroy(collision.gameObject); } else if (collision.tag == "FishPlayer") { Player p = collision.GetComponent <Player>(); p.loseLife(); } } else { if (collision.tag == "BearAllyBullet") { BulletSprite bs = collision.GetComponent <BulletSprite>(); bs.Dissipate(); } else if (collision.tag == "BearAlly") { Destroy(collision.gameObject); } else if (collision.tag == "BearPlayer") { Player p = collision.GetComponent <Player>(); p.loseLife(); } } }
public override void Updata() { BulletSprite.X += BulletSprite.SpeedX; BulletSprite.Y += BulletSprite.SpeedY; BulletSprite.Update(); }
/// <summary> /// Initializes a new instance of the <see cref="Bullet" /> class. /// </summary> public Bullet() { Sprite = new BulletSprite(); SetSpeed(SpeedXDirection, SpeedYDirection); }