213 lines
6.8 KiB
C#
213 lines
6.8 KiB
C#
|
using UnityEngine;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine.UI;
|
|||
|
using GCGame.Table;
|
|||
|
using Games.Item;
|
|||
|
|
|||
|
public class OtherPlayerMagicWeaponInfo : MonoBehaviour {
|
|||
|
|
|||
|
public UICameraTexture modelTexture; // 模型展示的RenderTexture
|
|||
|
public Text tipText; // 提示信息
|
|||
|
public Image[] weaponMagics; // 已装备的法宝 Image 数组
|
|||
|
public Image[] weaponMagicsBg;
|
|||
|
public Text Name; // 当前显示的法宝名称
|
|||
|
public Button leftBtn; // 左按钮
|
|||
|
public Button rightBtn; // 右按钮
|
|||
|
public Sprite noneMagicBg;
|
|||
|
|
|||
|
public static OtherPlayerMagicWeaponInfo Instance;
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
Instance = this;
|
|||
|
|
|||
|
// 翻页按钮事件监听
|
|||
|
leftBtn.onClick.AddListener(Click_LastModel);
|
|||
|
rightBtn.onClick.AddListener(Click_NextModel);
|
|||
|
}
|
|||
|
|
|||
|
private void OnDestroy()
|
|||
|
{
|
|||
|
Instance = null;
|
|||
|
}
|
|||
|
|
|||
|
// 初始化法宝界面
|
|||
|
public void InitMagicWeaponPanelInfo()
|
|||
|
{
|
|||
|
// 初始化法宝装备信息
|
|||
|
InitWeaponMagicInfo();
|
|||
|
|
|||
|
// 初始化法宝模型
|
|||
|
if (GameManager.gameManager.OtherPlayerData != null)
|
|||
|
{
|
|||
|
Tab_MagicWeaponActiveModel magicModel = TableManager.GetMagicWeaponActiveModelByID(GameManager.gameManager.OtherPlayerData.CurDressedMagicWeaponIndex, 0);
|
|||
|
if (magicModel != null)
|
|||
|
{
|
|||
|
InitModel(magicModel.ShowModel);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
int model = GetMagicModelNext(-1);
|
|||
|
InitModel(model);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// 获得法宝表格中,上一个法宝的索引
|
|||
|
int GetMagicModelLast(int id)
|
|||
|
{
|
|||
|
var magicModels = TableManager.GetMagicWeaponActiveModel().Keys;
|
|||
|
int result = -1;
|
|||
|
foreach (var key in magicModels)
|
|||
|
{
|
|||
|
if (key == id)
|
|||
|
return result;
|
|||
|
result = key;
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
// 获得法宝表格中,下一个法宝的索引
|
|||
|
int GetMagicModelNext(int id)
|
|||
|
{
|
|||
|
var magicModels = TableManager.GetMagicWeaponActiveModel().Keys;
|
|||
|
int? result = null;
|
|||
|
var valid = false;
|
|||
|
foreach (var key in magicModels)
|
|||
|
{
|
|||
|
if (result == null)
|
|||
|
result = key;
|
|||
|
if (valid)
|
|||
|
{
|
|||
|
result = key;
|
|||
|
break;
|
|||
|
}
|
|||
|
else if (key == id)
|
|||
|
valid = true;
|
|||
|
}
|
|||
|
if (result == null)
|
|||
|
result = -1;
|
|||
|
return result.Value;
|
|||
|
}
|
|||
|
|
|||
|
// 显示装备槽的装备情况
|
|||
|
void InitWeaponMagicInfo()
|
|||
|
{
|
|||
|
if (GameManager.gameManager.PlayerDataPool == null)
|
|||
|
return;
|
|||
|
GameItemContainer Container = GameManager.gameManager.OtherPlayerData.MagicPack;
|
|||
|
if (Container == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
for (int i = 0; i < weaponMagics.Length; i++)
|
|||
|
{
|
|||
|
weaponMagics[i].gameObject.SetActive(false);
|
|||
|
weaponMagicsBg[i].sprite = noneMagicBg;
|
|||
|
}
|
|||
|
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);
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(weaponMagicsBg[line.SubClassID - 1], GCGame.Utils.GetItemQualityFrame(line.Quality));
|
|||
|
if (line.QualityEffect > 0)
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(true, line.QualityEffect, weaponMagics[line.SubClassID - 1].transform);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(false, line.QualityEffect, weaponMagics[line.SubClassID - 1].transform);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// 点发法宝回调
|
|||
|
public void Click_WeaponMagic(int index)
|
|||
|
{
|
|||
|
GameItemContainer Container = GameManager.gameManager.OtherPlayerData.MagicPack;
|
|||
|
if (Container == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
GameItem tempItem;
|
|||
|
for (int i = 0; i < Container.ContainerSize; ++i)
|
|||
|
{
|
|||
|
tempItem = Container.GetItem(i);
|
|||
|
if (tempItem.DataID == -1)
|
|||
|
{
|
|||
|
continue;
|
|||
|
}
|
|||
|
|
|||
|
Tab_CommonItem line = TableManager.GetCommonItemByID(tempItem.DataID, 0);
|
|||
|
if(line.SubClassID - 1== index)
|
|||
|
{
|
|||
|
MagicTooltipLogic.ShowEquipTooltip(tempItem, ItemTooltipsLogic.ShowType.Info);
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// 当前被选中的法宝ID
|
|||
|
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 (GameManager.gameManager.OtherPlayerData.IsMagicModelActive(modelID) == true)
|
|||
|
tipText.text = string.Format("<color=#00ff00ff>{0}</color>", StrDictionary.GetClientDictionaryString("#{41015}"));
|
|||
|
else
|
|||
|
{
|
|||
|
tipText.text = StrDictionary.GetClientDictionaryString("#{41016}", magicModel.Color, GetColorItemCount(magicModel.Color), magicModel.Num);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// 配合提示使用
|
|||
|
// 获取装备中品质大于 color 的法宝数目
|
|||
|
public int GetColorItemCount(int color)
|
|||
|
{
|
|||
|
int count = 0;
|
|||
|
List<GameItem> gameItems = GameManager.gameManager.PlayerDataPool.MagicPack.GetList();
|
|||
|
for (int i = 0; i < gameItems.Count; i++)
|
|||
|
{
|
|||
|
if ((int)(gameItems[i].GetQuality()) >= color)
|
|||
|
count++;
|
|||
|
}
|
|||
|
return count;
|
|||
|
}
|
|||
|
|
|||
|
public void Click_LastModel()
|
|||
|
{
|
|||
|
int modelId = GetMagicModelLast(selectModelId);
|
|||
|
InitModel(modelId);
|
|||
|
}
|
|||
|
|
|||
|
public void Click_NextModel()
|
|||
|
{
|
|||
|
int modelId = GetMagicModelNext(selectModelId);
|
|||
|
InitModel(modelId);
|
|||
|
}
|
|||
|
}
|