]> git.lizzy.rs Git - SuperMouseAdventure.git/blob - 2DGame/Assets/Scripts/Maus/InvincibilityFrames.cs
Invincibility Frames v0.1
[SuperMouseAdventure.git] / 2DGame / Assets / Scripts / Maus / InvincibilityFrames.cs
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4
5 public class InvincibilityFrames : MonoBehaviour
6 {
7     SpriteRenderer spriteRenderer;
8     Health health;
9
10     public bool invincible;
11
12     public float invincibilityFramesNumber = 2;
13     private float invincibilityFrames;
14
15     // Start is called before the first frame update
16     void Start()
17     {
18         spriteRenderer = GetComponent<SpriteRenderer>();
19         health = GetComponent<Health>();
20     }
21
22     // Update is called once per frame
23     void Update()
24     {
25         if(invincible == true)
26         {
27             invincibilityFrames = invincibilityFramesNumber;
28             invincibilityFrames -= Time.deltaTime;
29             if(invincibilityFrames > 0)
30             {
31                 invincible = true;
32             }
33             if (invincibilityFrames == 0)
34             {
35                 invincible = false;
36             }
37         }
38
39         print(invincible);
40     }
41 }