432 lines
14 KiB
C#
432 lines
14 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using GCGame.Table;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System.Collections;
|
|
using Games.Events;
|
|
using Games.Item;
|
|
using Games.LogicObj;
|
|
using Module.Log;
|
|
|
|
public class MagicInfoWnd : MonoBehaviour
|
|
{
|
|
public UICameraTexture modelTexture; // 模型展示的RenderTexture
|
|
public Text tipText; // 提示信息,已激活的提示已激活,未激活的提示激活条件
|
|
public GameObject hasActiveTip; // 已激活的图片提示
|
|
public Image[] weaponQuilitys; //
|
|
public Image[] weaponMagics; //
|
|
public Text Name; //
|
|
public GameObject leftBtn; // 左按钮
|
|
public GameObject rightBtn; // 右按钮
|
|
public GameObject hasnEquipBtn; // 未装备按钮
|
|
public GameObject hasEquipBtn; // 已装备按钮
|
|
public Button EquipBtn; // 装备按钮
|
|
public UIContainerBase m_Container; // 玩家背包中的法宝
|
|
|
|
public void Start()
|
|
{
|
|
hasActiveTip.SetActive(false);
|
|
|
|
m_Container.SetShowItemFinishCallFun(UpdateRedPoint);
|
|
InitWeaponMagicInfo();
|
|
ShowMagicInBag();
|
|
|
|
// 显示左侧模型
|
|
if(GameManager.gameManager.PlayerDataPool != null)
|
|
{
|
|
Tab_MagicWeaponActiveModel magicModel = TableManager.GetMagicWeaponActiveModelByID(GameManager.gameManager.PlayerDataPool.DressMagicModelId, 0);
|
|
if(magicModel!=null)
|
|
{
|
|
InitModel(GameManager.gameManager.PlayerDataPool.DressMagicModelId);
|
|
|
|
// 开始时也需要更新一次按钮状态
|
|
int index = 0;
|
|
var magicModels = TableManager.GetMagicWeaponActiveModel();
|
|
int[] keys = new int[magicModels.Count];
|
|
magicModels.Keys.CopyTo(keys, 0);
|
|
for (int i = 0; i < keys.Length; i++)
|
|
{
|
|
if (keys[i] == selectModelId)
|
|
{
|
|
index = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
SetLRBtnState(index, keys.Length);
|
|
}
|
|
else
|
|
{
|
|
if(selectModelId == -1)
|
|
{
|
|
var magicModels = TableManager.GetMagicWeaponActiveModel();
|
|
int[] keys = new int[magicModels.Count];
|
|
magicModels.Keys.CopyTo(keys, 0);
|
|
selectModelId = keys[0];
|
|
}
|
|
|
|
// 开始时也需要更新一次按钮状态
|
|
InitModel(selectModelId);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 显示已装备的法宝
|
|
/// </summary>
|
|
void InitWeaponMagicInfo()
|
|
{
|
|
if (GameManager.gameManager.PlayerDataPool == null)
|
|
return;
|
|
GameItemContainer Container = GameManager.gameManager.PlayerDataPool.GetItemContainer(GameItemContainer.Type.TYPE_MAGICPACK);
|
|
if (Container == null)
|
|
{
|
|
return;
|
|
}
|
|
for(int i = 0; i < weaponMagics.Length; i++)
|
|
{
|
|
weaponMagics[i].gameObject.SetActive(false);
|
|
weaponQuilitys[i].gameObject.SetActive(false);
|
|
}
|
|
for (int i = 0; i < Container.ContainerSize; i++)
|
|
{
|
|
GameItem gameItem = Container.GetItem(i);
|
|
Tab_CommonItem line = TableManager.GetCommonItemByID(gameItem.DataID, 0);
|
|
if (line == null)
|
|
{
|
|
continue;
|
|
}
|
|
if (line.SubClassID - 1 < weaponMagics.Length)
|
|
{
|
|
weaponMagics[line.SubClassID - 1].gameObject.SetActive(true);
|
|
LoadAssetBundle.Instance.SetImageSprite(weaponMagics[line.SubClassID - 1], line.Icon);
|
|
weaponQuilitys[line.SubClassID - 1].gameObject.SetActive(true);
|
|
LoadAssetBundle.Instance.SetImageSprite(weaponQuilitys[line.SubClassID - 1], GCGame.Utils.GetItemQualityFrame(line.Quality));
|
|
if (line.QualityEffect > 0)
|
|
{
|
|
CommonItemContainerItem.ShowQualityEffect(true, line.QualityEffect, weaponQuilitys[line.SubClassID - 1].transform);
|
|
}
|
|
else
|
|
{
|
|
CommonItemContainerItem.ShowQualityEffect(false, line.QualityEffect, weaponQuilitys[line.SubClassID - 1].transform);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Click_WeaponMagic(int index)
|
|
{
|
|
GameItemContainer Container = GameManager.gameManager.PlayerDataPool.GetItemContainer(GameItemContainer.Type.TYPE_MAGICPACK);
|
|
if (Container == null)
|
|
{
|
|
return;
|
|
}
|
|
GameItem gameItem = Container.GetItem(index);
|
|
if (gameItem == null || gameItem.IsValid() == false)
|
|
return;
|
|
MagicTooltipLogic.ShowEquipTooltip(gameItem, ItemTooltipsLogic.ShowType.Equiped);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 显示背包中的法宝信息
|
|
/// </summary>
|
|
public void ShowMagicInBag()
|
|
{
|
|
List<GameItem> gameItems = GameManager.gameManager.PlayerDataPool.BackPack.GetList();
|
|
int Count = gameItems.Count;
|
|
List<GameItem> magicItems = new List<GameItem>();
|
|
for (int i = 0; i < Count; i++)
|
|
{
|
|
GameItem gameItem = gameItems[i];
|
|
if (gameItem.IsMagicMent())
|
|
{
|
|
magicItems.Add(gameItem);
|
|
}
|
|
}
|
|
magicItems.Sort((a, b) =>
|
|
{
|
|
int SlotA = a.GetMagicSlotIndex();
|
|
int SlotB = b.GetMagicSlotIndex();
|
|
int SortA = a.SortId();
|
|
int SortB = b.SortId();
|
|
|
|
if (SortA > SortB)
|
|
return 1;
|
|
if (SortA < SortB)
|
|
return -1;
|
|
if(SortA == SortB)
|
|
{
|
|
if (SlotA > SlotB)
|
|
return 1;
|
|
if (SlotA < SlotB)
|
|
return -1;
|
|
}
|
|
|
|
return 0;
|
|
});
|
|
|
|
if(magicItems.Count <= 0)
|
|
{
|
|
// 其实也可以直接关闭红点,因为已经没有背包已经没有法宝了
|
|
UpdateRedPoint();
|
|
}
|
|
|
|
m_Container.InitContentItem(magicItems, null);
|
|
}
|
|
|
|
|
|
// 41021 宝物 已佩戴
|
|
//41022 宝物 佩戴
|
|
public void UpdateDressTip()
|
|
{
|
|
if (selectModelId == Singleton<ObjManager>.Instance.MainPlayer.MagicID)
|
|
{
|
|
hasEquipBtn.SetActive(true);
|
|
hasnEquipBtn.SetActive(false);
|
|
EquipBtn.gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
|
|
hasEquipBtn.SetActive(false);
|
|
hasnEquipBtn.SetActive(false);
|
|
EquipBtn.gameObject.SetActive(true);
|
|
}
|
|
|
|
private int selectModelId = -1;
|
|
public void InitModel(int modelID)
|
|
{
|
|
if (modelTexture == null)
|
|
return;
|
|
Tab_MagicWeaponActiveModel magicModel = TableManager.GetMagicWeaponActiveModelByID(modelID, 0);
|
|
if (magicModel == null)
|
|
{
|
|
return;
|
|
}
|
|
Tab_CharModel charModelTab = TableManager.GetCharModelByID(magicModel.ShowModel, 0);
|
|
if (charModelTab != null)
|
|
{
|
|
modelTexture.gameObject.SetActive(true);
|
|
modelTexture.InitModelPath(charModelTab.ResPath, charModelTab, LoadAssetBundle.BUNDLE_PATH_MODEL,true);
|
|
selectModelId = modelID;
|
|
Name.text = charModelTab.Name;
|
|
}
|
|
|
|
if (modelID == Singleton<ObjManager>.Instance.MainPlayer.MagicID)
|
|
{
|
|
// 已穿戴
|
|
hasActiveTip.SetActive(true);
|
|
tipText.text = StrDictionary.GetClientDictionaryString("#{41016}", magicModel.Level, "<color=#0ABC37FF>" + GetLevelItemCount(magicModel.Level, magicModel.Color), magicModel.Num + "</color>");
|
|
EquipBtn.gameObject.SetActive(false);
|
|
hasEquipBtn.SetActive(true);
|
|
hasnEquipBtn.SetActive(false);
|
|
|
|
return;
|
|
}
|
|
|
|
if (GameManager.gameManager.PlayerDataPool.IsMagicModelActive(modelID) == true)
|
|
{
|
|
// 已激活
|
|
hasActiveTip.SetActive(true);
|
|
tipText.text = StrDictionary.GetClientDictionaryString("#{41016}", magicModel.Level, "<color=#0ABC37FF>" + GetLevelItemCount(magicModel.Level, magicModel.Color), magicModel.Num + "</color>");
|
|
EquipBtn.gameObject.SetActive(true);
|
|
hasEquipBtn.SetActive(false);
|
|
hasnEquipBtn.SetActive(false);
|
|
return;
|
|
|
|
}
|
|
else
|
|
{
|
|
// 未激活
|
|
hasActiveTip.SetActive(false);
|
|
tipText.text = StrDictionary.GetClientDictionaryString("#{41016}", magicModel.Level, "<color=#F4002CFF>" + GetLevelItemCount(magicModel.Level, magicModel.Color), magicModel.Num + "</color>");
|
|
EquipBtn.gameObject.SetActive(false);
|
|
hasEquipBtn.SetActive(false);
|
|
hasnEquipBtn.SetActive(true);
|
|
|
|
return;
|
|
}
|
|
}
|
|
|
|
public int GetLevelItemCount(int level,int quality)
|
|
{
|
|
int count = 0;
|
|
List<GameItem> gameItems = GameManager.gameManager.PlayerDataPool.MagicPack.GetList();
|
|
for(int i=0;i<gameItems.Count;i++)
|
|
{
|
|
int levelNeed = gameItems[i].GetMinLevelRequire();
|
|
int color = (int)gameItems[i].GetQuality();
|
|
if (levelNeed!=-1 && levelNeed >= level && color >= quality)
|
|
count++;
|
|
}
|
|
return count;
|
|
}
|
|
|
|
public void Click_LastModel()
|
|
{
|
|
int index = 0;
|
|
var magicModels = TableManager.GetMagicWeaponActiveModel();
|
|
int[] keys = new int[magicModels.Count];
|
|
magicModels.Keys.CopyTo(keys, 0);
|
|
for (int i = 1; i < keys.Length; i++)
|
|
{
|
|
if (keys[i] == selectModelId)
|
|
{
|
|
index = i - 1;
|
|
break;
|
|
}
|
|
}
|
|
|
|
SetLRBtnState(index, keys.Length);
|
|
|
|
InitModel(keys[index]);
|
|
}
|
|
|
|
private void SetLRBtnState(int index, int lenght)
|
|
{
|
|
if(index <= 0)
|
|
{
|
|
leftBtn.SetActive(false);
|
|
}
|
|
else
|
|
{
|
|
leftBtn.SetActive(true);
|
|
}
|
|
|
|
if(index >= lenght - 1)
|
|
{
|
|
rightBtn.SetActive(false);
|
|
}
|
|
else
|
|
{
|
|
rightBtn.SetActive(true);
|
|
}
|
|
|
|
}
|
|
|
|
public void Click_NextModel()
|
|
{
|
|
int index = 0;
|
|
var magicModels = TableManager.GetMagicWeaponActiveModel();
|
|
int[] keys = new int[magicModels.Count];
|
|
magicModels.Keys.CopyTo(keys, 0);
|
|
for (int i = 0; i < keys.Length - 1; i++)
|
|
{
|
|
if (keys[i] == selectModelId)
|
|
{
|
|
index = i + 1;
|
|
break;
|
|
}
|
|
}
|
|
|
|
SetLRBtnState(index, keys.Length);
|
|
|
|
InitModel(keys[index]);
|
|
}
|
|
|
|
public void Click_Equip()
|
|
{
|
|
if (selectModelId == -1)
|
|
return;
|
|
CG_HANDLE_MAGIC_WEAPON send = (CG_HANDLE_MAGIC_WEAPON)PacketDistributed.CreatePacket(MessageID.PACKET_CG_HANDLE_MAGIC_WEAPON);
|
|
send.Guid = (ulong)selectModelId;
|
|
send.Handletype = (int)CG_HANDLE_MAGIC_WEAPON.EMagicWeaponHandleType.EActiveModel;
|
|
if (Singleton<ObjManager>.Instance.MainPlayer.MagicID == selectModelId)
|
|
{
|
|
send.Handletype = (int)CG_HANDLE_MAGIC_WEAPON.EMagicWeaponHandleType.EUnActiveModel;
|
|
}
|
|
send.SendPacket();
|
|
}
|
|
|
|
public void Click_Tip()
|
|
{
|
|
MessageHelpLogic.ShowHelpMessage(36);
|
|
}
|
|
|
|
public static int[] COMMON_MAGIC_DATA_ID = new int[4] { 60171, 60176, 60181, 60186 };
|
|
public void Click_Get()
|
|
{
|
|
//ItemTooltipsLogic.ShowItemTooltip(SavvyItemID, ItemTooltipsLogic.ShowType.GetPath);
|
|
int _Prefession = 0;
|
|
var _MainPlayer = Singleton<ObjManager>.Instance.MainPlayer;
|
|
if (_MainPlayer != null)
|
|
{
|
|
_Prefession = _MainPlayer.Profession;
|
|
}
|
|
else
|
|
{
|
|
_Prefession = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Profession;
|
|
}
|
|
|
|
EquipEnhanceHecheng.SetDefaultSelected(COMMON_MAGIC_DATA_ID[_Prefession]);
|
|
UIManager.ShowUI(UIInfo.EquipEnhance, (obj, sucess) =>
|
|
{
|
|
EquipEnhanceRoot.Instance().TryOpen(4);
|
|
});
|
|
}
|
|
|
|
public void UpdateRedPoint()
|
|
{
|
|
if(HasRedPoint())
|
|
{
|
|
MagicMain.Instance.SetRedPoint(true);
|
|
}
|
|
else
|
|
{
|
|
MagicMain.Instance.SetRedPoint(false);
|
|
}
|
|
}
|
|
|
|
public static bool HasRedPoint()
|
|
{
|
|
// 已装备法宝
|
|
GameItemContainer magicContainer = GameManager.gameManager.PlayerDataPool.GetItemContainer(GameItemContainer.Type.TYPE_MAGICPACK);
|
|
if(magicContainer == null)
|
|
{
|
|
LogModule.ErrorLog("Can't get magic pack container, therefore can't update red point !!!");
|
|
return false;
|
|
}
|
|
|
|
// 背包中的法宝
|
|
List<GameItem> gameItems = GameManager.gameManager.PlayerDataPool.BackPack.GetList();
|
|
int Count = gameItems.Count;
|
|
List<GameItem> magicItems = new List<GameItem>();
|
|
for (int i = 0; i < Count; i++)
|
|
{
|
|
if (gameItems[i].IsMagicMent())
|
|
{
|
|
GameItem gameItem = gameItems[i];
|
|
magicItems.Add(gameItem);
|
|
}
|
|
}
|
|
|
|
for(int i = 0; i < magicItems.Count; ++i)
|
|
{
|
|
GameItem equipMagic = magicContainer.GetItem(magicItems[i].GetSubClass() - 1);
|
|
|
|
// 最大最小穿戴等级判定
|
|
int nPlayerLevel = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level;
|
|
Tab_CommonItem commonItem = TableManager.GetCommonItemByID(magicItems[i].DataID, 0);
|
|
if (commonItem.MinLevelRequire > nPlayerLevel
|
|
|| commonItem.MaxLevelRequire < nPlayerLevel)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
// 法宝专属职业判定
|
|
int proLimit = commonItem.ProfessionRequire;
|
|
if (((proLimit >> GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Profession) & 1) == 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (magicItems[i].CombatValue > equipMagic.CombatValue)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
} |