You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
4.2 KiB
123 lines
4.2 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using IVDataFormat;
|
|
using IVServerFormat;
|
|
using System.Numerics;
|
|
using BigFloatNumerics;
|
|
|
|
[Serializable]
|
|
public class DevelopTheJungleDgData : GameModData, IHasRewards, IAutoProgressable
|
|
{
|
|
DevelopTheJungleDgProp Property => property as DevelopTheJungleDgProp;
|
|
DevelopTheJungleDgPlayProp PlayProperty => playProperty as DevelopTheJungleDgPlayProp;
|
|
|
|
IList<nGoods> requestRewards;
|
|
int remainRequestCount;
|
|
Action<IList<nGoods>, bool> onDoneGetResult;
|
|
|
|
public override string NameKey => "dungeon_title_DevelopTheJungle";
|
|
public string BGMPath => Property.bgmPath;
|
|
public string BackGroundPath => Property.backGroundPath;
|
|
|
|
public int OpenStage => (int)Property.openStage;
|
|
public bool AutoProgress { get; set; }
|
|
|
|
public IReadOnlyList<DevelopTheJungleDgProp.EnemyCreator> NormalEnemyCreators => Property.normalEnemyCreator;
|
|
public int WaveCount => Property.waveCount;
|
|
|
|
public float LimitTime => Property.limitTime;
|
|
public uint EnterTicketCount { get => PlayProperty.enterTicketCount; set => PlayProperty.enterTicketCount = value; }
|
|
|
|
public ItemProp EnterCostItem => Property.enterCostItem;
|
|
|
|
public uint TryCount { get => PlayProperty.tryCount; set => PlayProperty.tryCount = value; }
|
|
public uint ClearCount { get => PlayProperty.clearCount; set => PlayProperty.clearCount = value; }
|
|
|
|
public DevelopTheJungleDgData(DevelopTheJungleDgProp property, DevelopTheJungleDgPlayProp playProperty)
|
|
: base(property, playProperty)
|
|
{
|
|
SetLevel(Level);
|
|
}
|
|
|
|
public bool IsClear(uint level) => level < Level;
|
|
|
|
public void TryGetReward(uint level, Action<IList<nGoods>, bool> onRequestDone, float multifier = 1f, int count = 1)
|
|
{
|
|
if (requestRewards != null) return;
|
|
|
|
requestRewards = new List<nGoods>();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
var rewards = GetRewardList(level);
|
|
for (int j = 0; j < rewards.Count; j++)
|
|
{
|
|
var reward = rewards[j];
|
|
reward.propertyCount = (BigFloat)reward.propertyCount * multifier;
|
|
|
|
if (requestRewards.TryFind(reward.IsSameGoods, out var result))
|
|
result.propertyCount += reward.propertyCount;
|
|
else
|
|
requestRewards.OrderInsert(reward, nGoods.CompareByID);
|
|
}
|
|
}
|
|
|
|
remainRequestCount = requestRewards.Count;
|
|
onDoneGetResult = onRequestDone;
|
|
|
|
foreach (var reward in requestRewards)
|
|
{
|
|
SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.Property), typeof(nGoodsGet), OnGetRewardSuccess, OnGetRewardFail, reward, true);
|
|
}
|
|
|
|
if (requestRewards.Count == 0)
|
|
onDoneGetResult?.Invoke(new nGoods[0], true);
|
|
}
|
|
|
|
private void OnGetRewardSuccess(object result, object request)
|
|
{
|
|
if (--remainRequestCount <= 0)
|
|
{
|
|
nGoodsGet data = result as nGoodsGet;
|
|
|
|
DataHandler.AddGoods(requestRewards, data.playCurrency, true);
|
|
onDoneGetResult?.Invoke(requestRewards, true);
|
|
requestRewards = null;
|
|
}
|
|
}
|
|
|
|
private void OnGetRewardFail(SvError error, object request)
|
|
{
|
|
onDoneGetResult?.Invoke(new nGoods[0], false);
|
|
requestRewards = null;
|
|
}
|
|
|
|
public IList<nGoods> GetRewardList(uint level)
|
|
{
|
|
var rewards = new nGoods[Property.rewards.Length];
|
|
for (int i = 0; i < Property.rewards.Length; i++)
|
|
{
|
|
var reward = Property.rewards[i];
|
|
|
|
var goods = reward.itemProp.ConvertTo(reward.GetCount(level));
|
|
rewards[i] = goods;
|
|
}
|
|
|
|
return rewards;
|
|
}
|
|
|
|
public BigInteger GetRecommendBattlePower(uint level)
|
|
{
|
|
BigInteger total = 0;
|
|
for (int i = 0; i < NormalEnemyCreators.Count; i++)
|
|
{
|
|
var creator = NormalEnemyCreators[i];
|
|
total += DataHandler.CalcBattlePower(creator.GetHp(level), creator.GetAtk(level));
|
|
}
|
|
|
|
return total;
|
|
}
|
|
|
|
public bool CanSkip(uint level) => EnterTicketCount > 0 && level > 1;
|
|
|
|
public float GetRewardMultiplier() => BuffMgr.Instance.GetDevelopTheJungleBonus() / dConst.RateMaxFloat;
|
|
}
|