public override void StartAnimation(IAnimationManager animationManager) { base.StartAnimation(animationManager); targetUnit.UnitGraphics.costGraphics.Refresh(); PlayClip(chime); Invoke("EndAnimation", 1f); }
public static AnimationUpdateResult Update(this IAnimationManager manager, AnimationSeconds timeNow) { AnimationUpdateResult result; manager.TryUpdate(timeNow, out result).ThrowIfError(); return(result); }
protected virtual void PlayAnimation( IEquipmentHolder holder, Equipment equipment, Option <Node> dropTo, Godot.Animation animation, IAnimationManager animationManager, InteractionContext context) { animationManager.OnAnimationEvent .OfType <TriggerEvent>() .Where(e => e.Name == "Action" && e.Argument.Contains(Key)) .Take(1) .TakeUntil(Disposed.Where(identity)) .Subscribe(_ => Unequip(holder, equipment, dropTo, context), this); if (animationManager is IAnimationStateManager stateManager && AnimatorPath.IsSome && StatesPath.IsSome) { ( from animator in AnimatorPath.Bind(stateManager.FindAnimator) from states in StatesPath.Bind(stateManager.FindStates) from state in ActionState select(animator, states, state)).Iter(t => { t.animator.Animation = animation; t.states.Playback.Travel(t.state); }); }
/// Update all held animations public void Update(float delta, IAnimationManager <TStream> manager) { foreach (KeyValuePair <TStream, AnimationStream> entry in _streams) { entry.Value.Update(delta, manager); } }
public override void StartAnimation(IAnimationManager animationManager) { base.StartAnimation(animationManager); // Start all animations animations.ForEach(animation => animation.StartAnimation(this)); animationsPlaying = animations.Count; }
/// <include file="../../docs/Microsoft.Maui.Controls/AnimationExtensions.xml" path="//Member[@MemberName='Remove']/Docs" /> public static void Remove(this IAnimationManager animationManager, int tickerId) { var animation = s_tweeners[tickerId]; s_tweeners.Remove(tickerId); animationManager.Remove(animation); }
protected override Validation <string, Humanoid> CreateService( string key, string displayName, MorphableRace race, IEnumerable <IAttribute> attributes, IPairedEyeSight vision, ILocomotion locomotion, Skeleton skeleton, IActionSet actions, IAnimationManager animationManager, KinematicBody node, ILoggerFactory loggerFactory) { return(new Humanoid( key, displayName, race, Sex, attributes, vision, locomotion, skeleton, animationManager, actions, Optional(Markers).Flatten(), node, loggerFactory)); }
public static IAnimationStoryboard CreateStoryboard(this IAnimationManager manager) { IAnimationStoryboard storyboard; manager.TryCreateStoryboard(out storyboard).ThrowIfError(); return(storyboard); }
public EntityHeadController(IAnimationManager animator, EntityAgent entity, Shape entityShape) { this.entity = entity; this.animManager = animator; HeadElement = entityShape.GetElementByName("head"); NeckElement = entityShape.GetElementByName("neck"); HeadGlobalMatrix = Mat4f.Create(); HeadGlobalMatrixInverted = Mat4f.Create(); HeadLocalMatrix = Mat4f.Create(); // Head List <ShapeElement> elems = HeadElement.GetParentPath(); for (int i = 0; i < elems.Count; i++) { ShapeElement elem = elems[i]; float[] localTransform = elem.GetLocalTransformMatrix(); Mat4f.Mul(HeadGlobalMatrix, HeadGlobalMatrix, localTransform); } Mat4f.Mul(HeadGlobalMatrix, HeadGlobalMatrix, HeadElement.GetLocalTransformMatrix()); Mat4f.Invert(HeadGlobalMatrixInverted, HeadGlobalMatrix); }
public BoneMorph( Skeleton skeleton, IAnimationManager manager, BoneMorphDefinition definition, ILoggerFactory loggerFactory) : base(definition, loggerFactory) { Ensure.That(skeleton, nameof(skeleton)).IsNotNull(); Ensure.That(manager, nameof(manager)).IsNotNull(); Skeleton = skeleton; AnimationManager = manager; int FindBone(string name) { var index = Skeleton.FindBone(name); if (index == -1) { throw new ArgumentOutOfRangeException( nameof(name), $"The morph '{Definition.Key}' contains a non-existent bone: '{name}'."); } return(index); } BoneIndexes = definition.Bones.Select(FindBone).Freeze(); if (!BoneIndexes.Any()) { throw new ArgumentOutOfRangeException( nameof(definition), $"The morph '{Definition.Key}' does not have any target bones."); } }
public static IAnimationVariable CreateAnimationVariable(this IAnimationManager manager, double initialValue) { IAnimationVariable variable; manager.TryCreateAnimationVariable(initialValue, out variable).ThrowIfError(); return(variable); }
public static IAnimationStoryboard GetStoryboardFromTag(this IAnimationManager manager, object tag) { IAnimationStoryboard storyboard; manager.TryGetStoryboardFromTag(tag, out storyboard).ThrowIfError(); return(storyboard); }
public static IAnimationVariable GetVariableFromTag(this IAnimationManager manager, object tag) { IAnimationVariable variable; manager.TryGetVariableFromTag(tag, out variable).ThrowIfError(); return(variable); }
/// <summary> /// Initializes the root object. /// </summary> /// <param name="serviceProvider"> /// IServiceProvider used to locate the IGraphicsDeviceService implementation. /// </param> public void Initialize(IServiceProvider serviceProvider) { try { //Save the service provider. Services = serviceProvider; //Get the graphics device from the service provider. IGraphicsDeviceService service = Services.GetService(typeof(IGraphicsDeviceService)) as IGraphicsDeviceService; if (service == null) { string msg = "could not locate the IGraphicsDeviceService implementation."; throw new NullReferenceException(msg); } //Get the graphics device from the graphics device service. mGraphicsDevice = service.GraphicsDevice; //Create the default content manager. mDefaultContentManager = new ContentManager(serviceProvider, "Content"); //Create all the other core plug-ins. mSceneManager = new DefaultSceneManager(this, "sceneManager"); mPostProcessManager = new DefaultPostProcessManager(this, "postProcessManager"); mRenderer = new DeferredRenderer(this, "deferred_renderer"); mPhysicsManager = new JigLibXPhysicsManager(this, "physicsManager"); mEntityManager = new DefaultEntityManager(this, "entityManager"); mAnimationManager = new DefaultAnimationManager(this, "animationManager"); mGuiManager = new DefaultGuiManager(this, "guiManager"); //Update the physics before updating the scene so that the physics objects //(which are nodes) can update their positions based on the physics world. mPhysicsManager.UpdateOrder = 0; mSceneManager.UpdateOrder = 1; mRenderer.Layer = 0; //Add all the core plug-ins to the plug-ins dictionary. AddPlugin(mSceneManager); AddPlugin(mPostProcessManager); AddPlugin(mRenderer); AddPlugin(mPhysicsManager); AddPlugin(mEntityManager); AddPlugin(mAnimationManager); AddPlugin(mGuiManager); //Initialize all the plugins. foreach (KeyValuePair <string, IPlugin> kvp in mPlugins) { kvp.Value.Initialize(); } mInitialized = true; } catch (Exception e) { throw new Exception("Root.Initialize(): " + e.Message); } }
public Tweener(uint length, uint rate, IAnimationManager animationManager) { Value = 0.0f; Length = length; Rate = rate; this.animationManager = animationManager; Loop = false; }
public override void StartAnimation(IAnimationManager animationManager) { base.StartAnimation(animationManager); PlayClip(healAudio); healEffect.transform.position = targetUnit.transform.position; healEffect.Play(); Invoke("EndAnimation", 1f); }
public override void StartAnimation(IAnimationManager animationManager) { base.StartAnimation(animationManager); int round = game.round + 1; MainText.Show("Round " + round, game.GetPlayerForRound(round).playerName, 2f); Invoke("EndAnimation", 2f); }
/// <summary> /// Initializes the cache to the Animation Manager then spits it back out. /// </summary> /// <param name="api"></param> /// <param name="manager"></param> /// <param name="entity"></param> /// <param name="entityShape"></param> /// <param name="requireJointsForElements"></param> /// <returns></returns> public static IAnimationManager InitManager(ICoreAPI api, IAnimationManager manager, Entity entity, Shape entityShape, params string[] requireJointsForElements) { if (entityShape == null) { return(new NoAnimationManager()); } string dictKey = entity.Code + "-" + entity.Properties.Client.ShapeForEntity.Base.ToString(); object animCacheObj; Dictionary <string, AnimCacheEntry> animCache; entity.Api.ObjectCache.TryGetValue("animCache", out animCacheObj); animCache = animCacheObj as Dictionary <string, AnimCacheEntry>; if (animCache == null) { entity.Api.ObjectCache["animCache"] = animCache = new Dictionary <string, AnimCacheEntry>(); } IAnimator animator; AnimCacheEntry cacheObj; if (animCache.TryGetValue(dictKey, out cacheObj)) { manager.Init(entity.Api, entity); animator = api.Side == EnumAppSide.Client ? ClientAnimator.CreateForEntity(entity, cacheObj.RootPoses, cacheObj.Animations, cacheObj.RootElems, entityShape.JointsById) : ServerAnimator.CreateForEntity(entity, cacheObj.RootPoses, cacheObj.Animations, cacheObj.RootElems, entityShape.JointsById) ; manager.Animator = animator; } else { entityShape.ResolveAndLoadJoints(requireJointsForElements); manager.Init(entity.Api, entity); IAnimator animatorbase = api.Side == EnumAppSide.Client ? ClientAnimator.CreateForEntity(entity, entityShape.Animations, entityShape.Elements, entityShape.JointsById) : ServerAnimator.CreateForEntity(entity, entityShape.Animations, entityShape.Elements, entityShape.JointsById) ; manager.Animator = animatorbase; animCache[dictKey] = new AnimCacheEntry() { Animations = entityShape.Animations, RootElems = (animatorbase as ClientAnimator).rootElements, RootPoses = (animatorbase as ClientAnimator).RootPoses }; } return(manager); }
public override void StartAnimation(IAnimationManager animationManager) { base.StartAnimation(animationManager); host = transform.parent.GetComponentInParent <Unit>(); puff.transform.position += Vector3.up * 0.2f; puff.Play(); PlayClip(death); Invoke("RemoveVisuals", 0.2f); Invoke("EndAnimation", 1.5f); }
public ValueChangeEvent(string name, float value, IAnimationManager source) { Ensure.That(name, nameof(name)).IsNotNull(); Ensure.That(source, nameof(source)).IsNotNull(); Name = name; Value = value; Source = source; _path = new Lazy <IEnumerable <string> >(() => name.Split('.')); }
public TriggerEvent(string name, Option <object> argument, IAnimationManager source) { Ensure.That(name, nameof(name)).IsNotNull(); Ensure.That(source, nameof(source)).IsNotNull(); Name = name; Argument = argument; Source = source; _path = new Lazy <IEnumerable <string> >(() => name.Split('.')); }
public static IAnimation AddAnimation( IBone[] bones, IAnimationManager animationManager, IDcx dcx) { var isDck = dcx is Dck; var dcxAnimationData = dcx.AnimationData; var animation = animationManager.AddAnimation(); animation.Name = dcx.Name; animation.FrameCount = (int)dcxAnimationData.FrameCount; animation.FrameRate = 30; foreach (var jointData in dcxAnimationData.JointDataList) { var jointIndex = jointData.JointIndex; var jointKeyframes = animation.AddBoneTracks(bones[jointIndex]); Keyframe <float>[][] frames; frames = DcxHelpers.ReadKeyframes_( isDck, dcxAnimationData, jointData.ScaleAxes, dcxAnimationData.ScaleValues); DcxHelpers.MergeKeyframesToScaleTrack( frames, jointKeyframes.Scales); frames = DcxHelpers.ReadKeyframes_( isDck, dcxAnimationData, jointData.RotationAxes, dcxAnimationData.RotationValues); DcxHelpers.MergeKeyframesToRotationTrack( frames, jointKeyframes.Rotations); frames = DcxHelpers.ReadKeyframes_( isDck, dcxAnimationData, jointData.PositionAxes, dcxAnimationData.PositionValues); DcxHelpers.MergeKeyframesToPositionTrack( frames, jointKeyframes.Positions); animation.AddBoneTracks(bones[jointIndex]).Set(jointKeyframes); } return(animation); }
void Start() { Instance = this; _rigidbody = Player.GetComponent <Rigidbody>(); _walkForce = _rigidbody.mass * 500; _jumpImpulse = _rigidbody.mass * 5f; if (PlayerAnimator != null) { AnimationManager = AnimationManagerBase.CreateOrGet(PlayerAnimator.gameObject); } }
protected abstract Validation <string, TCharacter> CreateService( string key, string displayName, TRace race, IEnumerable <IAttribute> attributes, TVision vision, TLocomotion locomotion, Skeleton skeleton, IActionSet actions, IAnimationManager animationManager, KinematicBody node, ILoggerFactory loggerFactory);
public void Initialize( FrameworkElement initialContent, ContentControl frame = null, IAnimationManager animationManager = null) { _frame = frame; _animationManager = animationManager; var content = initialContent; _stack.Push(content); }
private void Form1_Load(object sender, EventArgs e) { //in a real app will be injected _manager = new AnimationManager(numberOfParticles: 2, numberOfIterations: 20, roomWidth: ClientSize.Width, roomHeight: ClientSize.Height); // Use double buffering to reduce flicker. SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true); UpdateStyles(); }
/// <summary> /// Returns the current frame for the given animation, using a layer of /// indirection to support hot reloading. /// </summary> public AssetNames GetCurrentFrame(IAnimationManager manager) { var template = manager.Get(Name); if (template.StepAfter == 0 || template.Frames.Length == 1) { return(template.Frames[0]); } var frameCount = TickCounter / template.StepAfter; var frameIx = frameCount % template.Frames.Length; return(template.Frames[frameIx]); }
public static int Insert(this IAnimationManager animationManager, Func <long, bool> step) { var id = s_currentTweener++; Animation animation = null; animation = new TweenerAnimation(step) { Name = $"{id}", Easing = Easing.Linear, }; s_tweeners[id] = animation; animation.Commit(animationManager); return(id); }
public static int Add(this IAnimationManager animationManager, Action <double> step) { var id = s_currentTweener++; var animation = new Animation { Name = $"{id}", Easing = Easing.Linear, Step = step }; s_tweeners[id] = animation; animation.Commit(animationManager); return(id); }
public BoneMorph( [NotNull] Skeleton skeleton, [NotNull] IAnimationManager manager, [NotNull] BoneMorphDefinition definition) : base(definition) { Ensure.Any.IsNotNull(skeleton, nameof(skeleton)); Ensure.Any.IsNotNull(manager, nameof(manager)); Skeleton = skeleton; AnimationManager = manager; BoneIndexes = definition.Bones.Select(FindBone).ToList(); _disposable = AnimationManager.OnAdvance.Subscribe(_ => Apply()); }