Visual indicators of charge point charge

This commit is contained in:
Ava Gaiety Wroten 2020-06-17 13:38:15 -05:00
parent 2137627c8f
commit 6e2025ddba
2 changed files with 4817 additions and 0 deletions

File diff suppressed because it is too large Load diff

View file

@ -9,10 +9,14 @@ public class ChargePoint : MonoBehaviour
int charges = 0; int charges = 0;
bool charged = false; bool charged = false;
ChargeCounter chargeCounter; ChargeCounter chargeCounter;
ParticleSystem ps;
SpriteRenderer sr;
void Start() void Start()
{ {
chargeCounter = GameObject.FindWithTag("Charge Counter").GetComponent<ChargeCounter>(); chargeCounter = GameObject.FindWithTag("Charge Counter").GetComponent<ChargeCounter>();
ps = GetComponent<ParticleSystem>();
sr = GetComponent<SpriteRenderer>();
} }
public void adjustCharges(int amount = 1) public void adjustCharges(int amount = 1)
@ -29,5 +33,34 @@ public class ChargePoint : MonoBehaviour
chargeCounter.RemoveChargedPoint(gameObject); chargeCounter.RemoveChargedPoint(gameObject);
charged = false; charged = false;
} }
VisualUpdate();
}
void VisualUpdate()
{
var em = ps.emission;
if (charges == 0)
{
em.rateOverTime = 5;
Color transparent = Color.white;
transparent.a = 0;
sr.color = transparent;
}
else if (!charged)
{
em.rateOverTime = 20;
Color orange = new Color(255, 182, 0);
orange.a = 0.1f;
sr.color = orange;
}
else
{
em.rateOverTime = 40;
Color green = Color.green;
green.a = 0.3f;
sr.color = green;
}
} }
} }