// 初始化所有玩家的对战信息表 void initVSInfoPlayerFrame() { VSInfoPlayerInfo = new UVSInfoPlayerInfo[UDefines.WAR_PERSON_MAX_COUNT]; VSInfoPlayerRes = AssetBundleManager.GetAssets(AssetType.Asset_Prefab, "UI/Prefabs/DynamicState_Moba/WarRecordTable_End/VSInfoPlayerInfo"); // 赋值预制体 if (VSInfoPlayerRes == null) { Debug.LogError("VSInfoPlayerRes = null"); return; } GameObject instance; for (int i = 0; i < UDefines.WAR_PERSON_MAX_COUNT; ++i) { if (i < 5) { instance = VSInfoPlayerRes.InstanceMainRes(); if (!instance) { Debug.LogError("setRecordTable1PlayerInfo instance = NULL"); return; } instance.name = VSInfoPlayerRes.AssetName; instance.transform.SetParent(selfVSInfoPlayerGroup.transform, false); } else { instance = VSInfoPlayerRes.InstanceMainRes(); if (!instance) { Debug.LogError("setRecordTable1PlayerInfo instance = NULL"); return; } instance.name = VSInfoPlayerRes.AssetName; instance.transform.SetParent(enemyVSInfoPlayerGroup.transform, false); } VSInfoPlayerInfo[i] = instance.GetComponent <UVSInfoPlayerInfo>(); VSInfoPlayerInfo[i].initVSPlayerInfo(); VSInfoPlayerInfo[i].gameObject.SetActive(true); } nCurVSInfoBlueIndex = 0; nCurVSInfoRedIndex = UDefines.WAR_PERSON_MAX_COUNT / 2; RankScoreTip = VSInfoTrans.Find("TitleFrame/RankScoreTip").gameObject; MatchTypeText = VSInfoTrans.transform.Find("TitleFrame/MatchTypeDesc").GetComponent <Text>(); GradeDesc = RankScoreTip.transform.Find("GradeDesc").GetComponent <Text>(); StarUpDesc = RankScoreTip.transform.Find("RankIconList/StarUpDesc").GetComponent <Text>(); RankIconDefaultItem = RankScoreTip.transform.Find("RankIconList/DefaultItem").gameObject; }
public static void OpenUIWindowDebugPlane() { if (null == DebugPlaneRes) { DebugPlaneRes = AssetBundleManager.GetAssets(AssetType.Asset_Prefab, PrefabGUID, true); GameObject go = null; if (!ResNode.isNullOrEmpty(DebugPlaneRes)) { go = DebugPlaneRes.InstanceMainRes(); if (go) { go.transform.SetParent(UISystem.Instance.transform); go.transform.localPosition = Vector3.zero; go.transform.localScale = Vector3.one; } } } if (m_Instance) { m_Instance.gameObject.SetActive(true); m_Instance.transform.SetParent(UISystem.Instance.transform); m_Instance.transform.localPosition = Vector3.zero; m_Instance.transform.localScale = Vector3.one; } }
private void LoadEffect(ref GameObject effectObject, string sEffectName, int nSortID = 0) { if (parentsView == null) { return; } if (parentsView.SelectTransForm == null) { return; } if (nSortID <= 0) { return; } ResNode itemNode = AssetBundleManager.GetAssets(AssetType.Asset_Prefab, "Effect/Scene/UI/StaticState/Thumbs_up_RoomView/" + sEffectName); if (itemNode == null) { return; } effectObject = itemNode.InstanceMainRes(); if (effectObject == null) { return; } effectObject.transform.SetParent(parentsView.SelectTransForm, false); effectObject.transform.transform.localPosition = GetEffectPosition(nSortID); }
public void InitTalentNumButtonInfo(ref int[] LevelArray, HeroTalentViewPart talentView) { m_TalentView = talentView; int nConfigLevelCount = LevelArray.Length; NumSelectButtonArray = new HeroTalentNumSelectButton[nConfigLevelCount]; string sPrefabName = "UI/Prefabs/HeroTalentView/TalentNumButtonInStatic"; ResNode NumButtonPrefab = AssetBundleManager.GetAssets(AssetType.Asset_Prefab, sPrefabName); if (NumButtonPrefab == null) { Debug.Log("NumButtonPrefab Is Null"); return; } for (int i = 0; i < nConfigLevelCount; ++i) { GameObject NumButtonObject = NumButtonPrefab.InstanceMainRes(); if (NumButtonObject == null) { return; } HeroTalentNumSelectButton item = NumButtonObject.GetComponent <HeroTalentNumSelectButton>(); item.InitTalentNumButtonInfo(LevelArray[i], this); item.ButtonToggle.group = ToggleGroup; item.SlotId = i; NumButtonObject.transform.SetParent(this.transform, false); NumSelectButtonArray[i] = item; } }
private static void OnSceneLoadFinish(string sceneName) { isHaveData = false; //如果是非吃鸡场景,卸载. if (GameLogicAPI.getCurGameMode() != Game_ManagedDef.EGameMode.EGM_MCAMP) { AssetBundleManager.DeleteAssets(ref SafeZoneEffectRes, true); SafeZoneEffectInstance = null; return; } if (null == SafeZoneEffectRes) { SafeZoneEffectRes = AssetBundleManager.GetAssets(AssetType.Asset_Prefab, SafeZoneEffectGUID, true); if (!ResNode.isNullOrEmpty(SafeZoneEffectRes)) { SafeZoneEffectInstance = SafeZoneEffectRes.InstanceMainRes <Effect.EffectNode>(); if (SafeZoneEffectInstance) { SafeZoneEffectInstance.Init(); SafeZoneEffectInstance.StopEffect(); SafeZoneTransform = SafeZoneEffectInstance.transform; SafeZoneTransform.SetParent(EntityFactory.EffectGroup.transform); GenerateZoneMaterial(SafeZoneEffectInstance); } } } if (SafeZoneEffectInstance) { SafeZoneEffectInstance.StopEffect(); } }
//实例化新飘字节点 private UWarFloatFontItem CreateNewFont() { if (null == floatFontItemRes) { return(null); } GameObject go = floatFontItemRes.InstanceMainRes(); if (null == go) { return(null); } UWarFloatFontItem uFontItem = go.GetComponent <UWarFloatFontItem>(); if (null == uFontItem) { return(null); } else { uFontItem.SetFloatFontView(this); if (m_Anim != null) { uFontItem.SetAnimManager(m_Anim); } return(uFontItem); } }
/// <summary> /// 添加分割线 /// </summary> /// <param name="newItem"></param> protected void AddSeparationLineComponent(TItem newItem) { if (SeparationLineComponentRes == null) { return; } GameObject component; if (!m_LineGroupIDDic.ContainsKey(newItem.ItemGroupID)) { if (m_LineComponentsCache.Count > 0) { component = m_LineComponentsCache[m_LineComponentsCache.Count - 1]; m_LineComponentsCache.RemoveAt(m_LineComponentsCache.Count - 1); } else { component = SeparationLineComponentRes.InstanceMainRes(); component.transform.SetParent(Container, false); GameUtil.FixInstantiated(SeparationLineComponentRes, component); } m_LineGroupIDDic.Add(newItem.ItemGroupID, component); } else { component = m_LineGroupIDDic[newItem.ItemGroupID]; } component.transform.SetAsLastSibling(); component.gameObject.SetActive(true); }
public void Init() { m_diyChannelItemPrefabRes = AssetBundleManager.GetAssets(AssetType.Asset_Prefab, "UI/Prefabs/Chat/ChatDiyChannelItem"); if (m_diyChannelItemPrefabRes == null) { return; } foreach (var item in m_ChannelNameMap) { String channelName = item.Key; GameObject ob = m_diyChannelItemPrefabRes.InstanceMainRes(); ob.transform.SetParent(m_ChannelGroup.transform); ob.name = item.Key; ob.transform.FindChild("ChannelName").GetComponent <Text>().text = ChatBoxWndView.getChannelName((EMChatChannelType)item.Value); Toggle tg = ob.GetComponent <Toggle>(); // 初始化复选框状态 initChannelGroup(channelName, ref tg); // 设置复选框状态变化回调 tg.onValueChanged.AddListener(delegate(bool check) { this.onValueChanged(check, ob); }); } }
public override bool Init(IUIWnd wnd) { base.Init(wnd); buttonPrefabRes = AssetBundleManager.GetAssets(AssetType.Asset_Prefab, UPath.UPrefabsPath + "SideButtonList/SideButtonListItem"); buttonList = new SideButtonListItem[m_nMaxListItemNum]; float yOffset = -293f; for (int i = 0; i < m_nMaxListItemNum; ++i) { if (buttonPrefabRes != null) { SideButtonListItem item = buttonPrefabRes.InstanceMainRes <SideButtonListItem>(); buttonList[i] = item; RectTransform btnTrans = item.transform as RectTransform; Vector3 btnPos = btnTrans.localPosition; btnPos.y = yOffset; btnTrans.localPosition = btnPos; yOffset += 55f; btnTrans.SetParent(buttonContainer, false); item.gameObject.SetActive(false); } } upBtn.gameObject.SetActive(false); downBtn.gameObject.SetActive(false); m_nCurIndexOffset = 0; return(true); }
public override void OnAwake(Camera sceneCamera) { EffectRes = AssetBundleManager.GetAssets(AssetType.Asset_Prefab, assetGUID, true); if (null == EffectRes) { return; } hostNode = EffectRes.InstanceMainRes <Effect.EffectNodeBase>(); if (!hostNode) { AssetBundleManager.DeleteAssets(ref EffectRes, true); enabled = false; return; } effectGo = hostNode.gameObject; effectGo.transform.SetParent(EffectParent); effectGo.transform.position = EffectPosition; effectGo.transform.rotation = EffectRoation; effectGo.transform.localScale = EffectScale; hostNode.PlayOnAwake = false; hostNode.isStaticEffect = false; hostNode.Init(); hostNode.StopEffect(); Effect.EffectNodeBase.ResigterEffectQualityChange(OnEffectQualityChange); }
/// <summary> /// 添加可选的英雄头像 /// </summary> /// <param name="_nIndex">头像在列表的序号</param> /// <param name="_nHeroID">英雄ID</param> private void AddHeroHeadPortrait(int _nIndex, int _nHeroID) { GameObject newHeadPortrait = m_goHeroPortraitResNode.InstanceMainRes(); if (newHeadPortrait != null) { UCreateHeroPortraitBtn portrait = newHeadPortrait.GetComponent <UCreateHeroPortraitBtn>(); portrait.HeroPortrait.sprite = USpriteManager.Instance.GetSprite(USpriteManager.ESpriteType.EST_HeadPortrait, m_viewMediator.GetID(), 1, 7, _nHeroID); portrait.HeroID = _nHeroID; var btnPortrait = portrait.gameObject.GetComponent <Button>(); if (btnPortrait != null) { btnPortrait.onClick.AddListener(() => { onClickHeroHeadPortrait(portrait.HeroID); }); } Vector2 newPosition = Vector2.zero; portrait.GetRectTransform.SetParent(HeroPortraitAttach, false); newPosition.x = ((_nIndex % 2) == 0 ? -1 : 1) * portrait.GetRectTransform.sizeDelta.x / 4; newPosition.y = _nIndex == 0 ? 0 : m_listCreateHeroPortrait[_nIndex - 1].GetRectTransform.anchoredPosition.y - portrait.GetRectTransform.sizeDelta.y * 0.8f; portrait.GetRectTransform.anchoredPosition = newPosition; m_listCreateHeroPortrait.Add(portrait); } }
/// <summary> /// 添加显示对象 /// </summary> protected TComponent AddItemComponent(TItem newItem) { if (DefaultItemComponentRes == null) { return(null); } TComponent component; if (m_ItemComponentsCache.Count > 0) { component = m_ItemComponentsCache[m_ItemComponentsCache.Count - 1]; m_ItemComponentsCache.RemoveAt(m_ItemComponentsCache.Count - 1); } else { component = DefaultItemComponentRes.InstanceMainRes <TComponent>(); component.transform.SetParent(Container, false); Utilites.FixInstantiated(component.gameObject, DefaultItemComponentRes.GetResPosition(), DefaultItemComponentRes.GetResRotation(), DefaultItemComponentRes.GetResScale(), DefaultItemComponentRes.GetResAnchoredPosition(), DefaultItemComponentRes.GetResSizeDelta()); } component.transform.SetAsLastSibling(); component.gameObject.SetActive(true); m_ItemComponent.Add(component); newItem.ClearPopupMenuAction = OnClickAction; component.onEnter.AddListener(OnEnterAction); component.onExit.AddListener(OnExitAction); SetData(component, newItem); return(component); }
public void CreateTalentNum() { ResNode uiTopButtonPrefab = AssetBundleManager.GetAssets(AssetType.Asset_Prefab, "UI/Widgets/BUttons/TopButton"); GameObject talentNumTop = uiTopButtonPrefab.InstanceMainRes(); if (talentNumTop == null) { return; } talentNumTop.name = nMaxSortIndex.ToString(); talentNumTop.transform.SetParent(this.topTalentPageNumPart.transform, false); talentNumTop.transform.localPosition = new Vector3((float)((nMaxSortIndex - 1) * nIntervalDistace), bPageAddButton.transform.localPosition.y, 0); talentNumTop.transform.FindChild("Text").GetComponent <Text>().text = (nMaxSortIndex).ToString(); var buttonTop = talentNumTop.GetComponent <UButtonGroupItem>(); buttonTop.Group = topTalentPageNumPart.GetComponent <UButtonGroup>(); this.arrayTopButton.Add(talentNumTop); buttonTop.onSelectedChanged.AddListener(delegate(bool bSeletect) { if (bSeletect) { this.onNumListBtnClick(talentNumTop); } }); TalentChangePageModelInfo talentInfo = talentPageWnd.GetAllViewData(this.nMaxSortIndex); SetTopPageDescShow(talentInfo, this.nMaxSortIndex); talentNumTop.transform.SetAsLastSibling(); bPageAddButton.transform.localPosition = new Vector3((float)(nMaxSortIndex * nIntervalDistace), bPageAddButton.transform.localPosition.y, 0);//= }
public void Update() { if (test) { test = false; ResNode itemNode = AssetBundleManager.GetAssets(AssetType.Asset_Prefab, "Effect/Scene/UI/StaticState/Baoshi/" + szModelPath); if (itemNode == null) { return; } Effect.EffectNode itemObject = itemNode.InstanceMainRes <Effect.EffectNode>(); if (itemObject == null) { return; } //itemObject.StopEffect(); itemObject.PlayEffect(false, -1, itemObject.SrcObj, itemObject.DstObj); itemObject.transform.SetParent(parent, false); itemObject.transform.localPosition = new UnityEngine.Vector3(0f, 0f, 0f); } if (testDelete) { testDelete = false; SceneEffectManager.Instance.DestroySceneEffect(ref deleteParam); } }
public void OnNameChangeBtnClick() { if (actorNameChangeView == null) { actorNameChangeNode = AssetBundleManager.GetAssets(AssetType.Asset_Prefab, UPath.UPrefabsPath + "PlayerInfo/" + "ActorNameChangeView"); if (actorNameChangeNode == null) { Debug.Log("actorNameChangePrefab Is Null"); return; } GameObject actorNameChangeObject = actorNameChangeNode.InstanceMainRes(); if (actorNameChangeObject == null) { return; } actorNameChangeView = actorNameChangeObject.GetComponent <ActorNameChangeView>(); actorNameChangeObject.transform.SetParent(this.transform, false); actorNameChangeObject.SetActive(false); } if (actorNameChangeView == null) { return; } actorNameChangeView.OpenActorNameChangeView(); }
private void CreateSubItem(SChatMessageObjectInfo info, float width, ref float curOffsetX, ref float curOffsetY, List <LineObjCache> curLineObject) { if (width < 0f || curLineObject == null) { return; } ResNode itemPrefab = LogicDataCenter.chatMessageManager.GetChatItemPrefabByObjType(info.type); if (itemPrefab == null) { return; } GameObject itemObj = itemPrefab.InstanceMainRes(); if (itemObj == null) { return; } IChatItem subItem = itemObj.GetComponent <IChatItem>(); if (subItem == null) { itemPrefab.DestroyInstanceRes(ref itemObj); return; } subItem.SetResNode(itemPrefab); currChatBoxItem.Add(subItem); itemObj.transform.SetParent(this.transform, false); if (subItem.SetItemData(info) == false) { return; } for (int i = 0; i < 100; ++i) { IChatItem nextItem; subItem.SplitByWidth(width, curOffsetX, out subItem, out nextItem); if (subItem != null) { curOffsetX += subItem.GetItemWidth(); AddLineObject(subItem, curLineObject); } if (nextItem == null) { break; } AlignLineObject(ref curOffsetX, ref curOffsetY, curLineObject); subItem = nextItem; currChatBoxItem.Add(subItem); } }
protected void InstantiateTreeNodeHorizonalLine() { UWarTreeNodeHorizonalLineComponnet newNode = TreeNodeHorizonalLinePrefabRes.InstanceMainRes <UWarTreeNodeHorizonalLineComponnet>(); newNode.transform.SetParent(m_UnuseTreeNodeHorizonalLineContainner, false); UnuseTreeNodeHorizonalLineList.Add(newNode); newNode.SetVisible(false); }
protected void InstantiateTreeNode() { UWarGoodsStoreTreeNodeComponent newNode = TreeNodeComponentPrefabRes.InstanceMainRes <UWarGoodsStoreTreeNodeComponent>(); newNode.transform.SetParent(m_UnuseTreeNodeContainner, false); UnuseTreeNodeList.Add(newNode); newNode.SetVisible(false); }
public void Awake() { isOnGameRuning = true; m_WindowHwnd = GameLogicAPI.getMainWindHwnd(); if (!Application.isEditor) { GameLogicAPI.SetWindowText(Initialize.m_WindowHwnd, "泰坦-大地之子,勇往直前"); } InitDoTween(); GameLogicAPI.OpenLog(); if (AssetBundleManager.isVaild) { LoadingWaitngResNode = AssetBundleManager.GetAssets(AssetType.Asset_Prefab, "fa32d80346317d445bf6bdd4f1b4c5da", true); if (!ResNode.isNullOrEmpty(LoadingWaitngResNode)) { LoadingWaitngResNode.InstanceMainRes(); } } DontDestroyOnLoad(gameObject); Type[] types = new Type[] { typeof(Trace), }; CreateModulesSync(types); if (Time.timeScale < 0.01) { Time.timeScale = 1f; } mainCam = Camera.main; Instance = this; myTransform = this.transform; SoliderTarget = myTransform.FindChild("SoldierTarget").gameObject; Hero_Camera = Initialize.mainCam.gameObject; TargetFrame = myTransform.FindChild("TargetFrame").gameObject; Second_Camera = myTransform.FindChild("Second_Camera").gameObject; SecondTarget = Second_Camera.transform.FindChild("SecondTarget").gameObject; CamInitPos = Hero_Camera.transform.position; CamInitQua = Hero_Camera.transform.rotation; SetState(InitializeState.Init); SceneManager.RegisterSceneLoadFinishEvent(SceneLoadFinish); SceneManager.RegisterSceneLoadStartEvent(SceneLoadStart); SceneResInfoManager.RegisterActiveSceneChangedEvent(ActiveSceneChanged); UISystem.OnResolutionChanged += DoMouseLockInModeType; //将显示层配置文档初始化提前避免启用多线程时配置文档未初始化 //ViewConfigManager.Init(); }
public void showOftenUseHeroInfo(List <cmd_entity_hero_info> heroInfoList) { if (heroInfoList.Count > 5 || heroReqRes == null) { return; } // 在创建预制体之前,先把group内的东西清空 int nChildCount = heroGroup.transform.childCount; for (int i = 0; i < nChildCount; i++) { GameObject go = heroGroup.transform.GetChild(0).gameObject; ResNode.DestroyRes(ref go); } bool bIsFirst = true; int nMaxUseTime = 0; // dicHeroInfo接收的经常使用的英雄是按照使用英雄的次数进行排序的 foreach (cmd_entity_hero_info item in heroInfoList) { if (item.nHeroID == 0) { continue; } // 可以先打开游戏看一下像经验条一样,我要先确定最大经验, 即英雄使用做多的次数 if (bIsFirst) { nMaxUseTime = item.nGameCount; bIsFirst = false; } // 创建预制体并进行赋值显示 GameObject instance = heroReqRes.InstanceMainRes(); instance.name = heroReqRes.AssetName; if (instance == null) { continue; } instance.transform.SetParent(heroGroup.transform, false); HeroInfo heroInfo = instance.GetComponent <HeroInfo>(); if (heroInfo == null) { continue; } bool bReqSelf = LogicDataCenter.playerSystemDataManager.bRequestSelf; int nReqID = LogicDataCenter.playerSystemDataManager.nRequestPDBID; heroInfo.setRequestInfo(bReqSelf, nReqID); heroInfo.setHeroInfo(item, nMaxUseTime); } }
/// <summary> /// 实例化创建头顶称号 /// </summary> /// <param name="bcn">节点信息</param> /// <returns></returns> private UTopName InstanceUTopName(TopNameNode bcn) { GameObject go = TopNamePrefabRes.InstanceMainRes(); if (RectPosition(go, bcn)) { UTopName ut = go.GetComponent <UTopName>(); ut.resNode = TopNamePrefabRes; return(ut); } return(null); }
public void OnInputfieldAddItem(ChatBoxAddInputFieldItemData msgData) { ResNode itemPrefab = LogicDataCenter.chatMessageManager.GetChatItemPrefabByObjType(msgData.objInfo.type); if (itemPrefab == null) { return; } GameObject itemObj = itemPrefab.InstanceMainRes(); if (itemObj == null) { return; } IChatItem subItem = itemObj.GetComponent <IChatItem>(); subItem.SetResNode(itemPrefab); if (subItem == null) { itemPrefab.DestroyInstanceRes(ref itemObj); return; } if (subItem.SetItemData(msgData.objInfo) == false) { itemPrefab.DestroyInstanceRes(ref itemObj); return; } if (msgData.bClearInputField) { inputField.ClearContent(); } if (msgData.bActiveInputField) { inputField.ActivateInputField(); } inputField.selectionFocusPosition = inputField.caretPosition; inputField.InsertItem(itemObj, subItem, -1); // 自动发送 if (msgData.bAutoSend) { OnSendBtnClick(); } }
//public List<UWarExtraTest> TestObjects = new List<UWarExtraTest>(); //public float FindDistance = 30f; //public List<UWarExtraTest> NearObjects = new List<UWarExtraTest>(); //List<UWarExtraTest> aroundList = new List<UWarExtraTest>(); //List<UWarExtraTest> attachList = new List<UWarExtraTest>(); //public void TestFindNearObject() //{ // var myScreenPos = RectTransformUtility.WorldToScreenPoint(UISystem.Instance.GetCamera(), GetTransform().position); // Vector2 rtScreenPos; // List<UWarExtraTest> tmpList = new List<UWarExtraTest>(NearObjects); // aroundList.Clear(); // foreach (var rt in TestObjects) // { // rtScreenPos = RectTransformUtility.WorldToScreenPoint(UISystem.Instance.GetCamera(), rt.GetRectTransform.position); // if((myScreenPos - rtScreenPos).magnitude< FindDistance) // { // aroundList.Add(rt); // } // } // if(aroundList.Count == 0) // { // return; // } // foreach(var rtt in aroundList) // { // if (!NearObjects.Contains(rtt)) // NearObjects.Add(rtt); // else // tmpList.Remove(rtt); // } // while (tmpList.Count > 0) // { // var tmprt = tmpList[0]; // NearObjects.Remove(tmprt); // tmpList.RemoveAt(0); // } //} //protected void AttachEntityPoint(UWarExtraTest newTest) //{ // if (attachList.Contains(newTest)) // return; // var HeroSprite = USpriteManager.Instance.GetSprite(USpriteManager.ESpriteType.EST_HeadPortrait, WndID.WND_ID_WAR_HEROBEARING, 1, 4, newTest.headID); // var entitySelectionItem = ResNode.InstantiateRes<UWarExtraPlayerSelectionItem>(m_SelectionItemPrefab.gameobjct); // entitySelectionItem.SelectionEntityHead.sprite = HeroSprite; // entitySelectionItem.SelectionEntityID = newTest.entityID; // entitySelectionItem.transform.SetParent(m_EntityAttachPoint, false); // attachList.Add(newTest); // if (attachList.Count > 0) // PlayLayoutAnim(); //} //protected void DettachEntityPoint(UWarExtraTest newTest) //{ // if (!attachList.Contains(newTest)) // return; // var count = m_EntityAttachPoint.childCount; // for (int i = 0; i < count; i++) // { // var com = m_EntityAttachPoint.GetChild(i).GetComponent<UWarExtraPlayerSelectionItem>(); // if (com.SelectionEntityID == newTest.entityID) // { // attachList.Remove(newTest); // ResNode.DestroyRes(ref com.gameObject); // break; // } // } // ResetLayoutAnim(); //} protected void AttachEntityPoint(EntityView _ev) { if (m_dicAttachItems.ContainsKey(_ev.ID)) { return; } int nEntityHeroID = _ev.Property.GetNumProp(ENTITY_PROPERTY.PROPERTY_VOCATION); var HeroSprite = USpriteManager.Instance.GetSprite(USpriteManager.ESpriteType.EST_HeadPortrait, WndID.WND_ID_WAR_HEROBEARING, 1, 4, nEntityHeroID); int MaxHp = _ev.Property.GetNumProp(ENTITY_PROPERTY.PROPERTY_MAX_HP); int CurHp = _ev.Property.GetNumProp(ENTITY_PROPERTY.PROPERTY_HP); var entitySelectionItem = m_SelectionItemResNode.InstanceMainRes <UWarExtraPlayerSelectionItem>(); entitySelectionItem.SelectionEntityHead.sprite = HeroSprite; entitySelectionItem.SelectionEntityID = _ev.ID; entitySelectionItem.SelectionEntityView = _ev; entitySelectionItem.SelectionSpellID = m_Mediator.SelectionSpellID; entitySelectionItem.SetHP(CurHp, MaxHp); entitySelectionItem.transform.SetParent(m_EntityAttachPoint, false); CreatureStateMachine playerMachine = (CreatureStateMachine)_ev.StateMachine; if (playerMachine) { int formType = playerMachine.creaturePropety.GetNumProp(ENTITY_PROPERTY.PROPERTY_FORMTYPE); if (formType == (int)FORM_TYPE.FORM_HATHPACE) { entitySelectionItem.Standpoint.sprite = USpriteManager.Instance.GetSprite(USpriteManager.ESpriteType.EST_MinimapIcon, "Icon_gaotai", GetUIWnd().GetID()); entitySelectionItem.Standpoint.SetNativeSize(); entitySelectionItem.Standpoint.gameObject.SetActive(true); } else if (formType == (int)FORM_TYPE.FORM_SKY) { entitySelectionItem.Standpoint.sprite = USpriteManager.Instance.GetSprite(USpriteManager.ESpriteType.EST_MinimapIcon, "Icon_chibang", GetUIWnd().GetID()); entitySelectionItem.Standpoint.SetNativeSize(); entitySelectionItem.Standpoint.gameObject.SetActive(true); } else { entitySelectionItem.Standpoint.gameObject.SetActive(false); } } else { entitySelectionItem.Standpoint.gameObject.SetActive(false); } m_dicAttachItems.Add(_ev.ID, entitySelectionItem); PlayLayoutAnim(); }
// 设置经常使用英雄信息 private void SetOftenUseHeroInfo(List <cmd_entity_hero_info> heroInfoList, GameObject heroGroup, ResNode heroIns, int nPDBID, bool bIsSelf) { if (heroInfoList.Count > 5 || heroIns == null) { return; } // 每次先清空HeroGroup内容 int nChildCount = heroGroup.transform.childCount; for (int i = nChildCount - 1; i >= 0; --i) { GameObject go = heroGroup.transform.GetChild(i).gameObject; ResNode.DestroyRes(ref go); } bool bIsFirst = true; int nMaxUseNum = 0; // heroInfoList数据是按使用次数从大向小排序的 foreach (var item in heroInfoList) { if (item.nHeroID == 0) { return; } // 确定最大使用次数 if (bIsFirst) { bIsFirst = false; nMaxUseNum = item.nGameCount; } // 创建预制体并进行赋值显示 GameObject inst = heroIns.InstanceMainRes(); if (inst == null) { continue; } inst.transform.SetParent(heroGroup.transform, false); HeroInfo heroInfo = inst.GetComponent <HeroInfo>(); if (heroInfo == null) { continue; } heroInfo.setRequestInfo(bIsSelf, nPDBID); heroInfo.setHeroInfo(item, nMaxUseNum); } }
// 初始化數據圖表的所有玩家的預製體 private void initDataChartFrame() { DataChartPlayer = new UDataChartPlayer[UDefines.WAR_PERSON_MAX_COUNT]; ToggleHead.onValueChanged.AddListener(onChickToggleHead); ToggleHead2.onValueChanged.AddListener(onChickToggleHead2); ToggleHead3.onValueChanged.AddListener(onChickToggleHead3); toggleDataRes = AssetBundleManager.GetAssets(AssetType.Asset_Prefab, "UI/Prefabs/DynamicState_Moba/WarRecordTable_End/TogglePrefab"); if (toggleDataRes == null) { Debug.LogError("toggleDataRes = null"); return; } DataChartPlayerReqRes = AssetBundleManager.GetAssets(AssetType.Asset_Prefab, "UI/Prefabs/DynamicState_Moba/WarRecordTable_End/DataChartPlayerInfo"); // 赋值预制体 if (DataChartPlayerReqRes == null) { Debug.LogError("DataChartPlayerReqRes end3PlayerReq = null"); return; } for (int i = 0; i < UDefines.WAR_PERSON_MAX_COUNT; ++i) { GameObject instance = DataChartPlayerReqRes.InstanceMainRes(); if (!instance) { Debug.LogError("DataChartPlayerReqRes instance = NULL"); return; } instance.name = DataChartPlayerReqRes.AssetName; // 以5個玩家為分界點,將單獨玩家數據圖表創建到group中 if (i < 5) { instance.transform.SetParent(selfDataChartPlayerGroup.transform, false); } else { instance.transform.SetParent(enemyDataChartPlayerGroup.transform, false); } // 將每個玩家的對象保存起來 DataChartPlayer[i] = instance.GetComponent <UDataChartPlayer>(); } // 初始化數據圖表右側的數據描述 initToggle(); nCurDataChartBlueIndex = 0; nCurDataChartRedIndex = UDefines.WAR_PERSON_MAX_COUNT / 2; }
private bool OnLoadView(ResNode viewPrefab) { Initialize.PrintTickCheck("OnLoadView", _bStart: true); if (viewPrefab == null) { return(false); } ViewInstance = viewPrefab.InstanceMainRes(); Initialize.PrintTickCheck(GetID() + ",OnLoadView - InstanceMainRes"); if (!ViewInstance) { return(false); } ViewInstance.name = viewPrefab.AssetName; m_wndView = ViewInstance.GetComponent <IUIWndView>() as T; if (m_wndView == null) { Debug.LogError("UISystem OnLoadView m_wndView == null id=" + GetID()); viewPrefab.DestroyInstanceRes(ref ViewInstance); return(false); } if (m_wndView.Init(this) == false) { Debug.LogError("UISystem OnLoadView m_wndView.Init == false id=" + GetID()); viewPrefab.DestroyInstanceRes(ref ViewInstance); return(false); } Initialize.PrintTickCheck(GetID() + ",OnLoadView - View.Init"); UISystem.Instance.AddView(m_wndView, GetLayer()); Initialize.PrintTickCheck(GetID() + ",OnLoadView - AddView"); m_wndView.SetRendererVisible(m_isVisible); Initialize.PrintTickCheck(GetID() + ",OnLoadView - View.SetRendererVisible"); return(true); }
public GameObject Instantiate(ENTITY_TYPE entityType) { if (OrginalObj != null) { GameObject o = OrginalObj.InstanceMainRes(); if (o) { o.name = entityType.ToString() + "--cache"; o.transform.SetParent(PrefabCacheRoot.transform); o.SetActive(false); } return(o); } return(null); }
/// <summary> /// 实例化资源 /// </summary> /// <param name="go">源物体</param> /// <param name="useSource">使用源物体,不会去缓存池中查找,等于原来的 GameObject.Instantiate</param> /// <returns></returns> public static GameObject InstantiateRes(UnityEngine.Object go, bool useSource = false) { if (!go) { return(null); } if (!useSource) { ResNode res = null; if (IntanceResNodeTable.TryGetValue(go, out res)) { return(res.InstanceMainRes()); } } return(GameObject.Instantiate(go) as GameObject); }
/// <summary> /// 给对象添加TooltipTrigger脚本 /// </summary> /// <param name="_tTrans">要添加Trigger的对象</param> /// <returns>TooltipTrigger脚本</returns> public static T AddComponent <T>(this GameObject _uGameObject, ETooltipStyle _eStyle) where T : UTooltipTrigger { T tmpTrigger = null; //将类型转为字符串并根据‘_’标识符切割 string StyleName = _eStyle.ToString().Split('_')[1]; string TriggerStylePath = UPath.UTooltipStyle + StyleName; if (_uGameObject.GetComponent <T>() == null) { tmpTrigger = _uGameObject.AddComponent <T>(); ResNode stylePerfabe = AssetBundleManager.GetAssets(AssetType.Asset_Prefab, TriggerStylePath); TooltipStyle InstanceTooltipStyle = stylePerfabe.InstanceMainRes <TooltipStyle>(); TooltipStyle tooltipStyle = null; if (!UTooltipManager.Instance.Tooltips.ContainsKey(InstanceTooltipStyle.TooltipID)) { tooltipStyle = InstanceTooltipStyle; tooltipStyle.name = tooltipStyle.name; tooltipStyle.transform.SetParent(UTooltipManager.Instance.TooltipContainer.transform, false); Tooltip newTooltip = new Tooltip() { GameObject = tooltipStyle.gameObject }; newTooltip.Initialize(); newTooltip.Deactivate(); UTooltipManager.Instance.Tooltips.Add(tooltipStyle.TooltipID, newTooltip); } else { tooltipStyle = UTooltipManager.Instance.Tooltips[InstanceTooltipStyle.TooltipID].TooltipStyle; var temp = InstanceTooltipStyle.gameObject; stylePerfabe.DestroyInstanceRes(ref temp); } tmpTrigger.tooltipStyle = tooltipStyle; } else { tmpTrigger = _uGameObject.GetComponent <T>(); } return(tmpTrigger); }
static public void Init() { if (bInit) { return; } ResNode bloodSystemPrefab = AssetBundleManager.GetAssets(AssetType.Asset_Prefab, "UI/Prefabs/Blood/UIBloodSystem"); if (null == bloodSystemPrefab) { return; } Instance = bloodSystemPrefab.InstanceMainRes <UBloodManager>(); Instance.name = bloodSystemPrefab.AssetName; bInit = true; }