private void Start() { // TODO: 临时解决办法,场景进入成功时发送事件 Appcontext.getInstance().setScripts(); this.inputManager = Appcontext.getInstance().inputManager; this.playerManager = Appcontext.getInstance().playerManager; }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { if (isStartLoad) { return; } this.isStartLoad = true; Appcontext.getInstance().loadNextScene(SceneSwitchEnum.CIRCLE); } }
/// <summary> /// 奔跑 /// </summary> private void run() { Vector3 moveDir = Appcontext.getInstance().inputManager.getMoveDirection(); if (moveDir == Vector3.zero) { if (this.m_Animator.GetBool("Run")) { this.m_Animator.SetBool("Run", false); } return; } if (moveDir.x <= 0) { this.transform.localScale = new Vector3(-1, 1, 1); } else if (moveDir.x >= 0) { this.transform.localScale = new Vector3(1, 1, 1); } float dir = this.transform.localScale.x; // 撞到墙停止移动 if ( CommonUtil.ray2DCheck(this.transform.position, new Vector2(dir, 0), ConstValue.sprintCheckDistance, this.layerMask) || CommonUtil.ray2DCheck(this.transform.position + new Vector3(0, -0.3f, 0), new Vector2(dir, 0), ConstValue.sprintCheckDistance, this.layerMask) || CommonUtil.ray2DCheck(this.transform.position + new Vector3(0, -0.6f, 0), new Vector2(dir, 0), ConstValue.sprintCheckDistance, this.layerMask)) { if (this.m_Animator.GetBool("Run")) { this.m_Animator.SetBool("Run", false); } return; } this.transform.Translate(moveDir * ConstValue.moveSpeed * Time.deltaTime); if (!this.m_Animator.GetBool("Run")) { this.m_Animator.SetBool("Run", true); } }