protected override void OnCreate() { GameObject go = new GameObject("Coroutine"); m_Agent = go.AddComponent <CoroutineAgent>(); go.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector; Object.DontDestroyOnLoad(go); }
public void LoadAssetAndInitialize(string assetName, Transform parent, Vector3 pos, System.Action <GameObject> call = null) { UnityEngine.Object ret = LoadAssetFromResource(assetName); if (ret == null) { AssetBundleReader reader = AssetBundleReaderManager.Instance.LoadAssetBundle(assetName); AssetPack ap = null; CoroutineAgent.WaitOperation( () => reader.IsLoaded, () => { if (reader.IsLoaded && reader.AssetBundleData != null) { ret = reader.AssetBundleData.LoadAsset(assetName.AssetFileName().NoExtension()); reader.UnLoadAssetBundle(); } if (ret != null) { if (!m_dicAsset.ContainsKey(assetName)) { ap = new AssetPack(ret, false); m_dicAsset.Add(assetName, ap); } else { ap = m_dicAsset[assetName]; Debug.logger.LogWarning("ResMgr", "ResMgr.LoadAssetAndInitialize: asset name->" + assetName + ", already in asset pool"); } } else { Debug.logger.LogError("ResMgr", "ResMgr.LoadAssetAndInitialize: assetName->" + assetName + ", finds no asset!"); } //targetObj.GetComponent<UITexture>().mainTexture = (Texture)ret; GameObject go = GameObject.Instantiate(ret) as GameObject; go.transform.parent = parent; go.transform.localPosition = pos; go.transform.localScale = Vector3.one; if (call != null) { call(go); } }, this); } else { GameObject go = GameObject.Instantiate(ret) as GameObject; go.transform.parent = parent; go.transform.localPosition = pos; go.transform.localScale = Vector3.one; if (call != null) { call(go); } } }
public override void Perform() { Animation playerAnim = Parent.RoleObject.GetComponent <Animation>(); playerAnim[StateDef.PlayerAnimationClipName.OrdinaryAttack1R].time = 0; playerAnim.Play(StateDef.PlayerAnimationClipName.OrdinaryAttack1R); //m_duration = playerAnim[StateDef.PlayerAnimationClipName.OrdinaryAttack1R].length; CoroutineAgent.DelayOperation(playerAnim[StateDef.PlayerAnimationClipName.OrdinaryAttack1R].length, base.Perform); }
public override void Perform() { Debug.logger.Log("SunYuanSkill2 " + this.Level + " power " + this.SkillData.name); Animation playerAnim = Parent.RoleObject.GetComponent <Animation>(); playerAnim[StateDef.PlayerAnimationClipName.OrdinaryAttack1R].time = 0; playerAnim.Play(StateDef.PlayerAnimationClipName.OrdinaryAttack1R); //m_duration = playerAnim[StateDef.PlayerAnimationClipName.OrdinaryAttack1R].length; CoroutineAgent.DelayOperation(playerAnim[StateDef.PlayerAnimationClipName.OrdinaryAttack1R].length, base.Perform); }
/// <summary> /// 全てのダウンロードを取り止める /// </summary> public static void AbortAll() { if (instance == null) { return; } instance.downloadQueue.Clear(); if (instance.currentDownload != null) { CoroutineAgent.Stop(instance.currentDownload); } }
/// <summary> /// 暗い状態から透明に /// </summary> public void FadeIn(Action didEnd = null, bool bImmediate = false) { if (bImmediate) { var col = m_sptShade.color; col.a = 0f; m_sptShade.color = col; if (didEnd != null) { didEnd(); } return; } CoroutineAgent.Execute(this.FadeProc(false, didEnd)); }
/// <summary> /// 透明な状態から暗くなる. /// </summary> public void FadeOut(Action didEnd = null, bool bImmediate = false) { this.GetScript <Canvas>("canvas").gameObject.SetActive(true); if (bImmediate) { var col = m_sptShade.color; col.a = 1f; m_sptShade.color = col; if (didEnd != null) { didEnd(); } return; } CoroutineAgent.Execute(this.FadeProc(true, didEnd)); // 立て続けに呼ばれる状況などを加味してコルーチンを追加していき順番に処理させたい為CroutineAgentを使用する. }
public void LoadAssetTexture(string assetName, GameObject targetObj, bool isKeepInMemory = false) { UnityEngine.Object ret = LoadAssetFromResource(assetName); if (ret == null) { AssetBundleReader reader = AssetBundleReaderManager.Instance.LoadAssetBundle(assetName); AssetPack ap = null; CoroutineAgent.WaitOperation( () => reader.IsLoaded, () => { if (reader.IsLoaded && reader.AssetBundleData != null) { ret = reader.AssetBundleData.LoadAsset(assetName.AssetFileName().NoExtension()); reader.UnLoadAssetBundle(); } if (ret != null) { if (!m_dicAsset.ContainsKey(assetName)) { ap = new AssetPack(ret, isKeepInMemory); m_dicAsset.Add(assetName, ap); } else { ap = m_dicAsset[assetName]; Debug.logger.LogWarning("ResMgr", "ResMgr.LoadAssetTexture: asset name->" + assetName + ", already in asset pool"); } } else { Debug.logger.LogError("ResMgr", "ResMgr.LoadAssetTexture: assetName->" + assetName + ", finds no asset!"); } targetObj.GetComponent <UITexture>().mainTexture = (Texture)ret; }, this); } else { targetObj.GetComponent <UITexture>().mainTexture = (Texture)ret; } }
private IEnumerator Process() { // サーバ時刻を取得する yield return(ServerTime.SetFromTimeServer()); CoroutineAgent.Execute(TickTime()); IsReady = true; while (true) { if (downloadQueue.Count > 0) { currentDownload = CoroutineAgent.Execute(downloader.Download(downloadQueue.Dequeue())); yield return(currentDownload); currentDownload = null; } yield return(new WaitForEndOfFrame()); } }
/// <summary> /// 初期化処理 /// baseURLに http://drive.google.com が指定された場合、サーバにGoogleDriveを使用する。 /// </summary> public static void Init(string baseURL, string localCachePath, string fileDictFileID = null) { if (instance == null) { instance = new DownloadManager(); } instance.downloader = WWWDownloader.Create(URLBuilder, localCachePath); instance.downloadQueue = new Queue <WWWDownloader.Params>(); instance.useGoogleDrive = (baseURL == "http://drive.google.com"); if (instance.useGoogleDrive) { instance.baseURL = baseURL + "/uc?export=view&id="; } else { instance.baseURL = baseURL; } CoroutineAgent.Execute(instance.SetFilePathDictionary(fileDictFileID)) .Next(instance.Process()); }
void Awake() { coroutines = new Dictionary <int, Coroutine>(); instance = this; GameObject.DontDestroyOnLoad(this.gameObject); }
private void InitStates() { m_stateMachine = new SimpleStateMachine(); this.m_idleState.onEnter = () => { Animation playerAnim = RoleObject.GetComponent <Animation>(); playerAnim[StateDef.PlayerAnimationClipName.IdleR].time = 0; playerAnim[StateDef.PlayerAnimationClipName.IdleR].wrapMode = WrapMode.Loop; playerAnim.Play(StateDef.PlayerAnimationClipName.IdleR); }; this.m_bufferState.onEnter = () => { m_overlayItemModel.IsBuff = true; Animation playerAnim = RoleObject.GetComponent <Animation>(); playerAnim[StateDef.PlayerAnimationClipName.ChargeStartR].time = 0; playerAnim[StateDef.PlayerAnimationClipName.ChargeStartR].wrapMode = WrapMode.Once; playerAnim.Play(StateDef.PlayerAnimationClipName.ChargeStartR); CoroutineAgent.DelayOperation(playerAnim[StateDef.PlayerAnimationClipName.ChargeStartR].length, () => { m_stateMachine.State = m_idleState; }); }; this.m_debufferState.onEnter = () => { m_overlayItemModel.IsDebuff = true; Animation playerAnim = RoleObject.GetComponent <Animation>(); playerAnim[StateDef.PlayerAnimationClipName.WinR].time = 0; playerAnim[StateDef.PlayerAnimationClipName.WinR].wrapMode = WrapMode.Once; playerAnim.Play(StateDef.PlayerAnimationClipName.WinR); CoroutineAgent.DelayOperation(playerAnim[StateDef.PlayerAnimationClipName.WinR].length, () => { m_stateMachine.State = m_idleState; }); }; this.m_bloodState.onEnter = () => { m_overlayItemModel.IsBlooding = true; Animation playerAnim = RoleObject.GetComponent <Animation>(); playerAnim[StateDef.PlayerAnimationClipName.HitBellyR].time = 0; playerAnim[StateDef.PlayerAnimationClipName.HitBellyR].wrapMode = WrapMode.Once; playerAnim.Play(StateDef.PlayerAnimationClipName.HitBellyR); CoroutineAgent.DelayOperation(playerAnim[StateDef.PlayerAnimationClipName.HitBellyR].length, () => { m_stateMachine.State = m_idleState; }); }; this.m_normalHitState.onEnter = () => { Animation playerAnim = RoleObject.GetComponent <Animation>(); playerAnim[StateDef.PlayerAnimationClipName.Hit1R].time = 0; playerAnim[StateDef.PlayerAnimationClipName.Hit1R].wrapMode = WrapMode.Once; playerAnim.Play(StateDef.PlayerAnimationClipName.Hit1R); CoroutineAgent.DelayOperation(playerAnim[StateDef.PlayerAnimationClipName.Hit1R].length, () => { m_stateMachine.State = m_idleState; }); }; this.m_posionState.onEnter = () => { m_overlayItemModel.IsPoison = true; Animation playerAnim = RoleObject.GetComponent <Animation>(); playerAnim[StateDef.PlayerAnimationClipName.Hit2R].time = 0; playerAnim[StateDef.PlayerAnimationClipName.Hit2R].wrapMode = WrapMode.Once; playerAnim.Play(StateDef.PlayerAnimationClipName.Hit2R); CoroutineAgent.DelayOperation(playerAnim[StateDef.PlayerAnimationClipName.Hit2R].length, () => { m_stateMachine.State = m_idleState; }); }; this.m_pressureState.onEnter = () => { m_overlayItemModel.Pressure += 1; Animation playerAnim = RoleObject.GetComponent <Animation>(); playerAnim[StateDef.PlayerAnimationClipName.HitHardR].time = 0; playerAnim[StateDef.PlayerAnimationClipName.HitHardR].wrapMode = WrapMode.Once; playerAnim.Play(StateDef.PlayerAnimationClipName.HitHardR); CoroutineAgent.DelayOperation(playerAnim[StateDef.PlayerAnimationClipName.HitHardR].length, () => { m_stateMachine.State = m_idleState; }); }; }