using UnityEngine;
|
using UnityEngine.UI;
|
|
using System.Collections.Generic;
|
|
namespace Snxxz.UI
|
{
|
public class ModelShowPerfab : MonoBehaviour
|
{
|
[SerializeField] public Text titleText;
|
[SerializeField] public RawImage modelImg;
|
[SerializeField] public Text fightPowerText;
|
[SerializeField] public Image fightImg;
|
|
ModelShowType showType;
|
FashionDressModel fashionDressModel { get { return ModelCenter.Instance.GetModel<FashionDressModel>(); } }
|
ItemTipsModel tipsModel { get { return ModelCenter.Instance.GetModel<ItemTipsModel>(); } }
|
PlayerPackModel playerPack { get { return ModelCenter.Instance.GetModel<PlayerPackModel>(); } }
|
|
MagicianModel godWeaponModel
|
{
|
get { return ModelCenter.Instance.GetModel<MagicianModel>(); }
|
}
|
|
public void OnDisable()
|
{
|
switch (showType)
|
{
|
case ModelShowType.treasure:
|
UI3DTreasureExhibition.Instance.StopShow();
|
break;
|
case ModelShowType.mount:
|
break;
|
case ModelShowType.pet:
|
break;
|
}
|
}
|
|
public void SetModelShow(int id, ModelShowType showType, string title, int fightValue = 0)
|
{
|
titleText.text = title;
|
this.showType = showType;
|
var job = PlayerDatas.Instance.baseData.Job;
|
|
switch (showType)
|
{
|
case ModelShowType.treasure:
|
fightImg.SetSprite("FightingLv_Normal");
|
UI3DTreasureExhibition.Instance.BeginShowTreasure(id, modelImg);
|
break;
|
case ModelShowType.mount:
|
fightImg.SetSprite("FightingLv_Max");
|
UI3DModelExhibition.Instance.ShowHourse(id, modelImg);
|
break;
|
case ModelShowType.pet:
|
fightImg.SetSprite("FightingLv_Max");
|
var npcConfig = NPCConfig.Get(id);
|
UI3DModelExhibition.Instance.ShowNPC(id, npcConfig.UIModeLOffset, npcConfig.UIModelRotation, modelImg);
|
break;
|
case ModelShowType.FashionDress:
|
fightImg.SetSprite("FightingLv_Normal");
|
var itemConfig = ItemConfig.Get(id);
|
if(itemConfig != null)
|
{
|
int fashionType = 0;
|
int fashionId = 0;
|
bool isFashion = tipsModel.TryGetItemFashionData(itemConfig.ID, out fashionType, out fashionId);
|
if(isFashion)
|
{
|
List<int> fashionIds = null;
|
fashionDressModel.TryGetFashionIds(fashionType, out fashionIds);
|
if(fashionIds != null && fashionIds.Count > 0)
|
{
|
UI3DModelExhibition.Instance.ShowOtherPlayer(modelImg, SetFashionDressData(fashionIds));
|
}
|
}
|
|
}
|
break;
|
case ModelShowType.Magic:
|
SetMagicFightImg(id);
|
UI3DModelExhibition.Instance.ShowOtherPlayer(modelImg, SetMagicData(id));
|
break;
|
}
|
|
if (fightValue == 0)
|
{
|
fightImg.gameObject.SetActive(false);
|
fightPowerText.gameObject.SetActive(false);
|
}
|
else
|
{
|
fightImg.gameObject.SetActive(true);
|
fightPowerText.gameObject.SetActive(true);
|
fightPowerText.text = fightValue.ToString();
|
fightImg.SetNativeSize();
|
}
|
}
|
|
public UI3DPlayerExhibitionData SetFashionDressData(List<int> fashionIds)
|
{
|
var job = PlayerDatas.Instance.baseData.Job;
|
|
//var playerPack = ModelCenter.Instance.GetModel<PlayerPackModel>();
|
|
//var clothes = playerPack.GetItemModelByIndex(PackType.rptEquip, (int)RoleEquipType.retClothes);
|
//var clothesId = clothes == null ? 0 : (int)clothes.itemInfo.ItemID;
|
|
//var weapon = playerPack.GetItemModelByIndex(PackType.rptEquip, (int)RoleEquipType.retWeapon);
|
//var weaponId = weapon == null ? 0 : (int)weapon.itemInfo.ItemID;
|
|
//var wings = playerPack.GetItemModelByIndex(PackType.rptEquip, (int)RoleEquipType.retWing);
|
//var wingsId = wings == null ? 0 : (int)wings.itemInfo.ItemID;
|
|
//var secondary = playerPack.GetItemModelByIndex(PackType.rptEquip, (int)RoleEquipType.retWeapon2);
|
//var secondaryId = secondary == null ? 0 : (int)secondary.itemInfo.ItemID;
|
var fashionClothesId = 0;
|
var fashionWeaponId = 0;
|
var fashionSecondaryId = 0;
|
foreach(var fashionId in fashionIds)
|
{
|
FashionDress fashionDress = null;
|
bool isFashion = fashionDressModel.TryGetFashionDress(fashionId, out fashionDress);
|
if (isFashion)
|
{
|
int itemId = fashionDress.requireLevelUpItem;
|
var itemConfig = ItemConfig.Get(itemId);
|
switch (fashionDress.fashionDressType)
|
{
|
case 1:
|
fashionClothesId = fashionDress.GetEquipItemId();
|
break;
|
case 2:
|
fashionWeaponId = fashionDress.GetEquipItemId();
|
break;
|
case 3:
|
fashionSecondaryId = fashionDress.GetEquipItemId();
|
break;
|
}
|
}
|
|
}
|
|
//int _suitLevel = 0;
|
//ItemUseDataKey
|
//if (clothes != null)
|
//{
|
// if (clothes.itemInfo.IsSuite == 1)
|
// {
|
// if (clothes.GetUseDataModel(30) != null && clothes.GetUseDataModel(30)[0] != 0)
|
// {
|
// _suitLevel = clothes.GetUseDataModel(30)[0];
|
// }
|
// }
|
//}
|
|
//Dictionary<int, int> dict = null;
|
//EquipShowSwitch.IsGodWeaponEffectOn(PlayerDatas.Instance.baseData.equipShowSwitch, out dict);
|
|
UI3DPlayerExhibitionData data = new UI3DPlayerExhibitionData()
|
{
|
job = job,
|
//clothesId = clothesId,
|
//suitLevel = _suitLevel,
|
//weaponId = weaponId,
|
//wingsId = wingsId,
|
//secondaryId = secondaryId,
|
fashionClothesId = fashionClothesId,
|
fashionWeaponId = fashionWeaponId,
|
fashionSecondaryId = fashionSecondaryId,
|
isDialogue = false,
|
//godWeapons = dict
|
};
|
return data;
|
}
|
|
private UI3DPlayerExhibitionData SetMagicData(int itemId)
|
{
|
var job = PlayerDatas.Instance.baseData.Job;
|
|
var clothes = playerPack.GetItemModelByIndex(PackType.Equip, (int)RoleEquipType.Clothes);
|
var clothesId = clothes == null ? 0 : (int)clothes.itemInfo.ItemID;
|
|
var weapon = playerPack.GetItemModelByIndex(PackType.Equip, (int)RoleEquipType.Weapon);
|
var weaponId = weapon == null ? 0 : (int)weapon.itemInfo.ItemID;
|
|
var wings = playerPack.GetItemModelByIndex(PackType.Equip, (int)RoleEquipType.Wing);
|
var wingsId = wings == null ? 0 : (int)wings.itemInfo.ItemID;
|
|
var secondary = playerPack.GetItemModelByIndex(PackType.Equip, (int)RoleEquipType.Weapon2);
|
var secondaryId = secondary == null ? 0 : (int)secondary.itemInfo.ItemID;
|
|
var fashionClothes = playerPack.GetItemModelByIndex(PackType.Equip, (int)RoleEquipType.FashionClothes);
|
var fashionClothesId = fashionClothes == null ? 0 : (int)fashionClothes.itemInfo.ItemID;
|
|
var fashionWeapon = playerPack.GetItemModelByIndex(PackType.Equip, (int)RoleEquipType.FashionWeapon);
|
var fashionWeaponId = fashionWeapon == null ? 0 : (int)fashionWeapon.itemInfo.ItemID;
|
|
var fashionSecondary = playerPack.GetItemModelByIndex(PackType.Equip, (int)RoleEquipType.FashionWeapon2);
|
var fashionSecondaryId = fashionSecondary == null ? 0 : (int)fashionSecondary.itemInfo.ItemID;
|
|
int _suitLevel = 0;
|
|
if (clothes != null)
|
{
|
if (clothes.itemInfo.IsSuite == 1)
|
{
|
if (clothes.GetUseDataModel(30) != null && clothes.GetUseDataModel(30)[0] != 0)
|
{
|
_suitLevel = clothes.GetUseDataModel(30)[0];
|
}
|
}
|
}
|
|
int magicType = 0;
|
bool isMagic = godWeaponModel.TryGetMagicType(itemId, out magicType);
|
int magicEffectStage = godWeaponModel.GetGodWeaponStage(magicType) + 1;
|
magicEffectStage = magicEffectStage > 3 ? 3 : magicEffectStage;
|
Dictionary<int, int> dict = new Dictionary<int, int>();
|
if(isMagic)
|
{
|
dict[magicType] = godWeaponModel.GetGodWeaponStageRequireLevel(magicType, magicEffectStage);
|
}
|
|
UI3DPlayerExhibitionData data = new UI3DPlayerExhibitionData()
|
{
|
job = job,
|
|
fashionClothesId = fashionClothesId,
|
fashionWeaponId = fashionWeaponId,
|
fashionSecondaryId = fashionSecondaryId,
|
clothesId = clothesId,
|
suitLevel = _suitLevel,
|
weaponId = weaponId,
|
wingsId = wingsId,
|
secondaryId = secondaryId,
|
isDialogue = false,
|
godWeapons = dict
|
};
|
return data;
|
}
|
|
private void SetMagicFightImg(int itemId)
|
{
|
int magicType = 0;
|
bool isMagic = godWeaponModel.TryGetMagicType(itemId, out magicType);
|
if (!isMagic) return;
|
|
int magicEffectStage = godWeaponModel.GetGodWeaponStage(magicType) + 1;
|
magicEffectStage = magicEffectStage > 3 ? 3 : magicEffectStage;
|
switch(magicEffectStage)
|
{
|
case 1:
|
fightImg.SetSprite("FightingLv_100");
|
break;
|
case 2:
|
fightImg.SetSprite("FightingLv_200");
|
break;
|
case 3:
|
fightImg.SetSprite("FightingLv_300");
|
break;
|
}
|
}
|
}
|
|
public enum ModelShowType
|
{
|
treasure, //法宝
|
mount, //坐骑
|
pet, //灵宠
|
FashionDress, //时装
|
Magic,//神兵
|
}
|
}
|