63 lines
1.8 KiB
C#
63 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
[Serializable]
|
|
public class Step
|
|
{
|
|
public int id;
|
|
public string name1;
|
|
public string name2;
|
|
public string name3;
|
|
public string name4;
|
|
public string stepType;
|
|
public string maxScore;
|
|
public float score;
|
|
}
|
|
public class KaoHeManager : MonoBehaviour
|
|
{
|
|
public List<Step> results = new();
|
|
string name1;
|
|
string name2;
|
|
string name3;
|
|
string name4;
|
|
public string stepType;
|
|
public string maxScore;
|
|
public float totalScore;
|
|
List<string> recorder = new();
|
|
public void AddData(string name1, string name2, string name3, string name4, string stepType, string maxScore)
|
|
{
|
|
this.name1 = name1;
|
|
this.name2 = name2;
|
|
this.name3 = name3;
|
|
this.name4 = name4;
|
|
this.stepType = stepType;
|
|
this.maxScore = maxScore;
|
|
}
|
|
|
|
public void AddScore(int id, float score, Action<float, float> action)
|
|
{
|
|
Step step = results.Find(e => e.name1 == name1 && e.name2 == name2 && e.name3 == name3 && e.name4 == name4 && e.stepType == stepType);
|
|
if (recorder.Contains(name1 + name2 + name3 + name4 + id)) return;
|
|
if (step != null)
|
|
{
|
|
step.score += score;
|
|
}
|
|
else
|
|
{
|
|
step = new Step();
|
|
step.id = id;
|
|
step.name1 = name1;
|
|
step.name2 = name2;
|
|
step.name3 = name3;
|
|
step.name4 = name4;
|
|
step.stepType = stepType;
|
|
step.maxScore = maxScore;
|
|
step.score = score;
|
|
results.Add(step);
|
|
}
|
|
totalScore += score;
|
|
recorder.Add(name1 + name2 + name3 + name4 + id);
|
|
action?.Invoke(score, totalScore);
|
|
//Debug.Log(JsonConvert.SerializeObject(results));
|
|
}
|
|
} |