using UnityEngine;
|
using System;
|
|
using System.Collections.Generic;
|
|
namespace Snxxz.UI
|
{
|
[XLua.LuaCallCSharp]
|
[XLua.Hotfix]
|
public class KingTreasureShowModel : Model,IBeforePlayerDataInitialize,IPlayerLoginOk
|
{
|
KingTreasureModel kingTreasureModel { get { return ModelCenter.Instance.GetModel<KingTreasureModel>(); } }
|
public string effectDes { get; private set;}
|
public KingTreasureItemConfig kingTreasureItemConfig { get; private set; }
|
public int treasureId { get; private set; }
|
public string treasureSource { get; private set;}
|
public override void Init()
|
{
|
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
|
}
|
|
public override void UnInit()
|
{
|
|
}
|
|
public void SetInitData(int itemId)
|
{
|
ItemConfig itemConfig = ItemConfig.Get(itemId);
|
kingTreasureItemConfig = KingTreasureItemConfig.Get(itemId);
|
if (kingTreasureItemConfig == null || itemConfig == null) return;
|
|
this.treasureId = itemConfig.EffectValueA1;
|
this.treasureSource = kingTreasureItemConfig.description;
|
effectDes = string.Empty;
|
KingTreasureModel.Division division;
|
bool isDivision = kingTreasureModel.TryGetDivision(treasureId,kingTreasureItemConfig.rewardLevel, out division);
|
if(isDivision)
|
{
|
SetEffectDes(division.basePropertys);
|
SetEffectDes(division.specialPropertys);
|
WindowCenter.Instance.Open<KingTreasureShowWin>();
|
}
|
}
|
|
private void SetEffectDes(Dictionary<int, int> attrDict)
|
{
|
if (attrDict == null) return;
|
|
foreach (var key in attrDict.Keys)
|
{
|
var attrValue = attrDict[key];
|
var propertyConfig = PlayerPropertyConfig.Get(key);
|
if (propertyConfig != null)
|
{
|
string attrDes = StringUtility.Contact(propertyConfig.Name, "+", GetProValueTypeStr(propertyConfig, attrValue));
|
switch(propertyConfig.type)
|
{
|
case 2:
|
attrDes = StringUtility.Contact("<color=#ec4bf6>", attrDes, "</color>");
|
break;
|
default:
|
attrDes = StringUtility.Contact("<color=#fff4cd>", attrDes, "</color>");
|
break;
|
}
|
if (string.IsNullOrEmpty(effectDes))
|
{
|
effectDes = attrDes;
|
}
|
else
|
{
|
effectDes = StringUtility.Contact(effectDes, "\n", attrDes);
|
}
|
}
|
}
|
}
|
|
private string GetProValueTypeStr(PlayerPropertyConfig playerproModel, int value)
|
{
|
string s = "";
|
if (playerproModel.ISPercentage == 0)
|
{
|
s = value.ToString();
|
}
|
else if (playerproModel.ISPercentage == 1)
|
{
|
s = (float)Math.Round(value / 100f, 1) + "%";
|
}
|
else if (playerproModel.ISPercentage == 2)
|
{
|
s = ((float)Math.Round(value / 100f, 1)).ToString();
|
}
|
return s;
|
}
|
}
|
}
|