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.
115 lines
4.4 KiB
115 lines
4.4 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using IVDataFormat;
|
|
using IVServerFormat;
|
|
using System.Numerics;
|
|
using BigFloatNumerics;
|
|
|
|
[Serializable]
|
|
public class AtlantisDungeonData : GameModData, IHasRewards, IAutoProgressable
|
|
{
|
|
int requestCount = 0;
|
|
Action<IList<nGoods>, bool> onDoneGetResult;
|
|
|
|
AtlantisDungeonProperty Property => property as AtlantisDungeonProperty;
|
|
AtlantisDungeonPlayProperty PlayProperty => playProperty as AtlantisDungeonPlayProperty;
|
|
|
|
public override string NameKey => "dungeon_title_Atlantis";
|
|
public int OpenStage => Property.openStage;
|
|
public bool AutoProgress { get; set; }
|
|
public CharacterProperty[] NormalEnemyCandidates => Property.normalEnemyCreator.candidates;
|
|
public CharacterProperty[] EpicEnemyCandidates => Property.epicEnemyCreator.candidates;
|
|
public int WaveCount => Property.waveCount;
|
|
public float WaveIntervalTime => Property.waveIntervalTime;
|
|
public int NormalEnemyCountPerWave => Property.normalEnemyCreator.countPerWave;
|
|
public int EpicEnemyCountPerWave => Property.epicEnemyCreator.countPerWave;
|
|
public float GoalScore => Property.goalScore;
|
|
public float NormalEnemyScore => Property.normalEnemyCreator.score;
|
|
public float EpicEnemyScore => Property.epicEnemyCreator.score;
|
|
public float LimitTime => Property.limitTime;
|
|
public uint EnterTicketCount { get => PlayProperty.enterTicketCount; set => PlayProperty.enterTicketCount = value; }
|
|
public IList<nGoods> DefaultRewards { get; private set; }
|
|
public IList<nGoods> TotalRewards
|
|
{
|
|
get
|
|
{
|
|
//TODO: DefaultReward + BonusReward
|
|
return DefaultRewards;
|
|
}
|
|
}
|
|
|
|
public AtlantisDungeonData(AtlantisDungeonProperty property, AtlantisDungeonPlayProperty playProperty)
|
|
: base(property, playProperty)
|
|
{
|
|
SetLevel(Level);
|
|
}
|
|
|
|
public override void SetLevel(uint level)
|
|
{
|
|
level = Math.Min(level, MaxLevel);
|
|
DefaultRewards = GetRewardList(level);
|
|
PlayProperty.level = level;
|
|
}
|
|
|
|
public bool IsClear(uint level) => level < Level;
|
|
|
|
public void TryGetReward(Action<IList<nGoods>, bool> onRequestDone)
|
|
{
|
|
if (requestCount > 0) return;
|
|
|
|
requestCount = DefaultRewards.Count;
|
|
onDoneGetResult = onRequestDone;
|
|
|
|
foreach (var reward in TotalRewards)
|
|
{
|
|
SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.Property), typeof(nGoodsGet), OnGetRewardSuccess, OnGetRewardFail, reward, true);
|
|
}
|
|
|
|
if(requestCount == 0)
|
|
onDoneGetResult?.Invoke(new nGoods[0], true);
|
|
}
|
|
|
|
private void OnGetRewardSuccess(object result, object request)
|
|
{
|
|
if (--requestCount <= 0)
|
|
{
|
|
nGoodsGet data = result as nGoodsGet;
|
|
var totalReward = TotalRewards;
|
|
|
|
DataHandler.AddGoods(totalReward, data.playCurrency, true);
|
|
onDoneGetResult?.Invoke(totalReward, true);
|
|
}
|
|
}
|
|
|
|
private void OnGetRewardFail(SvError error, object request) => onDoneGetResult?.Invoke(new nGoods[0], false);
|
|
|
|
public BigFloat GetNormalEnemyHp(uint level) => Property.normalEnemyCreator.GetHp(level);
|
|
public BigFloat GetCurNormalEnemyHp() => Property.normalEnemyCreator.GetHp(Level);
|
|
public BigFloat GetNormalEnemyAtk(uint level) => Property.normalEnemyCreator.GetAtk(level);
|
|
public BigFloat GetCurNormalEnemyAtk() => Property.normalEnemyCreator.GetAtk(Level);
|
|
|
|
public BigFloat GetEpicEnemyHp(uint level) => Property.epicEnemyCreator.GetHp(level);
|
|
public BigFloat GetCurEpicEnemyHp() => Property.epicEnemyCreator.GetHp(Level);
|
|
public BigFloat GetEpicEnemyAtk(uint level) => Property.epicEnemyCreator.GetAtk(level);
|
|
public BigFloat GetCurEpicEnemyAtk() => Property.epicEnemyCreator.GetAtk(Level);
|
|
|
|
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)
|
|
{
|
|
return DataHandler.CalcBattlePower(GetNormalEnemyHp(level), GetNormalEnemyAtk(level)) +
|
|
DataHandler.CalcBattlePower(GetEpicEnemyHp(level), GetEpicEnemyAtk(level));
|
|
}
|
|
}
|