450 lines
14 KiB
C#
450 lines
14 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using Games.Item;
|
||
using Module.Log;
|
||
using UnityEngine.UI;
|
||
using GCGame.Table;
|
||
|
||
// 装备狂化
|
||
//5811 按钮下提醒
|
||
//5801 装备狂化前缀
|
||
//5803 字体颜色-品质狂化
|
||
//5804 道具提示字体颜色-品质狂化稀有
|
||
//5805 字体颜色-品质狂化稀有
|
||
//5806 无可狂化装备提示
|
||
//5807 强化百分比提升后缀(强化)
|
||
//5808 狂化百分比提升后缀(狂化)
|
||
//5809 装备属性强化加成百分比(非Tips)
|
||
//5416 无装备左侧
|
||
//5417 tip中狂化提升颜色
|
||
//5418 非tip中狂化提升颜色
|
||
public class EquipFrenzy : MonoBehaviour {
|
||
|
||
public static int EquipFrenzyEffectID = 8001;
|
||
private static bool hasAnyFrenzy = false;
|
||
public static bool HasAnyFrenzy
|
||
{
|
||
private set { hasAnyFrenzy = value; }
|
||
get { return hasAnyFrenzy; }
|
||
}
|
||
|
||
private static EquipFrenzy instance;
|
||
public static EquipFrenzy Instance
|
||
{
|
||
get { return instance; }
|
||
}
|
||
|
||
public EquipEnhanceRoot _EquipEnhanceRoot;
|
||
public CommonItemMaterialSlot frenzyMat;
|
||
public GameItem _SelectedEquip;
|
||
public FrenzyInfoItem normalItem;
|
||
public FrenzyInfoItem afterItem;
|
||
public GameObject frenzyPanel;
|
||
public GameObject hasFrenzyPanel;
|
||
public Text hasFrenzyTip;
|
||
public Button frenzyBtn;
|
||
public Text noneEquipTip;
|
||
public Text btnTip;
|
||
public Image[] arrows;
|
||
public Sprite blueSprite;
|
||
public Sprite yellowSprite;
|
||
public Button tipBtn;
|
||
public GameObject redTip;
|
||
public Text _CantCrazyTip;
|
||
|
||
private void Awake()
|
||
{
|
||
if(instance == null)
|
||
{
|
||
instance = this;
|
||
frenzyBtn.onClick.AddListener(OnFrenzyClick);
|
||
btnTip.text = StrDictionary.GetClientDictionaryString("#{5811}");
|
||
noneEquipTip.text = StrDictionary.GetClientDictionaryString("#{5806}");
|
||
hasFrenzyTip.text = StrDictionary.GetClientDictionaryString("#{5416}");
|
||
tipBtn.onClick.AddListener(() => { MessageHelpLogic.ShowHelpMessage(50); });
|
||
}
|
||
}
|
||
|
||
private void OnDestroy()
|
||
{
|
||
instance = null;
|
||
}
|
||
|
||
private void UpdateRedTip()
|
||
{
|
||
redTip.SetActive(HasAnyFrenzy);
|
||
}
|
||
|
||
private void OnEnable()
|
||
{
|
||
//UpdateRedTip();
|
||
ShowArrows(false);
|
||
var lastSelects = _EquipEnhanceRoot._EquipContainer.GetSelecteds<GameItem>();
|
||
|
||
// 每次开始显示,激活装备容器
|
||
_EquipEnhanceRoot._EquipContainer.gameObject.SetActive(true);
|
||
// 初始化装备列表
|
||
_EquipEnhanceRoot.InitAllEquipList();
|
||
|
||
_EquipEnhanceRoot._EquipContainer._IsMultiSelect = false;
|
||
|
||
if (_EquipEnhanceRoot._AllEquipList.Count == 0)
|
||
{
|
||
_EquipEnhanceRoot._EquipContainer.InitSelectContent(_EquipEnhanceRoot._AllEquipList, null);
|
||
|
||
noneEquipTip.gameObject.SetActive(true);
|
||
normalItem.ShowNothing();
|
||
afterItem.ShowNothing();
|
||
frenzyPanel.SetActive(false);
|
||
hasFrenzyPanel.SetActive(false);
|
||
|
||
return;
|
||
}
|
||
|
||
int minLv = GetMinLvRequired();
|
||
// 目标装备为 橙装
|
||
List<GameItem> targetEquip;
|
||
targetEquip = _EquipEnhanceRoot._AllEquipList;
|
||
//targetEquip = _EquipEnhanceRoot._AllEquipList.FindAll((equipItem) =>
|
||
//{
|
||
// if (equipItem.GetQuality() >= ItemQuality.QUALITY_PINK && equipItem.GetMinLevelRequire() >= minLv)
|
||
// {
|
||
// return true;
|
||
// }
|
||
|
||
// return false;
|
||
//});
|
||
|
||
if (targetEquip.Count <= 0)
|
||
{
|
||
_EquipEnhanceRoot._EquipContainer.gameObject.SetActive(false);
|
||
noneEquipTip.gameObject.SetActive(true);
|
||
normalItem.ShowNothing();
|
||
afterItem.ShowNothing();
|
||
frenzyPanel.SetActive(false);
|
||
hasFrenzyPanel.SetActive(false);
|
||
}
|
||
else
|
||
{
|
||
noneEquipTip.gameObject.SetActive(false);
|
||
List<GameItem> defaultSelect = new List<GameItem>();
|
||
if (EquipEnhanceRoot._DefaultSelectedItem != null
|
||
&& EquipEnhanceRoot._DefaultSelectedPage == 1)
|
||
{
|
||
defaultSelect.Add(EquipEnhanceRoot._DefaultSelectedItem);
|
||
EquipEnhanceRoot._DefaultSelectedPage = -1;
|
||
EquipEnhanceRoot._DefaultSelectedItem = null;
|
||
}
|
||
else if (lastSelects.Count > 0)
|
||
{
|
||
for (int i = 0; i < lastSelects.Count; ++i)
|
||
{
|
||
if (targetEquip.Contains(lastSelects[i]))
|
||
{
|
||
defaultSelect.Add(lastSelects[i]);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
if(defaultSelect.Count <= 0)
|
||
{
|
||
defaultSelect.Add(targetEquip[0]);
|
||
}
|
||
|
||
Hashtable hash = new Hashtable();
|
||
hash.Add("KuanghuaTips", true);
|
||
|
||
_EquipEnhanceRoot._EquipContainer.InitSelectContent(targetEquip, defaultSelect, OnSelectEquip, null, hash);
|
||
}
|
||
}
|
||
|
||
private int GetMinLvRequired()
|
||
{
|
||
int result = int.MaxValue;
|
||
var tabs = TableManager.GetEquipFrenzy().Values;
|
||
foreach(var item in tabs)
|
||
{
|
||
if (result > item.EquipLevelMin)
|
||
{
|
||
result = item.EquipLevelMin;
|
||
}
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
public void OnEquipUpdate()
|
||
{
|
||
if(EquipFrenzy.instance.gameObject.activeInHierarchy)
|
||
{
|
||
_EquipEnhanceRoot._EquipContainer.ForeachActiveItem<EquipEnhanceItem>(
|
||
(EquipEnhanceItem item) =>
|
||
{
|
||
if(item._EquipItem.Guid == _SelectedEquip.Guid)
|
||
{
|
||
item.RefreshEqupItem();
|
||
}
|
||
});
|
||
OnSelectEquip(_SelectedEquip);
|
||
}
|
||
}
|
||
|
||
private void ShowArrows(bool isShow)
|
||
{
|
||
if(isShow)
|
||
{
|
||
Tab_EquipAttr tabItem = TableManager.GetEquipAttrByID(_SelectedEquip.DataID, 0);
|
||
for(int i = 0; i < arrows.Length; ++i)
|
||
{
|
||
if (_SelectedEquip.BaseAttrs.Count <= i)
|
||
{
|
||
arrows[i].gameObject.SetActive(false);
|
||
continue;
|
||
}
|
||
else
|
||
{
|
||
arrows[i].gameObject.SetActive(true);
|
||
if (tabItem.GetIsEnchanceAddbyIndex(i) > 0)
|
||
{
|
||
arrows[i].sprite = yellowSprite;
|
||
}
|
||
else
|
||
{
|
||
arrows[i].sprite = blueSprite;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
foreach (Image i in arrows)
|
||
{
|
||
i.gameObject.SetActive(false);
|
||
}
|
||
}
|
||
}
|
||
|
||
private void OnSelectEquip(object item)
|
||
{
|
||
GameItem tempSelect = item as GameItem;
|
||
if(tempSelect == null)
|
||
{
|
||
LogModule.WarningLog("Wrong select type in equip frenzy");
|
||
normalItem.ShowNothing();
|
||
afterItem.ShowNothing();
|
||
frenzyPanel.SetActive(false);
|
||
hasFrenzyPanel.SetActive(false);
|
||
}
|
||
else
|
||
{
|
||
_SelectedEquip = tempSelect;
|
||
Tab_CommonItem itemTab = TableManager.GetCommonItemByID(_SelectedEquip.DataID, 0);
|
||
var tab = TableManager.GetEquipFrenzy().Values;
|
||
bool hasFound = false;
|
||
foreach(var kv in tab)
|
||
{
|
||
if ((int)_SelectedEquip.GetQuality() == kv.Quality
|
||
&& itemTab.MinLevelRequire >= kv.EquipLevelMin
|
||
&& itemTab.MinLevelRequire <= kv.EquipLevelMax)
|
||
{
|
||
hasFound = true;
|
||
frenzyMat.InitMaterial(kv.FrenzyConsumeSubType, kv.FrenzyConsumeNum);
|
||
break;
|
||
}
|
||
}
|
||
|
||
frenzyMat.gameObject.SetActive(hasFound);
|
||
|
||
ShowArrows(true);
|
||
|
||
GameItem equipItem = SimulationAttr(_SelectedEquip);
|
||
if (_SelectedEquip.IsFrenzy)
|
||
{
|
||
normalItem.Show(equipItem, hasFound);
|
||
afterItem.Show(_SelectedEquip, hasFound);
|
||
|
||
frenzyPanel.SetActive(false);
|
||
hasFrenzyPanel.SetActive(true);
|
||
}
|
||
else
|
||
{
|
||
normalItem.Show(_SelectedEquip, hasFound);
|
||
afterItem.Show(equipItem, hasFound);
|
||
|
||
frenzyPanel.SetActive(true);
|
||
hasFrenzyPanel.SetActive(false);
|
||
}
|
||
|
||
if (hasFound)
|
||
{
|
||
_CantCrazyTip.text = "";
|
||
}
|
||
else
|
||
{
|
||
GUIData.AddNotifyData("#{5811}");
|
||
_CantCrazyTip.text = StrDictionary.GetClientDictionaryString("#{5811}");
|
||
}
|
||
}
|
||
}
|
||
|
||
// 虚拟狂化前或者狂化后的属性
|
||
// affect 影响结果 -1 求当前装备狂化前;1 求装备狂化后
|
||
private GameItem SimulationAttr(GameItem equip)
|
||
{
|
||
GameItem resultEquip = (GameItem)equip.Clone();
|
||
resultEquip.IsFrenzy = !equip.IsFrenzy;
|
||
//float percentage = (equip.GetStrengthVal() + equip.GetFrenzyVal()) / 100.0f + 1.0f;
|
||
//float enhancePer = equip.GetStrengthVal() / 100.0f + 1.0f;
|
||
//if (!equip.IsFrenzy)
|
||
//{
|
||
// for (int i = 0; i < resultEquip.BaseAttrs.Count; ++i)
|
||
// {
|
||
// float baseValue = resultEquip.BaseAttrs[i]._Value1 / enhancePer;
|
||
// resultEquip.BaseAttrs[i]._Value1 = (int)(baseValue * percentage);
|
||
// }
|
||
//}
|
||
//else
|
||
//{
|
||
// for (int i = 0; i < resultEquip.BaseAttrs.Count; ++i)
|
||
// {
|
||
// float baseValue = resultEquip.BaseAttrs[i]._Value1 / percentage;
|
||
// resultEquip.BaseAttrs[i]._Value1 = (int)(baseValue * enhancePer);
|
||
// }
|
||
//}
|
||
|
||
resultEquip.EnchanceScore = CombatValue.CalculateEquipSingle(resultEquip);
|
||
resultEquip.BaseCombat = CombatValue.CalculateBaseAttr(resultEquip);
|
||
resultEquip.BaseCombat += CombatValue.CalculateXilian(resultEquip.ExAttrs, resultEquip.DataID);
|
||
resultEquip.BaseCombat += CombatValue.CalculateGemOpen(resultEquip);
|
||
|
||
if (resultEquip.IsFrenzy)
|
||
{
|
||
//Debug.LogError(equip._NormalGemSuit+"...........宝石全部等级");
|
||
|
||
int combat = 0;
|
||
if (equip._GemSuit1 > 0)
|
||
{
|
||
|
||
var normalSuitTab = TableManager.GetGemSuitByID(equip._GemSuit1);
|
||
combat += normalSuitTab.CombatValue;
|
||
}
|
||
|
||
if (equip._GemSuit2 > 0)
|
||
{
|
||
var eliteSuitTab = TableManager.GetGemSuitByID(equip._GemSuit2);
|
||
combat += eliteSuitTab.CombatValue;
|
||
}
|
||
|
||
if (equip._GemSuit3 > 0)
|
||
{
|
||
var eliteSuitTab = TableManager.GetGemSuitByID(equip._GemSuit3);
|
||
combat += eliteSuitTab.CombatValue;
|
||
}
|
||
resultEquip.EnchanceScore += combat;
|
||
//Debug.LogError(combat + "...........石之灵战力值");
|
||
}
|
||
|
||
return resultEquip;
|
||
}
|
||
|
||
private void OnFrenzyClick()
|
||
{
|
||
if (!string.IsNullOrEmpty(_CantCrazyTip.text))
|
||
{
|
||
GUIData.AddNotifyData("#{5811}");
|
||
return;
|
||
}
|
||
if(!_SelectedEquip.IsFrenzy)
|
||
{
|
||
ReqEquipFrenzy req = new ReqEquipFrenzy();
|
||
if (_SelectedEquip.IsPlayerEquiped())
|
||
{
|
||
req.packtype = (int)GameItemContainer.Type.TYPE_EQUIPPACK;
|
||
}
|
||
else
|
||
{
|
||
req.packtype = (int)GameItemContainer.Type.TYPE_BACKPACK;
|
||
}
|
||
req.equipguid = (long)_SelectedEquip.Guid;
|
||
|
||
req.SendMsg();
|
||
}
|
||
}
|
||
|
||
#region 红点相关
|
||
|
||
public static void CheckAnyFrenzy()
|
||
{
|
||
HasAnyFrenzy = false;
|
||
|
||
Tab_FunctionOpen tab = TableManager.GetFunctionOpenByID(16, 0);
|
||
if (tab == null || GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level < tab.OpenLevel)
|
||
{
|
||
return;
|
||
}
|
||
|
||
List<int> equipLvs = new List<int>();
|
||
int tempLv = 0;
|
||
|
||
var equipList = GameManager.gameManager.PlayerDataPool.EquipPack.GetList();
|
||
foreach (var equipItem in equipList)
|
||
{
|
||
tempLv = equipItem.GetMinLevelRequire();
|
||
if (equipItem.IsValid() && EquipEnhanceRoot.CanEquipFrenzy(equipItem) && !equipItem.IsFrenzy)
|
||
{
|
||
if (equipLvs.Contains(tempLv) == false)
|
||
{
|
||
equipLvs.Add(tempLv);
|
||
}
|
||
}
|
||
}
|
||
|
||
//var backPackItems = GameManager.gameManager.PlayerDataPool.BackPack.GetList();
|
||
//foreach (var backPackItem in backPackItems)
|
||
//{
|
||
// tempLv = backPackItem.GetMinLevelRequire();
|
||
// if (backPackItem.IsValid() && backPackItem.IsEquipMent()
|
||
// && backPackItem.GetQuality() >= ItemQuality.QUALITY_PINK
|
||
// && tempLv >= 60
|
||
// && !backPackItem.IsFrenzy)
|
||
// {
|
||
// if (equipLvs.Contains(tempLv) == false)
|
||
// {
|
||
// equipLvs.Add(tempLv);
|
||
// }
|
||
// }
|
||
//}
|
||
|
||
var tabs = TableManager.GetEquipFrenzy().Values;
|
||
HasAnyFrenzy = false;
|
||
foreach (var equipLv in equipLvs)
|
||
{
|
||
if (HasAnyFrenzy == true)
|
||
{
|
||
break;
|
||
}
|
||
|
||
foreach (var kv in tabs)
|
||
{
|
||
if (equipLv >= kv.EquipLevelMin && equipLv <= kv.EquipLevelMax)
|
||
{
|
||
if (GameManager.gameManager.PlayerDataPool.BackPack.GetItemCountByDataId(kv.FrenzyConsumeSubType) >= kv.FrenzyConsumeNum)
|
||
{
|
||
HasAnyFrenzy = true;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if (ExtraFunTipRoot.Instance() != null)
|
||
{
|
||
ExtraFunTipRoot.Instance().UpdateFrenzy();
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
}
|