Last active
July 28, 2018 19:29
-
-
Save mvenezia/abcf0bdd674f1f7c752b1c2cbdc0beb0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.UI; | |
public class ShieldPowerUp : MonoBehaviour { | |
#region Member Variables | |
public static ShieldPowerUp instance; | |
public bool on; | |
public GameObject shieldHitVisualFX; | |
public SpriteRenderer shieldActiveVisualFX; | |
#endregion | |
void Awake() | |
{ | |
if (instance == null) | |
instance = this; | |
else | |
Destroy(this); | |
} | |
void Start () { | |
InitMembers(); | |
} | |
//============================= | |
public void ShieldTakesHit() | |
{ | |
ShieldHitFX(); | |
TurnShieldOff(); | |
} | |
#region Private Member Functions | |
void InitMembers() | |
{ | |
on = false; | |
shieldActiveVisualFX.enabled = false; | |
} | |
void ShieldHitFX() | |
{ | |
GameObject vfx = Instantiate(shieldHitVisualFX, gameObject.transform.position, gameObject.transform.rotation); | |
vfx.GetComponent<ParticleSystem>().Play(); | |
} | |
void TurnShieldOff() | |
{ | |
on = false; | |
shieldActiveVisualFX.enabled = false; | |
} | |
void TurnShieldOn() | |
{ | |
on = true; | |
shieldActiveVisualFX.enabled = true; | |
} | |
#endregion | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment