//--------------------------------------------------------
|
// [Author]: 玩个游戏
|
// [ Date ]: Tuesday, March 12, 2019
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using UnityEngine.UI;
|
using System.Collections.Generic;
|
using System.Linq;
|
using LitJson;
|
|
public class ItemTipUtility
|
{
|
public enum TipType
|
{
|
Item,
|
Equip,
|
PetMount,
|
BoxItem, //宝箱随机物品
|
BoxChooseItem, //宝箱自选物品
|
TreasurePavilion, //古宝物品(碎片)
|
Hero, //武将
|
Mingge, //命格
|
}
|
|
public class TipData
|
{
|
public string guid;
|
public int itemId;
|
public int appointID;
|
public int goodId;
|
public int exchangeItemId; //部分界面要动态变化物品的情况
|
|
public BaseInfo baseInfo;
|
public BaseProperty baseProperty;
|
public SkillInfo skillInfo;
|
public GetWay getWay;
|
public bool showAll;
|
}
|
|
public struct BaseInfo
|
{
|
public int itemId;
|
public int count;
|
public bool isAuction;
|
public bool isEquiped;
|
public bool isPreview;
|
|
public bool isOverdue;
|
public int auctionSurplusTime;
|
public int overdueSurplusTime;
|
public int levelLimit;
|
public int moneyLimit;
|
}
|
|
public struct BaseProperty
|
{
|
public List<Int2> baseProperties;
|
public int star;
|
public List<Int2> starProperties;
|
}
|
|
|
|
|
public struct SkillInfo
|
{
|
public List<int> skills;
|
}
|
|
|
public struct GetWay
|
{
|
public bool defaultUnfold;
|
public int itemId;
|
public List<int> ways;
|
}
|
|
public struct ItemViewInfo
|
{
|
public int itemId;
|
public bool compare;
|
public bool unfoldGetWay;
|
public bool isAuctionEquip;
|
public int appointID; //定制装备
|
}
|
|
|
|
public static TipData mainTipData { get; private set; } // 注意当递进点击打开多个tip界面会变更数据,不能依赖此值
|
public static TipData secondaryData { get; private set; }
|
|
public static void ShowMoneyTip(int moneyType, bool showGetWay = true)
|
{
|
if (GeneralDefine.MoneyDisplayModel.ContainsKey(moneyType))
|
{
|
Show(GeneralDefine.MoneyDisplayModel[moneyType], showGetWay);
|
}
|
else
|
{
|
SysNotifyMgr.Instance.ShowTip("LackMoney", moneyType);
|
// Debug.LogErrorFormat("配置MoneyDisplayModel 查无此货币:{0}", moneyType);
|
}
|
}
|
|
|
//showGetWay 是否获取途径界面
|
public static void Show(int itemId, bool showGetWay = false, int _appointID = 0)
|
{
|
if (!ItemConfig.HasKey(itemId))
|
{
|
Debug.LogErrorFormat("查无此物品:{0}", itemId);
|
return;
|
}
|
|
|
if (showGetWay)
|
{
|
//验证有没配置获取途径
|
if (ItemConfig.Get(itemId).GetWay.Length == 0)
|
{
|
showGetWay = false;
|
}
|
}
|
Show(new ItemViewInfo()
|
{
|
itemId = itemId,
|
unfoldGetWay = showGetWay,
|
appointID = _appointID
|
});
|
}
|
|
public static void Show(ItemViewInfo item)
|
{
|
var itemId = item.itemId;
|
if (!ItemConfig.HasKey(itemId))
|
{
|
Debug.LogErrorFormat("查无此物品:{0}", itemId);
|
return;
|
}
|
|
// secondaryData = null;
|
|
var config = ItemConfig.Get(itemId);
|
PrintItemBrief(itemId);
|
|
var tipType = GetTipType(itemId);
|
switch (tipType)
|
{
|
case TipType.Equip:
|
// 来源无法确定的,没有GUID的,1.定制 2.如奖励获得展示
|
mainTipData = new TipData()
|
{
|
itemId = itemId,
|
appointID = item.appointID,
|
};
|
|
// 装备默认会掉在掉落背包里
|
if (item.appointID == 0)
|
{
|
mainTipData.guid = PackManager.Instance.GetItemGUIDByID(itemId, true, PackType.DropItem);
|
}
|
|
break;
|
|
default:
|
mainTipData = CreateItemData(itemId);
|
break;
|
}
|
|
mainTipData.getWay.defaultUnfold = item.unfoldGetWay;
|
if (mainTipData.getWay.defaultUnfold)
|
{
|
UIManager.Instance.OpenWindow<ItemTipWayWin>(itemId);
|
return;
|
}
|
|
|
switch (tipType)
|
{
|
case TipType.Equip:
|
UIManager.Instance.OpenWindow<EquipTipWin>();
|
break;
|
|
// case TipType.PetMount:
|
// WindowCenter.Instance.Open<PetMountTipWin>();
|
// break;
|
case TipType.Hero:
|
FirstChargeManager.Instance.heroItemID = itemId;
|
UIManager.Instance.OpenWindow<FirstChargeHeroInfoWin>();
|
break;
|
case TipType.BoxItem:
|
UIManager.Instance.OpenWindow<BoxItemWin>();
|
break;
|
case TipType.BoxChooseItem:
|
UIManager.Instance.OpenWindow<ChooseItemsWin>();
|
break;
|
case TipType.TreasurePavilion:
|
GubaoManager.Instance.ShowTip(itemId, 0);
|
break;
|
default:
|
UIManager.Instance.OpenWindow<ItemTipWin>();
|
break;
|
}
|
}
|
|
// showAll 默认正常全部显示,命格点套装特殊不显示物品信息
|
public static void Show(string guid, bool _showAll = true)
|
{
|
var item = PackManager.Instance.GetItemByGuid(guid);
|
if (item == null)
|
{
|
return;
|
}
|
PrintItemBrief(item.itemId, item);
|
|
secondaryData = null;
|
var tipType = GetTipType(item.itemId);
|
switch (tipType)
|
{
|
case TipType.Equip:
|
var packType = item.packType;
|
switch (packType)
|
{
|
case PackType.Equip:
|
case PackType.DropItem:
|
mainTipData = new TipData() { guid = guid };
|
break;
|
default:
|
|
break;
|
}
|
break;
|
case TipType.Mingge:
|
mainTipData = new TipData()
|
{
|
guid = guid,
|
showAll = _showAll
|
};
|
break;
|
default:
|
mainTipData = CreateItemData(guid);
|
break;
|
}
|
|
switch (tipType)
|
{
|
case TipType.Equip:
|
UIManager.Instance.OpenWindow<EquipTipWin>();
|
break;
|
// case TipType.PetMount:
|
// WindowCenter.Instance.Open<PetMountTipWin>();
|
// break;
|
case TipType.BoxItem:
|
UIManager.Instance.OpenWindow<BoxItemWin>();
|
break;
|
case TipType.BoxChooseItem:
|
UIManager.Instance.OpenWindow<ChooseItemsWin>();
|
break;
|
case TipType.Mingge:
|
UIManager.Instance.OpenWindow<MinggeSmallTipWin>();
|
break;
|
default:
|
UIManager.Instance.OpenWindow<ItemTipWin>();
|
break;
|
}
|
|
}
|
|
|
|
static TipData CreateItemData(string guid)
|
{
|
var item = PackManager.Instance.GetItemByGuid(guid);
|
if (item == null)
|
{
|
return default(TipData);
|
}
|
|
return new TipData()
|
{
|
itemId = item.itemId,
|
guid = guid,
|
|
baseInfo = GetBaseInfo(guid),
|
baseProperty = GetBaseProperty(item.itemId),
|
};
|
}
|
|
static TipData CreateItemData(int itemId)
|
{
|
return new TipData()
|
{
|
itemId = itemId,
|
baseInfo = GetBaseInfo(itemId),
|
exchangeItemId = itemId,
|
|
};
|
}
|
|
|
private static BaseInfo GetBaseInfo(int itemId)
|
{
|
var config = ItemConfig.Get(itemId);
|
var money = 0;
|
if (config.Type == 81)
|
{
|
var chestConfig = ChestsConfig.Get(itemId);
|
money = chestConfig.OpenMoney;
|
}
|
|
var baseInfo = new BaseInfo()
|
{
|
itemId = itemId,
|
isAuction = false,
|
isEquiped = false,
|
isPreview = true,
|
auctionSurplusTime = 0,
|
levelLimit = config.UseLV,
|
moneyLimit = money,
|
};
|
|
return baseInfo;
|
}
|
|
private static BaseInfo GetBaseInfo(string guid)
|
{
|
var item = PackManager.Instance.GetItemByGuid(guid);
|
var isEquiped = false;// equipModel.GetEquip(new Int2(level, place)) == guid;
|
var money = 0;
|
|
var baseInfo = new BaseInfo()
|
{
|
itemId = item.itemId,
|
count = item.count,
|
isAuction = item.isAuction,
|
isEquiped = isEquiped,
|
isPreview = false,
|
isOverdue = ItemLogicUtility.Instance.IsOverdue(guid),
|
auctionSurplusTime = item.isAuction ? item.auctionSurplusTime : 0,
|
overdueSurplusTime = item.overdueSurplusTime,
|
levelLimit = item.isAuction ? 0 : item.config.UseLV,
|
moneyLimit = money,
|
};
|
|
return baseInfo;
|
}
|
|
private static BaseProperty GetBaseProperty(int itemId)
|
{
|
var baseProperties = new List<Int2>();
|
var config = ItemConfig.Get(itemId);
|
|
if (config.Effect1 == 220)
|
{
|
return GetBaseProperty(config.EffectValueA1);
|
}
|
|
|
if (config.Effect2 != 0)
|
{
|
baseProperties.Add(new Int2(config.Effect2, config.EffectValueA2));
|
}
|
|
if (config.Effect3 != 0)
|
{
|
baseProperties.Add(new Int2(config.Effect3, config.EffectValueA3));
|
}
|
|
if (config.Effect4 != 0)
|
{
|
baseProperties.Add(new Int2(config.Effect4, config.EffectValueA4));
|
}
|
|
if (config.Effect5 != 0)
|
{
|
baseProperties.Add(new Int2(config.Effect5, config.EffectValueA5));
|
}
|
|
var baseProperty = new BaseProperty()
|
{
|
baseProperties = baseProperties,
|
};
|
|
return baseProperty;
|
}
|
|
private static BaseProperty GetBaseProperty(string guid)
|
{
|
var item = PackManager.Instance.GetItemByGuid(guid);
|
var equipPosition = new Int2(item.config.LV, item.config.EquipPlace);
|
var equiped = true;//equipModel.GetEquip(equipPosition) == guid;
|
|
var baseProperty = GetBaseProperty(item.itemId);
|
|
if (equiped)
|
{
|
var starProperties = new List<Int2>();
|
baseProperty.starProperties = starProperties;
|
}
|
|
return baseProperty;
|
}
|
|
private static TipType GetTipType(int itemId)
|
{
|
var boxType = ChestsAwardConfig.GetBoxType(itemId);
|
if (boxType == 1)
|
{
|
return TipType.BoxItem;
|
}
|
else if (boxType == 2)
|
{
|
return TipType.BoxChooseItem;
|
}
|
|
|
var config = ItemConfig.Get(itemId);
|
switch (config.Type)
|
{
|
case 101:
|
case 102:
|
case 103:
|
case 104:
|
case 105:
|
case 106:
|
case 107:
|
case 108:
|
case 109:
|
case 110:
|
case 111:
|
case 112:
|
return TipType.Equip;
|
case 147:
|
return TipType.TreasurePavilion;
|
case 150:
|
return TipType.Hero;
|
case 201:
|
case 202:
|
case 203:
|
case 204:
|
case 205:
|
case 206:
|
case 207:
|
case 208:
|
case 209:
|
case 210:
|
case 211:
|
case 212:
|
return TipType.Mingge;
|
default:
|
return TipType.Item;
|
}
|
|
|
}
|
|
|
|
|
|
[System.Diagnostics.Conditional("UNITY_EDITOR")]
|
private static void PrintItemBrief(int itemId)
|
{
|
var config = ItemConfig.Get(itemId);
|
Debug.LogFormat("查看物品:itemId->{0} ;name->{1}", itemId, config.ItemName);
|
}
|
|
[System.Diagnostics.Conditional("UNITY_EDITOR")]
|
private static void PrintItemBrief(int itemId, ItemModel item)
|
{
|
var config = ItemConfig.Get(itemId);
|
Debug.LogFormat("查看物品:itemId->{0};name->{1};服务端索引->{3};guid->{2}",
|
itemId, config.ItemName, item.guid, item.gridIndex);
|
}
|
|
}
|