Exemplo n.º 1
0
    // Same as animation,
    // [Header("Hit FX Impact")]
    // public SO_ImpactFX sOImpactFX;
    // private ImpactFX impactFX;
    // public ImpactFXPool impactFXPool;
    // private Vector3 hitPosition;

    public IEnumerator TakeHitAnimation()
    {
        // Hit FX.
        //HitEffect();
        // Slow down time.
        TimeSlow.StartTimeSlow(0.25f);
        // Set camera nudge backwards from the hit.
        CameraFollow.CameraNudge_St(normHitDirection, takeHitCamNudge);
        //StartCoroutine(TimeSlow.SlowTimeScale(5, 0));
        // Can be transfered to the update.
        // Switch this for an Interumpt/Stun, stop all input, attacks, etc. Can also add variables for knockback and stun duration, based on damage received, buffs, damage immunity, etc.
        // Player cannot move with input.
        charMov.StopInputMove();
        // Player cannot flip.
        charMov.charCanFlip = false;
        charMov.FlipSpriteDirectionBased(normHitDirection);
        // Stops; player attack movement, attack FXs that are stopped on stun, weapon attack motion. When stopping attack with true, player will be interupted but will immediately be able to start a new attack.
        charAtk.StopAttack(true);
        // Player weapon does not follow cursor.
        weapLookAt.lookAtEnabled = false;
        //
        // Setup hit animation.
        timer          = 0f;
        spriteNumber   = 0;
        spriteR.sprite = hitSprites[0];
        spriteNumber++;
        while (timer < getHitDuration)
        {
            //print("Should be changing sprite to getting hit in the face sprite.");
            timer += Time.deltaTime /* /getHitDuration */;
            if (spriteNumber < hitSprites.Length && timer > hitSpriteTimings[spriteNumber])
            {
                spriteR.sprite = hitSprites[spriteNumber];
                spriteNumber++;
            }
            yield return(null);
        }
        // If health reaches 0, iniate death sequence.
        if (currentHealth <= 0f)
        {
            charDeath.CharacterDies();
        }
        else
        {
            charMov.canInputMove = true;
            //charAtk.atkChain.ready = true;
            weapLookAt.lookAtEnabled = true;
            charMov.charCanFlip      = true;
        }
    }