IEnumerator EndGame() { yield return(new WaitForSeconds(1.0f)); // 清空道具 GamePersist.GetInstance().myProps.Clear(); Application.LoadLevel(GamePersist.GetInstance().currentLevel + 2); }
void OnTriggerEnter2D(Collider2D other) { if (!GamePersist.GetInstance().hero.isHide) { GamePersist.GetInstance().subtitle = "被发现了,你输了"; StartCoroutine(EndGame()); } }
private void OnCollisionExit2D(Collision2D coll) { if (coll.gameObject.GetComponent <Hero>() != null) { GamePersist.GetInstance().hero.jumpEnable = false; Debug.Log("离开地板"); } }
private void OnCollisionEnter2D(Collision2D coll) { if (coll.gameObject.GetComponent <Hero>() != null) { GamePersist.GetInstance().hero.jumpEnable = true; Debug.Log("与地板碰撞"); } }
private void OnTriggerExit2D(Collider2D collision) { if (GamePersist.GetInstance().hero.isHide) { GamePersist.GetInstance().hero.isHide = false; GamePersist.GetInstance().hero.heroRect.Translate(new Vector3(0, 0, -3)); } }
private void OnTriggerStay2D(Collider2D collision) { if (Input.GetKey(KeyCode.E)) { GamePersist.GetInstance().myProps.Add(propName); GamePersist.GetInstance().subtitle = "获得了道具" + propName; this.gameObject.SetActive(false); } }
// 把人物移动到上一层 void OnTriggerEnter2D(Collider2D other) { if (other.GetComponent <Hero>() != null) { Debug.Log("移动向上一层"); GamePersist.GetInstance().hero.Heroposition(new Vector2(210, 405)); GamePersist.GetInstance().currentLevel++; } }
void OnTriggerEnter2D(Collider2D other) { if (other.GetComponent <Hero>() != null) { Debug.Log("移动向上一层"); GamePersist.GetInstance().hero.HeroMove(new Vector2(toX, toY)); //GamePersist.GetInstance().currentLevel++; } }
public void PauseBtn() { // 设置状态 GamePersist.GetInstance().hero.inputEnable = false; GamePersist.GetInstance().isPause = true; // 按钮状态 this.pauseBtn.SetActive(false); this.continueBtn.SetActive(true); }
private void OnTriggerExit2D(Collider2D collision) { if (GamePersist.GetInstance().hero.isHide) { // 出来 GamePersist.GetInstance().hero.isHide = false; GamePersist.GetInstance().hero.DisHide(); } }
// Update is called once per frame void Update() { GamePersist.GetInstance().waterHeight = GamePersist.GetInstance().waterHeight + this.waterSpeed; if (GamePersist.GetInstance().GetDiff() < 0) { // 600为宽度 剩下为长度 this.GetComponent <RectTransform>().sizeDelta = new Vector2(600, -1 * GamePersist.GetInstance().GetDiff()); } }
private void unStick() { Debug.Log("Unstick"); GamePersist.GetInstance().hero.transform.parent = this.pretrans.transform; GamePersist.GetInstance().hero.moveEnable = true; GamePersist.GetInstance().hero.EnableGravity(); GamePersist.GetInstance().hero.KeepVertical(); isStick = false; }
public void Update() { if (enable) { if (GamePersist.GetInstance().hero.interEnable) { this.gameObject.GetComponent <RectTransform>().Rotate(new Vector3(0, 0, angle)); } } }
public void Update() { if (enable) { if (GamePersist.GetInstance().hero.interEnable) { GrowUp(); } } }
public void OnTriggerEnter2D(Collider2D other) { if (other.GetComponent <Hero>() != null) { Debug.Log("与水滴碰撞"); GamePersist.GetInstance().hero.DoAWarn("好痛"); GamePersist.GetInstance().hero.AddForce(10000000); //GamePersist.GetInstance().hero.velocity(); } }
public void Update() { if (enable) { if (GamePersist.GetInstance().hero.interEnable) { this.actSth.SetActive(true); } } }
public void Update() { if (enable) { if (GamePersist.GetInstance().hero.interEnable) { GamePersist.GetInstance().hero.DoAWarn(warnStr); enable = false; } } }
public void Update() { if (enable) { if (GamePersist.GetInstance().hero.interEnable) { flash.SetActive(true); this.Invoke("Disact", 0.3f); } } }
void Restart() { if (GamePersist.GetInstance().buildNum == 1) { SceneManager.LoadScene("caption1"); } else if (GamePersist.GetInstance().buildNum == 2) { SceneManager.LoadScene("caption2"); } }
public void Update() { if (enable) { if (GamePersist.GetInstance().hero.interEnable) { GamePersist.GetInstance().hero.keyAndWater = true; GamePersist.GetInstance().hero.DoAWarn("拿到了水和钥匙"); } } }
// 清除障碍物 public override bool Invoke() { if (GamePersist.GetInstance().hero.door == null) { return(false); } // 把门直接设置为false GamePersist.GetInstance().hero.obstacle.SetActive(false); GamePersist.GetInstance().hero.door = null; return(true); }
void Update() { if (GamePersist.GetInstance().hero.faceRight) { rect.localPosition = new Vector3(10, 0, 0); } else { rect.localPosition = new Vector3(-10, 0, 0); } }
void OnTriggerEnter2D(Collider2D other) { //if (Input.GetKey("e")) //{ GamePersist.GetInstance().subtitle = "你怎么会来这里,他们杀人不眨眼,你快逃吧,只有唯一一条路可以出去,我只知道在山上。"; StartCoroutine(Delay.DelayToInvokeDo(() => { GamePersist.GetInstance().subtitle = "拿着这个信物,找到 XXX,他会带你离开。"; }, 1f)); //} }
void OnTriggerStay2D(Collider2D other) { if (Input.GetKey("e")) { if (!GamePersist.GetInstance().hero.isHide) { GamePersist.GetInstance().hero.isHide = true; GamePersist.GetInstance().subtitle = "你藏起来了"; GamePersist.GetInstance().hero.heroRect.Translate(new Vector3(0, 0, 3)); } } }
void OnTriggerEnter2D(Collider2D other) { GamePersist.GetInstance().subtitle = "啊,你手里有 XX(伙夫赠送的道具),我相信你。"; StartCoroutine(Delay.DelayToInvokeDo(() => { GamePersist.GetInstance().subtitle = "我们从这里出去,到金城关前出关,我这里有文牒。"; }, 1f)); StartCoroutine(Delay.DelayToInvokeDo(() => { GamePersist.GetInstance().subtitle = "你通关了"; }, 3f)); }
private void Start() { GamePersist.GetInstance().boss = this; // boss行动路线 pos[0] = new Vector2(228, 0); pos[1] = new Vector2(60, 0); pos[2] = new Vector2(-90, -65); pos[3] = new Vector2(-120, -65); image = this.GetComponent <Image>(); this.enable = false; DoAWarn("灯怎么黑了"); }
public void Update() { if (enable) { if (GamePersist.GetInstance().hero.interEnable) { disactSth.SetActive(false); actSth.SetActive(true); GamePersist.GetInstance().hero.interEnable = false; } } }
IEnumerator ChangeScene() { yield return(new WaitForSeconds(delay)); GamePersist.GetInstance().levelState[sceneIndex - 3] = true; GamePersist.GetInstance().currentLevel = 1; // 清空背包 GamePersist.GetInstance().myProps.Clear(); // 加载场景 Application.LoadLevel(sceneIndex); }
// 清除障碍物 public override bool Invoke() { if (GamePersist.GetInstance().hero.obstacle == null) { return(false); } // 直接设为false GamePersist.GetInstance().hero.obstacle.SetActive(false); GamePersist.GetInstance().hero.obstacle = null; GamePersist.GetInstance().audio.PlayAudioClip("斧头"); return(true); }
IEnumerator DectorInput() { while (true) { yield return(new WaitForSeconds(0.12f)); if (this.show.activeSelf == false) { continue; } if (Input.GetKey("a")) { if (index == 1) { index = 6; } else { --index; } } else if (Input.GetKey("d")) { if (index == 6) { index = 1; } else { ++index; } } else if (Input.GetKey(KeyCode.E)) { // 使用道具 if (index <= GamePersist.GetInstance().myProps.Count) { string propName = GamePersist.GetInstance().myProps[index - 1]; // 调用对应的道具功能 GamePersist.GetInstance().propMap[propName].Invoke(); // 消耗道具 GamePersist.GetInstance().myProps.Remove(propName); Escape(); } } else if (Input.GetKey(KeyCode.Q)) { Escape(); } } }