コード例 #1
0
    public bool Hit()
    {
        bool successfullKick             = false;
        bool hitSomething                = false;
        List <Collider2D> hitColliders   = new List <Collider2D>();
        GameObject        attachedObject = GameData.playerGrapplingHandler.attachedObject;

        GameData.playerGrapplingHandler.ReleaseHook();

        if (currentKick.HitTest(attachedObject, ref hitColliders) && (attachedObject.CompareTag("Enemy") || attachedObject.CompareTag("Ring")))
        {
            if (attachedObject.CompareTag("Enemy"))
            {
                EnemyHandler enemy = attachedObject.GetComponent <EnemyHandler>();
                successfullKick = !enemy.TestCounter();

                if (successfullKick)
                {
                    if (!currentKick.isAOE)
                    {
                        currentKick.DealDamageToEnemy(enemy);
                    }
                    else
                    {
                        foreach (Collider2D collider in hitColliders)
                        {
                            if (collider.CompareTag("Enemy"))
                            {
                                currentKick.DealDamageToEnemy(collider.GetComponent <EnemyHandler>());
                            }
                        }
                    }

                    if (Vector2.Distance(transform.position, attachedObject.transform.position) < currentKick.perfectTimingMaximumDistance)
                    {
                        currentKick.ApplyPerfectTimingEffect(enemy);
                    }

                    if (reAimMode)
                    {
                        StartCoroutine(ReAim());
                    }
                    else
                    {
                        StartCoroutine(Repropulsion());
                    }
                }
            }
            else
            {
                hitSomething = true;
                foreach (Collider2D collider in hitColliders)
                {
                    if (collider.CompareTag("Enemy"))
                    {
                        currentKick.DealDamageToEnemy(collider.GetComponent <EnemyHandler>());
                    }
                }
            }
        }
        isKicking = false;

        if (!hitSomething)
        {
            GameData.playerMovement.Propel(GetComponent <Rigidbody2D>().velocity *GameData.playerGrapplingHandler.velocityKeptReleasingHook / 100, true, true);
        }
        else
        {
            StartCoroutine(ReAim());
        }

        return(successfullKick);
    }