public void Destroy() { ResetModel(); CleanupMaterials(); var helpers = mDMono.GetComponentsInChildren <MoveEditor.FXHelper>(); for (int i = 0; i < helpers.Length; ++i) { helpers[i].StopAll(true); } if (_HeadBar != null) { _HeadBar.ClearBars(); } CharacterVariant variant = mDMono.GetComponentInChildren <CharacterVariant>(); if (variant != null) { variant.Recycle(); PoolModel.DestroyModel(variant.gameObject); } GameObject.Destroy(mDMono.gameObject); if (enemyController.onDestroy != null) { enemyController.onDestroy(enemyController); } }
public void Destroy() { var helpers = mDMono.GetComponentsInChildren <MoveEditor.FXHelper>(); if (helpers != null && helpers.Length > 0) { for (var i = 0; i < helpers.Length; i++) { helpers[i].StopAll(true); } } PlayerDataLookupSet pdls = mDMono.transform.GetDataLookupILRComponentInChildren <PlayerDataLookupSet>("Hotfix_LT.UI.PlayerDataLookupSet", showErrorTips: false); if (pdls != null) { pdls.Destroy(); } CharacterVariant variant = mDMono.GetComponentInChildren <CharacterVariant>(); if (variant != null) { variant.Recycle(); PoolModel.DestroyModel(variant.gameObject); } GameObject.Destroy(mDMono.gameObject); }
public void ChangeArenaModel(string Tid, int skin = 0, bool ChangeModel = false) { try { if (ChangeModel) { ResetModel(); _HeadBar = null; CharacterVariant CV = mDMono.transform.GetComponentInChildren <CharacterVariant>(); if (CV != null && GameEngine.Instance != null) { SetObjLayer(CV.CharacterInstance, GameEngine.Instance.defaultLayer); CV.Recycle(); PoolModel.DestroyModel(CV.gameObject); } MoveEditor.FXHelper FH = mDMono.transform.GetComponentInChildren <MoveEditor.FXHelper>(); if (FH != null) { FH.StopAll(true); } if (enemyController.SkinnedRigPrefab != null) { PoolModel.DestroyModel(enemyController.SkinnedRigPrefab); } string classname = null; string characterid = CharacterTemplateManager.Instance.TemplateidToCharacterid(Tid); var charTpl = CharacterTemplateManager.Instance.GetHeroInfo(characterid, skin); classname = charTpl.model_name;//需添加皮肤 if (string.IsNullOrEmpty(classname)) { EB.Debug.LogError("OnViewIdAllocated: classname not found for tid = {0}", Tid); return; } enemyController.CharacterModel = CharacterCatalog.Instance.GetModel(classname); OnSpawnFun(); Role = _role; SceneLogic scene = MainLandLogic.GetInstance(); string sceneName = scene.CurrentSceneName; SetNpcName(sceneName); } } catch (System.Exception e) { EB.Debug.LogError(e.StackTrace); } }
//public override void OnEnable() //{ // RegisterMonoUpdater(); //} public void DestroyCharacter() { if (m_Character != null) { if (!ShouldSetMipMapBias) { UpdateMipMapBias(m_Avatar, 0.0f); } MoveEditor.FXHelper fxHelper = m_Character.GetComponent <MoveEditor.FXHelper>(); if (fxHelper != null) { fxHelper.StopAll(true); //if (PSPoolManager.Instance != null) //{ // PSPoolManager.Instance.Update(); //} } CharacterVariant variant = m_CharacterContainer.GetComponentInChildren <CharacterVariant>(); if (variant != null && GameEngine.Instance != null) { SetObjLayer(variant.CharacterInstance, GameEngine.Instance.defaultLayer); variant.Recycle(); PoolModel.DestroyModel(variant.gameObject); } m_Character = null; } /* * if (!string.IsNullOrEmpty(m_VariantName)) * { * if (PoolModel != null) * { * PoolModel.RemoveResource(variantPath, false); * } * * m_VariantName = null; * } */ m_Loading = false; }
public void ChangeModel(string modelName, bool firstCreate, float scale = 1) { if (playerController == null) { EB.Debug.LogWarning("playerController is null"); return; } if (playerController.CharacterModel != null && playerController.CharacterModel.ResourcePrefabNameMain.IndexOf(modelName) >= 0) { EB.Debug.LogWarning("ChangeModel: Aready Exist model={0}", modelName); return; } if (_HeadBar != null) { _HeadBar.ClearBars(); _HeadBar = null; } try { CharacterVariant CV = mDMono.transform.GetComponentInChildren <CharacterVariant>(); MoveEditor.FXHelper FH = mDMono.transform.GetComponentInChildren <MoveEditor.FXHelper>(); if (FH != null) { FH.StopAll(true); } if (CV != null && GameEngine.Instance != null) { SetObjLayer(CV.CharacterInstance, GameEngine.Instance.defaultLayer); CV.Recycle(); PoolModel.DestroyModel(CV.gameObject); } if (playerController.SkinnedRigPrefab != null) { PoolModel.DestroyModel(playerController.SkinnedRigPrefab); } /// playerController.Gender = eGender.Male; playerController.CharacterModel = CharacterCatalog.Instance.GetModel(modelName); string prefabName = playerController.CharacterModel.PrefabNameFromGenderMain(playerController.Gender); PoolModel.GetModelAsync(prefabName, mDMono.transform.position, Quaternion.identity, (o, prm) => { var variantObj = o as GameObject; variantObj.transform.SetParent(mDMono.transform); variantObj.transform.localPosition = Vector3.zero; CharacterVariant variant = variantObj.GetComponent <CharacterVariant>(); variant.SyncLoad = true; IDictionary partions = GetPartitionsData(LoginManager.Instance.LocalUserId.Value); variant.InstantiateCharacter(partions); InitDataLookupSet(); playerController.SkinnedRigPrefab = variant.CharacterInstance; playerController.SkinnedRigPrefab.name = prefabName + "_Character"; playerController.SkinnedRigPrefab.tag = "CharacterMesh"; playerController.SkinnedRigPrefab.transform.SetParent(mDMono.transform); playerController.SkinnedRigPrefab.transform.localRotation = Quaternion.identity; playerController.SkinnedRigPrefab.transform.localScale = new Vector3(scale, scale, scale); _combatController = mDMono.GetComponent <CombatController>(); _combatController.Initialize(playerController.SkinnedRigPrefab.transform, playerController.CharacterModel, 1 << LayerMask.NameToLayer("Enemy")); playerController.CharacterComponent = mDMono.GetComponent <CharacterComponent>(); playerController.CharacterComponent.OnSpawn(playerController.CharacterModel, playerController.SkinnedRigPrefab, -1, false); _HeadBar = playerController.SkinnedRigPrefab.GetMonoILRComponent <HeadBars2D>(false); if (_HeadBar == null) { _HeadBar = playerController.SkinnedRigPrefab.AddMonoILRComponent <HeadBars2D>("Hotfix_LT.UI.HeadBars2D"); } if (mDMono.GetComponent <Collider>() != null && mDMono.GetComponent <Collider>() is BoxCollider) { BoxCollider box = mDMono.GetComponent <Collider>() as BoxCollider; box.size = new Vector3(1.5f, 1.5f, 1.5f) + new Vector3(0, playerController.CharacterModel.heightOffset, 0); box.center = new Vector3(0, box.size.y / 2.0f, 0); } _muzzle = GameUtils.SearchHierarchyForBone(playerController.SkinnedRigPrefab.transform, "muzzle"); if (null == _muzzle) { _muzzle = mDMono.transform; } if (firstCreate) { LevelOwnerComponent.AssignLevelOwner(mDMono.gameObject); // this must be called after PlayerManager.RegisterPlayerController(this); } _avatar = playerController.SkinnedRigPrefab.GetComponent <AvatarComponent>(); _shouldSetHideColor = !PerformanceManager.Instance.CurrentEnvironmentInfo.slowDevice; if (!firstCreate) { PlayerDataLookupSet PDLS = playerController.SkinnedRigPrefab.transform.GetDataLookupILRComponent <PlayerDataLookupSet>(); if (PDLS != null) { PDLS.UserId = playerController.playerUid; } } MoveController mc = playerController.SkinnedRigPrefab.GetComponent <MoveController>(); if (mDMono != null && mDMono.GetComponent <CharacterComponent>().State != eCampaignCharacterState.Idle) { mc.TransitionTo(MoveController.CombatantMoveState.kLocomotion); } }, null); } catch (System.NullReferenceException e) { EB.Debug.LogError(e.ToString()); } }