Exemple #1
0
        protected override void OnKeyReleased(object sender, KeyEventArgs e)
        {
            if (IsDead() || !KeyDown || (e != null && Game.KeyIsNotAllowed(e.Code)))
            {
                return;
            }

            KeyDown = false;

            if (!Game.IsRunning())
            {
                // Interrupt aiming if the player releases the key while paused
                if (!CanRotate)
                {
                    AimAssistance.AimEnd();
                    foreach (AimAssistance a in AimAssistanceExtras)
                    {
                        a.AimEnd();
                    }
                }
                return;
            }

            if (CanRotate)
            {
                return;
            }

            Weapon.Fire(Utils.GetPointInDirection(Position, Rotation, 40), Rotation, Utils.GetPointInDirection(Position, Rotation, AimAssistance.Reticle.Y));
            foreach (AimAssistance a in AimAssistanceExtras)
            {
                Weapon.Fire(Utils.GetPointInDirection(Position, Rotation + a.RotationOffset, 40), Rotation + a.RotationOffset, Utils.GetPointInDirection(Position, Rotation + a.RotationOffset, a.Reticle.Y));
            }

            StartRotationDelay();

            AimAssistance.AimEnd();
            foreach (AimAssistance a in AimAssistanceExtras)
            {
                a.AimEnd();
            }
        }
        private void Tick(Object source, ElapsedEventArgs e)
        {
            if (!Game.IsRunning())
            {
                return;
            }

            int l = 0;
            int c = 0;

            for (int py = 0; py < Points.Count; py++)
            {
                for (int px = 0; px < Points[py].Count; px++)
                {
                    // Update Point
                    Points[py][px].Update(UpdateTimerDeltaTime);

                    // Update Display Objects
                    if (px == 0 || py == 0)
                    {
                        continue;
                    }

                    if (Points[py][px].PointLeft != null)
                    {
                        Lines[l].Size     = new Vector2f(Utils.Distance(Points[py][px].PointLeft.Position, Points[py][px].Position), Lines[l].Size.Y);
                        Lines[l].Position = Points[py][px].Position;
                        Lines[l].Rotation = (float)Utils.GetAngle(Points[py][px].Position, Points[py][px].PointLeft.Position);
                        l++;
                    }
                    if (Points[py][px].PointAbove != null)
                    {
                        Lines[l].Size     = new Vector2f(Utils.Distance(Points[py][px].PointAbove.Position, Points[py][px].Position), Lines[l].Size.Y);
                        Lines[l].Position = Points[py][px].Position;
                        Lines[l].Rotation = (float)Utils.GetAngle(Points[py][px].Position, Points[py][px].PointAbove.Position);
                        l++;
                    }

                    Corners[c++].Position = Points[py][px].Position;
                }
            }
        }
Exemple #3
0
        protected override void OnKeyPressed(object sender, KeyEventArgs e)
        {
            if (KeyDown || IsDead() || (e != null && Game.KeyIsNotAllowed(e.Code)))
            {
                return;
            }

            KeyDown = true;

            if (!Game.IsRunning())
            {
                return;
            }

            CanRotate = false;
            RotationDelayTimer.Stop();

            AimAssistance.AimStart();
            foreach (AimAssistance t in AimAssistanceExtras)
            {
                t.AimStart();
            }
        }