/// Runs every "frame" while the simulation is not paused public void Update(float deltaTime) { Update_DoJob(deltaTime); Update_DoMovement(deltaTime); if (cbCharacterChanged != null) { cbCharacterChanged(this); } animation.Update(deltaTime); }
private void updateAnimations(float deltaTime) { float baseAnimSpeed = 1; //float topAnimSpeed = 1; timer += deltaTime; if (baseAnim.Type == ChaAnimType.CAT_JUMP_START) { if (timer >= baseAnim.AnimationState.Length) { // takeoff animation finished, so time to leave the ground! SetBaseAnimation(anims.Where(o => o.Type == ChaAnimType.CAT_JUMP_LOOP).First(), true); // apply a jump acceleration to the character verticalVelocity = JUMP_ACCEL; } } else if (baseAnim.Type == ChaAnimType.CAT_JUMP_END) { if (timer >= baseAnim.AnimationState.Length) { // safely landed, so go back to running or idling if (keyDirection == Mogre.Vector3.ZERO) { SetBaseAnimation(anims.Where(o => o.Type == ChaAnimType.CAT_IDLE_BASE).First()); SetTopAnimation(anims.Where(o => o.Type == ChaAnimType.CAT_IDLE_TOP).First()); } else { SetBaseAnimation(anims.Where(o => o.Type == ChaAnimType.CAT_RUN_BASE).First(), true); SetTopAnimation(anims.Where(o => o.Type == ChaAnimType.CAT_RUN_TOP).First(), true); } } } // increment the current base and top animation times if (baseAnim.Type != ChaAnimType.CAT_NONE) { baseAnim.Update(deltaTime * baseAnimSpeed); } if (topAnim.Type != ChaAnimType.CAT_NONE) { topAnim.Update(deltaTime * baseAnimSpeed); } // apply smooth transitioning between our animations fadeAnimations(deltaTime); }