|
using System.Text;
|
using System.Collections.Generic;
|
using LitJson;
|
using System;
|
using UnityEngine;
|
|
namespace vnxbqy.UI
|
{
|
|
public class TreasureEffectModel : Model, IBeforePlayerDataInitialize, IAfterPlayerDataInitialize, IPlayerLoginOk
|
{
|
public List<int> treasureAddAtklist { get; private set; }
|
public List<string> treasureIdlist { get; private set; }
|
public Dictionary<int, Dictionary<int, int>> treasureSignDict { get; private set; }
|
TreasureModel m_Model;
|
TreasureModel model {
|
get { return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<TreasureModel>()); }
|
}
|
|
SignInModel signInModel { get { return ModelCenter.Instance.GetModel<SignInModel>(); } }
|
|
public override void Init()
|
{
|
FuncConfigConfig addExp = FuncConfigConfig.Get("VIPAddAtkEXP");
|
int[] addExpIds = ConfigParse.GetMultipleStr<int>(addExp.Numerical2);
|
treasureAddAtklist = new List<int>();
|
for (int i = 0; i < addExpIds.Length; i++)
|
{
|
treasureAddAtklist.Add(addExpIds[i]);
|
}
|
|
FuncConfigConfig MWSignDayAttr = FuncConfigConfig.Get("MWSignDayAttr");
|
int treasureId = int.Parse(MWSignDayAttr.Numerical2);
|
JsonData signAttrData = JsonMapper.ToObject(MWSignDayAttr.Numerical1);
|
treasureSignDict = new Dictionary<int, Dictionary<int, int>>();
|
Dictionary<int, int> attrDict = new Dictionary<int, int>();
|
treasureSignDict.Add(treasureId, attrDict);
|
foreach (var id in signAttrData.Keys)
|
{
|
attrDict.Add(int.Parse(id), int.Parse(signAttrData[id].ToString()));
|
}
|
|
treasureIdlist = TreasureConfig.GetKeys();
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
treasureId = 0;
|
vipLv = 0;
|
showType = 0;
|
killNpcAtk = 0;
|
effectDesSB.Length = 0;
|
}
|
|
public void OnAfterPlayerDataInitialize()
|
{
|
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
|
}
|
|
public override void UnInit()
|
{
|
|
}
|
public bool CheckIsTreasure(int id)
|
{
|
if (treasureIdlist.Contains(id.ToString()))
|
{
|
return true;
|
}
|
|
return false;
|
}
|
|
public int treasureId { get; private set; }
|
public int vipLv { get; private set; }
|
public StringBuilder effectDesSB = new StringBuilder();
|
public int killNpcAtk { get; private set; }
|
public int showType;
|
|
public void SetTreasureID(int id, int vipLv = 0)
|
{
|
this.treasureId = id;
|
this.vipLv = vipLv;
|
SetTreasureEffectDes(out showType);
|
if (!WindowCenter.Instance.IsOpen<TreasureEffectWin>())
|
{
|
WindowCenter.Instance.Open<TreasureEffectWin>();
|
}
|
}
|
|
/// <summary>
|
/// type 1 Vip杀怪等级 2 每日签到 3 获得经验
|
/// </summary>
|
/// <param name="type"></param>
|
public void SetTreasureEffectDes(out int type)
|
{
|
type = 0;
|
effectDesSB.Length = 0;
|
killNpcAtk = 0;
|
TreasureConfig treasureConfig = TreasureConfig.Get(treasureId);
|
if (treasureAddAtklist.Contains(treasureId))
|
{
|
type = 1;
|
var killConfig = VIPKillNPCConfig.Get(Mathf.Max(model.vipKillNPCTreasure.level, 1));
|
if (killConfig != null)
|
{
|
killNpcAtk = killConfig.MaxAtk;
|
}
|
string des = treasureConfig.Verse[0].Replace("{0}", killNpcAtk.ToString());
|
effectDesSB.Append(des);
|
return;
|
}
|
|
if (treasureSignDict.ContainsKey(treasureId))
|
{
|
Dictionary<int, int> attrDict = treasureSignDict[treasureId];
|
Treasure treasure;
|
model.TryGetTreasure(treasureId, out treasure);
|
bool isHaveTreasure = false;
|
if (treasure != null)
|
{
|
if (treasure.state == TreasureState.Collected)
|
{
|
isHaveTreasure = true;
|
}
|
}
|
foreach (var id in attrDict.Keys)
|
{
|
PlayerPropertyConfig propertyConfig = PlayerPropertyConfig.Get(id);
|
string des = string.Format(treasureConfig.Verse[0], PlayerPropertyConfig.GetValueDescription(id, attrDict[id]), propertyConfig.Name);
|
effectDesSB.Append(des);
|
if (signInModel.totalSignInCount > 0)
|
{
|
des = string.Format(treasureConfig.Verse[1], signInModel.totalSignInCount);
|
effectDesSB.Append(StringUtility.Contact("\n", des));
|
int addAtk = signInModel.totalSignInCount * attrDict[id];
|
if (isHaveTreasure)
|
{
|
des = string.Format(treasureConfig.Verse[2], Language.Get("TreasureEffect105", PlayerPropertyConfig.GetValueDescription(id, addAtk)));
|
}
|
else
|
{
|
des = string.Format(treasureConfig.Verse[2], Language.Get("TreasureEffect104", PlayerPropertyConfig.GetValueDescription(id, addAtk)));
|
}
|
effectDesSB.Append(StringUtility.Contact("\n", des));
|
}
|
}
|
return;
|
}
|
|
if (effectDesSB.Length <= 0)
|
{
|
type = 3;
|
effectDesSB.Append(treasureConfig.Verse[0]);
|
}
|
|
}
|
|
Dictionary<int, int> atkDict = new Dictionary<int, int>();
|
public int GetTreasureFight()
|
{
|
int fight = model.GetTreasureFightPower(treasureId);
|
switch (showType)
|
{
|
case 1:
|
var killConfig = VIPKillNPCConfig.Get(1);
|
if (killConfig != null)
|
{
|
atkDict.Clear();
|
atkDict.Add(67, killConfig.MinAtk);
|
atkDict.Add(68, killConfig.MaxAtk);
|
fight += UIHelper.GetFightPower(atkDict);
|
}
|
break;
|
case 2:
|
fight += UIHelper.GetFightPower(treasureSignDict[treasureId]);
|
break;
|
case 3:
|
break;
|
default:
|
break;
|
}
|
|
return fight;
|
}
|
|
public int GetFightPower(int _treasureId, int _type, int _value)
|
{
|
Treasure _treasure;
|
model.TryGetTreasure(_treasureId, out _treasure);
|
var _fight = model.GetTreasureFightPower(_treasureId);
|
switch (_type)
|
{
|
case 1:
|
var killConfig = VIPKillNPCConfig.Get(Mathf.Max(_value, 1));
|
if (killConfig != null)
|
{
|
var _propertyDict = new Dictionary<int, int>();
|
_propertyDict.Add(67, killConfig.MinAtk);
|
_propertyDict.Add(68, killConfig.MaxAtk);
|
_fight += UIHelper.GetFightPower(_propertyDict);
|
}
|
break;
|
case 2:
|
if (_treasure.treasureStages[0].unlockType == TreasureStageUnlock.Property)
|
{
|
_fight += UIHelper.GetFightPower(_treasure.treasureStages[0].propertyDict);
|
}
|
break;
|
}
|
return _fight;
|
}
|
}
|
}
|