Ejemplo n.º 1
0
        /// <summary>
        /// Enqueues an item to the Concurrent ReadyQueue
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void Fire(object sender, AddBulletEventArgs e)
        {
            if (sender is not Bullet)
            {
                throw new Exception("Fire event Invoked with non-bullet sender");
            }

            if (e.Parent is Player)
            {
                Player p = (Player)e.Parent;
                if (p.Invincible && !p.GodMode)
                {
                    return;
                }
            }
            else
            {
                if (e.Parent.Invincible)
                {
                    return;
                }
            }

            Bullet b = (Bullet)sender;

            readyQueue.Enqueue(e);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add a bullet by EventArgs passed from the EventManager Concurrent Queue
        /// </summary>
        /// <param name="e"></param>
        private void ReadBullet(AddBulletEventArgs e)
        {
            Bullet b = e.Bullet;

            b.Dispose += this.eventManager.Dispose;
            if (e.Parent is Player)
            {
                this.player_bullets.Add(b);
            }
            else
            {
                this.enemy_bullets.Add(b);
            }
        }