private IEnumerator RandomAnimation(MateInfo mateInfo) { if (mateInfo.Animator == null) { yield break; } float time = 0; while (!mateInfo.StopAnimation) { time = 0; float interval = Random.Range(mateInfo.IntervalMin, mateInfo.IntervalMax); while (time < interval && !mateInfo.StopAnimation) { time += Time.deltaTime; yield return(null); } if (mateInfo.Animator != null && mateInfo.Animator.runtimeAnimatorController != null && mateInfo.Animator.runtimeAnimatorController.animationClips != null) { int state = Random.Range(1, mateInfo.Animator.runtimeAnimatorController.animationClips.Length); mateInfo.Animator.SetInteger("State", state); mateInfo.Animator.SetTrigger("Jump"); } } }
private void LoadMate(AccessoryButton accessoryButton) { this.UnloadMate(accessoryButton); MateInfo mateInfo = this.GetMateInfo(accessoryButton); AssetBundle assetBundle = this.GetAssetBundle(accessoryButton.AB); Object obj = assetBundle.LoadAsset(accessoryButton.Prefab); mateInfo.Object = GameObject.Instantiate(obj) as GameObject; mateInfo.Object.name = string.Format("{0}(Clone)", accessoryButton.name); mateInfo.Object.transform.SetParent(mateInfo.Root, false); mateInfo.Object.AddComponent <FixShader>(); mateInfo.Animator = mateInfo.Object.GetComponent <Animator>(); if (mateInfo.Coroutine != null) { this.StopCoroutine(mateInfo.Coroutine); } mateInfo.Coroutine = this.StartCoroutine(this.RandomAnimation(mateInfo)); this.mates.Add(accessoryButton, mateInfo); StatusBar.Instance.ShowMessage(accessoryButton.ImageBox.sprite); Debug.LogFormat("<><MateLoader.LoadMate>{0}", accessoryButton.Prefab); }