private void DiedAnimationFinished(AnimationEventType type, string name) { GetComponent <AnimationTransform> ().Pause(); GetComponent <AnimationTransform> ().OnAnimationEvent -= DiedAnimationFinished; StartCoroutine(DiedStuffToDelay()); }
/// <summary> /// /// </summary> /// <param name="type"></param> /// <param name="param"></param> void SendEventToOwner(AnimationEventType type, string param) { if (eventCallback != null) { eventCallback(this, type, param); } }
private void am_Event(AnimationEventType pType) { if (pType == AnimationEventType.Stop) { this.needtoClose = true; } }
private void AnimationEventHappened(AnimationEventType type, string name) { // Debug.LogError ("look " + type); // // animationTransform.SetTrigger ("idle"); // animationTransform.SetTrigger ("walkLeft"); }
private void animationEditor1_Event(AnimationEventType pType) { switch (pType) { case AnimationEventType.ChangeEffect: { this.StopPreview(); this.animationMaker = new AnimationMaker(this.panelSize, this.animation); int x = (this.panel1.Width - this.animationMaker.Width) / 2; int y = (this.panel1.Height - this.animationMaker.Height) / 2; this.animationMaker.Location = new System.Drawing.Point(x, y); this.animationMaker.Parent = this.panel1; this.animationMaker.ChangeEffect(); return; } case AnimationEventType.Update: this.animationMaker.RefrshAnimation(false); return; case AnimationEventType.StartPreview: case AnimationEventType.StopPreview: break; case AnimationEventType.ReDraw: this.animationMaker.RefrshAnimation(false); break; default: return; } }
internal StyleAnimationEvent(AnimationEventType type, UIElement target, AnimationState state, AnimationOptions options) { this.evtType = type; this.target = target; this.state = state; this.options = options; }
public void AddEvent(string stateName, AnimationEventType eventType, System.Action <Animator> callback, int layer = 0) { string layerName = _animator.GetLayerName(layer); int fullnameHash = Animator.StringToHash(layerName + "." + stateName); switch (eventType) { case AnimationEventType.STATE_ENTER: if (!_onStateEnterClbk.ContainsKey(fullnameHash)) { _onStateEnterClbk.Add(fullnameHash, new System.Action <Animator>(callback)); } else { _onStateEnterClbk[fullnameHash] += callback; } break; case AnimationEventType.STATE_END: if (!_onStateExitClbk.ContainsKey(fullnameHash)) { _onStateExitClbk.Add(fullnameHash, new System.Action <Animator>(callback)); } else { _onStateExitClbk[fullnameHash] += callback; } break; case AnimationEventType.STATE_ENTER_TRANSITION_END: if (!_onStateEnterTransitionEndClbk.ContainsKey(fullnameHash)) { _onStateEnterTransitionEndClbk.Add(fullnameHash, new System.Action <Animator>(callback)); } else { _onStateEnterTransitionEndClbk[fullnameHash] += callback; } break; case AnimationEventType.STATE_EXIT_TRANSITION_START: if (!_onStateExitTransitionStartClbk.ContainsKey(fullnameHash)) { _onStateExitTransitionStartClbk.Add(fullnameHash, new System.Action <Animator>(callback)); } else { _onStateExitTransitionStartClbk[fullnameHash] += callback; } break; default: break; } }
private void AnimationEventHappened(AnimationEventType type, string animationName) { if (type == AnimationEventType.LOOP) { if (Moving && animationTransform.LastPlay != null && animationTransform.LastPlay.Contains("Walk")) { // Debug.Log ("Move cycle!"); MovementCycled(); } } }
public static void AddEvent(this Animator animator, string stateName, AnimationEventType eventType, System.Action <Animator> callback, int layer = 0) { if (isUsingSMBMethod) { AddEventSMB(animator, stateName, eventType, callback, layer); } else { AddEventPolling(animator, stateName, eventType, callback, layer); } }
static void AddEventPolling(Animator animator, string stateName, AnimationEventType eventType, System.Action <Animator> callback, int layer) { var polling = animator.GetComponent <AnimatorPolling>(); if (polling == null) { polling = animator.gameObject.AddComponent <AnimatorPolling>(); } polling.AddEvent(stateName, eventType, callback, layer); }
public void HandleAnimationEvent(AnimationEventType type, string animationName) { if (!attacking) { return; } switch (type) { case AnimationEventType.ATTACK_SWING_MOMENT: // if (lastAttack.TypeChoice.IsRanged () & lastAttack.WeaponUsed.IsThrown ()) { // //nothing // } else { WeaponSwingFXType swingFx = lastAttack.WeaponUsed.SwingSoundFX; characterAudioSource.clip = SoundDispenser.instance.SwingFXFromType(swingFx); characterAudioSource.Play(); // } break; case AnimationEventType.ATTACK_HIT_MOMENT: //this is where it should split off and launch the weapon if the attack was ranged if (lastAttack.TypeChoice.IsRanged()) { GenericWeapon wp = lastAttack.WeaponUsed; GameObject missileAnimPrefab = MissileAnimationPrefabDispenser.instance.GetAnimationPrefabByName(wp.MissileAnimationName); if (missileAnimPrefab != null) { LaunchMissileAndSetup(missileAnimPrefab); } else { AttackAnimationHitMoment(); } } else { AttackAnimationHitMoment(); } break; case AnimationEventType.LOOP: if (rangedAttacking) { animationTransform.Idle(); } else { AttackAnimationEnded(); } break; } }
static void AddEventSMB(Animator animator, string stateName, AnimationEventType eventType, System.Action <Animator> callback, int layer) { var layerName = animator.GetLayerName(layer); var callbackSMB = animator.GetBehaviours(Animator.StringToHash(layerName + "." + stateName), 0); bool found = false; foreach (var smb in callbackSMB) { CallbackSMB clbk = smb as CallbackSMB; if (clbk.GetType() != typeof(CallbackSMB)) { continue; } found = true; switch (eventType) { case AnimationEventType.STATE_ENTER: clbk.enterAction += callback; break; case AnimationEventType.STATE_END: clbk.exitAction += callback; break; case AnimationEventType.STATE_ENTER_TRANSITION_END: clbk.startTransition += callback; break; case AnimationEventType.STATE_EXIT_TRANSITION_START: clbk.exitTransition += callback; break; default: break; } } if (!found) { Debug.LogError("This animator does not have a state called " + stateName, animator); } }
/// <summary> /// Used by all animation events as the function to call from editor settings. /// </summary> /// <param name="type">Type.</param> public void EventFired(AnimationEventType type) { // if(anim != null) // Debug.Log ("event fired by "+ name + ": " + type + "@"+ anim.GetNextAnimatorStateInfo(0).normalizedTime); if (OnAnimationEvent != null) { OnAnimationEvent(type, LastPlay); } if (transform.parent != null) { AnimationTransform paren = transform.parent.GetComponent <AnimationTransform> (); if (paren != null) { paren.EventFired(type); } } }
public void HandleAnimationEvent(AnimationEventType type, string animationName) { if (!casting) { return; } switch (type) { case AnimationEventType.CAST_PREPARE_MOMENT: break; case AnimationEventType.CAST_RELEASE_MOMENT: Debug.Log("Casting!"); CastAnimationReleaseMoment(); break; case AnimationEventType.LOOP: CastAnimationEnded(); break; } }
// Methods //static ViewItem() //{ // //this._weasel = new PrivateObjectWeasel("Microsoft.MediaCenter.UI.ViewItem, Microsoft.MediaCenter.UI, Version=6.0.6000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); //} //public ViewItem(object zone) //{ // this._weasel = new PrivateObjectWeasel("Microsoft.MediaCenter.UI.ViewItem, Microsoft.MediaCenter.UI, Version=6.0.6000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", new object[] { zone }); //} //public ViewItem(View viewOwner) //{ // this.CommonCreate(viewOwner); //} //public ViewItem(object zone) //{ // this._weasel = new PrivateObjectWeasel("Microsoft.MediaCenter.UI.ViewItem, Microsoft.MediaCenter.UI, Version=6.0.6000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", new object[] { zone }); //} //public ViewItem(View viewOwner); public bool ApplyAnimatableValue(AnimationEventType type, object args, object objOldValue, object objNewValue, bool fOnlyApplyIfAnimating) { return (bool)this._weasel.Invoke("ApplyAnimatableValue", new object[] { type, args, objOldValue, objNewValue, fOnlyApplyIfAnimating }); }
public AnimationEventArgs(AnimationEventType type) { Type = type; }
private Animation LoadAnimationFromOffset(DSBinaryReader bin, int offset, int animID_ForDebug) { int oldOffset = (int)bin.BaseStream.Position; bin.BaseStream.Seek(offset, SeekOrigin.Begin); var anim = new Animation(); try { int eventCount = bin.ReadInt32(); int eventHeadersOffset = bin.ReadInt32(); bin.BaseStream.Seek(0x10, SeekOrigin.Current); //skip shit we don't need int animFileOffset = bin.ReadInt32(); for (int i = 0; i < eventCount; i++) { //lazily seek to the start of each event manually. bin.BaseStream.Seek(eventHeadersOffset + (EventHeaderSize * i), SeekOrigin.Begin); int startTimeOffset = bin.ReadInt32(); int endTimeOffset = bin.ReadInt32(); int eventBodyOffset = bin.ReadInt32(); bin.BaseStream.Seek(startTimeOffset, SeekOrigin.Begin); float startTime = bin.ReadSingle(); bin.BaseStream.Seek(endTimeOffset, SeekOrigin.Begin); float endTime = bin.ReadSingle(); bin.BaseStream.Seek(eventBodyOffset, SeekOrigin.Begin); int eventTypeValue = bin.ReadInt32(); int eventParamOffset = bin.ReadInt32(); bin.BaseStream.Seek(eventParamOffset, SeekOrigin.Begin); AnimationEventType eventType = (AnimationEventType)eventTypeValue; var nextEvent = new AnimationEvent(i + 1, eventType, animID_ForDebug); nextEvent.StartTime = startTime; nextEvent.EndTime = endTime; for (int j = 0; j < nextEvent.Parameters.Count; j++) { var nextParamVal = new MultiDword() { Int = bin.ReadInt32() }; if (AnimationEvent.CheckIfParamIsUnlikelyToBeFloat(nextParamVal)) { nextEvent.Parameters[j].Value = nextParamVal.Int.ToString(); } else { string convStr = nextParamVal.Float.ToString(); nextEvent.Parameters[j].Value = convStr + (convStr.Contains(".") ? "" : ".0"); } } anim.Events.Add(nextEvent); } bin.BaseStream.Seek(animFileOffset, SeekOrigin.Begin); int fileType = bin.ReadInt32(); if (fileType == 0) { int dataOffset = bin.ReadInt32(); bin.BaseStream.Seek(dataOffset, SeekOrigin.Begin); int nameOffset = bin.ReadInt32(); if (nameOffset == 0) { throw new Exception("Anim file type was that of a named one but the name pointer was NULL."); } bin.BaseStream.Seek(nameOffset, SeekOrigin.Begin); anim.FileName = ReadUnicodeString(bin); } else if (fileType == 1) { anim.FileName = null; } else { throw new Exception($"Unknown anim file type code: {fileType}"); } return(anim); } catch (EndOfStreamException) { MiscUtil.PrintlnDX($"Warning: reached end of file while parsing animation {animID_ForDebug}; data may not be complete.", ConsoleColor.Yellow); //if (!MiscUtil.ConsolePrompYesNo("Would you like to continue loading the file and run the risk of " + // "accidentally outputting a file that might be missing some of its original data?")) //{ // throw new LoadAbortedException(); //} //else //{ // return a; //} return(anim); } finally { bin.BaseStream.Seek(oldOffset, SeekOrigin.Begin); } }
public AnimationRelation(string tag, AnimationEventType type, int action_index) { this.tag = tag; this.type = type; this.action_index = action_index; }
public bool PlayAnimation(AnimationEventType type) { return (bool)this._weasel.Invoke("PlayAnimation", new object[] { type }); }
public IAnimationProvider GetAnimation(AnimationEventType type) { return (IAnimationProvider)this._weasel.Invoke("GetAnimation", new object[] { type }); }
public void DetachAnimation(AnimationEventType type) { this._weasel.Invoke("DetachAnimation", new object[] { type }); }
public AnimationEvent(AnimationBase sender, AnimationEventType playbackType) : base(sender) { PlaybackType = playbackType; }