备份CatanBuilding瘦身独立工程
This commit is contained in:
85
Assets/Scripts/EventGatherCore/EventGatherCoreTest.cs
Normal file
85
Assets/Scripts/EventGatherCore/EventGatherCoreTest.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class EventGatherCoreTest : MonoBehaviour
|
||||
{
|
||||
/* [SerializeField] private int TotalTestCount = 5000;
|
||||
[SerializeField] private float Interval = 0.0002f;
|
||||
private EventGatherCoreData _data;
|
||||
private EventGatherCoreTableContext _ctx;
|
||||
private void Start()
|
||||
{
|
||||
_data = EventGatherCoreData.CreateNew();
|
||||
_ctx = EventGatherCoreTableContext.GetTestSample();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.T))
|
||||
RunSingleTest();
|
||||
if (Input.GetKeyDown(KeyCode.S))
|
||||
StartCoroutine(RunStatisticTest());
|
||||
}
|
||||
|
||||
private bool RunSingleTest()
|
||||
{
|
||||
var rewardIdx = EventGatherCoreSystem.PickRandomRewardIdx();
|
||||
// Debug.Log($"[EventGatherCore] Draw Reward Idx: {rewardIdx}, Reward Id: {_data.StageData.RewardIdList[rewardIdx]}");
|
||||
_data.StageData.SetRewardClaimed(rewardIdx);
|
||||
var rewardId = _data.StageData.RewardIdList[rewardIdx];
|
||||
if (_ctx.IsCoreItem(rewardId))
|
||||
{
|
||||
// Debug.Log($"[EventGatherCore] {rewardId} is core Item.");
|
||||
_data.StageData.AddCoreItem();
|
||||
}
|
||||
// Debug.Log($"[EventGatherCore] CoreItemCount: {_data.StageData.CoreItemReceivedCount}.");
|
||||
if (_data.StageData.IsStageCleared(_ctx, _data.RoundCount))
|
||||
{
|
||||
Debug.Log($"[EventGatherCore] Stage Cleared.");
|
||||
_data.MoveToNextStage();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private IEnumerator RunStatisticTest()
|
||||
{
|
||||
int i = 0;
|
||||
Dictionary<int, Dictionary<int, int>> res = new Dictionary<int, Dictionary<int, int>>();
|
||||
res[0] = new Dictionary<int, int>();
|
||||
res[1] = new Dictionary<int, int>();
|
||||
res[2] = new Dictionary<int, int>();
|
||||
res[3] = new Dictionary<int, int>();
|
||||
res[4] = new Dictionary<int, int>();
|
||||
Debug.Log($"[EventGatherCore] Running like hell...");
|
||||
yield return new WaitForSeconds(Interval);
|
||||
while (i < TotalTestCount)
|
||||
{
|
||||
var playTimeCount = 1;
|
||||
while (RunSingleTest() == false)
|
||||
{
|
||||
playTimeCount++;
|
||||
}
|
||||
if (res[i % 5].ContainsKey(playTimeCount))
|
||||
res[i % 5][playTimeCount]++;
|
||||
else
|
||||
res[i % 5].Add(playTimeCount, 1);
|
||||
i++;
|
||||
yield return new WaitForSeconds(Interval);
|
||||
}
|
||||
int sum;
|
||||
foreach (var kv in res.OrderBy(x => x.Key))
|
||||
{
|
||||
sum = 0;
|
||||
Debug.Log($"<color=yellow>[EventGatherCore] Stage{kv.Key + 1}: </color>");
|
||||
foreach (var kv2 in kv.Value.OrderBy(x => x.Key))
|
||||
{
|
||||
Debug.Log($"[EventGatherCore] Play Count {kv2.Key}: {kv2.Value}");
|
||||
sum += kv2.Value * kv2.Key;
|
||||
}
|
||||
Debug.Log($"[EventGatherCore] Average: {sum / (float)TotalTestCount * 5}");
|
||||
}
|
||||
}
|
||||
*/}
|
||||
Reference in New Issue
Block a user