/// <summary> /// 创建皮肤控制器 /// </summary> private void BuildSkinControl() { // 不同实体类型加载 switch (Type) { case ENTITY_TYPE.TYPE_PLAYER_ROLE: { skinControl = m_gameObject.GetComponent <SkinCtrl.PersonSkinControl>(); skinControl.Init(); } break; case ENTITY_TYPE.TYPE_MONSTER: { skinControl = m_gameObject.GetComponent <SkinCtrl.MonsterSkinControl>(); skinControl.Init(); } break; case ENTITY_TYPE.TYPE_TANK: { skinControl = m_gameObject.GetComponent <SkinCtrl.TankSkinControl>(); skinControl.Init(); } break; default: break; } }
private static void InsetToTree(SkinQuadTreeNode root, U3D_Render.SkinCtrl.EntitySkinControl instance) { if (!instance) { return; } if (!instance.isActiveAndEnabled) { return; } Vector2 pos2D = Vector2.zero; pos2D.x = instance.transform.position.x; pos2D.y = instance.transform.position.z; SkinQuadTreeNode p = GetQuadTreeParent(root, pos2D); if (null != p) { //SkinQuadTreeLeaf leaf = new SkinQuadTreeLeaf(); //leaf.parent = p; // p.m_LeavesList.Add(leaf); // leaf.skinControl = instance; p.m_LeavesList.Add(instance); instance.hostQuadTreeNode = p; } }
/// <summary> /// 重置 /// </summary> public void Restore() { CacheSkin(); //要在他们之前清理,因为动态脚本是依赖静态脚本的 DestroyDynamicCommopnent(); if (skinControl) { skinControl.Clear(); skinControl = null; } if (m_property) { m_property.Restore(); m_property = null; } if (m_stateMachine) { m_stateMachine.Clear(); m_stateMachine.ResetAllMembers(); m_stateMachine = null; } if (m_LightEffectManager) { m_LightEffectManager.Clear(); m_LightEffectManager.Restore(); m_LightEffectManager = null; } m_SkillCtrl = null; UBloodManager.Instance.DestroyBlood(ID); commands.Clear(); //commands = null; }
private static void RefershQuadTreeNode() { U3D_Render.EntityView heroView = EntityFactory.getMainPlayer(); if (null == heroView) { return; } if (!heroView.StateMachine) { return; } Vector3 pos = heroView.StateMachine.transform.position; Vector2 pos2D = Vector2.zero; Vector2 Dir2D = Vector2.zero; pos2D.x = pos.x; pos2D.y = pos.z; GenerateActiveQuadParent(quadTreeRoot, 0.0f, pos2D, Vector2.zero, CellSize, ref ActiveLeafList, ref ActiveParent, ref unUsedLeafList, ref unUsedParent); ActiveLeafList.Sort(CompareFunc); //GetActiveNode(ref ActiveLeafList); int currShowCount = GetActiveNodeCount(ActiveLeafList); currShowCount = Mathf.Min(currSkinShowCount, currShowCount); for (int i = 0; i < currShowCount; i++) { U3D_Render.SkinCtrl.EntitySkinControl instance = ActiveLeafList[i]; if (!instance || !instance.isActiveAndEnabled) { continue; } instance.OnNotCull(); } for (int i = currShowCount; i < ActiveLeafList.Count; i++) { U3D_Render.SkinCtrl.EntitySkinControl instance = ActiveLeafList[i]; if (!instance || !instance.isActiveAndEnabled) { continue; } instance.OnCull(); } foreach (U3D_Render.SkinCtrl.EntitySkinControl instance in unUsedLeafList) { if (!instance || !instance.isActiveAndEnabled) { continue; } instance.OnCull(); } }
public void RemoveLeaf(U3D_Render.SkinCtrl.EntitySkinControl instance) { if (!instance) { return; } m_LeavesList.Remove(instance); }
public static void RemoveSkinControlToManager(U3D_Render.SkinCtrl.EntitySkinControl instance) { if (!bInitCulling || !instance) { return; } allSkinControl.Remove(instance); instance.hostQuadTreeNode = null; }
public static void PushSkinControlToManager(U3D_Render.SkinCtrl.EntitySkinControl instance) { if (!bInitCulling || !instance) { return; } allSkinControl.Add(instance); InsetToTree(quadTreeRoot, instance); }
public void Clear() { isBeCached = false; if (m_MainAnimator) { m_MainAnimator.runtimeAnimatorController = orginalAnimatorController; } m_nSkinID = -1; m_SkinObj = null; m_SkinObj_B = null; m_SkinObj_A = null; m_MainAnimator = null; m_AnimatorB = null; m_bipedIKAnimator = null; m_creatureProperty = null; m_ReferencedSkinCtrl = null; m_SkinnedMeshRenderList.Clear(); m_MeshRenderList.Clear(); m_AllRenders.Clear(); m_cameraProperty = null; m_characterController = null; m_entitySkinConfig = null; if (m_playEntityStaticEffect) { m_playEntityStaticEffect.Clear(); } if (m_switchEffectWithHeroDistance) { m_switchEffectWithHeroDistance.Clear(); } m_playEntityStaticEffect = null; m_switchEffectWithHeroDistance = null; m_sidekickEntity = null; m_SkinDataObj = null; foreach (RenderVisibleHelper vis in m_VisibleHelperList) { vis.hostSkin = null; var temp1 = vis; ResNode.DestroyRes(ref temp1); } ResNode.DestroyRes(ref m_bindEffect_A); ResNode.DestroyRes(ref m_bindEffect_B); ResNode.DestroyRes(ref m_bindSound); ResNode.DestroyRes(ref m_overrideController); m_VisibleHelperList.Clear(); ResNode.DestroyRes(ref m_characterShadow); ClearAlpha(); ClearBonesMap(); m_isLoadFinish = false; }
public static void UpdateSkinControl(U3D_Render.SkinCtrl.EntitySkinControl instance) { if (null != instance.hostQuadTreeNode) { if (instance.hostQuadTreeNode.IsPointOnParent(instance.transform.position)) { return; } instance.hostQuadTreeNode.RemoveLeaf(instance); instance.hostQuadTreeNode = null; } //人物会有传送,插入到父节点可能不对,直接从根节点开始 // SkinQuadTreeNode parent = instance.hostQuadTreeNode.m_Parent == null ? quadTreeRoot : instance.hostQuadTreeNode.m_Parent; //InsetToTree(parent, instance); InsetToTree(quadTreeRoot, instance); }
private static int CompareFunc(U3D_Render.SkinCtrl.EntitySkinControl left, U3D_Render.SkinCtrl.EntitySkinControl right) { if (!left && !right) { return(0); } if (!left.isActiveAndEnabled && !right.isActiveAndEnabled) { return(0); } if (!left) { return(1); } if (!left.isActiveAndEnabled) { return(1); } if (!right) { return(-1); } if (!right.isActiveAndEnabled) { return(-1); } int leftproity = left.GetSkinShowProity(); int rightproity = right.GetSkinShowProity(); //显示的优先级在距离前面 if (leftproity < rightproity) { return(1); } if (leftproity > rightproity) { return(-1); } //然后看距离 U3D_Render.EntityView heroView = EntityFactory.getMainPlayer(); if (null == heroView) { return(0); } if (!heroView.StateMachine) { return(0); } if (heroView.SkinControl == right) { return(1); } if (heroView.SkinControl == left) { return(-1); } Vector3 pos = heroView.StateMachine.transform.position; float leftdistance = GameUtil.GetSqrDistanceWithOutY(pos, left.transform.position); float rightdistance = GameUtil.GetSqrDistanceWithOutY(pos, right.transform.position); return(leftdistance.CompareTo(rightdistance)); }