/// <summary> /// 选择神兽 /// </summary> /// <param name="item"></param> /// <returns></returns> private bool OnBeastListSelect(IXUIListItem item) { if (null == item) { return(false); } //如果选择过了,就不能在选择其他神兽 if (this.CanSelectOtherBeast()) { return(false); } else { int id = (int)item.Id; //显示选择之后神兽的信息 //this.ShowHeroInfo(id); if (!this.IsSucSelectBeast(ref id)) { return(false); } else { this.SelectBeastTypeId = id; //显示技能 //this.ShowAllSkill(id); //发送试图选择该神兽的请求 this.SendSelectBeast(id); if (Singleton <RoomManager> .singleton.EGamePhase == EGamePhase.GAME_PHASE_BANNING) { } return(true); } } return(false); }
public virtual FlyTextEntity Add(string strText, long targetBeastId, float PosZ) { XLog.Log.Debug("AddFlyText" + strText); FlyTextEntity flyTextEntity = null; if (this.m_flyTextList.Last != null && !this.m_flyTextList.Last.Value.Active) { flyTextEntity = this.m_flyTextList.Last.Value; this.m_flyTextList.RemoveLast(); flyTextEntity.Active = true; } else { IXUIListItem item = this.m_uiList.AddListItem(); if (item != null) { flyTextEntity = new FlyTextEntity(item, targetBeastId); } else { XLog.Log.Error("Item == null"); } } flyTextEntity.PosZ = PosZ; this.InitFlyText(flyTextEntity, strText, targetBeastId); this.m_flyTextList.AddFirst(flyTextEntity); return(flyTextEntity); }
/// <summary> /// 刷新该item是否被选择,如果选择就播放选择的动画 /// </summary> /// <param name="uiItem"></param> /// <param name="unRoleId"></param> private void RefreshItemEnable(IXUIListItem uiItem, long unRoleId) { if (uiItem != null) { bool enableSelect = false; BeastData beastData = Singleton <RoomManager> .singleton.GetBeastData(unRoleId); if (beastData != null && beastData.PlayerId == Singleton <PlayerRole> .singleton.ID) { switch (Singleton <RoomManager> .singleton.BeastSelectType) { case EGameBeastSelectType.GAME_BEAST_SELECT_TYPE_MATCH: enableSelect = true; break; case EGameBeastSelectType.GAME_BEAST_SELECT_TYPE_RANK: //if (this.m_unTurnRoleId == unRoleId || beastData.HTypeId > 0u) //{ // enableSelect = true; // } break; } } uiItem.SetEnableSelect(enableSelect); } }
public void RefreshSkill(BeastData oBeastData) { if (base.Prepared) { if (oBeastData != null) { if (Singleton <RoomManager> .singleton.RepeatSelectBeastInAllCamp == 0) { this.SetSelectBeastId(oBeastData.Id, oBeastData.BeastTypeId); } else { for (int i = 0; i < base.uiBehaviour.m_ourBeastList.Count; i++) { IXUIListItem itemByIndex = base.uiBehaviour.m_ourBeastList.GetItemByIndex(i); BeastData beastData = Singleton <RoomManager> .singleton.GetBeastData(itemByIndex.Id); if (oBeastData.Id == beastData.Id) { this.SetSelectBeastId(oBeastData.Id, oBeastData.BeastTypeId); } } } IXUIListItem item = this.GetCampTypeListItem(oBeastData.Id); if (item != null) { this.RefreshPlayerInfo(item, oBeastData); } this.RefreshSkill(oBeastData.Id, oBeastData.Skills); } } }
/// <summary> /// 获取UI组件的id /// </summary> /// <param name="iXUIObject"></param> /// <returns></returns> public static string GetUIObjectId(IXUIObject iXUIObject) { if (iXUIObject == null) { return(string.Empty); } string text = iXUIObject.CachedGameObject.name; IXUIListItem iXUIListItem = iXUIObject as IXUIListItem; if (iXUIListItem != null) { text = iXUIListItem.Id.ToString(); } while (iXUIObject.parent != null) { iXUIObject = iXUIObject.parent; string arg = iXUIObject.CachedGameObject.name; iXUIListItem = (iXUIObject as IXUIListItem); if (iXUIListItem != null) { arg = iXUIListItem.Id.ToString(); } text = string.Format("{0}#{1}", arg, text); } return(text); }
/// <summary> /// 刷新所有己方角色信息 /// </summary> public void RefreshAllRole() { if (Singleton <RoomManager> .singleton.MatchType == EMatchtype.MATCH_1C3) { if (base.Prepared) { List <Beast> list = Singleton <BeastManager> .singleton.GetAllBeastByCamp(Singleton <PlayerRole> .singleton.CampType); for (int i = 0; i < list.Count; i++) { IXUIListItem item = base.uiBehaviour.m_List_RoleList.GetItemByIndex(i); if (null == item) { item = base.uiBehaviour.m_List_RoleList.AddListItem(); } Beast beast = list[i]; item.Id = beast.Id; DataBeastlist data = GameData <DataBeastlist> .dataMap[beast.BeastTypeId]; int hp = beast.Hp; int hpMax = beast.HpMax; string text = string.Format("{0}/{1}", hp, hpMax); if (data != null) { item.SetText("lb_roleName", data.Name); //设置神兽名称 item.SetText("lb_life", text); //设置神兽血量 item.SetIconSprite(data.IconFile, UIManager.singleton.GetAtlasName(EnumAtlasType.Beast, data.IconFile)); } } } } }
private void Translate(Beast beast, IXUIListItem uiListItem, bool bSmooth) { if (beast != null && uiListItem != null) { if (null != beast.Object) { IXUIListHeadInfoItem iXUIListHeadInfoItem = uiListItem as IXUIListHeadInfoItem; if (iXUIListHeadInfoItem == null) { XLog.Log.Error("null == uiListItemHeadInfo"); } else { Vector3 movingPos = beast.MovingPos; movingPos.y += beast.Height + 2f; Vector3 position = Camera.main.WorldToScreenPoint(movingPos); Vector3 vector = Singleton <UIManager> .singleton.UICamera.ScreenToWorldPoint(position); Vector3 position2 = iXUIListHeadInfoItem.CachedGameObject.transform.position; Vector3 position3 = bSmooth ? Vector3.Lerp(position2, vector, 0.6f) : vector; iXUIListHeadInfoItem.CachedTransform.position = position3; Vector3 localPosition = iXUIListHeadInfoItem.CachedTransform.localPosition; localPosition.z = vector.z / 100f; iXUIListHeadInfoItem.CachedTransform.localPosition = localPosition; } } } }
/// <summary> /// 取得该组件所在的id(包含父亲节点的id) /// </summary> /// <param name="uiObject"></param> /// <returns></returns> public static string GetUIObjectId(IXUIObject uiObject) { string result; if (null == uiObject) { result = string.Empty; } else { string text = uiObject.CacheGameObject.name; IXUIListItem iXUIListItem = uiObject as IXUIListItem; if (iXUIListItem != null) { text = iXUIListItem.Id.ToString(); } while (null != uiObject.Parent) { uiObject = uiObject.Parent; string arg = uiObject.CacheGameObject.name; iXUIListItem = (uiObject as IXUIListItem); if (null != iXUIListItem) { arg = iXUIListItem.Id.ToString(); } text = string.Format("{0}#{1}", arg, text); } result = text; } return(result); }
public static void S_OnAddListItem(IXUIDlg uiDlg, IXUIList uiList, IXUIListItem uiListItem) { if (null != XUITool.Instance) { XUITool.Instance.OnAddListItem(uiDlg, uiList, uiListItem); } }
public void OnAddListItem(IXUIDlg uiDlg, IXUIList uiList, IXUIListItem uiListItem) { if (this.m_addListItemEventHandler != null) { this.m_addListItemEventHandler(uiDlg, uiList, uiListItem); } }
private void ShowEnemyBeastInfo() { List <PlayerData> enemyPlayers = Singleton <RoomManager> .singleton.EnemyPlayerDatas; int index = 0; foreach (var player in enemyPlayers) { foreach (var beast in player.Beasts) { if (index < this.m_iCampNum) { IXUIListItem item = base.uiBehaviour.m_list_EnemyPlayer.GetItemByIndex(index); if (null == item) { item = base.uiBehaviour.m_list_EnemyPlayer.AddListItem(); } this.ShowBeastInfo(item, player, beast); index++; } } } while (index < base.uiBehaviour.m_list_EnemyPlayer.Count) { IXUIListItem item = base.uiBehaviour.m_list_EnemyPlayer.GetItemByIndex(index); if (item != null) { item.SetVisible(false); } index++; } }
/// <summary> /// 显示神兽信息界面 /// </summary> /// <param name="item"></param> /// <param name="playerData"></param> /// <param name="beastData"></param> private void ShowBeastInfo(IXUIListItem item, PlayerData playerData, BeastData beastData) { if (item != null && playerData != null && beastData != null) { item.SetText("NickNameAndLevel/Label_Player_Name", playerData.Name); item.SetText("NickNameAndLevel/Label_Player_Level", "LV" + playerData.Level); item.SetSprite("Icon/Sprite_Player_Icon", playerData.Icon); DataBeastlist beastList = GameData <DataBeastlist> .dataMap[beastData.BeastTypeId]; if (beastList != null) { //取得皮肤数据 DataSuit suit = null; GameData <DataSuit> .dataMap.TryGetValue(beastData.BeastTypeId, out suit); //神兽名字 string beastName = string.IsNullOrEmpty(beastList.NickName) ? "" : ("-" + beastList.NickName); //神兽皮肤名字 string beastNickname = (suit == null) ? beastList.Name : suit.Name; item.SetText("Label_Beast_Name", string.Format("{0}{1}", beastNickname, beastName)); //设置神兽皮肤 IXUIPicture beastSkin = item.GetUIObject("Picture_Beast_Skin") as IXUIPicture; if (beastSkin != null) { beastSkin.SetVisible(true); beastSkin.SetTexture(string.Format("Texture/Beast/{0}", (suit == null) ? beastList.ModelFile : suit.PicName)); } } else { item.SetVisible(false); } item.Id = playerData.PlayerId; item.SetVisible(true); } }
//刷新加载完成后去除的遮罩,实际上LOL并没有,所以我这里不采用,只是设置几个变量 public void RefreshMask() { if (base.Prepared && base.IsVisible()) { bool flag = true; for (int i = 0; i < base.uiBehaviour.m_list_OurPlayer.Count; i++) { IXUIListItem item = base.uiBehaviour.m_list_OurPlayer.GetItemByIndex(i); if (item != null) { flag = this.IsFinishLoad(item); } } for (int i = 0; i < base.uiBehaviour.m_list_EnemyPlayer.Count; i++) { IXUIListItem item = base.uiBehaviour.m_list_EnemyPlayer.GetItemByIndex(i); if (item != null) { flag = this.IsFinishLoad(item); } } if (flag) { //过几秒中Loading界面消失,在Update里面更新时间 this.m_fStartTime = Time.time; this.m_bStartTime = true; } } }
/// <summary> /// 刷新神兽选择之后的状态 /// </summary> public void RefreshBeastSelectStatus() { if (base.uiBehaviour != null) { for (int i = 0; i < base.uiBehaviour.m_BeastList.Count; i++) { IXUIListItem item = base.uiBehaviour.m_BeastList.GetItemByIndex(i); if (item != null) { IXUISprite icon = item.GetUIObject("Icon") as IXUISprite; if (icon != null) { icon.Color = Color.white; } } } //循环遍历所有已经选择的英雄,设置icon为灰色 foreach (var current in this.m_dicRoleSelectBeastID) { if (this.m_unRandomBeastID != current.Value && this.m_lBeastIdCurrent != current.Value) { IXUIListItem item = base.uiBehaviour.m_BeastList.GetItemById((uint)current.Value); if (item != null && item.Index > 0) { IXUISprite icon = item.GetUIObject("Icon") as IXUISprite; if (icon != null) { icon.Color = UnityTools.GrayColor; } } } } //如果可以重复选择,就不设置为灰色 if (Singleton <RoomManager> .singleton.RepeatSelectBeastInAllCamp == 1) { foreach (var current in this.m_dicRoleSelectBeastID) { if (this.m_unRandomBeastID != current.Value && this.m_lBeastIdCurrent != current.Value) { IXUIListItem item = base.uiBehaviour.m_BeastList.GetItemById((uint)current.Value); if (item != null && item.Index > 0) { IXUISprite icon = item.GetUIObject("Icon") as IXUISprite; if (icon != null) { icon.Color = Color.white; } } } } } if (Singleton <RoomManager> .singleton.IsLadderMode() && Singleton <RoomManager> .singleton.EGamePhase == EGamePhase.GAME_PHASE_CHOOSING) { //开始协程刷新被ban的神兽头像icon颜色 } } }
/// <summary> /// 选择该神兽 /// </summary> /// <param name="unBeastMarkId"></param> public void SelectRole(long unBeastMarkId) { if (unBeastMarkId != 0 && base.Prepared) { //根据神兽id取得我方神兽列表中的item,如果不为为空就选中该item IXUIListItem itemId = base.uiBehaviour.m_ourBeastList.GetItemById(unBeastMarkId); if (itemId != null) { base.uiBehaviour.m_ourBeastList.SetSelectedItemById(unBeastMarkId); } else { //如果为空,就去敌方列表中找,找到选中 itemId = base.uiBehaviour.m_enmeyBeastList.GetItemById(unBeastMarkId); if (itemId != null) { base.uiBehaviour.m_enmeyBeastList.SetSelectedItemById(unBeastMarkId); } } BeastData beastData = Singleton <RoomManager> .singleton.GetBeastData(unBeastMarkId); if (beastData != null) { //显示技能 //this.ShowAllSkill(beastData.BeastTypeId); //刷新神兽选择列表的状态 this.RefreshBeastSelectStatus(); //显示选择后的神兽信息 this.ShowBeastInfo(beastData.BeastTypeId); //刷新装备 this.RefreshEquip(beastData.Id, beastData.BeastTypeId); //刷新提示 this.RefreshTip(unBeastMarkId); if (Singleton <RoomManager> .singleton.IsObserver) { this.ShowBeastSelect(); } else { //如果已经被选择的话,就显示皮肤选择界面 if (beastData.IsSelected) { this.ShowSkinSelect(); base.uiBehaviour.m_BeastList.SetVisible(false); } //否则显示神兽界面选择 else { this.ShowBeastSelect(); } } this.IsSelected = beastData.IsSelected; this.m_nCurEquipSelectIndex = beastData.EquipIndex; } } }
private bool OnClickRoleTypeList(IXUIListItem item) { if (null == item) { return(false); } this.m_iRoleIndex = (int)item.Id; RefreshRoleIntro((EnumRoleTypeIndex)this.m_iRoleIndex); this.SelectRoleType(); return(true); }
public void ShowCampTypeEffect(long beastId) { if (base.Prepared) { IXUIListItem campTypeItem = this.GetCampTypeListItem(beastId); if (campTypeItem != null) { this.ShowCampTypeEffect(campTypeItem); } } }
/// <summary> /// 某个角色被选择事件 /// </summary> /// <param name="item"></param> /// <returns></returns> private bool OnRoleListSelect(IXUIListItem item) { if (null == item) { return(false); } if (this.SelectRoleId != item.Id) { Debug.Log("Select Id:" + item.Id); this.SelectRoleId = item.Id; } return(true); }
private void RefreshPlayerInfo(IXUIListItem item, BeastData beast) { //DataBeastlist dataBeast = GameData<DataBeastlist>.dataMap[beast.BeastTypeId]; DataBeastlist dataBeast = null; GameData <DataBeastlist> .dataMap.TryGetValue(beast.BeastTypeId, out dataBeast); IXUISprite icon = item.GetUIObject("Sprite_Icon") as IXUISprite; if (dataBeast != null) { //如果是自己的阵营,就显示头像。地方就显示随机头像 if (beast.CampType == Singleton <PlayerRole> .singleton.CampType) { icon.SetSprite(dataBeast.IconFile, UIManager.singleton.GetAtlasName(EnumAtlasType.Beast, dataBeast.IconFile)); } else { //icon.SetSprite("Window"); icon.SetSprite(dataBeast.IconFile, UIManager.singleton.GetAtlasName(EnumAtlasType.Beast, dataBeast.IconFile)); } } else { if (beast.BeastTypeId == this.m_unRandomBeastID) { icon.SetSprite("9"); } } bool visible = Singleton <RoomManager> .singleton.IsObserver || Singleton <PlayerRole> .singleton.CampType == beast.CampType; IXUIList equipList = item.GetUIObject("List_Equip") as IXUIList; if (equipList != null) { } else { XLog.Log.Error("null == uiListEquip"); } this.RefreshItemEnable(item, beast.Id); IXUIObject uiObject = item.GetUIObject("Texture_Shadow"); if (uiObject != null) { uiObject.SetVisible(false); } item.Id = beast.Id; }
private IXUIListItem GetCampTypeListItem(long beastId) { if (!base.Prepared) { return(null); } else { IXUIListItem itemById = base.uiBehaviour.m_ourBeastList.GetItemById(beastId); if (null == itemById) { itemById = base.uiBehaviour.m_enmeyBeastList.GetItemById(beastId); } return(itemById); } }
/// <summary> /// 敌方神兽被选择 /// </summary> /// <param name="item"></param> /// <returns></returns> private bool OnListEnemyBeastSelect(IXUIListItem item) { bool result; if (item == null || 0u == item.Id) { result = false; } else { this.m_lBeastIdCurrent = item.Id; this.SelectRole(this.m_lBeastIdCurrent); result = true; } return(result); }
public FlyTextEntity(IXUIListItem flyTextItem, long unTargetHeroId) { this.m_bActive = true; this.m_unTargetBeastId = unTargetHeroId; this.m_uiListItem = flyTextItem; this.m_uiLabel = (this.m_uiListItem.GetUIObject("Label_FlyText") as IXUILabel); this.m_uiSprite = (this.m_uiListItem.GetUIObject("Sprite_Shadow") as IXUISprite); if (null == this.m_uiLabel) { this.m_uiLabel = WidgetFactory.CreateWidget <IXUILabel>(); XLog.Log.Debug("null == m_uiLabel"); } if (null == this.m_uiSprite) { this.m_uiSprite = WidgetFactory.CreateWidget <IXUISprite>(); } }
/// <summary> /// 我方和敌方的选择神兽列表刷新 /// </summary> /// <param name="uiList"></param> /// <param name="listPlayerData"></param> /// <param name="eCampType"></param> private void SetPlayerInfoToList(IXUIList uiList, List <PlayerData> listPlayerData, ECampType eCampType) { if (uiList != null) { for (int i = 0; i < uiList.Count; i++) { IXUIListItem item = uiList.GetItemByIndex(i); if (item != null) { item.Clear(); IXUIList equip = item.GetUIObject("List_Equip") as IXUIList; if (equip != null) { for (int j = 0; j < equip.Count; j++) { IXUIListItem equipItem = equip.GetItemByIndex(j); if (equipItem != null) { equipItem.Clear();//清空装备icon } } } IXUIObject uiObject = item.GetUIObject("Texture_Shadow") as IXUIObject; if (uiObject != null) { uiObject.SetVisible(true); } item.SetText("Label_Sequence", ""); } } int num = 0; foreach (var playerData in listPlayerData) { foreach (var beastData in playerData.Beasts) { IXUIListItem item = (num >= uiList.Count) ? null : uiList.GetItemByIndex(num); if (item != null) { this.RefreshPlayerInfo(item, playerData, beastData, eCampType); } num++; } } Debug.Log("Beast num=" + num); } }
/// <summary> /// 服务器某个被点击 /// </summary> /// <param name="item"></param> /// <returns></returns> private bool OnServerListItemClick(IXUIListItem item) { if (null == item) { return(false); } this.m_selectedServerId = item.Id; ServerInfo info = SystemConfig.GetServerInfoById(this.m_selectedServerId); bool active = true; if (info.flag == (int)ServerType.Close || info.flag == (int)ServerType.Maintain) { active = false; } ShowServerSignal(active, info); return(true); }
/// <summary> /// 是否能选择其他神兽,如果选择过了就不能再次选择 /// </summary> /// <returns>true表示选择过了,false表示没有</returns> private bool CanSelectOtherBeast() { IXUIListItem selectItem = base.uiBehaviour.m_ourBeastList.GetSelectedItem(); bool result; if (selectItem == null) { result = false; } else { BeastData beastData = Singleton <RoomManager> .singleton.GetBeastData(selectItem.Id); result = (beastData != null && beastData.IsSelected); } return(result); }
/// <summary> /// 我方的玩家选择神兽 /// </summary> /// <param name="item"></param> /// <returns></returns> private bool OnListOurBeastSelect(IXUIListItem item) { bool result; if (item == null || item.Id == 0u) { result = false; } else { this.m_lBeastIdCurrent = item.Id; BeastData data = Singleton <RoomManager> .singleton.GetBeastData(this.m_lBeastIdCurrent); this.SelectRole(this.m_lBeastIdCurrent); result = true; } return(result); }
public override void Init() { base.Init(); this.m_unRandomBeastID = 2147483647u; if (Singleton <RoomManager> .singleton.IsObserver) { IXUIListItem[] allItems = base.uiBehaviour.m_ourBeastList.GetAllItems(); for (int i = 0; i < allItems.Length; i++) { IXUIListItem item = allItems[i]; item.RegisterClickEventHandler(new ClickEventHandler(this.OnListItemOnClickOurBeast)); } allItems = base.uiBehaviour.m_enmeyBeastList.GetAllItems(); for (int i = 0; i < allItems.Length; i++) { IXUIListItem item = allItems[i]; item.RegisterClickEventHandler(new ClickEventHandler(this.OnListItemOnClickEnemyBeast)); } } }
public override FlyTextEntity Add(string strText, long targetBeastId, float PosZ) { FlyTextEntity flyTextEntity = null; if (this.m_flyTextList.First != null) { flyTextEntity = this.m_flyTextList.First.Value; flyTextEntity.Active = true; } else { IXUIListItem item = this.m_uiList.AddListItem(); if (item != null) { flyTextEntity = new FlyTextEntity(item, targetBeastId); this.m_flyTextList.AddFirst(flyTextEntity); } } this.InitFlyText(flyTextEntity, strText, targetBeastId); return(flyTextEntity); }
private void RefreshHp() { if (this.m_List_Hp == null) { return; } float cellwidth = 150f / this.m_unHpMax; if (this.m_unHpMax != this.m_List_Hp.Count) { while (this.m_unHpMax > this.m_List_Hp.Count) { this.m_List_Hp.AddListItem(); } while (this.m_unHpMax < this.m_List_Hp.Count) { this.m_List_Hp.DelItemByIndex(this.m_List_Hp.Count - 1); } this.m_List_Hp.SetSize(cellwidth, 18f); this.IsFriend = this.m_bIsFriend; } for (int i = 0; i < this.m_List_Hp.Count; i++) { IXUIListItem itemByIndex = this.m_List_Hp.GetItemByIndex(i); if (itemByIndex != null) { if (i < this.m_unHp) { itemByIndex.SetVisible(true); } else { itemByIndex.SetVisible(false); } itemByIndex.SetSize(cellwidth, 18f); } } this.m_List_Hp.Refresh(); }
private void RefreshPlayerInfo(IXUIListItem uiListItem, PlayerData playerData, BeastData beast, ECampType eCampType) { if (beast != null) { this.SetSelectBeastId(beast.Id, beast.BeastTypeId); Debug.Log("Our BeastId:" + beast.Id); if (playerData != null && uiListItem != null) { uiListItem.Clear(); IXUILabel label = uiListItem.GetUIObject("Label_PlayerName") as IXUILabel; if (label != null) { label.SetText(playerData.Name); } if (Singleton <RoomManager> .singleton.MathMode != EnumMathMode.EnumMathMode_Story) { uiListItem.SetText("Label_Sequence", GetSequence(eCampType, uiListItem.Index).ToString()); } this.RefreshPlayerInfo(uiListItem, beast); } } }