IEnumerator Wallrun(WrType t) { switch (t) { case WrType.r: PlayAnim(AnimationStates.EnterWRR); break; case WrType.l: PlayAnim(AnimationStates.EnterWRL); break; } wallrunStartFireOnce = false; rb.AddForce(rb.transform.forward * wallrunEnterAcceleration, ForceMode.Acceleration); yield return(new WaitForSeconds(wallruntime)); wallrunStartFireOnce = true; canWallrunFlag = false; switch (t) { case WrType.r: rb.AddForce(rb.transform.right * wallrunExitAcceletation * 0.01f, ForceMode.Impulse); PlayAnim(AnimationStates.ExitWRR); break; case WrType.l: rb.AddForce(-rb.transform.right * wallrunExitAcceletation * 0.01f, ForceMode.Impulse); PlayAnim(AnimationStates.ExitWRL); break; } }
// Update is called once per frame void Update() { state = States.idle; //VisualDebugger.Log(1, "Amt Jump", amtJump); //VisualDebugger.Log(2, "Is Grounded", isGrounded); //VisualDebugger.Log(3, "Speed", rb.velocity); movement = new Vector3(Input.GetAxis("Horizontal"), 0.0f, Input.GetAxis("Vertical")); isGrounded = Physics.CheckSphere(groundCheck.position, checkRad, groundMask); speed = Mathf.Clamp(speed, 0.0f, Mathf.Infinity); if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.D) /* && Grapple.isGrapple */) { state = States.sprint; speed = defSpeed; rb.drag = drag; } else if (rb.velocity.x > 0 || rb.velocity.z > 0) { state = States.idle; speed -= notMovingSpeedDecayRate * Time.deltaTime; rb.drag = decayDrag; } if (rb.velocity.y < 0 && !isGrounded) { rb.drag = fallDrag; } if (isGrounded) { amtJump = 0; canWallrunFlag = true; } /// this entire section needs to be redone, its only here for reference //if (Input.GetButtonDown("Jump") && amtJump >= 2 && (!isGrounded || state == States.wallrun)) //{ // state = States.doublejump; // Debug.Log("Juping in air"); // Jump(); //} //if (Input.GetButtonDown("Jump") && (isGrounded || state == States.wallrun)) //{ // state = States.jump; // Debug.Log("Jumping off ground"); // Jump(); //} //else if (Input.GetButtonUp("Jump")) // potential bug //{ // state = States.jump; // rb.drag = drag; //} // basic idea: /// space pressed /// checks: /// jump amount <= 2 jumps bool normalJump = true; if (state == States.wallrun && Input.GetKeyDown(jumpKey) && amtJump < 2) // bug watch { normalJump = false; switch (curtype) { case WrType.l: rb.AddForce((Vector3.up + new Vector3(0, 0, 0)) * jumpForce, ForceMode.Force); // left wallrun exit offset Debug.Log("fired cur"); break; case WrType.r: rb.AddForce((Vector3.up + new Vector3(0, 0, 0)) * jumpForce, ForceMode.Force); // right wallrun exit offset Debug.Log("fired cur"); break; } } if (Input.GetKeyDown(jumpKey) && amtJump < 2 && normalJump) { rb.AddForce(Vector3.up * jumpForce, ForceMode.Force); amtJump++; Debug.Log("fired nor"); } if (Input.GetKey(crouchKey) && isGrounded) { //rb.transform.localScale = playerCrouch; collider.height = playerCrouch.y; speed -= slideDecayRate * Time.deltaTime; speed = Mathf.Clamp(speed, 0, Mathf.Infinity); rb.drag = slideDrag; isSliding = true; } if (Input.GetKeyUp(crouchKey)) { //rb.transform.localScale = playerStand; collider.height = playerStand.y; speed = defSpeed; rb.drag = drag; isSliding = false; isSlideCool = false; slideCoolTimer -= Time.deltaTime; } bool wrFlag = false; curtype = WrType.r; if ((Physics.CheckSphere(wallCheckL.position, wallRunCheckRad, 1 << 16) || Physics.CheckSphere(wallCheckR.position, wallRunCheckRad, 1 << 16)) && !isGrounded && canWallrunFlag) // check left/right wallrun { amtJump = 0; state = States.wallrun; rb.useGravity = false; if (wallrunStartFireOnce && Physics.CheckSphere(wallCheckR.position, wallRunCheckRad, 1 << 16)) { wallrunInst = StartCoroutine(Wallrun(WrType.l)); curtype = WrType.l; wrFlag = true; } if (wallrunStartFireOnce && Physics.CheckSphere(wallCheckL.position, wallRunCheckRad, 1 << 16)) { wallrunInst = StartCoroutine(Wallrun(WrType.r)); curtype = WrType.r; wrFlag = true; } } else if (wrFlag) { Debug.Log("hey"); StopCoroutine(wallrunInst); switch (curtype) { case WrType.r: PlayAnim(AnimationStates.ExitWRR); break; case WrType.l: PlayAnim(AnimationStates.ExitWRL); break; } } if (!isGrounded && state != States.wallrun) { rb.AddRelativeForce(Vector3.down * fallSpeed * Time.deltaTime); } VisualDebugger.Log(4, "State", state); }
private string BuildRemoteUrl(string baseUrl, WrType wrType) { string fragment; switch (wrType) { case WrType.BrowserPoll: fragment = "long_poll"; break; case WrType.Browser: fragment = "browser"; break; default: fragment = "http"; break; } return string.Format( "{0}/{1}?token={2}&url={3}", TargetUrl, fragment, TargetToken, HttpUtility.UrlEncode(baseUrl) ); }