Visual indicators of charge point charge
This commit is contained in:
parent
2137627c8f
commit
6e2025ddba
2 changed files with 4817 additions and 0 deletions
File diff suppressed because it is too large
Load diff
|
@ -9,10 +9,14 @@ public class ChargePoint : MonoBehaviour
|
|||
int charges = 0;
|
||||
bool charged = false;
|
||||
ChargeCounter chargeCounter;
|
||||
ParticleSystem ps;
|
||||
SpriteRenderer sr;
|
||||
|
||||
void Start()
|
||||
{
|
||||
chargeCounter = GameObject.FindWithTag("Charge Counter").GetComponent<ChargeCounter>();
|
||||
ps = GetComponent<ParticleSystem>();
|
||||
sr = GetComponent<SpriteRenderer>();
|
||||
}
|
||||
|
||||
public void adjustCharges(int amount = 1)
|
||||
|
@ -29,5 +33,34 @@ public class ChargePoint : MonoBehaviour
|
|||
chargeCounter.RemoveChargedPoint(gameObject);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue