protected IEnumerator CreateAsync(Action <PreviewNPC> _callback) { if (isDummy_ == false) { GameSys.LogError("You can only start create NPC in dummy: " + actorInfo.ServerInstanceID); yield break; } isDownloading_ = true; PreviewNPC npc = null; //NPCRendererCtrl myRendererCtrl = null; bool faild = false; pendingDownload = Create(actorInfo, delegate(PreviewNPC _npc, EResult _result) { if (_result != EResult.Success) { faild = true; return; } npc = _npc; float previewScale = Mathf.Max(0, actorInfo.PreviewScale(previewConfigType)); if (previewScale == 0) { previewScale = 1; } npc.transform.localScale *= previewScale; pendingDownload = null; //myRendererCtrl = npc.GetComponent<NPCRendererCtrl>(); //TO TO:初始化出来应该先隐藏,由任务等其他信息决定是否要显示 by吴江 //myRendererCtrl.Show(false, true); }); if (mutualExclusion) { GameCenter.previewManager.PushDownLoadTask(pendingDownload); } while (npc == null || npc.inited == false) { if (faild) { yield break; } yield return(null); } if (mutualExclusion) { GameCenter.previewManager.EndDownLoadTask(pendingDownload); } pendingDownload = null; isDownloading_ = false; if (_callback != null) { _callback(npc); } }
public bool TryPreviewSingelNPC(NPCInfo _info, UITexture _showLabel, PreviewConfigType _previewType) { curShowLabel = _showLabel; CancelAllDownLoad(); if (_info != null) { PreviewNPC pp = PreviewNPC.CreateDummy(_info); pp.previewConfigType = _previewType; pp.StartAsyncCreate(CreateNPCCallBack); return(true); } return(false); }
/// <summary> /// 非经过我同意禁用本接口 by吴江 /// </summary> /// <param name="_info"></param> /// <param name="_callBack"></param> /// <returns></returns> public bool TryPreviewSingelNPC(int _npcTypeID, System.Action <PreviewNPC> _callBack) { NPCTypeRef refData = ConfigMng.Instance.GetNPCTypeRef(_npcTypeID); if (refData != null) { PreviewNPC pp = PreviewNPC.CreateDummy(refData); pp.mutualExclusion = false; pp.StartAsyncCreate(_callBack); return(true); } return(false); }
public void CreateNPCCallBack(PreviewNPC _npc) { //防止有之前延迟的模型加载,再次清理 ClearModel(); GameObject parent = GetModelTransform(_npc.PreviewPosition, _npc.PreviewRotation); if (null != parent) { _npc.transform.parent = parent.transform; _npc.transform.localPosition = new Vector3(0, -_npc.Height / 2f, 0); _npc.transform.localEulerAngles = new Vector3(0, 180f, 0); } _npc.FaceToNoLerp(180f); BindRenderAndUI(curShowLabel); }
public bool TryPreviewSingelNPC(int _npcTypeID, UITexture _showLabel, PreviewConfigType _previewType) { curShowLabel = _showLabel; CancelAllDownLoad(); NPCTypeRef refData = ConfigMng.Instance.GetNPCTypeRef(_npcTypeID); if (refData != null) { PreviewNPC pp = PreviewNPC.CreateDummy(refData); pp.previewConfigType = _previewType; pp.StartAsyncCreate(CreateNPCCallBack); return(true); } return(false); }
/// <summary> /// 创建NPC的净数据对象 by吴江 /// </summary> /// <param name="_info"></param> /// <returns></returns> public static PreviewNPC CreateDummy(NPCInfo _info) { GameObject newGO = null; if (GameCenter.instance.dummyMobPrefab != null) { newGO = Instantiate(GameCenter.instance.dummyNpcPrefab) as GameObject; newGO.name = "Dummy Preview NPC [" + _info.ServerInstanceID + "]"; } else { newGO = new GameObject("Dummy Preview NPC[" + _info.ServerInstanceID + "]"); } newGO.tag = "NPC"; PreviewNPC npc = newGO.AddComponent <PreviewNPC>(); npc.actorInfo = _info; npc.isDummy_ = true; return(npc); }