Пример #1
0
 public void TakeDamage(int damage, Transform damager)
 {
     if (!iFramesActive && currentState != PlayerStatus.State.Death)
     {
         if (isSword)
         {
             swordHealth -= damage;
         }
         else
         {
             axeHealth -= damage;
         }
         UpdateHealthText();
         PopulateHealthDots();
         //Debug.Log ("Took " + damage + " damage. Remaining: " + axeHealth + swordHealth);
         if (swordHealth <= 0 || axeHealth <= 0)
         {
             //Debug.Log ("Dead. " + axeHealth + swordHealth);
             Die();
             stopper.StartHitStop(hitZoomMulti * 0.9f, hitTimeScale * 0.9f, hitDuration * 1.2f);
         }
         else
         {
             playerStatus.CurrentState = PlayerStatus.State.Stunned;
             stopper.StartHitStop(hitZoomMulti, hitTimeScale, hitDuration);
             StartCoroutine(iFrames());
             Knockback(transform.position.x > damager.position.x);
         }
     }
 }
Пример #2
0
    void OnTriggerEnter2D(Collider2D other)
    {
        //Debug.Log ("Weapon triggered by " + other.name);
        if (currentState == State.Throwing)
        {
            Debug.Log(other.name);
            if (gravityEnabled == false)
            {
                EnableSuperGravity();

                /* OnTriggerEnter is most likely to occur when the axe hits an enemy, but could accidentally happen in other cases which is why I added this but commented it out
                 * throwSFXStop();
                 * throwRecallSFXStop();
                 * throwImpactSFXPlay(); */
            }
        }
        EnemyHealth enemy = other.GetComponent <EnemyHealth> ();

        if (enemy)
        {
            //Debug.Log ("Dealt damage");
            enemy.TakeDamage(currentDamage);
            stopper.StartHitStop(hitZoomMulti, hitTimeScale, hitDuration);
        }
    }