void Update() { if (!usrState) { transform.position = new Vector3(0, 0, -100); return; } MapDoor mapDoor = usrState.GetDoor(); if (mapDoor) { if (usrState.currentDir.x == -1 && usrState.nearDoor == UsrState.LEFT_DIR || usrState.currentDir.x == 1 && usrState.nearDoor == UsrState.RIGHT_DIR) { transform.position = (Vector2)mapDoor.transform.position + (mapDoor.dashDistance - mapDoor.boxCollider2D.size.x - usrState.startColliderSize.x) * usrState.currentDir; } } else { transform.position = new Vector3(0, 0, -100); } }
public void Dash() { if (!state.animator.GetBool("isDash") && state.nearDoor != 0 && state.isOnMove && (state.currentAni.IsName("run") || state.currentAni.IsName("rise") || state.currentAni.IsName("fall"))) { // dashTarget = state.GetDoor(); if (dashTarget == null || !dashTarget.IsEnable()) { return; } if (Mathf.Abs(transform.position.y - dashTarget.transform.position.y) <= state.doorDistance) //y轴对齐 { state.animator.SetBool("isDash", true); state.rigidbody2D.bodyType = RigidbodyType2D.Static; } } }