-
Notifications
You must be signed in to change notification settings - Fork 3
/
icicle
58 lines (53 loc) · 1.47 KB
/
icicle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class icicle : MonoBehaviour
{
[SerializeField]
private float senseTime;
private Transform playerTransform;
Vector3 whereToAtk;
public GameObject warning;
public GameObject obstacle;
void Start()
{
StartCoroutine(countTime(10f));
}
IEnumerator Sense()
{
for(int i = 0; i < senseTime; i++)
{
playerTransform = GameObject.FindGameObjectWithTag("Player").transform;
}
yield return null;
StartCoroutine("Warning");
}
IEnumerator Warning()
{
if (playerTransform != null)
{
whereToAtk = playerTransform.position;
GameObject warningObject = Instantiate(warning, whereToAtk, transform.rotation);
yield return new WaitForSeconds(3f);
DestroyImmediate(warningObject);
StartCoroutine("Attack");
}
}
IEnumerator Attack()
{
GameObject attackObject = Instantiate(obstacle, whereToAtk, transform.rotation);
yield return new WaitForSeconds(2f);
DestroyImmediate(attackObject);
}
IEnumerator countTime(float coolTime)
{
StartCoroutine(Sense());
yield return new WaitForSeconds(coolTime);
StartCoroutine(countTime(10f));
}
/*private void OnDestroy()
{
if() //player와 충돌 시
else if() //일정 시간이 지나면
}*/
}