Beispiel #1
0
        private bool CheckCollision(Fighter opponent)
        {
            float destination;
            Rectangle opponentHitBox;
            opponentHitBox = opponent.hitBox;
            destination = position.X + walkspeed;

            if (!opponent.inAir)
            {
                if (onLeft)
                {

                    if (hitBox.Right > opponentHitBox.Left)
                    {
                        if (GetState() != "Backward")
                        {
                            if (!opponent.CheckWall())
                            {
                                opponent.position.X += 0.7f;
                            }
                            return true;
                        }
                        else
                            return false;

                    }
                    else
                        return false;

                }
                else if (!onLeft)
                {
                    if (hitBox.Left < opponentHitBox.Right)
                    {
                        if (GetState() != "Backward")
                        {
                            if (!opponent.CheckWall())
                            {
                                opponent.position.X -= 0.7f;
                            }
                            return true;
                        }
                        else
                            return false;
                    }
                    else
                        return false;

                }
                else
                    return false;
            }
            else
                return false;
        }