SmashBros.Controllers.CharacterController.Collision C# (CSharp) Method

Collision() private method

private Collision ( Fixture chara, Fixture obj, Contact list ) : bool
chara FarseerPhysics.Dynamics.Fixture
obj FarseerPhysics.Dynamics.Fixture
list FarseerPhysics.Dynamics.Contacts.Contact
return bool
        private bool Collision(Fixture chara, Fixture obj, Contact list)
        {
            bool returnValue = false;
            if (model.state == CharacterState.attacking
                && (obj.CollisionCategories != Category.Cat20 || !((MoveModel)obj.Body.UserData).PlayerIndexes.Contains(model.playerIndex))
                && currentMove.Stats.Type == MoveType.Body
                && (currentMove.Stats.StopAtHit || obj.CollisionCategories != Category.Cat11)
                && currentMove.attackTimeLeft <= currentMove.Stats.Duration - currentMove.Stats.BodyStart)
            {
                moves.EndMove(currentMove);
                moves.RemoveMove(currentMove);
                view.Rotation = 0;
                view.BoundBox.Rotation = 0;
                model.attackMode = false;
                if ((obj.CollisionCategories == Category.Cat9 || obj.CollisionCategories == Category.Cat10) && chara.Body.Position.Y + view.size.Y / 2 <= obj.Body.Position.Y - (float)obj.Body.UserData / 2)
                {
                    model.inAir = false;
                    if (obj.CollisionCategories == Category.Cat10) model.onSoftBox = true;
                    model.jumpsLeft = 3;
                }

                NaturalState();
                returnValue = true;
            }
            else if ((obj.CollisionCategories == Category.Cat9 || obj.CollisionCategories == Category.Cat10)
                && (chara.Body.Position.Y + view.size.Y / 2 <= obj.Body.Position.Y - (float)obj.Body.UserData / 2 && view.VelocityY >= -0.001))
            {
                model.inAir = false;
                if (obj.CollisionCategories == Category.Cat10) model.onSoftBox = true;
                NaturalState();
                model.jumpsLeft = 3;
                returnValue = true;
            }
            else if (obj.CollisionCategories == Category.Cat9) returnValue = true;
            else if (obj.CollisionCategories == Category.Cat20)
            {
                MoveModel move = (MoveModel)obj.Body.UserData;
                if (!move.PlayerIndexes.Contains(model.playerIndex) && !model.invounerable)
                {
                    move.PlayerIndexes.Add(model.playerIndex);

                    MoveStats stats = move.Stats;
                    float ratio = 0;
                    if (stats.Type == MoveType.Charge && move.chargeTime < stats.MaxWait)
                        ratio = move.chargeTime / stats.MaxWait;
                    else ratio = 1;
                    Vector2 power = ratio * stats.Power;
                    int damage = (int)ratio * stats.Damage;

                    view.Velocity = move.Xdirection * power * (1 + model.damagePoints / 100) * (100 / model.weight);
                    if (Math.Abs(view.VelocityY) == 0) view.VelocityY = -1;
                    model.damagePoints += damage;
                    model.setState(CharacterState.takingHit);

                    if (OnHit != null) OnHit.Invoke(ConvertUnits.ToDisplayUnits(obj.Body.Position), damage, model.damagePoints, move.PlayerIndexes.First(), model.playerIndex, stats.hitSound);

                    //if (move.Adjustable && ((AdjustableMove)move).StopAtHit) move.attackTimeLeft = 0;
                }
            }
            else if (obj.CollisionCategories == Category.Cat7 || obj.CollisionCategories == Category.Cat8) OnCharacterDeath.Invoke(this, obj.CollisionCategories == Category.Cat7);

            return returnValue;
        }