Exemplo n.º 1
0
 private void InvokeFire()
 {
     _timer.Dispose();
     _timer = null;
     Fired?.Invoke(_lastSender, _lastArgs);
     _lastSender = null;
     _lastArgs   = null;
 }
Exemplo n.º 2
0
 private void OnDataReceivedWorker()
 {
     while (_IsRunning)
     {
         try
         {
             byte[] data = _BlockingCollection.Take(_CancellationTokenSource.Token);
             Fired?.Invoke(this, data);
         }
         catch (Exception) { }
     }
 }
        private void GlobalShortcuts_KeyUp(object sender, KeyEventArgs e)
        {
            int index = Array.IndexOf(keys, e.Key);

            if (index >= 0)
            {
                if (state.All(f => f))
                {
                    Fired?.Invoke(this, EventArgs.Empty);
                }
                state[index] = false;
            }
        }
Exemplo n.º 4
0
        public void Update(float dt)
        {
            if (Num != -1 && _numTimesFired >= Num)
            {
                return;
            }

            _timeElapsedSinceLastFire += dt;
            if (_timeElapsedSinceLastFire > Period)
            {
                Fired?.Invoke(this);
                _numTimesFired           += 1;
                _timeElapsedSinceLastFire = 0;
            }
        }
Exemplo n.º 5
0
    private void FireProjectile()
    {
        if (!firedFirstShot)
        {
            firedFirstShot = true;
        }

        GameObject projectile     = Instantiate(projectilePrefab, transform.position, Quaternion.identity) as GameObject;
        var        launchVelocity = fireVelocity * normalizedTrajectory;

        projectile.GetComponent <Projectile>().launchVelocity = launchVelocity;
        float angle = Vector2.SignedAngle(Vector2.right, launchVelocity);

        projectile.transform.rotation = Quaternion.Euler(0, 0, angle);
        Fired?.Invoke();
    }
Exemplo n.º 6
0
        private IEnumerator ShootLoop()
        {
            while (true)
            {
                do
                {
                    if (enemiesInRange.Count < 1)
                    {
                        yield return(new WaitForSeconds(0.1f));
                    }

                    UpdateTarget();
                } while (target == null);

                target.HealthPrediction -= stats.AttackDamage;
                animator.SetTrigger("Shoot");
                Fired?.Invoke(stats, transform, target);

                yield return(new WaitForSeconds(1f / stats.AttacksPerSecond));
            }
        }
Exemplo n.º 7
0
        public Status fire_at(int X, int Y)
        {
            Status status = Status.tba;

            if (!(board[Y, X].status == Status.tba))
            {
                status = Status.miss;
            }
            if (board[Y, X].type == Type.Wasser)
            {
                board[Y, X].status = Status.miss;
            }
            Fired?.Invoke(X, Y, this);
            status = Status.miss;
            if (board[Y, X].ship != null)
            {
                if (board[Y, X].ship.Lives > 0)
                {
                    board[Y, X].ship.Lives -= 1;
                }

                if (board[Y, X].ship.Lives == 0)
                {
                    foreach (GameElement g in board[Y, X].ship.positions)
                    {
                        g.status = Status.sunk;
                        Fired?.Invoke(g.X, g.Y, this);
                    }
                    status = Status.sunk;
                }
                else
                {
                    board[Y, X].status = Status.hit;
                    status             = Status.hit;
                    Fired?.Invoke(X, Y, this);
                }
            }

            return(status);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Fires the cannon's projectile from the cannon and its projection speed and projectile angle.
        /// </summary>
        public void Fire()
        {
            // Clear other trajectories
            foreach (Projectile p in projectiles)
            {
                p.RemoveTrajectory();
            }

            // Create a copy of the cannon's projectile
            Projectile projectile = new Projectile("projectile", Position, Projectile.TextureName, Projectile.Mass, Projectile.RestitutionCoefficient, Projectile.Radius, Projectile.DragCoefficient);

            // Determine the transformed position to fire the projectile from.
            projectile.Centre = DetermineFiringPosition();
            projectiles.Add(projectile);

            // Takes into account facing direction
            Vector2 impulse = projectile.Mass * Speed * new Vector2((int)Facing * MathF.Cos(ProjectionAngle), -MathF.Sin(ProjectionAngle));

            // Invoke events
            Fired?.Invoke(this, new FiringArgs(projectile, impulse));
            Triggered?.Invoke(this, new EventArgs());
        }
Exemplo n.º 9
0
 public static void Fire(ODEventType odEventType, object tag)
 {
     Fired?.Invoke(new ODEventArgs(odEventType, tag));
 }
Exemplo n.º 10
0
 public void FireEvent(string value) => Fired?.Invoke(this, new StringEventArgs(value));
Exemplo n.º 11
0
 // Поджигает дерево
 public void Fire(int power)
 {
     state.Fire(this, power);
     Fired?.Invoke(this, new FireTreeEventArgs());
 }
Exemplo n.º 12
0
 ///<summary>Invoke this method when the MySQL data adapter cannot fill a DataTable correctly or reports that it ran successfully.</summary>
 public static void Fire(DataReaderNullEventArgs e)
 {
     Fired?.Invoke(e);
 }
Exemplo n.º 13
0
 ///<summary>Invoke this method when a crashed table has been detected or reports that it is now OK.</summary>
 public static void Fire(CrashedTableEventArgs e)
 {
     Fired?.Invoke(e);
 }
Exemplo n.º 14
0
 protected override void RaiseEvent(Signal <T> signal)
 {
     Fired?.Invoke(signal.Data);
 }
Exemplo n.º 15
0
 public void FireEvent(ODEventArgs e)
 {
     Fired?.Invoke(e);
 }
Exemplo n.º 16
0
 public void Shoot()
 {
     Firing?.Invoke(this, EventArgs.Empty);
     Bang?.Invoke(this);
     Fired?.Invoke(this, new FiredArgs("Bang!"));
 }
Exemplo n.º 17
0
 ///<summary>Triggers the global Fired event to get called with the passed in ODEventArgs.</summary>
 public static void Fire(ODEventArgs e)
 {
     Fired?.Invoke(e);
 }