using UnityEngine;
|
using UnityEngine.Rendering;
|
using UnityEngine.UI;
|
using vnxbqy.UI;
|
|
public class CelestialPalaceRoomWin : Window
|
{
|
[SerializeField] Transform havePlayer;
|
[SerializeField] Transform noPlayer;
|
[SerializeField] ButtonEx btnNameList;
|
[SerializeField] ButtonEx btnLeft;
|
[SerializeField] ButtonEx btnRight;
|
[SerializeField] TextEx txtPlayerInfo;
|
[SerializeField] Image imgRealm;
|
[SerializeField] TextEx txtLv;
|
[SerializeField] TextEx txtServerName;
|
[SerializeField] AvatarCell avatarCell;
|
[SerializeField] ImageEx imgTitleNoPlayer;
|
[SerializeField] ImageEx imgTitlePlayer;
|
[SerializeField] TextEx txtTitle;
|
[SerializeField] RawImage rawImage;
|
int xgId;
|
int currentIndex; //当前查看的新晋仙官列表索引
|
CelestialPalaceModel model { get { return ModelCenter.Instance.GetModel<CelestialPalaceModel>(); } }
|
TitleModel titleModel { get { return ModelCenter.Instance.GetModel<TitleModel>(); } }
|
|
protected override void BindController()
|
{
|
btnNameList.SetListener(OnClickNameList);
|
btnLeft.SetListener(OnClickLeft);
|
btnRight.SetListener(OnClickRight);
|
}
|
|
protected override void OnPreOpen()
|
{
|
model.UpdateXiangongRecPlayerInfoEvent += OnUpdateXiangongRecPlayerInfoEvent;
|
model.UpdateXiangongNewPlayerInfoEvent += OnUpdateXiangongNewPlayerInfoEvent;
|
currentIndex = 0;
|
Display();
|
model.UpdateRedPoint();
|
}
|
|
protected override void OnPreClose()
|
{
|
model.UpdateXiangongRecPlayerInfoEvent -= OnUpdateXiangongRecPlayerInfoEvent;
|
model.UpdateXiangongNewPlayerInfoEvent -= OnUpdateXiangongNewPlayerInfoEvent;
|
}
|
|
private void OnUpdateXiangongNewPlayerInfoEvent()
|
{
|
Display();
|
model.UpdateRedPoint();
|
}
|
void OnUpdateXiangongRecPlayerInfoEvent()
|
{
|
CloseClick();
|
WindowCenter.Instance.Open<CelestialPalaceNameListWin>();
|
}
|
|
void Display()
|
{
|
xgId = model.currentSelectedXGId;
|
if (xgId <= 0)
|
{
|
CloseClick();
|
return;
|
}
|
txtTitle.text = Language.Get(StringUtility.Contact("CelestialPalaceName_", xgId));
|
bool isRoomHavePlayer = model.TryGetRoomNewPlayer(xgId, out var newPlayerList);
|
havePlayer.SetActive(isRoomHavePlayer);
|
noPlayer.SetActive(!isRoomHavePlayer);
|
btnLeft.SetActive(isRoomHavePlayer && currentIndex > 0);
|
btnRight.SetActive(isRoomHavePlayer && currentIndex < newPlayerList.Count - 1);
|
rawImage.SetActive(isRoomHavePlayer);
|
int titleId = XiangongConfig.Get(xgId).TitleID;
|
//存在新晋仙官
|
if (isRoomHavePlayer)
|
{
|
if (currentIndex < 0 || currentIndex > newPlayerList.Count - 1)
|
return;
|
uint nowPlayerId = newPlayerList[currentIndex];
|
if (model.allPlayerInfoDict == null || !model.allPlayerInfoDict.TryGetValue(xgId, out var xgInfo) || xgInfo == null||
|
!xgInfo.TryGetValue(nowPlayerId, out var celestialPalacePlayer))
|
return;
|
model.ShowTitle(titleId, imgTitlePlayer);
|
avatarCell.InitUI(AvatarHelper.GetAvatarModel((int)celestialPalacePlayer.PlayerID, (int)celestialPalacePlayer.Face, (int)celestialPalacePlayer.FacePic, celestialPalacePlayer.Job));
|
txtLv.text = Language.Get("PlayerDetail_Level", celestialPalacePlayer.LV);
|
string serverName = ServerListCenter.Instance.GetServerName((int)celestialPalacePlayer.ServerID);
|
txtServerName.text = serverName;
|
int realmLV = celestialPalacePlayer.RealmLV;
|
string name = celestialPalacePlayer.Name;
|
imgRealm.SetActive(realmLV > 0);
|
if (realmLV > 0)
|
{
|
RealmConfig realmConfig = RealmConfig.Get(realmLV);
|
if (realmConfig != null)
|
{
|
imgRealm.SetSprite(realmConfig.Img);
|
}
|
}
|
txtPlayerInfo.text = name;
|
ShowPlayer(rawImage, celestialPalacePlayer.Job, celestialPalacePlayer.EquipShowSwitch, celestialPalacePlayer.EquipShowID);
|
}
|
else
|
{
|
model.ShowTitle(titleId, imgTitleNoPlayer);
|
}
|
}
|
|
void OnClickNameList()
|
{
|
if (model.IsNeedSendA906Pack(xgId))
|
{
|
model.SendA906SeekPack(xgId);
|
}
|
else
|
{
|
CloseClick();
|
WindowCenter.Instance.Open<CelestialPalaceNameListWin>();
|
}
|
|
}
|
|
void OnClickLeft()
|
{
|
currentIndex -= 1;
|
Display();
|
}
|
|
void OnClickRight()
|
{
|
currentIndex += 1;
|
Display();
|
}
|
|
public void ShowPlayer(RawImage rawImage, int Job, uint EquipShowSwitch, uint[] EquipShowID)
|
{
|
var data = new UI3DPlayerExhibitionData
|
{
|
job = Job,
|
fashionClothesId = model.GetItemId(RoleEquipType.FashionClothes, EquipShowID),
|
fashionWeaponId = model.GetItemId(RoleEquipType.FashionWeapon, EquipShowID),
|
fashionSecondaryId = model.GetItemId(RoleEquipType.FashionWeapon2, EquipShowID),
|
clothesId = model.GetItemId(RoleEquipType.Clothes, EquipShowID),
|
suitLevel = (int)(EquipShowSwitch % 10),
|
weaponId = model.GetItemId(RoleEquipType.Weapon, EquipShowID),
|
wingsId = model.GetItemId(RoleEquipType.Wing, EquipShowID),
|
secondaryId = model.GetItemId(RoleEquipType.Weapon2, EquipShowID),
|
reikiRootEffectId = (int)EquipShowSwitch / 1000 % 1000,
|
isDialogue = false,
|
equipLevel = (int)EquipShowSwitch / 10 % 100,
|
titleID = XiangongConfig.Get(xgId).TitleID,
|
scale = 0.7f,
|
};
|
rawImage.SetActive(true);
|
UI3DModelExhibition.Instance.ShowPlayer(rawImage, data);
|
rawImage.raycastTarget = false;
|
}
|
|
protected override void OnAfterOpen()
|
{
|
|
}
|
|
protected override void OnAfterClose()
|
{
|
|
}
|
|
protected override void AddListeners()
|
{
|
|
}
|
}
|