void Update() { Debug.DrawRay(rayDown.position, Vector2.down * 1, Color.red); Debug.DrawRay(rayLeft.position, Vector2.left * 0.15f, Color.red); Debug.DrawRay(rayRight.position, Vector2.right * 0.15f, Color.red); if (GameManager.Instance.IsGameStart == false || GameManager.Instance.IsGameOver || GameManager.Instance.IsPause || EventSystem.current.IsPointerOverGameObject()) { return; } //if (Input.GetMouseButtonDown(0) && isJumping == false) if (Input.GetMouseButtonDown(0) && isJumping == false && nextPlatformLeft != Vector3.zero) { if (isMove == false) { EventCenter.Broadcast(EventType.PlayerMove); isMove = true; } EventCenter.Broadcast(EventType.DecidePath); isJumping = true; Vector3 mousePos = Input.mousePosition; //是否点击左边屏幕 if (mousePos.x <= Screen.width / 2) { isMoveLeft = true; } //是否点击右边屏幕 else if (mousePos.x > Screen.width / 2) { isMoveLeft = false; } Jump(); } //游戏结束 逻辑 if (rig2D.velocity.y < 0 && IsRayPlatform() == false && GameManager.Instance.IsGameOver == false) { GetComponent <BoxCollider2D>().enabled = false; GameManager.Instance.IsGameOver = true; StartCoroutine(CoroutineHelper.DealyBroadcast(EventType.ShowGameOverPanel)); } if (isJumping && IsRayObstacle() && GameManager.Instance.IsGameOver == false) { GameObject go = SimplePool.Spawn(vars.deathEffect, transform.position); GameManager.Instance.IsGameOver = true; //回收对象 StartCoroutine(CoroutineHelper.RecoverPoolCoroutine(go)); gameObject.GetComponent <SpriteRenderer>().enabled = false; StartCoroutine(CoroutineHelper.DealyBroadcast(EventType.ShowGameOverPanel)); Destroy(gameObject, 1f); } if (transform.position.y - Camera.main.transform.position.y < -6 && GameManager.Instance.IsGameOver == false) { GameManager.Instance.IsGameOver = true; print("游戏结束"); StartCoroutine(CoroutineHelper.DealyBroadcast(EventType.ShowGameOverPanel)); } }