Beispiel #1
0
 /// <summary>
 /// Coroutine that harms yoshi
 /// </summary>
 /// <returns></returns>
 private IEnumerator HarmYoshi()
 {
     while (true)
     {
         // If there's any attack
         if (Attack > 0)
         {
             // Harms Yoshi based on difficulty
             _healthTextScript.DeductHealth(
                 GameState.Instance.GameData.Difficulty == Assets.Classes.Difficulty.NORMAL ? Attack : Attack * 2);
         }
         yield return(new WaitForSeconds(1f / HarmRate)); // Waits a bit to harm him again
     }
 }
Beispiel #2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        // If this is yoshi
        if (collision.GetComponent <Yoshi>() != null)
        {
            // Set Yoshi back
            collision.transform.position = new Vector3(
                collision.transform.position.x,
                4.87f);

            // Deals 10 damage
            _healthTextScript.DeductHealth(10);

            // Play sound
            _audioSource.PlayOneShot(SetBackClip);
        }
    }