31 lines
723 B
C#
31 lines
723 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class ShieldController : MonoBehaviour
|
|
{
|
|
|
|
public float health = 5;
|
|
|
|
public Color startColor;
|
|
public Color endColor;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
GetComponent<Animation>().Play("Shield_init_anim");
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
health -= Time.deltaTime;
|
|
GetComponent<Renderer>().material.SetColor("_Color0", Color.Lerp(endColor, startColor, health / 5));
|
|
if (health <= 0)
|
|
{
|
|
GetComponent<Animation>().Play("Shield_exit_anim");
|
|
Destroy(gameObject, 0.25f);
|
|
}
|
|
}
|
|
}
|