-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntroLine.cs
More file actions
78 lines (60 loc) · 1.45 KB
/
Copy pathIntroLine.cs
File metadata and controls
78 lines (60 loc) · 1.45 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using UnityEngine;
using System.Collections;
public class IntroLine : MonoBehaviour {
public AudioClip PlayerClip1;
public AudioClip PlayerClip2;
public AudioClip EnemyClip1;
public AudioClip EnemyClip2;
int playerLine;
int enemyLine;
ArrayList playerList;
ArrayList enemyList;
int playerPlay;
int enemyPlay;
float clipTime;
float currentTime;
int numberP;
int numberE;
// Use this for initialization
void Start () {
playerList = new ArrayList();
enemyList = new ArrayList();
playerList.Add(PlayerClip1);
playerList.Add(PlayerClip2);
enemyList.Add (EnemyClip1);
enemyList.Add (EnemyClip2);
numberP = Mathf.Abs (Random.Range(0,100));
numberE = Mathf.Abs (Random.Range(0,100));
if(numberP < 50){
playerLine = 0;
}else{
playerLine = 1;
}
if(numberE < 50){
enemyLine = 0;
}else{
enemyLine = 1;
}
//playerLine = Mathf.Abs(Random.Range (0,playerList.Count-1));
//enemyLine = Mathf.Abs(Random.Range (0,enemyList.Count-1));
playerPlay = 0;
enemyPlay = 0;
currentTime = Time.time;
}
// Update is called once per frame
void Update () {
if(enemyPlay == 0){
audio.clip = enemyList[enemyLine] as AudioClip;
clipTime = audio.clip.length;
audio.Play();
audio.loop = false;
enemyPlay = 1;
}
if(enemyPlay == 1 && Time.time - currentTime > clipTime){
audio.clip = playerList[playerLine] as AudioClip;
audio.Play();
audio.loop = false;
enemyPlay++;
}
}
}