IEnumerator CouPreloadModel() { while (ConfigMng.Instance.Pendings > 0) { yield return(new WaitForFixedUpdate()); } if (GameCenter.loginMng.createPlayerInfoDic.Count == 0) { GameCenter.loginMng.InitCreatePlayerInfo(); foreach (PlayerBaseInfo item in GameCenter.loginMng.createPlayerInfoDic.Values) { CreatePlayer preloadPlayer = CreatePlayer.CreateDummy(item); preloadPlayer.StartAsyncCreate(() => { preloadPlayer.transform.position = new Vector3(-1000, -1000, -1000); }); AbilityInstance ability = new AbilityInstance(item.CreateAbilityID, 1, null, null); if (ability != null) { string effectName = ability.ProcessEffectList.Count > 0 ? ability.ProcessEffectList[0] : string.Empty; if (!string.IsNullOrEmpty(effectName)) { AssetMng.GetEeffctAssetObject(effectName, (x) => { }); //AssetMng.GetEffectInstance(effectName, null);//预加载特效 } } } } }
IEnumerator LoadScriptsConfig(string assetName, Action <string> _finish) { string scriptsConfig = string.Empty; string path = AssetMng.GetPathWithoutExtension("config/", AssetPathType.PersistentDataPath) + assetName; Debug.Log("path:" + path); WWW www = new WWW(path); while (www == null || !www.isDone) { yield return(new WaitForFixedUpdate()); } if (www != null && www.isDone) { scriptsConfig = www.text; Debug.Log("text:" + www.text); } else { Debug.LogError("资源加载失败:" + path); } if (_finish != null) { _finish(scriptsConfig); } www.Dispose(); www = null; yield break; }
public void DoRideEffect(string _effectName) { if (!CanShow) { return; } if (rideEffect == null) { AssetMng.GetEffectInstance(_effectName, (x) => { if (x != null && this != null) { rideEffect = x; x.SetMaskLayer(this.gameObject.layer); x.transform.parent = this.gameObject.transform; x.transform.localPosition = new Vector3(0, 0.1f, 0); x.transform.localEulerAngles = Vector3.zero; x.SetActive(true); } }); } else { RePlay(rideEffect.gameObject); } }
/// <summary> /// 创建一个特定特效的对象池 by吴江 /// </summary> /// <param name="_effectName"></param> /// <param name="_callback"></param> public void BuildDefEffecterPool(string _effectName, System.Action <exComponentPool <PoolEffecter> > _callback) { if (!effectPoolCacheList.Contains(_effectName)) { effectPoolCacheList.Add(_effectName); } AssetMng.GetEffectInstance(_effectName, (x) => { exComponentPool <PoolEffecter> pool = null; if (x != null) { x.name = _effectName; pool = new exComponentPool <PoolEffecter>(); GameObject.DontDestroyOnLoad(x); GameObject defEffecterPoolCache = new GameObject(_effectName + " ExPoolCache"); defEffecterPoolCache.transform.parent = poolObject.transform; defEffecterPoolCache.transform.localPosition = Vector3.zero; pool.Init(x, 3, defEffecterPoolCache.transform); } else { Debug.LogError(_effectName + "特效加载失败!"); } if (_callback != null) { _callback(pool); } }); }
protected override void Init() { base.Init(); animFSM = base.animFSM as SceneItemAnimFSM; if (animFSM != null) { animFSM.SetDeadAnim(actorInfo.DeadAnimName, actorInfo.DeadTime); animFSM.SetupIdleAndMoveAnimationName("idle1", "move2"); animFSM.SetupCombatAnimationName("idle1", null); animFSM.Idle(); } nameHeight = actorInfo.NameHeight; height = 0f; beAttackRadius = actorInfo.ColliderRadius; //IsActiveForMainplayer = CheckIsActiveForMainplayer(); if (headTextCtrl == null) { headTextCtrl = this.gameObject.AddComponent <HeadTextCtrl>(); } if (!actorInfo.IsActor) // && IsActiveForMainplayer) //过场动画演员不展示名字 { UpdateName(); } // if (actorInfo.BubbleContent != null) // { // headTextCtrl.SetBubble(actorInfo.BubbleContent.content, actorInfo.BubbleContent.time); // } AssetMng.GetEeffctAssetObject(actorInfo.DeadEffectName, null);//预加载死亡特效(镜像文件) inited_ = true; ActiveBoxCollider(IsActiveForMainplayer, actorInfo.colliderScale); ShowPointEffect(); }
public static AssetMng.DownloadID GetShadow(string _name, System.Action <GameObject, EResult> _onComplete) { string url = AssetMng.GetPathWithoutExtension("effect/" + _name, AssetPathType.PersistentDataPath) + ".object"; AssetMng.DownloadID downloadID = AssetMng.instance.LoadAsset <GameObject>(url, _name, _onComplete, true); return(downloadID); }
public void DoSedanEffect() { if (!CanShow) { return; } ClearSedanEffect(); for (int i = 1, max = 5; i < max; i++) { string pointName = "xl_hc_point" + i; AssetMng.GetEffectInstance("fx_hc_001", (x) => { if (x != null) { Transform point = MeshHelper.GetBone(this.transform, pointName); //this.transform.Find(pointName);// GameObject.Find(); effect_Sedan_last.Add(x); x.SetMaskLayer(this.gameObject.layer); x.transform.parent = (point == null)?this.gameObject.transform:point; x.transform.localPosition = Vector3.zero; x.transform.localScale = Vector3.one; x.SetActive(true); } }); } }
public void DoBuffEffect(string _assetName, Transform _parent) { if (!CanShow) { return; } if (_assetName.Length == 0 || _assetName == "0") { return; } if (buffDic.ContainsKey(_assetName) && buffDic[_assetName] != null) { buffDic[_assetName].SetActive(true); RePlay(buffDic[_assetName]); } else { if (!waitList.ContainsKey(_assetName)) { waitList[_assetName] = true; AssetMng.GetEffectInstance(_assetName, (x) => { if (x == null) { return; } if (this.gameObject == null) { Destroy(x); return; } buffDic[_assetName] = x; x.SetMaskLayer(this.gameObject.layer); if (_parent == null) { x.transform.parent = this.transform; } else { x.transform.parent = _parent; } x.transform.localScale = Vector3.one; x.transform.localEulerAngles = Vector3.zero; x.transform.localPosition = Vector3.zero; x.SetActive(waitList[_assetName]); FXRoot fr = x.GetComponent <FXRoot>(); if (fr != null) { fr.isWorldMatrix = true; } waitList.Remove(_assetName); }, true); } else if (!waitList[_assetName]) { waitList[_assetName] = true; } } }
void Awake() { instance = this; if (transform.parent == null) { DontDestroyOnLoad(this); } }
/// <summary> /// 获取随从模型 /// </summary> /// <param name="_url"></param> /// <param name="_onComplete"></param> /// <returns></returns> public static AssetMng.DownloadID GetEntourage(string _url, System.Action <GameObject, EResult> _onComplete) { AssetMng.DownloadID downloadID = AssetMng.instance.LoadAsset <GameObject>(AssetMng.GetPathWithExtension(_url, AssetPathType.PersistentDataPath), _url, _onComplete, true); return(downloadID); }
void Awake() { instance = this; mainPath = AssetMng.GetPathWithoutExtension("scene/", AssetPathType.PersistentDataPath); if (transform.parent == null) { DontDestroyOnLoad(this); } }
public virtual void StartAsyncCreate(System.Action <FlyPoint> _callback) { string pointName = string.Empty; this.gameObject.SetMaskLayer(LayerMask.NameToLayer("Static")); this.gameObject.name = "FlyPoint[" + refData.id + "]"; isDummy_ = false; Effect = null; typeID = ObjectType.FlyPoint; id = refData.id; AssetMng.GetEffectInstance(refData.resourceModel, (x) => { if (this == null) { Destroy(x); return; } x.SetMaskLayer(LayerMask.NameToLayer("Static")); Effect = x; if (Effect == null) { return; } Effect.transform.parent = gameObject.transform; Effect.transform.localPosition = new Vector3(0, 0, 0); Effect.transform.localRotation = Quaternion.Euler(0f, 0f, 0f); Effect.name = "effect"; }); if (headTextCtrl == null) { headTextCtrl = this.gameObject.AddComponent <HeadTextCtrl>(); } if (refData.name.Contains("\\n")) { pointName = refData.name.Replace("\\n", "\r\n"); } headTextCtrl.SetName(pointName == string.Empty ? refData.name : pointName); if (RefData.needLv > GameCenter.mainPlayerMng.MainPlayerInfo.Level) { headTextCtrl.SetTitle("Lv" + RefData.needLv); } height = 2.0f; ActiveBoxCollider(true, 3.0f); if (_callback != null) { _callback(this); } }
public static AssetMng.DownloadID GetMount(string _modelName, System.Action <GameObject, EResult> _onComplete) { string[] strs = _modelName.Split('/'); string resName = strs[strs.Length - 1]; AssetMng.DownloadID downloadID = AssetMng.instance.LoadAsset <GameObject>(AssetMng.GetPathWithExtension(_modelName, AssetPathType.PersistentDataPath), resName, _onComplete, true); return(downloadID); }
public void Enable(GameObject _actor, bool _isShow) { isShow = _isShow; if (_actor == null) { return; } isActive = true; if (boneObj == null) { boneObj = GetBone(_actor); } if (effectObj != null && effectObj.name != EffectName) { GameObject.DestroyImmediate(effectObj); effectObj = null; } if (!isDonwLoading) { if (effectObj == null) { isDonwLoading = true; AssetMng.GetEffectInstance(EffectName, (x) => { isDonwLoading = false; effectObj = x; if (boneObj == null) { boneObj = GetBone(_actor); } if (this == null || boneObj == null) { if (boneObj == null) { Debug.LogError("找不到指定挂点:" + boneName); } Destory(); return; } SetActive(isActive); if (preview || boneObj.layer == LayerMask.NameToLayer("Preview")) { SetPreviewShader(); } }); } else { SetActive(isActive); } } }
/// <summary> /// 播放攻击特效 by吴江 /// </summary> /// <param name="_effectName"></param> /// <param name="_time"></param> public void DoAttackEffect(string _effectName, float _time, float _speedRate, Vector3 _scale, Transform _parent) { if (isHide) { return; } if (!CanShow) { return; } if (_time == 0) { return; } waitEffect.Add(_effectName); if (curAttackEffect != null) { DestroyImmediate(curAttackEffect); } AssetMng.GetEffectInstance(_effectName, (x) => { if (x == null || this == null || this.gameObject == null || !waitEffect.Contains(_effectName)) { Destroy(x); return; } waitEffect.Remove(_effectName); curAttackEffect = x; AdjustSpeedRuntime(x, _speedRate); x.SetMaskLayer(this.gameObject.layer); if (_parent == null) { x.transform.parent = this.transform; } else { x.transform.parent = _parent; } x.transform.localPosition = Vector3.zero; x.transform.localEulerAngles = Vector3.zero; x.transform.localScale = _scale; if (_time >= 0) { Destroy(x, _time); } }); }
public void DoNormalEffect(string _effectName) { if (!CanShow || _effectName == string.Empty) { return; } ClearNormalEffect(); AssetMng.GetEffectInstance(_effectName, (x) => { if (this != null && this.gameObject != null && x != null) { normalEffect = x; x.SetMaskLayer(this.gameObject.layer); x.transform.parent = this.gameObject.transform; x.transform.position = this.gameObject.transform.position + new Vector3(0, 0.1f, 0); x.transform.rotation = this.gameObject.transform.rotation; } }, true); }
public void StartLoadResources(string _sceneName, int _sceneIndex, Action _callBack) { string mainPath = AssetMng.GetPathWithoutExtension("scene/", AssetPathType.PersistentDataPath); //获取本次所需要的所有特效名称 List <string> wholeNeedNames = new List <string>(); SceneRef refData = ConfigMng.Instance.GetSceneRef(_sceneIndex); if (refData != null) { wholeNeedNames.Add(refData.replaceNavmesh); } wholeNeedNames.Add(_sceneName); StartCoroutine(LoadResources(mainPath, wholeNeedNames, _callBack, true)); }
new void OnDestroy() { base.OnDestroy(); FDictionary dic = GameCenter.sceneMng.MobInfoDictionary; bool got = false; foreach (MonsterInfo item in dic.Values) { if (item.Prof == actorInfo.Prof) { got = true; break; } } if (!got)//如果场景中已经没有同类怪了,那么卸载资源 { AssetMng.instance.UnloadUrl(AssetMng.GetPathWithExtension(actorInfo.BoneName, AssetPathType.PersistentDataPath)); } }
new void OnDestroy() { base.OnDestroy(); FDictionary dic = GameCenter.sceneMng.NPCInfoDictionary; bool got = false; foreach (NPCInfo item in dic.Values) { if (item.Type == actorInfo.Type) { got = true; break; } } if (!got)//如果场景中已经没有同类怪了,那么卸载资源 { AssetMng.instance.UnloadUrl(AssetMng.GetPathWithExtension(actorInfo.AssetName, actorInfo.AssetType)); } }
protected virtual void EnterAwakeState(fsm.State _from, fsm.State _to, fsm.Event _event) { //Debug.Log("EnterAwakeState"); if (!isDevelopmentPattern) { Application.targetFrameRate = 30;//限制最多每秒计算30帧 } Caching.CleanCache(); //LayerMng.Init(); if (stageObj == null) { stageObj = new GameObject(); stageObj.transform.parent = this.transform; stageObj.transform.localPosition = Vector3.zero; stageObj.name = "Stage"; } GameObject assetLoadObj = new GameObject(); assetLoadObj.transform.parent = this.transform; assetLoadObj.transform.localPosition = Vector3.zero; assetLoadObj.name = "AssetLoad"; AssetMng assetMng = assetLoadObj.AddComponent <AssetMng>(); assetMng.Init(); GameObject.DontDestroyOnLoad(this.gameObject); ResgistMsg(); //UI部分 if (isDevelopmentPattern) { stateMachine.Send((int)EventType.INIT_CONFIG); } else { //GameCenter.uIMng.SwitchToUI(GUIType.UPDATEASSET); stateMachine.Send((int)EventType.UPDATEASSET); } }
/// <summary> /// 加载掩码 by吴江 /// </summary> /// <param name="_sceneName"></param> /// <param name="_sceneIndex"></param> /// <param name="_callBack"></param> public void StartLoadMapConfig(string _sceneName, int _sceneIndex, Action _callBack) { SceneRef sceneRef = ConfigMng.Instance.GetSceneRef(_sceneIndex); if (sceneRef != null) { string mainPath = AssetMng.GetPathWithoutExtension("scene/", AssetPathType.PersistentDataPath); StartCoroutine(LoadMapConfig(mainPath, sceneRef.replaceNavmesh, () => { if (_callBack != null) { _callBack(); } })); } else { Debug.LogError("场景 " + _sceneName + "的配置文件找不到!"); } }
public void DoDeadEffect(string _effectName) { if (!CanShow) { return; } ClearDeadEffect(); AssetMng.GetEffectInstance(_effectName, (x) => { if (x != null) { effect_Dead_last = x; x.SetMaskLayer(this.gameObject.layer); x.transform.parent = this.gameObject.transform; x.transform.position = this.gameObject.transform.position + new Vector3(0, 0.1f, 0); x.transform.rotation = this.gameObject.transform.rotation; x.SetActive(true); } }); }
public static AssetMng.DownloadID GetRace(int _id, System.Action <GameObject, EResult> _onComplete) { PlayerConfig playerConfig = ConfigMng.Instance.GetPlayerConfig(_id); if (playerConfig != null) { AssetMng.DownloadID downloadID = AssetMng.instance.LoadAsset <GameObject>(AssetMng.GetPathWithExtension(playerConfig.res_name, AssetPathType.PersistentDataPath), playerConfig.res_name, _onComplete, true); return(downloadID); } else { GameSys.LogError("Unknown raceID " + _id); _onComplete(null, EResult.NotFound); return(null); } }
public void DoBossEffect(float _radius, string _effectName) { if (!CanShow) { return; } ClearBossEffect(); AssetMng.GetEffectInstance(_effectName, (x) => { if (x != null) { effect_Boss_last = x; x.SetMaskLayer(this.gameObject.layer); x.transform.parent = this.gameObject.transform; x.transform.position = this.gameObject.transform.position + new Vector3(0, 0.1f, 0); x.transform.rotation = this.gameObject.transform.rotation; x.transform.localScale = new Vector3(_radius, 1, _radius); x.SetActive(true); } }); }
public void DoFlyEffect(string _effectName) { if (effect_fly_last != null) { Destroy(effect_fly_last); effect_fly_last = null; } if (!CanShow) { return; } if (effect_fly_last == null) { AssetMng.GetEffectInstance(_effectName, (x) => { if (x != null) { if (this == null) { Destroy(x); return; } if (GameCenter.mainPlayerMng.isStartingFlyEffect) //如果传送特效没在0.5f内出来,则不需要出来 解决:传送特效紫色的bug by邓成 { effect_fly_last = x; x.SetMaskLayer(this.gameObject.layer); x.transform.parent = this.gameObject.transform; x.transform.localPosition = new Vector3(0, 0.1f, 0); x.transform.localEulerAngles = Vector3.zero; x.SetActive(true); Invoke("ClearFlyEffect", 0.5f); } else { Destroy(x); } } }); } }
public static AssetMng.DownloadID GetRace(int _id, System.Action <GameObject, EResult> _onComplete, bool isCreatePlayer) { PlayerConfig playerConfig = ConfigMng.Instance.GetPlayerConfig(_id); if (playerConfig != null) { string resName = (isCreatePlayer?playerConfig.display_res:playerConfig.res_name); //Debug.Log("resName:"+resName); AssetMng.DownloadID downloadID = AssetMng.instance.LoadAsset <GameObject>(AssetMng.GetPathWithExtension(resName, AssetPathType.PersistentDataPath), resName, _onComplete, true); return(downloadID); } else { GameSys.LogError("Unknown raceID " + _id); _onComplete(null, EResult.NotFound); return(null); } }
//public static void UnloadRace(int _id) //{ // PlayerConfig playerConfig = ConfigMng.Instance.GetPlayerConfig(_id); // if (playerConfig != null) // { // AssetMng.instance.UnloadUrl(AssetMng.GetPathWithExtension("Player/" + playerConfig.res_name, (AssetPathType)playerConfig.path_type)); // } //} public static AssetMng.DownloadID GetNPC(int _id, System.Action <GameObject, EResult> _onComplete) { NPCTypeRef npcRef = ConfigMng.Instance.GetNPCTypeRef(_id); if (npcRef != null) { string[] strs = npcRef.res_name.Split('/'); string resName = strs[strs.Length - 1]; AssetMng.DownloadID downloadID = AssetMng.instance.LoadAsset <GameObject>(AssetMng.GetPathWithExtension(npcRef.res_name, (AssetPathType)npcRef.path_type), resName, _onComplete, true); return(downloadID); } else { GameSys.LogError("Unknown type " + _id); _onComplete(null, EResult.NotFound); return(null); } }
/// <summary> /// 场景物品 /// </summary> public static AssetMng.DownloadID GetSceneItem(int _id, System.Action <GameObject, EResult> _onComplete) { SceneItemRef itemRef = ConfigMng.Instance.GetSceneItemRef(_id); if (itemRef != null) { string[] strs = itemRef.assetName.Split('/'); string resName = strs[strs.Length - 1]; AssetMng.DownloadID downloadID = AssetMng.instance.LoadAsset <GameObject>(AssetMng.GetPathWithExtension(itemRef.assetName, AssetPathType.PersistentDataPath), resName, _onComplete, true); return(downloadID); } else { GameSys.LogError("Unknown type " + _id); _onComplete(null, EResult.NotFound); return(null); } }
public void DoAttckWholeTimeEffect(string _effectName, Transform _animaRoot) { if (isHide) { return; } if (!CanShow || _effectName == string.Empty) { return; } ClearAttckWholeTimeEffect(); AssetMng.GetEffectInstance(_effectName, (x) => { if (this != null && this.gameObject != null && x != null) { attckWholeTimeEffect = x; x.SetMaskLayer(this.gameObject.layer); x.transform.parent = _animaRoot; x.transform.localPosition = new Vector3(0, 0.1f, 0); x.transform.rotation = Quaternion.identity; } }, true); }
/// <summary> /// 创建链式特效(唯一) by吴江 /// </summary> /// <param name="_tarA"></param> /// <param name="_tarB"></param> /// <param name="_effectName"></param> public void CastLineEffect(Actor _tarA, Actor _tarB, string _effectName, float _speed = 1.0f) { if (lineEffectDic.ContainsKey(_effectName)) { Destroy(lineEffectDic[_effectName] as GameObject); lineEffectDic.Remove(_effectName); } if (_tarA == null || _tarB == null) { return; } AssetMng.GetEffectInstance(_effectName, (x) => { lineEffectDic[_effectName] = x; LightningEmitter le = x.GetComponent <LightningEmitter>(); if (le != null) { le.Target1 = _tarA.HitPoint; le.Target2 = _tarB.HitPoint; le.animSpeed = _speed; } }); }