Exemple #1
0
    IEnumerator CreateAsync(System.Action _callback = null)
    {
        if (isDummy_ == false)
        {
            GameSys.LogError("You can only start create other player in dummy: " + actorInfo.ServerInstanceID);
            yield break;
        }
        //
        isDownloading_ = true;                          //判断是否正在下载,防止重复创建

        OtherPlayer        opc            = null;
        PlayerRendererCtrl myRendererCtrl = null;
        bool faild = false;

        pendingDownload = Create(actorInfo, delegate(OtherPlayer _opc, EResult _result)
        {
            if (_result != EResult.Success)
            {
                faild = true;
                return;
            }

            opc             = _opc;
            pendingDownload = null;
            myRendererCtrl  = opc.gameObject.GetComponentInChildrenFast <PlayerRendererCtrl>();
            myRendererCtrl.Show(false);
        });
        while (opc == null || opc.inited == false)
        {
            if (faild)
            {
                yield break;
            }
            yield return(null);
        }

        pendingDownload = null;
        isDownloading_  = false;

        if (!actorInfo.IsAlive)
        {
            opc.Dead(true);
        }
        if (_callback != null)
        {
            _callback();
        }
    }