太多了...总之能用了,就这样吧,也懒得用英文写了(;´Д`) ParameterContainer用于管理所有的Reward和Parameter. TargetController用于生成目标,然后再让SceneBlockContainer实际生成目标块,并且兼顾reward计算功能和目标观察结果的获取. EnemyContainer用于生成和删除敌人. SceneBlockContainer用于生成和删除目标块. States用于管理HP. SceneBlock用于管理目标块的...一堆东西,比如目标大小,目标区内人数等和目标所属状态等.
69 lines
2.2 KiB
C#
69 lines
2.2 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using XCharts.Runtime;
|
|
|
|
public class WorldUIController : MonoBehaviour
|
|
{
|
|
public LineChart WinChart;
|
|
public int[] totalGames;
|
|
public int[] winGames;
|
|
|
|
private int maxXAxis = 0;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
totalGames = new int[(int)TargetController.Targets.Num];
|
|
winGames = new int[(int)TargetController.Targets.Num];
|
|
Array.Clear(totalGames, 0, (int)TargetController.Targets.Num);
|
|
Array.Clear(winGames, 0, (int)TargetController.Targets.Num);
|
|
//WinChart.Init();
|
|
WinChart.RemoveData();
|
|
for (int i = 0; i < (int)TargetController.Targets.Num; i++)
|
|
{
|
|
string lineName = Enum.GetName(typeof(TargetController.Targets), i);
|
|
WinChart.AddSerie<Line>(lineName);
|
|
}
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
public void updateChart(int targetType, int endType)
|
|
{
|
|
float winRatio = 0f;
|
|
switch (endType)
|
|
{
|
|
case (int)TargetController.EndType.Win:
|
|
//Win
|
|
totalGames[targetType] += 1;
|
|
winGames[targetType] += 1;
|
|
winRatio = (float)winGames[targetType] / totalGames[targetType];
|
|
WinChart.AddData(targetType, winRatio);
|
|
if (totalGames[targetType] > maxXAxis)
|
|
{
|
|
maxXAxis = totalGames[targetType];
|
|
WinChart.AddXAxisData(Convert.ToString(maxXAxis));
|
|
}
|
|
break;
|
|
case (int)TargetController.EndType.Lose:
|
|
//lose
|
|
totalGames[targetType] += 1;
|
|
winRatio = (float)winGames[targetType] / totalGames[targetType];
|
|
WinChart.AddData(targetType, winRatio);
|
|
if (totalGames[targetType] > maxXAxis)
|
|
{
|
|
maxXAxis = totalGames[targetType];
|
|
WinChart.AddXAxisData(Convert.ToString(maxXAxis));
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|