public void SetupPlayerAttackMotions(SO_CharAtk_Motion sOCharAtkMotion)
 {
     if (curSlow != 0f)
     {
         charMov.ReduceSpeed(-curSlow);
     }
     // Get references from the Scriptable Object.
     durations              = sOCharAtkMotion.durations;
     distances              = sOCharAtkMotion.distances;
     lockInputMovement      = sOCharAtkMotion.lockInputMovement;
     lockCharacterAndWeapon = sOCharAtkMotion.lockCharacterAndWeapon;
     slowDownRunSpeed       = sOCharAtkMotion.slowDownRunSpeed;
     //chargeAttack = sOCharAtkMotion.chargeAttack;
     loopMotions = sOCharAtkMotion.loopMotion;
     //loopFinalMotion = sOCharAtkMotion.loopFinalMotion;
     // Assign the current values for the first motion.
     // *Could run SetupNextMotionNow with a few changes?
     curMotion    = 0;
     curDistance  = distances[curMotion];
     curDuration  = durations[curMotion];
     curDirection = weapOrigTrans.up;
     curSpeed     = Mathf.Abs(curDistance / curDuration);
     if (curDistance < 0)
     {
         curDirection *= -1;
     }
     curPosition = weapOrigTrans.position;
     curSlow     = slowDownRunSpeed[curMotion];
     // Set initial locks and slowdown.
     // Locks the player movement input.
     if (lockInputMovement[curMotion])
     {
         charMov.StopInputMove();
     }
     else
     {
         charMov.canInputMove = true;
     }
     // This locks the character sprite flip and weapon rotation. (Can be seperated)
     if (lockCharacterAndWeapon[curMotion])
     {
         charMov.charCanFlip = false; weaponLookAt.lookAtEnabled = false;
     }
     else
     {
         charMov.charCanFlip = true; weaponLookAt.lookAtEnabled = true;
     }
     // Applies a slow to the player input movement speed.
     charMov.ReduceSpeed(curSlow);
     finalMotion      = false;
     exitPlayerMotion = false;
     moveTimer        = 0f;
     if (curMotion < loopMotions.Length - 1 && loopMotions[curMotion])
     {
         finalMotion = true;
     }
     this.StopAllCoroutines();
     charAtkMotionOn = true;
     this.StartCoroutine(CharAttackMotionTimer());
 }
Exemplo n.º 2
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;
        }
    }