Completed course 2 adn 3, working on 4
This commit is contained in:
49
Assets/Scripts/UnitStateBubble.cs
Normal file
49
Assets/Scripts/UnitStateBubble.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UnitStateBubble : MonoBehaviour
|
||||
{
|
||||
public Image stateBubble;
|
||||
public Sprite idleSprite;
|
||||
public Sprite gatherSprite;
|
||||
public Sprite attackSprite;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
public void OnStateChange(UnitState state)
|
||||
{
|
||||
stateBubble.enabled = true;
|
||||
switch(state)
|
||||
{
|
||||
case UnitState.Idle:
|
||||
{
|
||||
stateBubble.sprite = idleSprite;
|
||||
break;
|
||||
}
|
||||
case UnitState.Gather:
|
||||
{
|
||||
stateBubble.sprite = gatherSprite;
|
||||
break;
|
||||
}
|
||||
case UnitState.Attack:
|
||||
{
|
||||
stateBubble.sprite = attackSprite;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
stateBubble.enabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user