override protected void OnReactionEvent(AnimationReactionEvent gameEvent) { if (gameEvent.priority == priority) { scheduledAnimations.Add(AnimationEffect.PlayBlocking(gameEvent.gameObject, gameEvent.animationType)); } }
public void Create(AnimationEffect effect) { AnimationEffect d = Instantiate(effect); d.effect = effect.Create(this); OnEffectCreated?.Invoke(d); }
protected IEnumerator RespawnPlayerCharacter(PlayerCharacter character) { // play caught animation AnimationEffect animationEffect = GetAnimationEffectForPlayerChaught(); GameObject emmonCaughtPrefab = MazeLevelGameplayManager.Instance.GetEffectAnimationPrefab(animationEffect); GameObject emmonCaughtPGO = GameObject.Instantiate(emmonCaughtPrefab, SceneObjectManager.Instance.transform); Vector3 emmonCaughtSpawnPosition = character.transform.position; emmonCaughtPGO.transform.position = emmonCaughtSpawnPosition; EffectController emmonCaughtPGOEffectController = emmonCaughtPGO.GetComponent <EffectController>(); emmonCaughtPGOEffectController.PlayEffect(animationEffect); character.FreezeCharacter(); CharacterBody.SetActive(false); SetBodyAlpha(0); // make body transparent before respawning ResetCharacterPosition(); float waitTime = 1.4f; yield return(new WaitForSeconds(waitTime)); _animationHandler.TriggerSpawning(); CharacterBody.SetActive(true); float spawnAnimationLength = 0.44f; yield return(new WaitForSeconds(spawnAnimationLength)); character.UnfreezeCharacter(); }
public void PlayAnimationEffect(Socket sender, AnimationEffect animation) { byte[] data = new byte[0x08]; Buffer.BlockCopy(BitConverter.GetBytes((ushort)animation), 0, data, 0, sizeof(ushort)); data[0x03] = 0x04; SendPacket(sender, ServerOpcode.PlayAnimationEffect, data); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * New Method: Clone //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ public AnimationEffect Clone() { AnimationEffect AE = new AnimationEffect(); AE.m_fTotalAnimationTime = this.m_fTotalAnimationTime; AE.m_vStartingPosition = this.m_vStartingPosition; AE.m_vEndPosition = this.m_vEndPosition; AE.m_vStartingRotation = this.m_vStartingRotation; AE.m_vEndRotation = this.m_vEndRotation; AE.m_vStartingScale = this.m_vStartingScale; AE.m_vEndScale = this.m_vEndScale; AE.m_cStartingColour = this.m_cStartingColour; AE.m_cEndColour = this.m_cEndColour; AE.m_sprNewSprite = this.m_sprNewSprite; AE.m_tTarget = this.m_tTarget; AE.m_bPositionChanging = this.m_bPositionChanging; AE.m_bRotationChanging = this.m_bRotationChanging; AE.m_bScaleChanging = this.m_bScaleChanging; AE.m_bColourChanging = this.m_bColourChanging; if (this.m_ttTimer != null) { AE.m_ttTimer = new TimeTracker(this.m_ttTimer.FinishTime); } #if UNITY_EDITOR AE.m_sEffectName = this.m_sEffectName; #endif return(AE); }
private IEnumerator LoadDataEnumerator() { //这里要跳两帧才能让登录界面先刷出来同时让用户无法感觉到后台在悄悄加载 if (skip) { yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); } mAnimEffectTemplateList.Clear(); if (Application.isEditor) //编辑器需要逐个加载,因此分帧处理 { List <ResourceRequestInfo> requests = new List <ResourceRequestInfo>(); string[] assetfiles = System.IO.Directory.GetFiles(Application.dataPath + "/Resources/Animation", "*.asset"); foreach (string assetfile in assetfiles) { string assetname = System.IO.Path.GetFileNameWithoutExtension(assetfile); ResourceRequestInfo rri = new ResourceRequestInfo(); rri.name = "Animation/" + assetname; requests.Add(rri); } BatchResourceAsynLoader brl = new BatchResourceAsynLoader(); StartCoroutine(brl.BatchAsynLoad(requests, typeof(AnimationEffect))); while (!brl.finish) { yield return(new WaitForEndOfFrame()); } effect_list = brl.GetResult <AnimationEffect>(); } else //导出的已经打包到Resource包,一并读取并不慢,因此不分帧 { effect_list = Resources.LoadAll <AnimationEffect>("Animation"); } if (skip) { yield return(new WaitForEndOfFrame()); } foreach (AnimationEffect effect in effect_list) { if (mAnimEffectTemplateList.ContainsKey(effect.getID())) { Trace.Warning("the AnimEffect id is already exist!" + effect.getID().ToString()); AnimationEffect conflitEffect = mAnimEffectTemplateList[effect.getID()]; Trace.Warning("Name1:" + conflitEffect.name + " Name2:" + effect.name); continue; } mAnimEffectTemplateList[effect.getID()] = effect; } Trace.Log("Loaded " + mAnimEffectTemplateList.Count.ToString() + " AnimationEffect(s)!"); yield return(true); }
public void Update() { if (mAnimationList == null) { return; } float currentHeight = -1.0f; //遍历列表,进行更新或关闭操作 for (int i = 0; i < mAnimationList.Count;) { AnimationEffect anim = mAnimationList[i]; bool bRemove = false; if (anim.needClose == true) //动作需要关闭并移除 { anim.Close(); bRemove = true; } else { if (anim.rigidHeight) { if (currentHeight < 0.0f) { Vector3 pos = transform.position; RaycastHit hitInfo; Ray PointToGroundRay = new Ray(pos, new Vector3(0, -1, 0)); if (Physics.Raycast(PointToGroundRay, out hitInfo, 100, collisionLayers)) { currentHeight = pos.y - hitInfo.point.y; } else { currentHeight = 0.0f; } } anim.currentHeight = currentHeight; } if (anim.Update() == false) //否则,对动作进行更新,更新失败的关闭并移除 { anim.Close(); bRemove = true; } } if (bRemove) { mAnimationList.Remove(anim); } else { i++; } } }
override protected void Complete() { if (gameObject.GetComponent <BubbleScore>().Score > 0) { effectController.AddEffect(AnimationEffect.Play(gameObject, AnimationType.ScoreText)); } Object.Destroy(gameObject, 0.5f); }
public virtual void Draw(SpriteBatch spriteBatch, AnimationEffect animationEffect) { var flip = (Direction == FaceDirection.Left); if (CurrentAnimation != null) { CurrentAnimation.Draw(spriteBatch, (flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None), Transform.Position, 0, 0.5f, Color, animationEffect); } }
private void LoadByEditorImp(string effectname) { AnimationEffect effect = Resources.Load <AnimationEffect>("Animation/" + effectname); if (effect != null) { mAnimEffectTemplateList[effect.getID()] = effect; } }
public static IHandler Animate( this IHandler handler, AnimationEffect effect) { return(new RegionOptions { Animation = new AnimationOptions { Effect = effect } }.Decorate(handler)); }
private void UpdateStarImages() { for (var index = currentStar; index < starCount; index++) { if (lastScore >= scores[index]) { currentStar = index + 1; StartCoroutine(AnimationEffect.Play(stars[index], AnimationType.ActivateStarBarStar)); } } }
void LoadFromAnimation(AnimationEffect animationEffect) { SetFromAnimationName(animationEffect.spriteName); nedAdjustHue.Value = animationEffect.hueShift.ToString(); nedAdjustBrightness.Value = animationEffect.brightness.ToString(); nedAdjustSaturation.Value = animationEffect.saturation.ToString(); nedSecondaryAdjustHue.Value = animationEffect.secondaryHueShift.ToString(); nedSecondaryAdjustBrightness.Value = animationEffect.secondaryBrightness.ToString(); nedSecondaryAdjustSaturation.Value = animationEffect.secondarySaturation.ToString(); //animationEffect.startFrameIndex; }
public void AddEffect(GameObject parent, AnimationType type, BubbleDeathType deathType, bool blocking) { if (!EffectDictionary.ContainsKey(deathType)) { EffectDictionary.Add(deathType, new List <IEnumerator>()); } var effect = blocking ? AnimationEffect.PlayAndRegister(parent, type, RegisterBlockers) : AnimationEffect.Play(parent, type); EffectDictionary[deathType].Add(effect); }
void SaveToAnimation(AnimationEffect animationEffect) { animationEffect.spriteName = GetAnimationName(); animationEffect.hueShift = nedAdjustHue.ValueAsDouble; animationEffect.brightness = nedAdjustBrightness.ValueAsDouble; animationEffect.saturation = nedAdjustSaturation.ValueAsDouble; animationEffect.secondaryHueShift = nedSecondaryAdjustHue.ValueAsDouble; animationEffect.secondaryBrightness = nedSecondaryAdjustBrightness.ValueAsDouble; animationEffect.secondarySaturation = nedSecondaryAdjustSaturation.ValueAsDouble; animationEffect.startFrameIndex = 0; }
public AnimationEffect CreateAnimation(int nID) { if (!mAnimEffectTemplateList.ContainsKey(nID)) { Trace.Warning("AnimationEffect creates failed. Id " + nID.ToString() + "has not loaded."); return(null); } AnimationEffect newEffect = GameObject.Instantiate(mAnimEffectTemplateList[nID]); return(newEffect); }
Effect GetAnimationEffect() { AnimationEffect animationEffect = new AnimationEffect(GetAnimationName(), GetTarget(), 0, nedAdjustHue.ValueAsDouble, nedAdjustSaturation.ValueAsDouble, nedAdjustBrightness.ValueAsDouble); if (rbFireBall.IsChecked == true) { animationEffect.secondaryHueShift = nedSecondaryAdjustHue.ValueAsDouble; animationEffect.secondarySaturation = nedSecondaryAdjustSaturation.ValueAsDouble; animationEffect.secondaryBrightness = nedSecondaryAdjustBrightness.ValueAsDouble; } return(animationEffect); }
// Constructors public Button(AnimationEffect buttonEffect, PressEffect pressEffect, Vector2 position, int spriteSheetLength) : base(position, 0f, spriteSheetLength, 1) { this.position = position; screenWidth = GraphicsDevice.Viewport.Width; screenHieght = GraphicsDevice.Viewport.Height; hitbox = new Rectangle((int)position.X - (int)frameSize.X / 2, (int)position.Y - (int)frameSize.Y / 2, (int)frameSize.X, (int)frameSize.Y); rectangle = new Rectangle(0, 0, 0, 0); scale = 1; this.buttonEffect = buttonEffect; this.pressEffect = pressEffect; }
private void EffectTools_OnEffectCreated(AnimationEffect animationEffect) { timeOfDraw = Time.time; GunEffect gunEffect = animationEffect.effect.GetComponent <GunEffect>(); EffectTools gunEffectTools = gunEffect.GetComponent <EffectTools>(); gunEffect.transform.position = transform.GetChild(0).position; gunEffect.transform.rotation = transform.rotation; gunEffect.transform.localScale = transform.localScale; gunEffect.dispatcher.OnDispatch += Dispatcher_OnDispatch; }
private List <IEnumerator> GetDefaultEffects(BubbleDeathType type) { var effects = new List <IEnumerator>(); var model = gameObject.GetComponent <BubbleModelBehaviour>().Model; if (model.definition.AnimationMap.ContainsKey(type)) { foreach (var animationType in model.definition.AnimationMap[type]) { effects.Add(AnimationEffect.PlayAndRegister(gameObject, animationType, RegisterBlockers)); } } return(effects); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * New Method: Resize Array //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ public static AnimationEffect[] ResizeArray(AnimationEffect[] Original, int NewSize) { AnimationEffect[] aeNewArray = new AnimationEffect[NewSize]; for (int i = 0; i < aeNewArray.Length; ++i) { if (i < Original.Length) { aeNewArray[i] = Original[i].Clone(); } else { aeNewArray[i] = new AnimationEffect(); } } return(aeNewArray); }
// 播放一个复杂动作 public AnimationEffect AddAnimation(int nID, AnimationParam param) { AnimationEffect newAnim = AnimationEffectFactory.Instance.CreateAnimation(nID); if (newAnim != null) { newAnim.param = param; newAnim.showLog = showLog; if (newAnim.Begin()) { mAnimationList.Add(newAnim); } } return(newAnim); }
private void EffectBuilder_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (loadingInternally) { return; } if (!(sender is EffectBuilder effectBuilder)) { return; } EffectEntry effectEntry = effectBuilder.EffectEntry; if (effectEntry == null) { return; } SetSelectedColorByEffectType(effectEntry.EffectKind); if (effectBuilder.EffectKind == EffectKind.SoundEffect) { string soundFileName = effectEntry.SoundEffect.soundFileName; AdjustSelectedEntryDuration(GetSoundFileDuration(soundFileName), true, soundFileName); } else if (effectBuilder.EffectKind == EffectKind.Animation) { AnimationEffect animationEffect = effectEntry.AnimationEffect; TimeSpan duration = GetAnimationDuration(animationEffect.spriteName); if (animationEffect.name != "") { AdjustSelectedEntryDuration(duration, false, animationEffect.name); } else { AdjustSelectedEntryDuration(duration, false, animationEffect.spriteName); } } else if (effectBuilder.EffectKind == EffectKind.Emitter) { EmitterEffect emitterEffect = effectEntry.EmitterEffect; TimeSpan duration = GetEmitterDuration(emitterEffect); AdjustSelectedEntryDuration(duration, false, null); } OnPropertyChanged(); }
private void OnAnimateStarsOnMapNodeEvent(AnimateStarsOnMapNodeEvent gameEvent) { GlobalState.EventService.RemoveEventHandler <AnimateStarsOnMapNodeEvent>(OnAnimateStarsOnMapNodeEvent); for (long starIndex = gameEvent.oldStars; starIndex < filledStars; ++starIndex) { // We need to make a copy of starIndex so our lambda doesn't reference it directly var index = starIndex; var newStarIndex = (index - gameEvent.oldStars); var delay = (0.4f * (newStarIndex + 1)); starPositions[index].enabled = false; Util.FrameUtil.AfterDelay(delay, () => { PlaySoundEvent.Dispatch(starSounds[newStarIndex]); StartCoroutine(AnimationEffect.Play(starPositions[index].gameObject, AnimationType.StarOnMapNode)); }); } }
/// <summary> /// Animate show-hide control. /// </summary> /// <param name="control">Control to target.</param> /// <param name="effect">Animation effect to use.</param> /// <param name="ms">Animation effect time in miliseconds.</param> /// <param name="angle">Angle.</param> public static void ShowHide(Control control, AnimationEffect effect, int ms, int angle) { int flags = effmap[(int)effect]; if (control.Visible) { flags |= 0x10000; angle += 180; } else { if (control.TopLevelControl == control) { flags |= 0x20000; } else if (effect == AnimationEffect.Blend) { throw new ArgumentException(); } } flags |= dirmap[(angle % 360) / 45]; AnimateWindow(control.Handle, ms, flags); }
public GameObject GetEffectAnimationPrefab(AnimationEffect animationEffect) { switch (animationEffect) { case AnimationEffect.EmmonCaught: return(_oneTimeAnimationEffectPrefab); case AnimationEffect.FaeCaught: return(_oneTimeAnimationEffectPrefab); case AnimationEffect.NotesPlayMusic: return(_notesPlayMusicEffectPrefab); case AnimationEffect.StartledSpinner: return(_loopedAnimationEffectPrefab); case AnimationEffect.SmokeExplosion: return(_oneTimeAnimationEffectPrefab); default: Logger.Error($"No prefab was set up for animationEffect {animationEffect}"); return(null); } }
//private void SetAnimationEffect(AnimationEffect animationEffect) //{ // if (currentEffect == animationEffect || !animationEffects.ContainsKey(animationEffect)) // return; // animationEffects[animationEffect].Reset(); // currentEffect = animationEffect; //} public void Draw(SpriteBatch spriteBatch, SpriteEffects flipEffects, Vector2 position, float rotation, float scale, Color color, AnimationEffect animationEffect) { //SetAnimationEffect(animationEffect); Frames[currentFrame].Draw(spriteBatch, flipEffects, position, rotation, scale, color, animationEffects[currentEffect]); }
public AnimationBuilder Effect(AnimationEffect effect) { AnimationOptions.Effect = effect; return(this); }
/// <summary> /// Retrieves the specified metrics and displays them in textual form. /// </summary> /// <param name="effect">The AnimationEffect whose metrics are to be displayed.</param> /// <param name="target">The AnimationEffecTarget whose metrics are to be displayed.</param> private void DisplayMetrics(AnimationEffect effect, AnimationEffectTarget target) { var s = new System.Text.StringBuilder(); AnimationDescription animationDescription = new AnimationDescription(effect, target); s.AppendFormat("Stagger delay = {0}ms", animationDescription.StaggerDelay.TotalMilliseconds); s.AppendLine(); s.AppendFormat("Stagger delay factor = {0}", animationDescription.StaggerDelayFactor); s.AppendLine(); s.AppendFormat("Delay limit = {0}ms", animationDescription.DelayLimit.TotalMilliseconds); s.AppendLine(); s.AppendFormat("ZOrder = {0}", animationDescription.ZOrder); s.AppendLine(); s.AppendLine(); int animationIndex = 0; foreach (var animation in animationDescription.Animations) { s.AppendFormat("Animation #{0}:", ++animationIndex); s.AppendLine(); switch (animation.Type) { case PropertyAnimationType.Scale: { ScaleAnimation scale = animation as ScaleAnimation; s.AppendLine("Type = Scale"); if (scale.InitialScaleX.HasValue) { s.AppendFormat("InitialScaleX = {0}", scale.InitialScaleX.Value); s.AppendLine(); } if (scale.InitialScaleY.HasValue) { s.AppendFormat("InitialScaleY = {0}", scale.InitialScaleY.Value); s.AppendLine(); } s.AppendFormat("FinalScaleX = {0}", scale.FinalScaleX); s.AppendLine(); s.AppendFormat("FinalScaleY = {0}", scale.FinalScaleY); s.AppendLine(); s.AppendFormat("Origin = {0}, {1}", scale.NormalizedOrigin.X, scale.NormalizedOrigin.Y); s.AppendLine(); } break; case PropertyAnimationType.Translation: s.AppendLine("Type = Translation"); break; case PropertyAnimationType.Opacity: { OpacityAnimation opacity = animation as OpacityAnimation; s.AppendLine("Type = Opacity"); if (opacity.InitialOpacity.HasValue) { s.AppendFormat("InitialOpacity = {0}", opacity.InitialOpacity.Value); s.AppendLine(); } s.AppendFormat("FinalOpacity = {0}", opacity.FinalOpacity); s.AppendLine(); } break; } s.AppendFormat("Delay = {0}ms", animation.Delay.TotalMilliseconds); s.AppendLine(); s.AppendFormat("Duration = {0}ms", animation.Duration.TotalMilliseconds); s.AppendLine(); s.AppendFormat("Cubic Bezier control points"); s.AppendLine(); s.AppendFormat(" X1 = {0}, Y1 = {1}", animation.Control1.X, animation.Control1.Y); s.AppendLine(); s.AppendFormat(" X2 = {0}, Y2 = {1}", animation.Control2.X, animation.Control2.Y); s.AppendLine(); s.AppendLine(); } Metrics.Text = s.ToString(); }
public static void EffectBase(PrototypeLoader pl, PrototypeBase pb, AnimationEffect e, XmlNode node) { PrototypeLoader.EffectBase(pl, pb, e, node); }