Axiom.Samples.CharacterSample.SinbadCharacterController.UpdateAnimations C# (CSharp) Метод

UpdateAnimations() приватный Метод

private UpdateAnimations ( Real deltaTime ) : void
deltaTime Real
Результат void
		private void UpdateAnimations( Real deltaTime )
		{
			Real baseAnimSpeed = 1;
			Real topAnimSpeed = 1;

			timer += deltaTime;

			if ( topAnimID == AnimationID.DrawSword )
			{
				// flip the draw swords animation if we need to put it back
				topAnimSpeed = swordsDrawn ? -1 : 1;

				// half-way through the animation is when the hand grasps the handles...
				if ( timer >= anims[ (int)topAnimID ].Length / 2 &&
					 timer - deltaTime < anims[ (int)topAnimID ].Length / 2 )
				{
					// toggle sword trails
					swordTrail.IsVisible = !swordsDrawn;

					// so transfer the swords from the sheaths to the hands
					if ( swordsDrawn )
					{
						swordTrail.RemoveNode( sword1.ParentNode );
						swordTrail.RemoveNode( sword2.ParentNode );
					}
					bodyEnt.DetachAllObjectsFromBone();
					bodyEnt.AttachObjectToBone( swordsDrawn ? "Sheath.L" : "Handle.L", sword1 );
					bodyEnt.AttachObjectToBone( swordsDrawn ? "Sheath.R" : "Handle.R", sword2 );

					if ( !swordsDrawn )
					{
						swordTrail.AddNode( sword1.ParentNode );
						swordTrail.AddNode( sword2.ParentNode );
					}
					// change the hand state to grab or let go
					anims[ (int)AnimationID.HandsClosed ].IsEnabled = !swordsDrawn;
					anims[ (int)AnimationID.HandsRelaxed ].IsEnabled = swordsDrawn;

				}//end if

				if ( timer >= anims[ (int)topAnimID ].Length )
				{
					// animation is finished, so return to what we were doing before
					if ( baseAnimID == AnimationID.IdleBase )
						SetTopAnimation( AnimationID.IdleTop );
					else
					{
						SetTopAnimation( AnimationID.RunTop );
						anims[ (int)AnimationID.RunTop ].Time = anims[ (int)AnimationID.RunBase ].Time;
					}

					swordsDrawn = !swordsDrawn;
				}//end if
			}//end if
			else if ( topAnimID == AnimationID.SliceVertical || topAnimID == AnimationID.SliceHorizontal )
			{
				if ( timer >= anims[ (int)topAnimID ].Length )
				{
					// animation is finished, so return to what we were doing before
					if ( baseAnimID == AnimationID.IdleBase )
						SetTopAnimation( AnimationID.IdleTop );
					else
					{
						SetTopAnimation( AnimationID.RunTop );
						anims[ (int)AnimationID.RunTop ].Time = anims[ (int)AnimationID.RunBase ].Time;
					}
				}
				// don't sway hips from side to side when slicing. that's just embarrasing.
				if ( baseAnimID == AnimationID.IdleBase )
					baseAnimSpeed = 0;
			}//end else if
			else if ( baseAnimID == AnimationID.JumpStart )
			{
				if ( timer >= anims[ (int)baseAnimID ].Length )
				{
					// takeoff animation finished, so time to leave the ground!
					SetBaseAnimation( AnimationID.JumpLoop, true );
					// apply a jump acceleration to the character
					verticalVelocity = JumpAcceleration;
				}
			}//end if
			else if ( baseAnimID == AnimationID.JumpEnd )
			{
				if ( timer >= anims[ (int)baseAnimID ].Length )
				{
					// safely landed, so go back to running or idling
					if ( keyDirection == Vector3.Zero )
					{
						SetBaseAnimation( AnimationID.IdleBase );
						SetTopAnimation( AnimationID.IdleTop );
					}
					else
					{
						SetBaseAnimation( AnimationID.RunBase, true );
						SetTopAnimation( AnimationID.RunTop, true );
					}
				}
			}

			// increment the current base and top animation times
			if ( baseAnimID != AnimationID.None )
				anims[ (int)baseAnimID ].AddTime( deltaTime * baseAnimSpeed );
			if ( topAnimID != AnimationID.None )
				anims[ (int)topAnimID ].AddTime( deltaTime * topAnimSpeed );

			// apply smooth transitioning between our animations
			FadeAnimations( deltaTime );
		}