嗯,我做了一个传送水龙头的兔子,我想这样做,如果你持有超过0.3fa泡沫激活并保护它我尝试了多个代码变量但我不能让它在某些情况下工作兔子传送并且在其他人之后激活泡沫我不知道它的简单事情我只需要调整if / else如果是这样我将感谢eny帮助
using UnityEngine;
using System.Collections;
public class tap : MonoBehaviour {
// Use this for initialization
public GameObject Bunny;
public GameObject BunnyUpEffect;
public GameObject BunnyDownEffect;
public static bool IsHeld = false;
float TimeHeld = 0f;
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButton (0)) {
TimeHeld += Time.deltaTime;
if (TimeHeld > 0.3f) {
BubbleScript.BubbleActive = true;
IsHeld = true;
}
}
else {
BubbleScript.BubbleActive = false;
IsHeld = false;
TimeHeld = 0f;
if (Input.GetMouseButtonDown(0) && IsHeld == false) {
if (BunnyScript.BunnyAlive == true) {
if (BunnyScript.RunBottom == true) {
if (Stats.Energy > 0) {
BunnyUpEffect.GetComponent<BunnyUpEffect> ().Up ();
}
} else if (BunnyScript.RunBottom == false) {
BunnyDownEffect.GetComponent<BunnyDownEffect> ().Down ();
}
Bunny.GetComponent<BunnyScript> ().ChangePos ();
}
}
}
}
}