void Update() { #if OPEN_DEBUG_MODE if (Input.GetKeyDown(KeyCode.PageDown)) { OnSceneEnd(); } #endif if (isParaOver) { bool showNext = false; if (isPageOver) { if (STBInput.GetButtonDown("Next") || STBInput.GetButtonDown("Skip")) { SoundManager.instance.PlayUiEfx(UiEfx.TEXT); showNext = true; isPageOver = false; pageEndMark.Hide(); storyBoard.ClearAll(); } } else { if (STBInput.GetButtonDown("Next") || STBInput.GetButton("Skip")) { SoundManager.instance.PlayUiEfx(UiEfx.TEXT); showNext = true; paraEndMark.Hide(); } } if (showNext) { isParaOver = false; if (currentPara < currentStory.Length) { StartCoroutine(ShowPara()); } else { storyBoard.ClearAll(); OnSceneEnd(); } } } }
void LateUpdate() { //Movement Vector3 movement = Vector3.zero; float horInput = STBInput.GetAxis("HorizontalMove"); float verInput = STBInput.GetAxis("VerticalMove"); Matrix4x4 rotCamera = Matrix4x4.Rotate(Quaternion.Euler(0f, Camera.main.transform.eulerAngles.y, 0f)); if (horInput != 0 || verInput != 0) { movement.x = horInput * moveSpeed; movement.z = verInput * moveSpeed; movement = Vector3.ClampMagnitude(movement, moveSpeed); if (GameManager.IsDirectionAdjustOn) { float angle = Camera.main.AdjustAngle(transform.position, movement); Matrix4x4 adjust = Matrix4x4.Rotate(Quaternion.Euler(0f, angle, 0f)); movement = adjust * movement; } movement = rotCamera * movement; } if (GameCursor.isActivated) { Vector3 rotation = GameCursor.GetPosition() - transform.position; rotation.y = 0f; if (rotation != Vector3.zero) { Quaternion direction = Quaternion.LookRotation(rotation); transform.rotation = Quaternion.Lerp(transform.rotation, direction, rotSpeed * Time.deltaTime); } } else { float horRotInput = STBInput.GetAxis("HorizontalRotate"); float verRotInput = STBInput.GetAxis("VerticalRotate"); if (horRotInput != 0 || verRotInput != 0) { Vector3 lookDir = new Vector3(horRotInput, 0f, verRotInput); if (GameManager.IsDirectionAdjustOn) { float angle = Camera.main.AdjustAngle(transform.position, lookDir); Matrix4x4 adjust = Matrix4x4.Rotate(Quaternion.Euler(0f, angle, 0f)); lookDir = adjust * lookDir; } lookDir = rotCamera * lookDir; Quaternion direction = Quaternion.LookRotation(lookDir); transform.rotation = Quaternion.Lerp(transform.rotation, direction, rotSpeed * Time.deltaTime); } else if (movement.magnitude != 0f) { Quaternion direction = Quaternion.LookRotation(movement); transform.rotation = Quaternion.Lerp(transform.rotation, direction, rotSpeed * Time.deltaTime); } } flame.CheckSpeed(movement); if (!charaController.isGrounded) { charaController.Move(new Vector3(0f, -9.8f, 0f) * Time.deltaTime); } movement *= Time.deltaTime; if (IsMovable) { charaController.Move(movement); } //Wingmen if (wingmen.Count != 0) { for (int i = wingmen.Count - 1; i >= 0; i--) { if (wingmen[i] == null) { wingmen.RemoveAt(i); } } } //Attack if (IsArmed) { timeFireRecharge += Time.deltaTime; if (STBInput.GetButton("Fire")) { if (timeFireRecharge > fireGap) { Fire(); } } else { timeFireRecharge = Mathf.Clamp(timeFireRecharge, 0f, fireGap); } } }
IEnumerator ShowPara() { StoryPara para = currentStory[currentPara]; if (!para.IsTag) { storyBoard.AddText(para.x, para.y); currentChar = 0; float time = 0f; float efxTime = 0f; bool isSpeedUp = false; while (currentChar < para.Length) { yield return(null); if (STBInput.GetButtonDown("Next")) { isSpeedUp = true; } if (STBInput.GetButtonUp("Next")) { isSpeedUp = false; } if (STBInput.GetButton("Skip")) { currentChar = para.Length - 1; } time += Time.deltaTime * (isSpeedUp ? 5f : 1f); efxTime += Time.deltaTime; if (time > TEXT_GAP) { currentChar++; if (efxTime >= TEXT_GAP) { SoundManager.instance.PlayUiEfx(UiEfx.TEXT); while (efxTime >= TEXT_GAP) { efxTime -= TEXT_GAP; } } storyBoard.SetText(para.Substring(currentChar)); if (para.GetChar(currentChar - 1).Equals('\n')) { time -= TEXT_GAP * 5f; } else { time -= TEXT_GAP; } } } isParaOver = true; paraEndMark.Set(GetActPos(storyBoard.GetEndPosition())); currentPara++; para = currentStory[currentPara]; } if (para.IsTag) { currentPara++; if (para.IsBgmPlay) { SoundManager.instance.PlayBgm(bgm, 2f); } if (para.IsBgmStop) { SoundManager.instance.StopBgm(1f); } if (para.IsPageEnd) { paraEndMark.Hide(); pageEndMark.Set(); isPageOver = true; yield break; } if (para.IsClipEnd) { OnSceneEnd(); yield break; } if (!isParaOver) { StartCoroutine(ShowPara()); } } }