public static void CheckForAttackCollision(
            FighterModel thisFighter,
            Dictionary <string, ViewObject> thisFighterActions,
            FighterModel otherFighter,
            Dictionary <string, ViewObject> otherFighterActions)
        {
            // NEEDED FOR GetData()
            ViewObject otherFighterCurrentAction = GetFighterCurrentAction(otherFighterActions);

            if (thisFighterActions["Punch"].ToBeDrawn)
            {
                if (IsThereCollision(
                        thisFighter,
                        thisFighterActions["Punch"].GetColorData(),
                        otherFighter,
                        otherFighterCurrentAction.GetColorData()))
                {
                    if (!otherFighter.IsBlocking)
                    {
                        BattlegroundController.ResetViews(otherFighterActions);

                        if (thisFighter.Name == "Clark")
                        {
                            AudioController.PlaySound(AudioController.ClarkPunchInstance);
                        }
                        else if (thisFighter.Name == "Yuri")
                        {
                            AudioController.PlaySound(AudioController.YuriPunchInstance);
                        }

                        otherFighterActions["Hit"].ToBeDrawn = true;
                        otherFighterActions["Hit"].Drawn     = false;
                    }
                    else
                    {
                        // ADD BLOCKING FUNCTIONALITY HERE
                        // AudioController.PlaySound(AudioController.BlockSoundInstance);
                    }

                    otherFighter.HasBeenHit = true;
                }
            }
            else if (thisFighterActions["Kick"].ToBeDrawn)
            {
                if (IsThereCollision(
                        thisFighter,
                        thisFighterActions["Kick"].GetColorData(),
                        otherFighter,
                        otherFighterCurrentAction.GetColorData()))
                {
                    if (!otherFighter.IsBlocking)
                    {
                        if (thisFighter.Name == "Clark")
                        {
                            AudioController.PlaySound(AudioController.ClarkKickInstance);
                        }
                        else if (thisFighter.Name == "Yuri")
                        {
                            AudioController.PlaySound(AudioController.YuriKickInstance);
                        }

                        BattlegroundController.ResetViews(otherFighterActions);

                        otherFighterActions["Hit"].ToBeDrawn = true;
                        otherFighterActions["Hit"].Drawn     = false;
                    }
                    else
                    {
                        // ADD BLOCKING FUNCTIONALITY HERE
                        // AudioController.PlaySound(AudioController.BlockSoundInstance);
                    }

                    otherFighter.HasBeenHit = true;
                }
            }
        }
Exemplo n.º 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
                    }
                }
            }
        }