ThreeKingdomsSlingshot/Assets/Scripts/OutGame/SaveDataC.cs

141 lines
4.1 KiB
C#

using System;
using System.Collections.Generic;
using UnityEngine;
namespace TKS.OutGame
{
// 세이브 C 단계(PD #1093 C · 기획서 §11 "training" · "patrol" · "dev" · "counters" · inv "chests" · "treasures" + 연무장) — SaveData 의 필드.
[Serializable]
public class TrainState
{
[Tooltip("unit_type 키(infantry …)")]
public string type;
public int rank = 1;
[Tooltip("hp · atk · def 항목 Lv(0 = 훈련 안 함)")]
public int[] lv = { 0, 0, 0 };
}
[Serializable]
public class PatrolState
{
[Tooltip("누적 시작 시각(UTC ISO · 마지막 수확)")]
public string startAt = "";
[Tooltip("수확 소수점 이월(장비 · 상자 · 결정적 누적)")]
public float carryGear;
public float carryChest;
}
[Serializable]
public class DevState
{
public List<CountEntry> nodes = new List<CountEntry>();
[Tooltip("지금 트리에 쓴 도면(초기화 환급)")]
public int blueprintSpent;
}
[Serializable]
public class TreasureState
{
public string id;
[Tooltip("강화 ★(획득 = 0)")]
public int star;
public int shards;
}
[Serializable]
public class ArenaSample
{
public string name = "";
public List<string> heroes = new List<string>();
public int lv = 1;
public int score;
}
[Serializable]
public class ArenaState
{
[Tooltip("천하제일 탑 = 클리어한 최고 층")]
public int towerFloor;
public int towerTickets;
public int medals;
public int seasonScore;
[Tooltip("시즌 시작(UTC ISO) · season_days 지나면 순위 보상 후 새 시즌")]
public string seasonStart = "";
public int wins;
public int losses;
public List<ArenaSample> samples = new List<ArenaSample>();
[Tooltip("지난 시즌 순위·보상(표시)")]
public string lastSeason = "";
[Tooltip("적장 토벌 주(yyyy-ww) · 바뀌면 누적 피해 초기화")]
public string raidWeek = "";
public int raidDamage;
public string raidBoss = "";
}
/// <summary>C 단계 일일 횟수(날짜가 바뀌면 통째로 새로) — 던전 · 투기장 · 적장 · 순찰 즉시 수확 · 탑 광고 · 상점 무료 새로고침 · 투기장 상점.</summary>
[Serializable]
public class DailyC
{
public string day = "";
public List<CountEntry> dungeons = new List<CountEntry>();
public int arena;
public int raid;
public int towerAd;
public int freeRefresh;
public int arenaShop;
public int Dungeon(string id)
{
foreach (var c in dungeons)
if (c.id == id) return c.n;
return 0;
}
public void AddDungeon(string id)
{
foreach (var c in dungeons)
if (c.id == id)
{
c.n++;
return;
}
dungeons.Add(new CountEntry { id = id, n = 1 });
}
}
/// <summary>CountEntry 목록 도우미(카운터 · 상자 · 개발 노드).</summary>
public static class Counts
{
public static int Get(List<CountEntry> l, string id)
{
if (l == null) return 0;
foreach (var c in l)
if (c.id == id) return c.n;
return 0;
}
public static void Add(List<CountEntry> l, string id, int n)
{
foreach (var c in l)
if (c.id == id)
{
c.n = Mathf.Max(0, c.n + n);
return;
}
if (n > 0) l.Add(new CountEntry { id = id, n = n });
}
public static void Set(List<CountEntry> l, string id, int n)
{
foreach (var c in l)
if (c.id == id)
{
c.n = n;
return;
}
l.Add(new CountEntry { id = id, n = n });
}
}
}