AngryTanks.Client.LocalPlayer.KeyPressed C# (CSharp) Method

KeyPressed() private method

private KeyPressed ( Keys key ) : void
key Keys
return void
        private void KeyPressed(Keys key)
        {
            // jump out early if console prompt is active
            if (World.Console.PromptActive)
                return;

            switch (key)
            {
                // kill ourselves if we hit delete
                case Keys.Delete:
                    if (State == PlayerState.Alive)
                        Die(this);

                    break;

                // shoot when you hit enter
                case Keys.Enter:
                    {
                        // first limit how many shots we can fire
                        // how many active shots are there?
                        Byte numActiveShots = (Byte)ActiveShots.Count;

                        // is there shot slots left for the player to fire?
                        Byte maxShots = (Byte)World.VarDB["shotSlots"].Value;

                        if (numActiveShots >= maxShots)
                            return;

                        // find first available shot ID
                        Byte shotSlot = Shot.AllocateSlot(Shots);

                        // no more shot slots
                        if (shotSlot == ProtocolInformation.DummyShot)
                            return;

                        // fire away
                        Shoot(Shot.AllocateSlot(Shots), true);

                        break;
                    }

                default:
                    break;
            }
        }