private async Task Reset() { rigidbodyElement.IsKinematic = true; //sto motion and set kinematic (listen to our transform changes) rigidbodyElement.IsTrigger = true; //set as ghost (bullets will go thru) Entity.Transform.Position.Y = enemyInitPositionY; var random = enemyRandomLocal; // Appearance position Entity.Transform.Position.X = (((float)(random.NextDouble())) * gameWidthX) - gameWidthHalfX; // Waiting time enemyLife = enemyLifeBase + (enemyLifeBase * (float)random.NextDouble()); Entity.Transform.UpdateWorldMatrix(); rigidbodyElement.UpdatePhysicsTransformation(); if (playingAnimation == null || playingAnimation.Name != "Wait") { playingAnimation = animationComponent.Play("Wait"); } await Script.NextFrame(); rigidbodyElement.IsKinematic = false; rigidbodyElement.IsTrigger = false; rigidbodyElement.Activate(); }
public void Explode() { rigidbodyElement.IsKinematic = true; rigidbodyElement.IsTrigger = true; if (playingAnimation == null || playingAnimation.Name != "Dead") { playingAnimation = animationComponent.Play("Dead"); } exploding = WaitMs(1500); }
private AnimationOperation CreatePushOperation(PlayingAnimation playingAnimation) { return(AnimationOperation.NewPush(playingAnimation.Evaluator, playingAnimation.CurrentTime)); }
/// <summary> /// Plays right away the animation with the specified name, instantly removing all other blended animations. /// </summary> /// <param name="name">The animation name.</param> public PlayingAnimation Play(string name) { PlayingAnimations.Clear(); var playingAnimation = new PlayingAnimation(name, Animations[name]) { CurrentTime = TimeSpan.Zero, Weight = 1.0f }; PlayingAnimations.Add(playingAnimation); return playingAnimation; }
/// <summary> /// Blends progressively a new animation. /// </summary> /// <param name="name">The name.</param> /// <param name="desiredWeight">The desired weight.</param> /// <param name="fadeTimeSpan">The fade time span.</param> /// <exception cref="ArgumentException">name</exception> public PlayingAnimation Blend(string name, float desiredWeight, TimeSpan fadeTimeSpan) { if (!Animations.ContainsKey(name)) throw new ArgumentException("name"); var playingAnimation = new PlayingAnimation(name, Animations[name]) { CurrentTime = TimeSpan.Zero, Weight = 0.0f }; PlayingAnimations.Add(playingAnimation); if (fadeTimeSpan > TimeSpan.Zero) { playingAnimation.WeightTarget = desiredWeight; playingAnimation.RemainingTime = fadeTimeSpan; } else { playingAnimation.Weight = desiredWeight; } return playingAnimation; }
/// <summary> /// Helper function for playing animation given AgentAnimationKey. /// </summary> /// <param name="key"></param> private void PlayAnimation(AgentAnimationKeys key) { var animationComponent = Entity.Get<AnimationComponent>(); animationComponent.Play(key.ToString()); playingAnimation = animationComponent.PlayingAnimations[0]; }