//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * New Method: Begin Decrement Animation //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ public void BeginDecrementAnimation(string score) { m_eAnimationPhase = AnimationPhase.DECREMENT; m_iCurrentAnimation = 0; m_sScoreText = score; }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * New Method: Update Wait Time //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private void UpdateWaitTime() { if (m_ttWaitTimer.Update()) { m_ttWaitTimer.Reset(); m_eAnimationPhase = AnimationPhase.START; } }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * New Method: Update Start Animation //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ protected virtual void UpdateStartAnimation() { if (m_aeStartAnimation.UpdateAnimation()) { m_aeStartAnimation.Reset(); m_eAnimationPhase = AnimationPhase.LOOPING; } }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * New Method: Update Start Animation //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private void UpdateStartAnimation() { if (m_aeStartAnimation.UpdateAnimation()) { m_aeStartAnimation.Reset(); m_eAnimationPhase = AnimationPhase.LOOPING; } }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * New Method: Update End Animation //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private void UpdateEndAnimation() { if (m_aeEndAnimation.UpdateAnimation()) { m_aeEndAnimation.Reset(); m_eAnimationPhase = AnimationPhase.WAIT; } }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * New Method: Update End Animation //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ protected virtual void UpdateEndAnimation() { if (m_aeEndAnimation.UpdateAnimation()) { m_aeEndAnimation.Reset(); m_eAnimationPhase = AnimationPhase.WAIT; OnAnimationEnd(); } }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * New Method: Update Wait Time //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ protected virtual void UpdateWaitTime() { if (m_ttWaitTimer.Update()) { m_ttWaitTimer.Reset(); if (IsAllowedToAnimate()) { m_eAnimationPhase = AnimationPhase.START; OnAnimationStart(); } } }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * New Method: Stop Animation //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ public virtual void StopAnimation() { for (int i = 0; i < m_aaeLoopedAnimationCycle.Length; ++i) { m_aaeLoopedAnimationCycle [i].Reset(); } m_aeStartAnimation.Reset(); m_aeEndAnimation.Reset(); m_aeEndAnimation.ShowLastFrame(); m_eAnimationPhase = AnimationPhase.STOPPED; }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * New Method: Update Decrement Animation //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private void UpdateDecrementAnimation() { if (m_arDecrementAnimation[m_iCurrentAnimation].UpdateAnimation()) { m_arDecrementAnimation[m_iCurrentAnimation].Reset(); m_iCurrentAnimation += 1; // Update Score! if (m_rUIText != null && m_iCurrentAnimation == 1) // On Wait Animation? { m_rUIText.text = m_sScoreText; } if (m_iCurrentAnimation >= m_arDecrementAnimation.Length) { m_eAnimationPhase = AnimationPhase.IDLE; } } }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * Derived Method: Start //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void Start() { // Setup Everything necessary and deactivate player input m_eAnimationPhase = AnimationPhase.LOAD_PRELOADED_SPRITES; SetupTimeTrackers(); SetupAnimations(); ButtonManager.ToggleAllButtonsExcept(ButtonManager.ButtonType.SETTINGS, false); // Deactivate everything associated with the title screen intro except the first thing to be displayed... The Cultural Infusion Logo. We shall reactivate everything one by one as they are needed m_srCulturalInfusionLogo.gameObject.SetActive(true); m_srBackgroundSpriteRenderer.gameObject.SetActive(false); m_goJokosWorld.SetActive(false); m_goGameTitle.SetActive(false); m_goJokosDance.SetActive(false); m_goPlayButton.SetActive(false); m_goCreditsButton.SetActive(false); GetComponent <AudioSource>().Play(); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * New Method: Proceed To Next Phase //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ public void ProceedToNextPhase() { m_eAnimationPhase += 1; switch (m_eAnimationPhase) { case AnimationPhase.LANDSCAPE_WAIT: { m_srBackgroundSpriteRenderer.gameObject.SetActive(true); m_srCulturalInfusionLogo.gameObject.SetActive(false); m_aLandscapeAnimation[0].SetPosition(0.0f); break; } case AnimationPhase.JOKOS_WORLD_INTRO: { m_goJokosWorld.SetActive(true); break; } case AnimationPhase.GAME_TITLE_INTRO: { m_goGameTitle.SetActive(true); break; } case AnimationPhase.JOKOS_DANCE_INTRO: { m_goJokosDance.SetActive(true); ProceedToNextPhase(); break; } case AnimationPhase.PLAYBUTTON_INTRO: { m_goCreditsButton.SetActive(true); m_goPlayButton.SetActive(true); break; } case AnimationPhase.GAME_ACTIVATION: { ActivateGame(); break; } default: { break; } } }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * Derived Method: Start //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void Start() { // Hide if full version if (GameManager.IsFullVersion) { this.gameObject.SetActive(false); m_eAnimationPhase = AnimationPhase.WAIT; } // Otherwise setup Animation sequences else { m_ttWaitTimer = new TimeTracker(m_fWaitTimeBetweenRepeats); m_aeStartAnimation.Setup(this.transform); m_aeEndAnimation.Setup(this.transform); for (int i = 0; i < m_aaeLoopedAnimationCycle.Length; ++i) { m_aaeLoopedAnimationCycle[i].Setup(this.transform); } } }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * New Method: Update Looped Animation //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ protected virtual void UpdateLoopedAnimation() { if (m_aaeLoopedAnimationCycle[m_iCurrentAnimationIndex].UpdateAnimation()) { m_aaeLoopedAnimationCycle[m_iCurrentAnimationIndex].Reset(); // If finished this animation frame, move on to next. If no more animation frames remain... reset back to first. m_iCurrentAnimationIndex += 1; if (m_iCurrentAnimationIndex >= m_aaeLoopedAnimationCycle.Length) { m_iCurrentAnimationIndex = 0; // Increment loop count. We have just finished a loop after all. Should we exceed the loop limit. Move on to next animation phase. m_iCurrentLoopCount += 1; if (m_iCurrentLoopCount >= m_iLoopedAnimationCycleLoopCount) { m_iCurrentLoopCount = 0; m_eAnimationPhase = AnimationPhase.END; } } } }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * Derived Method: On Enabled //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void OnEnable() { m_eAnimationPhase = AnimationPhase.IDLE; m_arDecrementAnimation[0].ShowFirstFrame(); }
void SetAnimationPhase(AnimationPhase animationPhase) { switch (animationPhase) { case AnimationPhase.Run: characterMesh.animation.Play("WalkCycle"); break; case AnimationPhase.Jump: characterMesh.animation.Play("Jump"); break; case AnimationPhase.Slide: characterMesh.animation.Play("Slide"); break; case AnimationPhase.Fall: characterMesh.animation.Play("Fall"); break; case AnimationPhase.Rush: characterMesh.animation.Play("Rush"); break; case AnimationPhase.RushDown: characterMesh.animation.Play("DownJump"); break; case AnimationPhase.Die: characterMesh.animation.Play("Die"); break; case AnimationPhase.Idle: default: characterMesh.animation.Play("Idle"); break; } }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * New Method: Update Game Activation //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private void UpdateGameActivationWait() { m_eAnimationPhase = AnimationPhase.IDLE; }
// Update is called once per frame void Update() { if (!start) { return; } if (done) { return; } // Preparativos cameraPlayer.gameObject.SetActive(false); ConfigController.inCinematic = true; // Desactivamos el Aggro del Jefe GameObject aggroRange = boss.GetComponentInChildren <AggroRange>(true).gameObject; aggroRange.SetActive(false); HUD.SetActive(false); // Movemos al jugador a la posición player.SetActive(false); player.transform.position = playerPosition.transform.position; player.transform.rotation = new Quaternion(0, 180, 0, 0); player.SetActive(true); switch (aPhase) { case AnimationPhase.ANIMATION_PHASE_1: camera1.gameObject.SetActive(true); time -= Time.deltaTime; if (time < 0) { camera2.gameObject.SetActive(true); camera1.gameObject.SetActive(false); aPhase = AnimationPhase.ANIMATION_PHASE_2; time = fixedTime; } break; case AnimationPhase.ANIMATION_PHASE_2: time -= Time.deltaTime; if (time < 0) { camera3.gameObject.SetActive(true); camera2.gameObject.SetActive(false); aPhase = AnimationPhase.ANIMATION_PHASE_3; time = fixedTime; } break; case AnimationPhase.ANIMATION_PHASE_3: time -= Time.deltaTime; if (time < 0) { camera4.gameObject.SetActive(true); camera3.gameObject.SetActive(false); aPhase = AnimationPhase.ANIMATION_PHASE_4; time = fixedTime; } break; case AnimationPhase.ANIMATION_PHASE_4: time -= Time.deltaTime; if (time < 0) { camera4.gameObject.SetActive(false); aPhase = AnimationPhase.ANIMATION_PHASE_END; start = false; time = fixedTime; cameraPlayer.gameObject.SetActive(true); aggroRange.SetActive(true); ConfigController.inCinematic = false; HUD.SetActive(true); } break; default: break; } }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * New Method: Start Animation //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ public virtual void StartAnimation() { m_eAnimationPhase = AnimationPhase.START; }