Ejemplo n.º 1
0
        private void handleShooting(float deltaTime)
        {
            timeSinceLastShot += deltaTime;
            shooter            = shooter ?? invaders[rng.Next(invaders.Count)];
            float firingSpeed = shooter[CombatBehavior.Key_FiringSpeed];

            if (timeSinceLastShot + rng.NextDouble() >= firingSpeed)
            {
                EventManager.Queue(FireWeaponEvent.SingleShot(shooter.ID));

                timeSinceLastShot = 0.0f;
                shooter           = null;
            }
        }
Ejemplo n.º 2
0
        public void OnKeyDown(object sender, KeyEventArgs e)
        {
            isKeyDown[e.KeyCode] = true;
            e.Handled            = true;

            switch (e.KeyCode)
            {
            case Keys.W:
                goto case Keys.Up;

            case Keys.Up:
                //determineDirectionAndIssueMove(Direction.North, true);
                break;

            case Keys.D:
                goto case Keys.Right;

            case Keys.Right:
                determineDirectionAndIssueMove(Direction.East, true);
                break;

            case Keys.S:
                goto case Keys.Down;

            case Keys.Down:
                //determineDirectionAndIssueMove(Direction.South, true);
                break;

            case Keys.A:
                goto case Keys.Left;

            case Keys.Left:
                determineDirectionAndIssueMove(Direction.West, true);
                break;

            case Keys.Space:
                eventManager.Queue(FireWeaponEvent.Start(playerEntity.ID));
                break;

            default:
                e.Handled = false;
                break;
            }
        }