//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Monday, November 27, 2017
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
using Snxxz.UI;
|
|
namespace Snxxz.UI
|
{
|
|
public class RoleParticularsWin : Window
|
{
|
[SerializeField] List<RoleEquip> roleEquipList = new List<RoleEquip>();
|
[SerializeField] Button addFriendBtn;
|
[SerializeField] Button m_ViewHorse;
|
[SerializeField] Button m_ViewPet;
|
[SerializeField] Button closeBtn;
|
[SerializeField] Text fairyName;
|
[SerializeField] Image realmImg;
|
[SerializeField] Text playerTxt;
|
[SerializeField] Text fightPowerTxt;
|
[SerializeField] RawImage roleModel;
|
|
RoleParticularModel model { get { return ModelCenter.Instance.GetModel<RoleParticularModel>(); } }
|
FriendsModel friendsModel { get { return ModelCenter.Instance.GetModel<FriendsModel>(); } }
|
ItemTipsModel itemTipsModel { get { return ModelCenter.Instance.GetModel<ItemTipsModel>(); } }
|
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
addFriendBtn.onClick.AddListener(OnAddFriend);
|
closeBtn.onClick.AddListener(CloseClick);
|
|
for (int i = 0; i < roleEquipList.Count; i++)
|
{
|
RoleEquipType roleEquipType = roleEquipList[i].type;
|
roleEquipList[i].itemCell.button.onClick.AddListener(() =>
|
{
|
OnRoleEquipClick(roleEquipType);
|
});
|
}
|
|
m_ViewHorse.onClick.AddListener(ViewHorse);
|
m_ViewPet.onClick.AddListener(ViewPet);
|
}
|
|
private void OnRoleEquipClick(RoleEquipType type)
|
{
|
RoleParticularModel.ItemData itemData = model.GetItemData(type);
|
if (itemData != null)
|
{
|
RoleParticularModel.ViewPlayerData viewPlayerData = model.GetViewPlayerData(model.viewPlayer);
|
ItemAttrData attrData = new ItemAttrData(itemData.ItemID, false, 1, -1, false, PackType.Deleted,
|
"", itemData.useDataDict);
|
attrData.SetStrengthData(viewPlayerData.rolePlusData.GetEquipStarLv((int)type),1);
|
attrData.SetGemModel(viewPlayerData.rolePlusData.GetEquipStone((int)type));
|
itemTipsModel.SetItemTipsModel(attrData);
|
}
|
}
|
|
protected override void OnPreOpen()
|
{
|
OnShowRoleEquip();
|
WindowCenter.Instance.windowAfterCloseEvent += WindowAfterCloseEvent;
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
WindowCenter.Instance.windowAfterCloseEvent -= WindowAfterCloseEvent;
|
}
|
|
protected override void OnAfterClose()
|
{
|
UI3DModelExhibition.Instance.StopShow();
|
if (!WindowJumpMgr.Instance.IsJumpState)
|
{
|
WindowCenter.Instance.Open<MainInterfaceWin>();
|
}
|
}
|
#endregion
|
|
private void WindowAfterCloseEvent(Window win)
|
{
|
if (win is ViewHorseDetailWin || win is ViewPetDetailWin)
|
{
|
OnShowRoleEquip();
|
}
|
}
|
|
private void OnAddFriend()
|
{
|
if (friendsModel.GetFirendInfo((uint)model.viewPlayer, (byte)GroupType.Balcklist) != null)
|
{
|
SysNotifyMgr.Instance.ShowTip("Friend_RemoveBlacklist");
|
return;
|
}
|
friendsModel.OnClickAddFriend((uint)model.viewPlayer);
|
}
|
|
private void ViewPet()
|
{
|
RoleParticularModel.ViewPlayerData viewPlayerData = model.GetViewPlayerData(model.viewPlayer);
|
if (viewPlayerData != null && viewPlayerData.rolePlusData.pets.Count > 0)
|
{
|
WindowCenter.Instance.Open<ViewPetDetailWin>();
|
}
|
}
|
|
private void ViewHorse()
|
{
|
RoleParticularModel.ViewPlayerData viewPlayerData = model.GetViewPlayerData(model.viewPlayer);
|
if (viewPlayerData != null && viewPlayerData.rolePlusData.horses.Count > 0)
|
{
|
WindowCenter.Instance.Open<ViewHorseDetailWin>();
|
}
|
}
|
|
private void OnShowRoleEquip()
|
{
|
for (int i = 0; i < roleEquipList.Count; i++)
|
{
|
ItemCell itemCell = roleEquipList[i].itemCell;
|
RoleParticularModel.ItemData itemData = model.GetItemData(roleEquipList[i].type);
|
itemCell.gameObject.SetActive(itemData != null);
|
if (itemData == null)
|
{
|
continue;
|
}
|
|
ItemCellModel cellModel = new ItemCellModel(itemData.ItemID, false, 1,
|
"", PackType.Equip, false, itemData.useDataDict);
|
itemCell.Init(cellModel);
|
}
|
|
var viewPlayerData = model.GetViewPlayerData(model.viewPlayer);
|
addFriendBtn.gameObject.SetActive(!viewPlayerData.IsCrossServerPlayer()
|
&& friendsModel.GetFirendInfo((uint)model.viewPlayer, (byte)GroupType.Friend) == null);
|
|
if (viewPlayerData != null)
|
{
|
m_ViewHorse.gameObject.SetActive(viewPlayerData.rolePlusData.horses.Count > 0);
|
m_ViewPet.gameObject.SetActive(viewPlayerData.rolePlusData.pets.Count > 0);
|
|
if (viewPlayerData.rolePropData.FamilyID == 0)
|
{
|
fairyName.gameObject.SetActive(false);
|
}
|
else
|
{
|
fairyName.gameObject.SetActive(true);
|
fairyName.text = StringUtility.Contact(Language.Get("RoleParticularWin_1"), viewPlayerData.rolePropData.FamilyName);
|
}
|
var realmLv = viewPlayerData.rolePropData.RealmLV;
|
realmImg.gameObject.SetActive(realmLv > 0);
|
if (realmLv > 0)
|
{
|
RealmConfig _tagRealmModel = RealmConfig.Get(realmLv);
|
if (_tagRealmModel != null)
|
{
|
realmImg.SetSprite(_tagRealmModel.Img);
|
}
|
}
|
playerTxt.text = StringUtility.Contact(viewPlayerData.rolePropData.Name, "Lv. ", viewPlayerData.rolePropData.LV);
|
fightPowerTxt.text = StringUtility.Contact(Language.Get("RoleParticularWin_2"), viewPlayerData.rolePropData.FightPower);
|
|
int clothes = 0;
|
int _suitLevel = 0;
|
RoleParticularModel.ItemData itemData = model.GetItemData(RoleEquipType.Clothes);
|
if (itemData != null)
|
{
|
clothes = itemData.ItemID;
|
_suitLevel = viewPlayerData.GetEquipSuitLevel();
|
}
|
int weapon = 0;
|
itemData = model.GetItemData(RoleEquipType.Weapon);
|
if (itemData != null)
|
{
|
weapon = itemData.ItemID;
|
}
|
int wing = 0;
|
itemData = model.GetItemData(RoleEquipType.Wing);
|
if (itemData != null)
|
{
|
wing = itemData.ItemID;
|
}
|
int weapon2 = 0;
|
itemData = model.GetItemData(RoleEquipType.Weapon2);
|
if (itemData != null)
|
{
|
weapon2 = itemData.ItemID;
|
}
|
int fashionClothes = 0;
|
itemData = model.GetItemData(RoleEquipType.FashionClothes);
|
if (itemData != null)
|
{
|
fashionClothes = itemData.ItemID;
|
}
|
int fashionWeapon = 0;
|
itemData = model.GetItemData(RoleEquipType.FashionWeapon);
|
if (itemData != null)
|
{
|
fashionWeapon = itemData.ItemID;
|
}
|
int fashionWeapon2 = 0;
|
itemData = model.GetItemData(RoleEquipType.FashionWeapon2);
|
if (itemData != null)
|
{
|
fashionWeapon2 = itemData.ItemID;
|
}
|
|
var data = new UI3DPlayerExhibitionData
|
{
|
job = viewPlayerData.rolePropData.Job,
|
fashionClothesId = fashionClothes,
|
fashionWeaponId = fashionWeapon,
|
fashionSecondaryId = fashionWeapon2,
|
clothesId = clothes,
|
suitLevel = _suitLevel,
|
weaponId = weapon,
|
wingsId = wing,
|
secondaryId = weapon2,
|
isDialogue = false,
|
};
|
UI3DModelExhibition.Instance.ShowPlayer(roleModel, data);
|
}
|
}
|
|
[Serializable]
|
public class RoleEquip
|
{
|
public RoleEquipType type;
|
public ItemCell itemCell;
|
}
|
}
|
|
}
|
|
|
|
|