]> git.lizzy.rs Git - SuperMouseAdventure.git/blob - 2DGame/Assets/Scripts/Enemies/Boss/BossCollision.cs
snail hiding v0.1
[SuperMouseAdventure.git] / 2DGame / Assets / Scripts / Enemies / Boss / BossCollision.cs
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4
5 public class BossCollision : MonoBehaviour
6 {
7     Boss boss;
8
9     SpriteRenderer spriteRenderer;
10
11     public float flashingTime;
12     [HideInInspector]
13     public bool invulnerable;
14
15     private void Start()
16     {
17         boss = GetComponent<Boss>();
18         spriteRenderer = GetComponent<SpriteRenderer>();
19     }
20
21     //Bei Beruehrung mit der Schere wird die Gesundheit um 1 verringert
22     public void OnCollisionEnter2D(Collision2D collision)
23     {
24         if (boss.bossfight && !invulnerable)
25         {
26             if (collision.gameObject.CompareTag("Bullet"))
27             {
28                 boss.bossHealth--;
29                 Destroy(collision.gameObject);
30                 invulnerable = true;
31                 //StartCoroutine("GetInvincible");
32             }
33         }
34     }
35
36     /**IEnumerator GetInvincible()
37     {
38         invulnerable = true;
39         Physics2D.IgnoreLayerCollision(7, 8, true);
40         for (int i = 0; i < 4; i++)
41         {
42             spriteRenderer.enabled = false;
43             yield return new WaitForSeconds(flashingTime);
44             spriteRenderer.enabled = true;
45             yield return new WaitForSeconds(flashingTime);
46         }
47         Physics2D.IgnoreLayerCollision(7, 8, false);
48         spriteRenderer.enabled = true;
49         invulnerable = false;
50     }*/
51 }