示例#1
0
        protected override void OnCreate()
        {
            GameObject go = new GameObject("Coroutine");

            m_Agent      = go.AddComponent <CoroutineAgent>();
            go.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector;
            Object.DontDestroyOnLoad(go);
        }
示例#2
0
    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);
            }
        }
    }
示例#3
0
    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);
    }
示例#4
0
    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);
    }
示例#5
0
    /// <summary>
    /// 全てのダウンロードを取り止める
    /// </summary>
    public static void AbortAll()
    {
        if (instance == null)
        {
            return;
        }

        instance.downloadQueue.Clear();
        if (instance.currentDownload != null)
        {
            CoroutineAgent.Stop(instance.currentDownload);
        }
    }
示例#6
0
 /// <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));
 }
示例#7
0
 /// <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を使用する.
 }
示例#8
0
    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;
        }
    }
示例#9
0
    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());
        }
    }
示例#10
0
    /// <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());
    }
示例#11
0
 void Awake()
 {
     coroutines = new Dictionary <int, Coroutine>();
     instance   = this;
     GameObject.DontDestroyOnLoad(this.gameObject);
 }
示例#12
0
    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; });
        };
    }