virtual public void Initialize(Ilife lifeData, string resourcePath, AssetType resourceType) { m_LifeData = lifeData; m_iInstanceId = lifeData.GetInstanceId(); m_ObjectInstance = GameObject.Instantiate(ResourceManager.Instance.LoadBuildInResource<GameObject>(resourcePath, resourceType)); //load material string localpath = resourcePath.Substring(0, resourcePath.LastIndexOf('/')); m_NormalMaterial = ResourceManager.Instance.LoadBuildInResource<Material>(localpath + "/Normal", AssetType.Char); m_HighlightMaterial = ResourceManager.Instance.LoadBuildInResource<Material>(localpath + "/SelectedHighlight", AssetType.Char); m_MeshRender = ComponentTool.FindChildComponent<SkinnedMeshRenderer>("Body", m_ObjectInstance); if (null == m_NormalMaterial || null == m_HighlightMaterial || null == m_MeshRender) { Debuger.LogWarning("can't load mesh render or normal&highlight materials !"); } //mark transform m_CharContainer = m_ObjectInstance.AddComponent<CharTransformContainer>(); m_CharContainer.Initialize(lifeData.GetInstanceId(), lifeData); if (null == m_ObjectInstance) { Debuger.LogError("Can't load resource " + resourcePath); } m_AnimatorAgent = new AnimatorAgent(m_ObjectInstance); }
virtual public void Initialize(Ilife lifeData, string resourcePath, AssetType resourceType) { m_LifeData = lifeData; m_iInstanceId = lifeData.GetInstanceId(); m_ObjectInstance = GameObject.Instantiate(ResourceManager.Instance.LoadBuildInResource <GameObject>(resourcePath, resourceType)); //load material string localpath = resourcePath.Substring(0, resourcePath.LastIndexOf('/')); m_NormalMaterial = ResourceManager.Instance.LoadBuildInResource <Material>(localpath + "/Normal", AssetType.Char); m_HighlightMaterial = ResourceManager.Instance.LoadBuildInResource <Material>(localpath + "/SelectedHighlight", AssetType.Char); m_MeshRender = ComponentTool.FindChildComponent <SkinnedMeshRenderer>("Body", m_ObjectInstance); if (null == m_NormalMaterial || null == m_HighlightMaterial || null == m_MeshRender) { Debuger.LogWarning("can't load mesh render or normal&highlight materials !"); } //mark transform m_CharContainer = m_ObjectInstance.AddComponent <CharTransformContainer>(); m_CharContainer.Initialize(lifeData.GetInstanceId(), lifeData); if (null == m_ObjectInstance) { Debuger.LogError("Can't load resource " + resourcePath); } m_AnimatorAgent = new AnimatorAgent(m_ObjectInstance); }
public override List<Ilife> GetTargetList(Ilife thisUnit, TargetData data, FuncContext context) { List<Ilife> res = new List<Ilife>(); if (thisUnit == null) { return res; } Vector3 point = ((ITransformBehaviour) (thisUnit)).GetTransformData().GetPosition(); float r = ((ITransformBehaviour)(thisUnit)).GetTransformData().GetScale().x; var lifeList = LifeManager.GetLifeList(); foreach (var elem in lifeList) { if (elem.Key == thisUnit.GetInstanceId()) { continue; } Ilife otherLifes = elem.Value; Vector3 point1 = ((ITransformBehaviour)(otherLifes)).GetTransformData().GetPosition(); if (Vector3.Distance(point, point1) < r) { // add to target list res.Add(otherLifes); } } return res; }
public override List <Ilife> GetTargetList(Ilife thisUnit, TargetData data, FuncContext context) { List <Ilife> res = new List <Ilife>(); if (thisUnit == null) { return(res); } Vector3 point = ((ITransformBehaviour)(thisUnit)).GetTransformData().GetPosition(); float r = ((ITransformBehaviour)(thisUnit)).GetTransformData().GetScale().x; var lifeList = LifeManager.GetLifeList(); foreach (var elem in lifeList) { if (elem.Key == thisUnit.GetInstanceId()) { continue; } Ilife otherLifes = elem.Value; Vector3 point1 = ((ITransformBehaviour)(otherLifes)).GetTransformData().GetPosition(); if (Vector3.Distance(point, point1) < r) { // add to target list res.Add(otherLifes); } } return(res); }