예제 #1
0
    public IEnumerator TestHPBarFluctuation()
    {
        // Use the Assert class to test conditions.
        // yield to skip a frame

        // Cycle between draining the player's HP to 0 and bringing it back to full
        GameObject playerPrefab = Resources.Load <GameObject>("Prefabs/Player");
        GameObject hpBarPrefab  = Resources.Load <GameObject>("Prefabs/HPBar");

        GameObject playerGO = MonoBehaviour.Instantiate <GameObject>(playerPrefab);
        GameObject hpBarGO  = MonoBehaviour.Instantiate <GameObject>(hpBarPrefab);

        SidescrollerCharacter player = playerGO.GetComponent <SidescrollerCharacter>();
        HPBar hpBar = hpBarGO.GetComponentInChildren <HPBar>();

        float prevFillAmount = hpBar.fillAmount;

        player.TakeDamage(1);

        yield return(null);

        float newFillAmount = hpBar.fillAmount;

        Assert.AreNotEqual(prevFillAmount, newFillAmount);
    }
예제 #2
0
 // Use this for initialization
 void Awake()
 {
     player = GameObject.FindObjectOfType <SidescrollerCharacter>();
 }
예제 #3
0
 // Use this for initialization
 protected override void Awake()
 {
     base.Awake();
     player = GameObject.FindObjectOfType <SidescrollerCharacter>();
     StartCoroutine(TrackHP());
 }