public void GetStates_WithNoStates_IEnumerator_Current_Throws() { SimpleAnimation animation = Instantiate(); IEnumerable <SimpleAnimation.State> states = animation.GetStates(); var it = states.GetEnumerator(); Assert.Throws <InvalidOperationException>(() => { SimpleAnimation.State state = it.Current; }); }
public void GetStates_WithNoStates_IEnumerator_MoveNext_ReturnsFalse() { SimpleAnimation animation = Instantiate(); IEnumerable <SimpleAnimation.State> states = animation.GetStates(); var it = states.GetEnumerator(); Assert.IsFalse(it.MoveNext()); }
public void GetStates_ModifyStates_IEnumerator_MoveNext_Throws() { SimpleAnimation animation = Instantiate(); var clip = Resources.Load <AnimationClip>("LinearX"); var clipInstance = Object.Instantiate <AnimationClip>(clip); animation.AddClip(clipInstance, "SingleClip"); IEnumerable <SimpleAnimation.State> states = animation.GetStates(); var it = states.GetEnumerator(); animation.RemoveState("SingleClip"); Assert.Throws <InvalidOperationException>(() => { it.MoveNext(); }); }
public void GetStates_WithSingleState_IEnumerator_Returns_ValidState() { SimpleAnimation animation = Instantiate(); var clip = Resources.Load <AnimationClip>("LinearX"); var clipInstance = Object.Instantiate <AnimationClip>(clip); animation.AddClip(clipInstance, "SingleClip"); IEnumerable <SimpleAnimation.State> states = animation.GetStates(); var it = states.GetEnumerator(); it.MoveNext(); SimpleAnimation.State state = it.Current; Assert.AreEqual("SingleClip", state.name); }
IEnumerator Start() { SoundManager.Play(SoundManager.SEClip.bossStart); yield return(new WaitForSeconds(3f)); foreach (var state in simpleAnimation.GetStates()) { nameList.Add(state.name); } // 一定時間ごとにアニメーションを繰り返す SetRepeatCall(() => !PlayData.bossDied, changeSpan, () => { int rnd = Random.Range(0, 3); // SE SoundManager.Play(SoundManager.SEClip.bossAtack1 + rnd); simpleAnimation.CrossFade(nameList[index], 0.5f); index++; index = Mathf.Clamp(index, 0, nameList.Count - 1); }); }
private void Update() { if (!Application.isPlaying) { return; } if (hitboxes != null) { ; var nowstates = simpleAnimation.GetStates().FirstOrDefault(s => s.enabled); if (nowstates == null) { return; } //var newKeyframesIndex = Convert.ToInt32(Math.Floor(hitboxes[nowstates.name].keyframes.Count * elapsedTime)); var newKeyframesIndex = GetNowKeyFrame(); if (prestate == null || stateChanged) { prestate = nowstates; foreach (var e in nowColliders) { if (e.Key != null) { Destroy(e.Key.gameObject); } } nowColliders.Clear(); preveousKeyFrameIndex = -1; stateChanged = false; } if (preveousKeyFrameIndex != newKeyframesIndex) { var destroylist = new List <GameObject>(); ///生存期間のすぎたcolliderのリスト化 nowColliders.RemoveAll((KVPair <GameObject, KeyFrameCollider> e) => { var elapsed = newKeyframesIndex - e.Value.startframe; if (elapsed >= e.Value.dulation && e.Key.activeSelf) { destroylist.Add(e.Key); return(true); } return(false); }); /// 生存期間の過ぎたcolliderの削除 foreach (var e in destroylist) { Destroy(e); } //新たに発生したcolliderの追加 if (hitboxes.data.Find(e => e.Key == nowstates.name) != null) { for (int i = preveousKeyFrameIndex + 1; i <= newKeyframesIndex; i++) { foreach (var e in hitboxes[nowstates.name].keyframes[i].colliders) { Debug.Log("create col"); var col = AddColliderComponentFromParam(e); nowColliders.Add(new KVPair <GameObject, KeyFrameCollider>(col, e)); } } } /* * if (KeyframesIndex == 0) * { * nowkeyframedata.colliders.Add(new KeyFrameCollider()); * var obj = new GameObject("test"); * var objtrans = obj.GetComponent<Transform>(); * var rigidbody = obj.AddComponent<Rigidbody>(); * rigidbody.useGravity = false; * var col = obj.AddComponent<CapsuleCollider>(); * nowkeyframedata.colliders[0].collider = col; * col.center = new Vector3(3, 0); * col.radius = 1; * col.height = 2; * col.tag = "test"; * col.isTrigger = true; * * objtrans.SetParent(gameObject.transform, false); * * } */ } preveousKeyFrameIndex = newKeyframesIndex; } }