// WINDOW BORDERS:
 public static void CheckForWindowCollisions(FighterModel fighter)
 {
     if (fighter.Bounds.Left <= 0 - (fighter.Bounds.Width / 4))
     {
         fighter.Move("collisionLeft");
     }
     else if (fighter.Bounds.Right - (fighter.Bounds.Width / 4) >= PlazaSmashGame.WindowWidth)
     {
         fighter.Move("collisionRight");
     }
 }
Example #2
0
        private static void DetermineInput(Keys[] fighterKeys, Keys[] currentPressedKeys, FighterModel fighter, Dictionary <string, ViewObject> actions)
        {
            if (actions["Hit"].Drawn)
            {
                if (!BlockInput)
                {
                    foreach (Keys pressedKey in currentPressedKeys)
                    {
                        if (pressedKey == fighterKeys[0])
                        {
                            BattlegroundController.ResetViews(actions);

                            fighter.Move("left");

                            actions["Move"].ToBeDrawn = true;
                            actions["Move"].Drawn     = false;

                            for (int i = 0; i < currentPressedKeys.Length; i++)
                            {
                                if (currentPressedKeys[i] == fighterKeys[1] || currentPressedKeys[i] == fighterKeys[2] ||
                                    currentPressedKeys[i] == fighterKeys[2])
                                {
                                    currentPressedKeys[i] = Keys.None;
                                }
                            }
                        }
                        else if (pressedKey == fighterKeys[1])
                        {
                            BattlegroundController.ResetViews(actions);

                            fighter.Move("right");

                            actions["ReversedMove"].ToBeDrawn = true;
                            actions["ReversedMove"].Drawn     = false;

                            for (int i = 0; i < currentPressedKeys.Length; i++)
                            {
                                if (currentPressedKeys[i] == fighterKeys[0] || currentPressedKeys[i] == fighterKeys[2] ||
                                    currentPressedKeys[i] == fighterKeys[3])
                                {
                                    currentPressedKeys[i] = Keys.None;
                                }
                            }
                        }
                        else if (pressedKey == fighterKeys[2] && !PreviousKeyboardState.IsKeyDown(fighterKeys[2]))
                        {
                            fighter.Punch();

                            // TO REDUCE INPUT DELAY:
                            actions["Move"].Drawn         = true;
                            actions["ReversedMove"].Drawn = true;

                            actions["Punch"].ToBeDrawn = true;
                            actions["Punch"].Drawn     = false;

                            for (int i = 0; i < currentPressedKeys.Length; i++)
                            {
                                if (currentPressedKeys[i] == fighterKeys[0] || currentPressedKeys[i] == fighterKeys[1] ||
                                    currentPressedKeys[i] == fighterKeys[3])
                                {
                                    currentPressedKeys[i] = Keys.None;
                                }
                            }
                        }
                        else if (pressedKey == fighterKeys[3] && !PreviousKeyboardState.IsKeyDown(fighterKeys[3]))
                        {
                            fighter.Kick();

                            actions["Move"].Drawn         = true;
                            actions["ReversedMove"].Drawn = true;

                            actions["Kick"].ToBeDrawn = true;
                            actions["Kick"].Drawn     = false;

                            for (int i = 0; i < currentPressedKeys.Length; i++)
                            {
                                if (currentPressedKeys[i] == fighterKeys[0] || currentPressedKeys[i] == fighterKeys[1] ||
                                    currentPressedKeys[i] == fighterKeys[2])
                                {
                                    currentPressedKeys[i] = Keys.None;
                                }
                            }
                        }

                        // ADD BLOCKING FUNCTIONALITY HERE
                    }
                }
            }
        }