//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Monday, November 20, 2017
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using UnityEngine.UI;
|
using System;
|
using System.Collections.Generic;
|
|
using Snxxz.UI;
|
//翅膀精炼红点
|
namespace Snxxz.UI
|
{
|
|
[XLua.LuaCallCSharp]
|
public class WingsRedDot : Model, IPlayerLoginOk, IBeforePlayerDataInitialize
|
{
|
private const int Redpoint_key = 10603;
|
public Redpoint redPointStre = new Redpoint(MainRedDot.RedPoint_key1, Redpoint_key);
|
private int WingNumber = 0;//翅膀数量标记
|
private int Marking = 0;
|
private bool IsOnePutOn = true;
|
public bool IsBoolOpenWingeWin = false;
|
PlayerPackModel _playerPack;
|
PlayerPackModel playerPack
|
{
|
get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PlayerPackModel>()); }
|
}
|
|
public override void Init()
|
{
|
|
}
|
public void OnPlayerLoginOk()
|
{
|
|
playerPack.ItemCntAddAct += ItemCntAddAct;//物品数量增加
|
playerPack.ItemCntReduceAct += ItemCntReduceAct;//物品数量减少
|
FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChange;
|
ItemModel itemModel = playerPack.GetItemModelByIndex(PackType.rptEquip, (int)RoleEquipType.retWing);
|
if (IsOnePutOn)
|
{
|
WingsDot();
|
}
|
if (itemModel != null)
|
{
|
IsOnePutOn = false;
|
}
|
|
}
|
public void OnBeforePlayerDataInitialize()
|
{
|
playerPack.ItemCntAddAct -= ItemCntAddAct;//物品数量增加
|
FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChange;
|
playerPack.ItemCntReduceAct -= ItemCntReduceAct;//物品数量减少
|
}
|
|
|
|
public override void UnInit()
|
{
|
|
}
|
|
|
|
private void OnFuncStateChange(int obj)
|
{
|
if (obj == 90)
|
{
|
WingsDot();
|
}
|
}
|
|
public class WingsInformation
|
{
|
public int WingsID;
|
public int WingsCount;
|
}
|
private Dictionary<int, WingsInformation> _dicWings = new Dictionary<int, WingsInformation>();
|
private List<WingRefineAttrConfig> WingRefineAttr = new List<WingRefineAttrConfig>();
|
public void WingsDot()
|
{
|
redPointStre.state = RedPointState.None;
|
ItemModel itemModel = playerPack.GetItemModelByIndex(PackType.rptEquip, (int)RoleEquipType.retWing);
|
|
if (itemModel == null || !FuncOpen.Instance.IsFuncOpen(90))
|
{
|
WingNumber = 0;
|
Marking = 0;
|
return;
|
}
|
var WingItemA = WingRefineExpConfig.Get(itemModel.itemInfo.ItemID);
|
if (WingItemA == null)
|
{
|
WingNumber = 0;
|
Marking = 0;
|
return;
|
}
|
SinglePackModel singlePackModel = playerPack.GetSinglePackModel(PackType.rptItem);
|
Dictionary<int, ItemModel> backpack_dic = singlePackModel.GetPackModelIndexDict();
|
|
List<int> wingsRefinelist = itemModel.GetUseDataModel((int)ItemUseDataKey.Def_IudetWingProgressValue);
|
if (wingsRefinelist != null)
|
{
|
var config = WingRefineExpConfig.Get((int)itemModel.itemInfo.ItemID);
|
int WingsPhase = config.WingsPhase;//获取翅膀阶数
|
if (WingRefineAttr.Count <= 0)
|
{
|
WingRefineAttr = Config.Instance.GetAllValues<WingRefineAttrConfig>();
|
}
|
//var WingRefineAttr = Config.Instance.GetAllValues<WingRefineAttrConfig>();
|
int Max = 0;
|
foreach (var value in WingRefineAttr)
|
{
|
if (value.wingsPhase == WingsPhase)
|
{
|
Max = value.EXPupper;//最大精炼度
|
}
|
}
|
int Now = wingsRefinelist[0];
|
if (Now >= Max)
|
{
|
WingNumber = 0;
|
Marking = 0;
|
return;
|
}
|
}
|
_dicWings.Clear();
|
foreach (int index in backpack_dic.Keys)
|
{
|
var WingItem = WingRefineExpConfig.Get((int)backpack_dic[index].itemInfo.ItemID);
|
if (ItemConfig.tag_Wings.ContainsKey((int)backpack_dic[index].itemInfo.ItemID) && WingItem != null)
|
{
|
WingsInformation _WingsInformation = new WingsInformation();
|
_WingsInformation.WingsID = (int)backpack_dic[index].itemInfo.ItemID;
|
_WingsInformation.WingsCount = (int)backpack_dic[index].itemInfo.ItemCount;
|
_dicWings.Add(index, _WingsInformation);
|
}
|
}
|
var config1 = WingRefineExpConfig.Get((int)itemModel.itemInfo.ItemID);
|
foreach (var key in _dicWings.Keys)
|
{
|
var wings = ItemConfig.Get(_dicWings[key].WingsID);
|
if (wings.EndureReduceType != 0)
|
{
|
return;
|
}
|
var config2 = WingRefineExpConfig.Get(_dicWings[key].WingsID);
|
if (config1.WingsPhase >= config2.WingsPhase)
|
{
|
WingNumber += playerPack.GetItemCountByID(PackType.rptItem, _dicWings[key].WingsID);
|
}
|
}
|
if (IsBoolOpenWingeWin)
|
{
|
return;
|
}
|
if (WingNumber > Marking && FuncOpen.Instance.IsFuncOpen(90))
|
{
|
Marking = WingNumber;
|
redPointStre.state = RedPointState.Simple;
|
return;
|
}
|
else
|
{
|
Marking = WingNumber;
|
}
|
}
|
private void ItemCntAddAct(PackType arg1, int ItemIndex, int ItemID)//物品数量增加
|
{
|
|
if (arg1 == PackType.rptItem)//物品背包物品增加
|
{
|
ItemBagAdd(ItemIndex, ItemID);
|
}
|
if (arg1 == PackType.rptEquip)//装备背包物品增加
|
{
|
ItemModel itemModel = playerPack.GetItemModelByIndex(PackType.rptEquip, (int)RoleEquipType.retWing);
|
if (IsOnePutOn)
|
{
|
WingsDot();
|
}
|
if (itemModel != null)
|
{
|
IsOnePutOn = false;
|
}
|
}
|
}
|
|
private void ItemBagAdd(int ItemIndex, int ItemID)//物品背包数量添加
|
{
|
ItemModel ItemModel = playerPack.GetItemModelByIndex(PackType.rptItem, ItemIndex);
|
int ItemCount = ItemModel.preItemCount;
|
var WingItem = WingRefineExpConfig.Get(ItemModel.itemId);
|
if (IsBoolOpenWingeWin || WingItem == null)
|
{
|
return;
|
}
|
if (_dicWings.ContainsKey(ItemIndex))
|
{
|
if (ItemCount > _dicWings[ItemIndex].WingsCount)
|
{
|
_dicWings[ItemIndex].WingsCount = ItemCount;
|
redPointStre.state = RedPointState.Simple;
|
}
|
else
|
{
|
_dicWings[ItemIndex].WingsCount = ItemCount;
|
}
|
}
|
}
|
private void ItemCntReduceAct(PackType arg1, int Index, int ItemID)
|
{
|
if (arg1 == PackType.rptItem)//物品背包物品减少
|
{
|
var WingItem = WingRefineExpConfig.Get(ItemID);
|
if (WingItem != null && _dicWings.ContainsKey(Index))
|
{
|
_dicWings.Remove(Index);
|
if (_dicWings.Count <= 0 && redPointStre.state == RedPointState.Simple)
|
{
|
redPointStre.state = RedPointState.None;
|
return;
|
}
|
}
|
}
|
if (arg1 == PackType.rptEquip)//装备脱下
|
{
|
ItemModel itemModel = playerPack.GetItemModelByIndex(PackType.rptEquip, (int)RoleEquipType.retWing);
|
if (itemModel == null && redPointStre.state == RedPointState.Simple)
|
{
|
redPointStre.state = RedPointState.None;
|
return;
|
}
|
}
|
}
|
}
|
}
|
|
|
|