Commit 8e8e24d9 authored by 문경훈's avatar 문경훈

SayLine(int lineIndex) added in Boss.cs

parent 54efc8b0
Pipeline #511 skipped
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
public class Boss : MonoBehaviour {
......@@ -8,6 +10,10 @@ public class Boss : MonoBehaviour {
public float reflectPercentage;
public List<string> bossLines = new List<string>();
public GameObject speechBubble;
bool speechOverlap = false;
public int HP = 100;
public int Atk = 10;
int maxHP;
......@@ -56,4 +62,31 @@ public class Boss : MonoBehaviour {
mainLogic.godnessManager.godnessHP -= 100;
mainLogic.OnGodnessClicked();
}
void SayLine(int lineIndex)
{
if (lineIndex < 0 || lineIndex >= bossLines.Count)
{
Debug.LogError("Error: Wrong boss line index.");
}
StartCoroutine(_sayLineCoroutine(lineIndex));
}
IEnumerator _sayLineCoroutine(int lineIndex)
{
if (speechBubble.activeSelf == true)
speechOverlap = true;
speechBubble.GetComponentInChildren<Text>().text = bossLines[lineIndex];
speechBubble.SetActive(true);
yield return new WaitForSeconds(2.0f);
if (speechOverlap == false)
{
speechBubble.GetComponentInChildren<Text>().text = "";
speechBubble.SetActive(false);
}
else
speechOverlap = false;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment