public IEnumerator Rotate_Pipe(Transform ring_T, float dest_Rotation) { if (!puzzle_Is_Solved) { if (local_Facing_Direction != Facing_Direction.WEST) { local_Facing_Direction++; } else { local_Facing_Direction = Facing_Direction.NORTH; } } bool fully_Rotated = false; float temp_Num; Transform temp_Rot = ring_T; current_Lerp_Time = 0f; temp_Num = dest_Rotation; if (temp_Num < 0) { temp_Num = 270f; } while (!fully_Rotated) { current_Lerp_Time += Time.deltaTime; if (current_Lerp_Time > rotation_Smoothing) { current_Lerp_Time = rotation_Smoothing; } float t = current_Lerp_Time / rotation_Smoothing; t = Mathf.Sin(t * Mathf.PI * 0.5f); ring_T.rotation = Quaternion.Lerp(temp_Rot.rotation, Quaternion.Euler(dest_Rotation, 0f, 0f), t); if (current_Lerp_Time >= rotation_Smoothing) { fully_Rotated = true; } if (current_Lerp_Time >= rotation_Smoothing) { fully_Rotated = true; } yield return(new WaitForSeconds(.02f)); } Check_Is_Puzzle_Solved(); }
public IEnumerator Rotate_Pipe(Transform ring_T, float dest_Rotation) { local_Temple_Three_Puzzle_Manager.pipe_SFX.Play(); if (local_Facing_Direction != Facing_Direction.WEST) { local_Facing_Direction++; } else { local_Facing_Direction = Facing_Direction.NORTH; } bool fully_Rotated = false; float temp_Num; Transform temp_Rot = ring_T; current_Lerp_Time = 0f; temp_Num = dest_Rotation; if (temp_Num < 0) { temp_Num = 270f; } if (is_On_Back_Wall) { while (!fully_Rotated) { current_Lerp_Time += Time.deltaTime; if (current_Lerp_Time > rotation_Smoothing) { current_Lerp_Time = rotation_Smoothing; } float t = current_Lerp_Time / rotation_Smoothing; t = Mathf.Sin(t * Mathf.PI * 0.5f); ring_T.rotation = Quaternion.Lerp(temp_Rot.rotation, Quaternion.Euler(dest_Rotation, 0f, 0f), t); if (current_Lerp_Time >= rotation_Smoothing) { fully_Rotated = true; } if (current_Lerp_Time >= rotation_Smoothing) { fully_Rotated = true; } yield return(new WaitForSeconds(.02f)); } } else { while (!fully_Rotated) { current_Lerp_Time += Time.deltaTime; if (current_Lerp_Time > rotation_Smoothing) { current_Lerp_Time = rotation_Smoothing; } float t = current_Lerp_Time / rotation_Smoothing; t = Mathf.Sin(t * Mathf.PI * 0.5f); ring_T.rotation = Quaternion.Lerp(temp_Rot.rotation, Quaternion.Euler(0f, 0f, dest_Rotation), t); if (current_Lerp_Time >= rotation_Smoothing) { fully_Rotated = true; } if (current_Lerp_Time >= rotation_Smoothing) { fully_Rotated = true; } yield return(new WaitForSeconds(.02f)); } } Update_Pipe_Status(); Update_System(); }
/// <summary> /// //checks for input to set the direction of the player /// </summary> void Update() { input = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")); if (Input.GetAxisRaw("Horizontal") > 0) { current_Direction = new Vector3(camera_Right_Vector.transform.forward.x, 0, camera_Right_Vector.transform.forward.z); local_Facing_Direction = Facing_Direction.RIGHT; transform.Translate(current_Direction.normalized * Time.deltaTime * movement_Speed); Set_Direction(); } if (Input.GetAxisRaw("Horizontal") < 0) { current_Direction = new Vector3(camera_Left_Vector.transform.forward.x, 0, camera_Left_Vector.transform.forward.z); local_Facing_Direction = Facing_Direction.LEFT; transform.Translate(current_Direction.normalized * Time.deltaTime * movement_Speed); Set_Direction(); } if (Input.GetAxisRaw("Vertical") > 0) { current_Direction = new Vector3(Camera.main.transform.forward.x, 0, Camera.main.transform.forward.z); local_Facing_Direction = Facing_Direction.FORWARDS; transform.Translate(current_Direction.normalized * Time.deltaTime * movement_Speed); Set_Direction(); } if (Input.GetAxisRaw("Vertical") < 0) { current_Direction = new Vector3(-Camera.main.transform.forward.x, 0, -Camera.main.transform.forward.z); local_Facing_Direction = Facing_Direction.BACKWARDS; transform.Translate(current_Direction.normalized * Time.deltaTime * movement_Speed); Set_Direction(); } //Setting animation parameters if ((Input.GetAxisRaw("Vertical") == 0 && (Input.GetAxisRaw("Horizontal")) == 0)) { if (is_Playing_Run_Animation) { anim.SetBool("Run", false); is_Playing_Run_Animation = false; if (local_Player_Manager.Moving_Sound.isPlaying) { local_Player_Manager.Moving_Sound.Stop(); } } } else { if (!is_Playing_Run_Animation) { anim.SetBool("Run", true); is_Playing_Run_Animation = true; if (!local_Player_Manager.Moving_Sound.isPlaying) { local_Player_Manager.Moving_Sound.Play(); } } } //sets diagonal orientation if the player is moving in both axes if (Input.GetAxis("Vertical") < 0 && Input.GetAxisRaw("Horizontal") > 0) { local_Facing_Direction = Facing_Direction.BACKWARDS_RIGHT; Set_Direction(); } if (Input.GetAxis("Vertical") < 0 && Input.GetAxisRaw("Horizontal") < 0) { local_Facing_Direction = Facing_Direction.BACKWARDS_LEFT; Set_Direction(); } if (Input.GetAxis("Vertical") > 0 && Input.GetAxisRaw("Horizontal") < 0) { local_Facing_Direction = Facing_Direction.FORWARDS_LEFT; Set_Direction(); } if (Input.GetAxis("Vertical") > 0 && Input.GetAxisRaw("Horizontal") > 0) { local_Facing_Direction = Facing_Direction.FORWARDS_RIGHT; Set_Direction(); } if (!Input.anyKey) { local_Facing_Direction = Facing_Direction.NEUTRAL; Set_Direction(); } //checks for input to handle the player dodge mechanic if (Input.GetButtonDown("Dash")) { if (dash_Avalable) { StartCoroutine("Dash_Forward"); local_UI_Manager.dash_Cooldown_Timer = dash_Cooldown; } } //checks which direction the player needs to face }
private void Proto_Movement(GameTime gameTime, Tools.KeyPress keyPress) { switch (actionState) { case Action_State.stand: if (sprite.Animation == RStand) { facingDirection = Facing_Direction.right; } if (sprite.Animation == LStand) { facingDirection = Facing_Direction.left; } if (sprite.Animation == RStand || sprite.Animation == LStand) { if (sprite.FrameIndex == 1) { if (keyPress.key_Right >= 1 && keyPress.key_Left >= 1) { sprite.PlayAnimation(AniSwitch(RStand, LStand)); } else if (keyPress.key_Z >= 1) { sprite.PlayAnimation(AniSwitch(RStand_RStance, LStand_LStance)); } else if (keyPress.key_Right >= 1) { if (facingDirection == Facing_Direction.left) { sprite.PlayAnimation(LStand_RStand); } else { sprite.PlayAnimation(AniSwitchStep(RStand_RRStep, RStand_RLStep)); } } else if (keyPress.key_Left >= 1) { if (facingDirection == Facing_Direction.right) { sprite.PlayAnimation(RStand_LStand); } else { sprite.PlayAnimation(AniSwitchStep(LStand_LRStep, LStand_LLStep)); } } } } else if (sprite.Animation == RStand_LStand || sprite.Animation == LStand_RStand) { if (sprite.FrameIndex == 2) { sprite.PlayAnimation(AniSwitch(LStand, RStand)); } } else if (sprite.Animation == RStand_RStance || sprite.Animation == LStand_LStance) { if (sprite.FrameIndex == 1) { sprite.PlayAnimation(AniSwitch(RStance, LStance)); actionState = Action_State.stance; } } else if (sprite.Animation == RStand_RRStep || sprite.Animation == RStand_RLStep || sprite.Animation == LStand_LRStep || sprite.Animation == LStand_LLStep) { if (sprite.FrameIndex == 1) { if (keyPress.key_Right >= 1 && facingDirection == Facing_Direction.right) { if (sprite.Animation == RStand_RRStep || sprite.Animation == RStand_RLStep) { sprite.PlayAnimation(AniSwitchStep(RRStep_RLStep, RLStep_RRStep)); actionState = Action_State.walk; } } else if (keyPress.key_Left >= 1 && facingDirection == Facing_Direction.left) { if (sprite.Animation == LStand_LRStep || sprite.Animation == LStand_LLStep) { sprite.PlayAnimation(AniSwitchStep(LRStep_LLStep, LLStep_LRStep)); actionState = Action_State.walk; } } else { sprite.PlayAnimation(AniSwitch(AniSwitchStep(RRStep_RStand, RLStep_RStand), AniSwitchStep(LRStep_LStand, LLStep_LStand))); } } } else if (sprite.Animation == RRStep_RStand || sprite.Animation == RLStep_RStand || sprite.Animation == LRStep_LStand || sprite.Animation == LLStep_LStand) { if (sprite.FrameIndex == 2) { if (sprite.Animation == RRStep_RStand || sprite.Animation == LRStep_LStand) { nextStep = Next_Step.left; sprite.PlayAnimation(AniSwitch(RStand, LStand)); } else if (sprite.Animation == RLStep_RStand || sprite.Animation == LLStep_LStand) { nextStep = Next_Step.right; sprite.PlayAnimation(AniSwitch(RStand, LStand)); } } } else { sprite.PlayAnimation(AniSwitch(RStand, LStand)); } break; case Action_State.walk: if (sprite.Animation == RRStep_RLStep || sprite.Animation == RLStep_RRStep || sprite.Animation == LRStep_LLStep || sprite.Animation == LLStep_LRStep) { if (sprite.FrameIndex == 3) { if (keyPress.key_Right >= 1) { if (sprite.Animation == RRStep_RLStep) { if (keyPress.key_Z >= 1) { sprite.PlayAnimation(RLStep_RRRun); nextStep = Next_Step.right; } else { sprite.PlayAnimation(RLStep_RRStep); nextStep = Next_Step.right; } } else if (sprite.Animation == RLStep_RRStep) { if (keyPress.key_Z >= 1) { sprite.PlayAnimation(RRStep_RLRun); nextStep = Next_Step.left; } else { sprite.PlayAnimation(RRStep_RLStep); nextStep = Next_Step.left; } } else { sprite.PlayAnimation(AniSwitch(AniSwitchStep(RRStep_RStand, RLStep_RStand), AniSwitchStep(LRStep_LStand, LLStep_LStand))); } } else if (keyPress.key_Left >= 1) { if (sprite.Animation == LRStep_LLStep) { if (keyPress.key_Z >= 1) { sprite.PlayAnimation(LLStep_LRRun); nextStep = Next_Step.right; } else { sprite.PlayAnimation(LLStep_LRStep); nextStep = Next_Step.right; } } else if (sprite.Animation == LLStep_LRStep) { if (keyPress.key_Z >= 1) { sprite.PlayAnimation(LRStep_LLRun); nextStep = Next_Step.left; } else { sprite.PlayAnimation(LRStep_LLStep); nextStep = Next_Step.left; } } else { sprite.PlayAnimation(AniSwitch(AniSwitchStep(RRStep_RStand, RLStep_RStand), AniSwitchStep(LRStep_LStand, LLStep_LStand))); } } else { sprite.PlayAnimation(AniSwitch(AniSwitchStep(RRStep_RStand, RLStep_RStand), AniSwitchStep(LRStep_LStand, LLStep_LStand))); } } } else if (sprite.Animation == RRStep_RLRun || sprite.Animation == RLStep_RRRun || sprite.Animation == LRStep_LLRun || sprite.Animation == LLStep_LRRun) { if (sprite.FrameIndex == 3) { sprite.PlayAnimation(AniSwitch(AniSwitchStep(RRRun_RLRun, RLRun_RRRun), AniSwitchStep(LRRun_LLRun, LLRun_LRRun))); actionState = Action_State.run; } } else if (sprite.Animation == RRStep_RStand || sprite.Animation == RLStep_RStand || sprite.Animation == LRStep_LStand || sprite.Animation == LLStep_LStand) { if (sprite.FrameIndex == 2) { if (sprite.Animation == RRStep_RStand || sprite.Animation == LRStep_LStand) { nextStep = Next_Step.left; sprite.PlayAnimation(AniSwitch(RStand, LStand)); actionState = Action_State.stand; } else if (sprite.Animation == RLStep_RStand || sprite.Animation == LLStep_LStand) { nextStep = Next_Step.right; sprite.PlayAnimation(AniSwitch(RStand, LStand)); actionState = Action_State.stand; } } } else { if (sprite.FrameIndex == 3) { sprite.PlayAnimation(AniSwitch(AniSwitchStep(RRStep_RStand, RLStep_RStand), AniSwitchStep(LRStep_LStand, LLStep_LStand))); } } break; case Action_State.stance: if (sprite.Animation == RStance) { facingDirection = Facing_Direction.right; } if (sprite.Animation == LStance) { facingDirection = Facing_Direction.left; } if (sprite.Animation == RStance || sprite.Animation == LStance) { if (sprite.FrameIndex == 1) { if (keyPress.key_Z >= 1) { if (facingDirection == Facing_Direction.right) { if (keyPress.key_Left >= 1) { sprite.PlayAnimation(RStance_LStance); } else if (keyPress.key_Right >= 1) { sprite.PlayAnimation(AniSwitchStep(RStance_RRRun, RStance_RLRun)); } } else if (facingDirection == Facing_Direction.left) { if (keyPress.key_Right >= 1) { sprite.PlayAnimation(LStance_RStance); } else if (keyPress.key_Left >= 1) { sprite.PlayAnimation(AniSwitchStep(LStance_LRRun, LStance_LLRun)); } } } else { sprite.PlayAnimation(AniSwitch(RStance_RStand, LStance_LStand)); } } } else if (sprite.Animation == RStance_RRRun || sprite.Animation == RStance_RLRun || sprite.Animation == LStance_LRRun || sprite.Animation == LStance_LLRun) { if (sprite.FrameIndex == 2) { if (facingDirection == Facing_Direction.right) { if (keyPress.key_Left >= 1) { sprite.PlayAnimation(AniSwitchStep(RRRun_RStance, RLRun_RStance)); } else if (keyPress.key_Right >= 1) { sprite.PlayAnimation(AniSwitchStep(RRRun_RLRun, RLRun_RRRun)); actionState = Action_State.run; } else { sprite.PlayAnimation(AniSwitchStep(RRRun_RStance, RLRun_RStance)); } } else if (facingDirection == Facing_Direction.left) { if (keyPress.key_Right >= 1) { sprite.PlayAnimation(AniSwitchStep(LRRun_LStance, LLRun_LStance)); } else if (keyPress.key_Left >= 1) { sprite.PlayAnimation(AniSwitchStep(LRRun_LLRun, LLRun_LRRun)); actionState = Action_State.run; } else { sprite.PlayAnimation(AniSwitchStep(LRRun_LStance, LLRun_LStance)); } } } } else if (sprite.Animation == RStance_RStand || sprite.Animation == LStance_LStand) { if (sprite.FrameIndex == 1) { sprite.PlayAnimation(AniSwitch(RStand, LStand)); actionState = Action_State.stand; } } else if (sprite.Animation == RRRun_RStance || sprite.Animation == RLRun_RStance || sprite.Animation == LRRun_LStance || sprite.Animation == LLRun_LStance) { if (sprite.FrameIndex == 2) { if (sprite.Animation == RRRun_RStance) { sprite.PlayAnimation(RStance); nextStep = Next_Step.left; } else if (sprite.Animation == RLRun_RStance) { sprite.PlayAnimation(RStance); nextStep = Next_Step.right; } else if (sprite.Animation == LRRun_LStance) { sprite.PlayAnimation(LStance); nextStep = Next_Step.left; } else if (sprite.Animation == LLRun_LStance) { sprite.PlayAnimation(LStance); nextStep = Next_Step.right; } } } else if (sprite.Animation == RStance_LStance || sprite.Animation == LStance_RStance) { if (sprite.FrameIndex == 2) { sprite.PlayAnimation(AniSwitch(LStance, RStance)); } } else { sprite.PlayAnimation(AniSwitch(RStance_RStand, LStance_LStand)); } break; case Action_State.run: if (sprite.Animation == RRRun_RLRun || sprite.Animation == RLRun_RRRun || sprite.Animation == LRRun_LLRun || sprite.Animation == LLRun_LRRun) { if (sprite.FrameIndex == 3) { if (keyPress.key_Right >= 1) { if (keyPress.key_Z >= 1) { if (sprite.Animation == RRRun_RLRun) { sprite.PlayAnimation(RLRun_RRRun); nextStep = Next_Step.right; } else if (sprite.Animation == RLRun_RRRun) { sprite.PlayAnimation(RRRun_RLRun); nextStep = Next_Step.left; } else { sprite.PlayAnimation(AniSwitch(AniSwitchStep(RRRun_RStance, RLRun_RStance), AniSwitchStep(LRRun_LStance, LLRun_LStance))); } } else { if (sprite.Animation == RRRun_RLRun) { sprite.PlayAnimation(RLRun_RRStep); nextStep = Next_Step.right; } else if (sprite.Animation == RLRun_RRRun) { sprite.PlayAnimation(RRRun_RLStep); nextStep = Next_Step.left; } else { sprite.PlayAnimation(AniSwitch(AniSwitchStep(RRRun_RStance, RLRun_RStance), AniSwitchStep(LRRun_LStance, LLRun_LStance))); } } } else if (keyPress.key_Left >= 1) { if (keyPress.key_Z >= 1) { if (sprite.Animation == LRRun_LLRun) { sprite.PlayAnimation(LLRun_LRRun); nextStep = Next_Step.right; } else if (sprite.Animation == LLRun_LRRun) { sprite.PlayAnimation(LRRun_LLRun); nextStep = Next_Step.left; } else { sprite.PlayAnimation(AniSwitch(AniSwitchStep(RRRun_RStance, RLRun_RStance), AniSwitchStep(LRRun_LStance, LLRun_LStance))); } } else { if (sprite.Animation == LRRun_LLRun) { sprite.PlayAnimation(LLRun_LRStep); nextStep = Next_Step.right; } else if (sprite.Animation == LLRun_LRRun) { sprite.PlayAnimation(LRRun_LLStep); nextStep = Next_Step.left; } else { sprite.PlayAnimation(AniSwitch(AniSwitchStep(RRRun_RStance, RLRun_RStance), AniSwitchStep(LRRun_LStance, LLRun_LStance))); } } } else { sprite.PlayAnimation(AniSwitch(AniSwitchStep(RRRun_RStance, RLRun_RStance), AniSwitchStep(LRRun_LStance, LLRun_LStance))); } } } else if (sprite.Animation == RRRun_RStance || sprite.Animation == RLRun_RStance || sprite.Animation == LRRun_LStance || sprite.Animation == LLRun_LStance) { if (sprite.FrameIndex == 2) { if (sprite.Animation == RRRun_RStance || sprite.Animation == LRRun_LStance) { nextStep = Next_Step.left; sprite.PlayAnimation(AniSwitch(RStance, LStance)); actionState = Action_State.stance; } else if (sprite.Animation == RLRun_RStance || sprite.Animation == LLRun_LStance) { nextStep = Next_Step.right; sprite.PlayAnimation(AniSwitch(RStance, LStance)); actionState = Action_State.stance; } } } else if (sprite.Animation == RRRun_RLStep || sprite.Animation == RLRun_RRStep || sprite.Animation == LRRun_LLStep || sprite.Animation == LLRun_LRStep) { if (sprite.FrameIndex == 3) { sprite.PlayAnimation(AniSwitch(AniSwitchStep(RRStep_RLStep, RLStep_RRStep), AniSwitchStep(LRStep_LLStep, LLStep_LRStep))); actionState = Action_State.walk; } } else { if (sprite.FrameIndex == 3) { sprite.PlayAnimation(AniSwitch(AniSwitchStep(RRRun_RStance, RLRun_RStance), AniSwitchStep(LRRun_LStance, LLRun_LStance))); } } break; } }
public Player(Game game, GraphicsDeviceManager graphics) : base(game) { this.game = game; position = new Vector2(400, 410); actionState = Action_State.stand; facingDirection = Facing_Direction.right; nextStep = Next_Step.right; scarfPosition = position - new Vector2(0, -180); scarf = new Scarf(game, position); setCanMove(true,true); }