今日した質問に近い内容です。
前回の質問(https://teratail.com/questions/8564)では、初回のみ説明窓(DescriptionWindow)が出てくるというのは解決できたのですが、
初回で説明窓が出ている間にカウントダウンが始まってしまっているので、説明窓を閉じた後にカウントダウンが始まるように直したいです。
以下はそれらのスクリプトです。
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
▪︎DescriptionWindow
lang
1#pragma strict 2 3var DescriptionWindow : GameObject; 4 5private var prefix : String = "dw_"; 6 7function Awake(){ 8 var isCheck : String = PlayerPrefs.GetString(prefix + "isCheck","false"); 9 if(isCheck != "false"){ 10 DescriptionWindow.SetActive(false); 11 } 12} 13 14function windowClose(){ 15 DescriptionWindow.SetActive(false); 16 PlayerPrefs.SetString(prefix + "isCheck","true"); 17}
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
▪︎InterfaceController
lang
1#pragma strict 2 3import UnityEngine.UI; 4 5// Attach GameObject. 6var startCountDown : UI.Text; 7var curtain : UI.Image; 8 9// Attach AudioClip. 10var seOnCountDown : AudioClip; 11var seOnFinish : AudioClip; 12 13private var totalDistance : float = 1210.0; //units. 14private var currentDistance : float = 0; 15private var maxSpeed : float = 35; 16private var currentSpeed : float = 0; //scroll speed in unit per second. 17private var updateDeltaTime : float = 0; 18private var onEntry : boolean = false; 19private var onEntryStep : int = 0; 20private var onPlay : boolean = false; 21private var onFinish : boolean = false; 22private var buttonAB : boolean = false; 23private var isDamage : boolean = false; 24 25// Other Componant. 26private var background : Background; 27private var player : GameObject; 28 29function Awake(){ 30 background = GameObject.Find("Background").transform.GetComponent(Background); 31 player = Resources.Load("Player/Player"); 32 curtain.enabled = false; 33} 34 35function Start(){ 36 updateDeltaTime = 0.0; 37 startCountDown.enabled = false; 38 startCountDown.text = "3"; 39 player = Instantiate(player); 40 onEntry = true; 41} 42 43function Update(){ 44 45 if (Input.GetKeyDown (KeyCode.A)) { 46 onClickButtonA(); 47 } 48 if (Input.GetKeyDown (KeyCode.S)) { 49 onClickButtonB(); 50 } 51 52 53 if(onEntry){ 54 updateDeltaTime += Time.deltaTime; 55 if(updateDeltaTime > 1.0 && onEntryStep == 0){ 56 startCountDown.enabled = true; 57 audio.PlayOneShot(seOnCountDown); 58 startCountDown.text = "3"; 59 onEntryStep++; 60 }else if(updateDeltaTime > 2.0 && onEntryStep == 1){ 61 startCountDown.text = "2"; 62 onEntryStep++; 63 }else if(updateDeltaTime > 3.0 && onEntryStep == 2){ 64 startCountDown.text = "1"; 65 onEntryStep++; 66 }else if(updateDeltaTime > 4.0 && onEntryStep == 3){ 67 startCountDown.text = "Go!"; 68 onEntryStep++; 69 70 //start! 71 GameObject.Find("Main Camera").GetComponent(AudioSource).Play(); 72 // audio.Play(); 73 onPlay = true; 74 currentSpeed += 2.0; 75 player.transform.GetComponent(Player).playStart(); 76 gameObject.transform.GetComponent(StopWatch).playStart(); 77 78 }else if(onEntryStep == 4){ 79 startCountDown.color.a -= 0.02f; 80 if(startCountDown.color.a <= 0.0){ 81 startCountDown.enabled = false; 82 onEntry = false; 83 } 84 } 85 } 86 87 if(onPlay){ 88 // speed down; 89 if(currentSpeed > maxSpeed){ 90 currentSpeed = maxSpeed; 91 }else if(currentSpeed > 25.0){ 92 currentSpeed = currentSpeed - (1.5 * Time.deltaTime); 93 }else if(currentSpeed < 12.0){ 94 currentSpeed = currentSpeed - (1.0 * Time.deltaTime); 95 }else if(currentSpeed < 8.0){ 96 currentSpeed = currentSpeed - (1.5 * Time.deltaTime); 97 }else{ 98 currentSpeed = currentSpeed - (0.5 * Time.deltaTime); 99 } 100 if(currentSpeed < 2){ 101 currentSpeed = 2.0; 102 } 103 104 //currentDistance 105 currentDistance = currentDistance + (currentSpeed * Time.deltaTime); 106 if(currentDistance >= totalDistance){ 107 // onGoal. 108 onGoal(); 109 110 } 111 } 112 113} 114 115function onGoal(){ 116 117 onPlay = false; 118 audio.PlayOneShot(seOnFinish); 119 player.transform.GetComponent(Player).onGoal(); 120 gameObject.transform.GetComponent(StopWatch).onGoal(); 121 GameObject.Find("Main Camera").GetComponent(AudioSource).Stop(); 122 123 // scroll-speed down. 124 iTween.ValueTo(gameObject,iTween.Hash( 125 "from",currentSpeed, 126 "to",0, 127 "time", 1.5, 128 "onupdate","iTweenUpdateScrollSpeedOnGoal" 129 )); 130 // Display goal-text. 131 iTween.ValueTo(gameObject,iTween.Hash( 132 "from",1, 133 "to",0, 134 "time", 1.0, 135 "onstart" , "iTweenStartDisplayTextOnGoal", 136 "onupdate", "iTweenUpdateDisplayTextOnGoal" 137 )); 138 139 yield WaitForSeconds(2.5); 140 141 // fadeOut. 142 iTween.ValueTo(gameObject,iTween.Hash( 143 "from",0, 144 "to",1, 145 "time", 1.3, 146 "onstart" , "iTweenStartOnGoalCurtain", 147 "onupdate","iTweenUpdateOnGoalCurtain", 148 "oncomplete","iTweenCompOnGoalCurtain" 149 )); 150} 151 152
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
度々すみませんが何卒ご助力ください。
追記:これはどこに書いたらいいですか?
lang
1function setOnEntry(boolean flag){ 2 onEntry = flag; 3}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2015/04/14 08:06
退会済みユーザー
2015/04/14 09:49
2015/04/14 09:51
退会済みユーザー
2015/04/14 10:11
2015/04/14 10:38
退会済みユーザー
2015/04/14 11:10
2015/04/14 11:14
退会済みユーザー
2015/04/14 11:43
2015/04/15 01:49
退会済みユーザー
2015/04/15 05:23