/// <summary> /// 播放结果动画 /// </summary> void OnPlayResult(int index, AniType atype) { GameObject border = o_table3[index].transform.FindChild("frame").FindChild("border").gameObject; GameObject result = o_table3[index].transform.FindChild("result").FindChild("result").gameObject; GameObject light = o_table3[index].transform.FindChild("result").FindChild("light").gameObject; GameObject img = o_table3[index].transform.FindChild("img").gameObject; border.SetActive(true); if (img.activeSelf) { img.SetActive(false); } if (atype == AniType.Result) { border.GetComponent <UIAnimation>().m_bRepeatTimes = 10; border.GetComponent <UIAnimation>().m_fPerFrameTime = 0.22f; light.SetActive(false); result.SetActive(true); result.GetComponent <UIAnimation>().Play(); } else if (atype == AniType.Light) { border.GetComponent <UIAnimation>().m_bRepeatTimes = 1; border.GetComponent <UIAnimation>().m_fPerFrameTime = 0.3f; result.SetActive(false); light.SetActive(true); light.GetComponent <UIAnimation>().Play(); } border.GetComponent <UIAnimation>().Play(); }
public AnimationData getAniName(AniType at) { if (mAniDataList.Count == 0) { Init(); } return(mAniDataList[at]); }
public void PlayAnimation(AniType eActiveAni) { if (AniState == eActiveAni) { return; } Anim.Play(ClipName[(int)eActiveAni], 0, 0f); AniState = eActiveAni; }
// ---------------------------------------- // // CONSTRUCTOR public AniProp(AniValue v, AniMator m, AniType t, float d, DefaultCallback c, float s, System.Object a, Hashtable o) { value = v; mator = m; type = t; duration = d; callback = c; startTime = s; argument = a; options = o; }
//播放动画时会被打断 public void PlayAniCanBreak(int frist, int end, AniType type, int speed) { frameLoop[0] = frist; frameLoop[1] = end; currentType = type; anispeed = speed; currentframe = frist; isPlay = true; }
//播放动画的简便方法,读取对应skin中的帧数 public void PlayAniBySkin(string name, AniType type, int speed) { frameLoop[0] = aniskin.ActionList[name][0]; frameLoop[1] = aniskin.ActionList[name][1]; currentType = type; anispeed = speed; currentframe = aniskin.ActionList[name][0]; isPlay = true; }
public void SetAnimaiton(AniType type) { switch (type) { case AniType.Attack: animator.Play(type.ToString(), -1, 0); break; default: animator.Play(type.ToString()); break; } }
public void Play(AniType aniType, Action handler = null) { bool playAni = true; Vector2 targetPos = Vector2.zero; switch (aniType) { case AniType.SHOW_MOVE_LEFT: RcTrans.anchoredPosition = new Vector2(RcTrans.rect.width, 0); targetPos = Vector2.zero; break; case AniType.SHOW_MOVE_RIGHT: RcTrans.anchoredPosition = new Vector2(-RcTrans.rect.width, 0); targetPos = Vector2.zero; break; case AniType.HIDE_MOVE_LEFT: RcTrans.anchoredPosition = Vector2.zero; targetPos = new Vector2(-RcTrans.rect.width, 0); break; case AniType.HIDE_MOVE_RIGHT: RcTrans.anchoredPosition = Vector2.zero; targetPos = new Vector2(RcTrans.rect.width, 0); break; default: playAni = false; break; } if (playAni) { Global.Instance.UiTopMask.SetActive(true); RcTrans.DOAnchorPos(targetPos, 0.5f).SetEase(Ease.InQuart).OnComplete(() => { Global.Instance.UiTopMask.SetActive(false); if (null != handler) { handler(); } }); } }
//播放动画需要等待当前动画播放完成 public void PlayAni(int frist, int end, AniType type, int speed) { if (!isPlay) { frameLoop[0] = frist; frameLoop[1] = end; currentframe = frist; } else { nextframeLoop[0] = frist; nextframeLoop[1] = end; } currentType = type; anispeed = speed; isPlay = true; }
void PlayAni(AniType action) { if ((isRun || isAttackRunning) && (int)AniType.Idle == action) { m_Anim.SetBool("Idle", false); return; } for (int idx = 0; idx < (int)AniType.Max; idx++) { if (idx == (int)AniType.Attack && idx == (int)action) { if (!isAttacking && PV.IsMine) { StartCoroutine("AttackAniCheck"); //m_Anim.SetBool(AniActionList[idx], false); //m_Anim.SetBool("Idle", true); continue; } else { continue; } } else if (idx == (int)action) { m_Anim.SetBool(AniActionList[idx], true); } else { m_Anim.SetBool(AniActionList[idx], false); } } curAniType = action; }
public void Play(AniType at, bool isReset = false) { AnimationData ad = AnimationManager.instance.getAniName(at); Play(ad.nKeyName); }
public void SetAnimationSpeed(AniType eActiveAni, float fSeepd = 1.0f) { Anim.speed = fSeepd; }
public string GetAniTypeClip(AniType aniType) { return(ClipName[(int)aniType]); }
void StopAni(AniType action) { m_Anim.SetBool(AniActionList[(int)action], false); }
// Extract animation properties from Hash private void CreateAnimations(System.Object obj, Hashtable properties, float duration, Hashtable options, AniType type) { foreach (DictionaryEntry item in properties) { // Extract name and value string name = (string)item.Key; System.Object value = item.Value; // Create value object AniValue aniv = new AniValue(obj, name); // Get current value System.Object current = aniv.Get(); System.Object start = null; System.Object target = null; System.Object diff = null; // Setup variables if (type == AniType.To) { start = current; target = value; } else if (type == AniType.From) { start = value; target = current; } else if (type == AniType.By) { start = current; diff = value; } // Cast value to destination type System.Object argument = System.Convert.ChangeType(item.Value, aniv.ValueType()); // Callback DefaultCallback callback = (DefaultCallback)options["callback"]; // Calculate difference for To and From if ((type == AniType.To || type == AniType.From) && DriveNeedsDiff((AnimationDriveType)options["drive"])) { try { //diff = target - start; //test = start + 0.1 * diff; System.Type startType = start.GetType(); // --- Builtin types if (startType != target.GetType()) { diff = (float)target - (float)start; } else if (startType == typeof(short)) { diff = (short)target - (short)start; } else if (startType == typeof(int)) { diff = (int)target - (int)start; } else if (startType == typeof(long)) { diff = (long)target - (long)start; } else if (startType == typeof(float)) { diff = (float)target - (float)start; } else if (startType == typeof(double)) { diff = (double)target - (double)start; } else if (startType == typeof(decimal)) { diff = (decimal)target - (decimal)start; // --- Unity types } else if (startType == typeof(Vector2)) { diff = (Vector2)target - (Vector2)start; } else if (startType == typeof(Vector3)) { diff = (Vector3)target - (Vector3)start; } else if (startType == typeof(Vector4)) { diff = (Vector4)target - (Vector4)start; } else if (startType == typeof(Color)) { diff = (Color)target - (Color)start; // --- Fallback } else { diff = (float)target - (float)start; } } catch { throw new System.Exception("Cannot find diff between " + start.GetType() + " and " + target.GetType() + ": Operation +, - or * not supported."); } } // Start time float startTime = 0; float delay = (float)options["delay"]; if (delay > 0) { startTime = Time.time + delay; } // Create animation object AniMator mat = new AniMator(start, target, diff, duration, (float)options["delay"], (AnimationEasingType)options["easing"], (EasingType)options["direction"], (AnimationDriveType)options["drive"]); // Add animation to main list AniProp anim = new AniProp(aniv, mat, type, duration, callback, startTime, argument, options); // Regular animation animations.Add(anim); // From: Set to starting value if (type == AniType.From) { aniv.Set(start); } } }
// Extract animation properties from Hash private void CreateAnimations(System.Object obj, Hashtable properties, float duration, Hashtable options, AniType type) { foreach (DictionaryEntry item in properties) { name = (string)item.Key; // Extract name and value System.Object value = item.Value; AniValue aniv = new AniValue(obj, name); // Create value object System.Object current = aniv.Get(); // Get current value System.Object start = null; System.Object target = null; System.Object diff = null; // Setup variables if (type == AniType.To) { start = current; target = value; } else if (type == AniType.From) { start = value; target = current; } else if (type == AniType.By) { start = current; diff = value; } // Calculate difference for To and From if ((type == AniType.To || type == AniType.From) && DriveNeedsDiff((AnimationDriveType)options["drive"])) { try { //diff = target - start; //test = start + 0.1 * diff; System.Type startType = start.GetType(); // --- Builtin types if (startType != target.GetType()) { diff = (float)target - (float)start; } else if (startType == typeof(short)) { diff = (short)target - (short)start; } else if (startType == typeof(int)) { diff = (int)target - (int)start; } else if (startType == typeof(long)) { diff = (long)target - (long)start; } else if (startType == typeof(float)) { diff = (float)target - (float)start; } else if (startType == typeof(double)) { diff = (double)target - (double)start; } else if (startType == typeof(decimal)) { diff = (decimal)target - (decimal)start; } // --- Unity types else if (startType == typeof(Vector2)) { diff = (Vector2)target - (Vector2)start; } else if (startType == typeof(Vector3)) { diff = (Vector3)target - (Vector3)start; } else if (startType == typeof(Vector4)) { diff = (Vector4)target - (Vector4)start; } else if (startType == typeof(Color)) { diff = (Color)target - (Color)start; } // --- Fallback else { diff = (float)target - (float)start; } } catch { throw new System.Exception("Cannot find diff between " + start.GetType() + " and " + target.GetType() + ": Operation +, - or * not supported."); } } // Create animation object AniMator mat = new AniMator(start, target, diff, duration, (float)options["delay"], (AnimationEasingType)options["easing"], (EasingType)options["direction"], (AnimationDriveType)options["drive"]); // Add to animations //if ((bool)options["physics"] == false && options["rigidbody"] == null) //{ // Regular animation animations.Add(new System.Object[] { aniv, mat, options["callback"] }); //} /*else * { * // Rigidbody animation * DefaultCallback callback; * //if (options["rigidbody"] != null && name == "position") { * // callback = (options["rigidbody"] as Rigidbody).MovePosition; * //} else if (options["rigidbody"] != null && name == "rotation") { * // callback = (options["rigidbody"] as Rigidbody).MoveRotation; * // Other callback * //} else { * callback = (DefaultCallback)options["callback"]; * //} * // Physics animation * fixedAnimations.Add(new System.Object[] { aniv, mat, callback }); * }*/ // From: Set to starting value if (type == AniType.From) { aniv.Set(start); } } }
// Extract animation properties from Hash private void CreateAnimations(System.Object obj, Hashtable properties, float duration, Hashtable options, AniType type) { foreach (DictionaryEntry item in properties) { name = (string)item.Key; // Extract name and value System.Object value = item.Value; AniValue aniv = new AniValue(obj, name);// Create value object System.Object current = aniv.Get(); // Get current value System.Object start = null; System.Object target = null; System.Object diff = null; // Setup variables if (type == AniType.To) { start = current; target = value; } else if (type == AniType.From) { start = value; target = current; } else if (type == AniType.By) { start = current; diff = value; } // Calculate difference for To and From if ((type == AniType.To || type == AniType.From) && DriveNeedsDiff((AnimationDriveType)options["drive"])) { try { //diff = target - start; //test = start + 0.1 * diff; System.Type startType = start.GetType(); // --- Builtin types if (startType != target.GetType()) diff = (float)target - (float)start; else if (startType == typeof(short)) diff = (short)target - (short)start; else if (startType == typeof(int)) diff = (int)target - (int)start; else if (startType == typeof(long)) diff = (long)target - (long)start; else if (startType == typeof(float)) diff = (float)target - (float)start; else if (startType == typeof(double)) diff = (double)target - (double)start; else if (startType == typeof(decimal)) diff = (decimal)target - (decimal)start; // --- Unity types else if (startType == typeof(Vector2)) diff = (Vector2)target - (Vector2)start; else if (startType == typeof(Vector3)) diff = (Vector3)target - (Vector3)start; else if (startType == typeof(Vector4)) diff = (Vector4)target - (Vector4)start; else if (startType == typeof(Color)) diff = (Color)target - (Color)start; // --- Fallback else diff = (float)target - (float)start; } catch { throw new System.Exception("Cannot find diff between " + start.GetType() + " and " + target.GetType() + ": Operation +, - or * not supported."); } } // Create animation object AniMator mat = new AniMator(start, target, diff, duration, (float)options["delay"], (AnimationEasingType)options["easing"], (EasingType)options["direction"], (AnimationDriveType)options["drive"]); // Add to animations //if ((bool)options["physics"] == false && options["rigidbody"] == null) //{ // Regular animation animations.Add(new System.Object[] { aniv, mat, options["callback"] }); //} /*else { // Rigidbody animation DefaultCallback callback; //if (options["rigidbody"] != null && name == "position") { // callback = (options["rigidbody"] as Rigidbody).MovePosition; //} else if (options["rigidbody"] != null && name == "rotation") { // callback = (options["rigidbody"] as Rigidbody).MoveRotation; // Other callback //} else { callback = (DefaultCallback)options["callback"]; //} // Physics animation fixedAnimations.Add(new System.Object[] { aniv, mat, callback }); }*/ // From: Set to starting value if (type == AniType.From) { aniv.Set(start); } } }
public AnimationData(AniType aniType, string keyName, bool isLoop) { nAniType = aniType; nKeyName = keyName; nIsLoop = isLoop; }