Esempio n. 1
0
    void LaunchGroundPoundAoE()
    {
        int nbrBlocksDestroyed = 0;

        RaycastHit2D[] blocks       = Physics2D.BoxCastAll(new Vector2(transform.position.x, transform.position.y - raycastLength), new Vector2(0.875f, 0.1f), 0, Vector2.zero, 0, groundLayer);// VARIABLE VARIABLE VARIABLE
        int            nbrBlocksHit = blocks.Length;

        for (int i = 0; i < nbrBlocksHit; ++i)
        {
            BlockController block = blocks[i].transform.GetComponent <BlockController>();

            if (block != null)// MAYBE USE TAG
            {
                block.DamageBlock(CalculateDamage(), ImpactSleepDuration, previousVelocityY);
                if (block.GetCurrentHp() <= 0)
                {
                    ++nbrBlocksDestroyed;
                }
            }
        }

        if (nbrBlocksDestroyed == nbrBlocksHit)
        {
            playerState = PlayerState.CrashingTroughBlocks;
        }
        else
        {
            playerState = PlayerState.Grounded;// FUNCTION FUNCTION FUNCTION
            animator.SetTrigger("Grounded");
        }

        if (nbrBlocksHit > 0)
        {
            CameraShaker.instance.startCameraShake(cameraShakeTime, cameraShakeSpeed, cameraShakeMagnitude);
        }
    }