Ejemplo n.º 1
0
        public void CreateShot(ShotFiredEventArgs args)
        {
            Sprite s    = _tileSheet.SpriteAnimation();
            Shot   shot = new Shot(s, args.FiredBy, args.Damage);

            shot.Location = args.Location;
            shot.Velocity = args.Velocity * args.ShotSpeed;

            shot.OnDestroy += HandleOnShotDestroy;

            _shots.Add(shot);
        }
Ejemplo n.º 2
0
        public void FireShot()
        {
            ShotFiredEventArgs args = new ShotFiredEventArgs
            {
                Location  = Location + _gunOffset,
                ShotSpeed = ShotSpeed,
                FiredBy   = FiredBy.Enemy,
                Damage    = EnemyShotDamage
                            // Don't know directional velocity because we don't know where the player is
            };

            ShotFired?.Invoke(this, args);
        }
Ejemplo n.º 3
0
        private void FireShot()
        {
            if (_shotTimer.Completed)
            {
                ShotFiredEventArgs args = new ShotFiredEventArgs
                {
                    Location  = Location + _gunOffset,
                    Velocity  = new Vector2(0, -1), // player can only fire on one direction
                    ShotSpeed = ShotSpeed,
                    FiredBy   = FiredBy.Player
                                // ShotBy = ShotBy.Player
                };

                ShotFired?.Invoke(this, args);
                _shotTimer.Reset();
            }
        }
 private void EnemyShotFired(object sender, ShotFiredEventArgs e)
 {
     ShotFired?.Invoke(sender, e);
 }