Date class를 생성할 Date Script 생성
Gacha class를 생성할 Gacha Script 생성
많은 데이터를 저장할 DataBase class를 선언하는 Database Script 생성
//Gacha
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
public class Gacha
{
private int gachaLevel;
private int gachaCount;
private int resumeLevel;
private bool isGacha;
void Awake()
{
gachaLevel = 1;
gachaCount = 0;
resumeLevel = 1;
}
public Gacha()
{
gachaLevel = 1;
gachaCount = 0;
resumeLevel = 1;
isGacha = false;
}
public int GetGachaLevel()
{
return gachaLevel;
}
public int GetGachaCount()
{
return gachaCount;
}
public int GetResumeLevel()
{
return resumeLevel;
}
public List<Employee> EmployeeGacha(int job, Date date)
{
gachaCount++;
isGacha = true;
List<Employee> temp = new List<Employee>();
int rank = ChooseRank();
if (rank == -1) Debug.Log("Gacah Rank Error");
for (int i = 0; i < resumeLevel; i++)
temp.Add(new Employee(rank, job, date));
return temp;
}
// public List<Expert> ExpertGacah()
// {
// }
private int ChooseRank()
{
int tmp = UnityEngine.Random.Range(1, 1000);
for (int i = 0; i < 7; i++)
{
if (tmp < DataBase.gachaProbability[gachaLevel, i]) return i;
tmp -= DataBase.gachaProbability[gachaLevel, i];
}
return -1;
}
public bool GetIsGacha()
{
return isGacha;
}
public void ToggleIsGacha()
{
isGacha = !isGacha;
}
}
//Date
using System;
using UnityEngine;
public class Date
{
private int year;
private int month;
private int day;
private int hour;
private int minute;
private int second;
private bool newMonth;
public Date()
{
year = 2000;
month = 1;
day = 1;
hour = 0;
minute = 0;
second = 0;
newMonth = false;
}
public Date(Date date)
{
year = date.GetYear();
month = date.GetMonth();
day = date.GetDay();
hour = 0;
minute = 0;
second = 0;
}
public int GetYear()
{
return year;
}
public int GetMonth()
{
return month;
}
public int GetDay()
{
return day;
}
public String GetDate()
{
return $"{year,4}/{month,2}/{day,2}";
}
public String GetTime()
{
return $"{hour,2}:{minute,2}:{second,2}";
}
public Date GetDateInfo()
{
return this;
}
public void AddSecond()
{
second++;
if (second >= 60) AddMinute();
}
private void AddMinute()
{
second = 0;
minute++;
if (minute >= 60) AddHour();
}
private void AddHour()
{
minute = 0;
hour++;
if (hour >= 24) AddDay();
}
private void AddDay()
{
hour = 0;
day++;
if (day > CheckMaxDay()) AddMonth();
}
private void AddMonth()
{
day = 1;
month++;
newMonth = true;
if (month > 12) AddYear();
}
private void AddYear()
{
month = 1;
year++;
}
private int CheckMaxDay()
{
if (month != 2) return DataBase.maxDay[month];
if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) return 29;
else return 28;
}
public bool GetNewMonth() { return newMonth; }
public void ToggleNewMonth() { newMonth = !newMonth; }
}
using UnityEngine;
using System;
using System.Collections.Generic;
using NUnit.Framework.Constraints;
using Unity.VisualScripting.Dependencies.Sqlite;
using Unity.VisualScripting;
public static class DataBase
{
public const int MAX_LEVEL = 300;
public const int MAX_TEAM_LEVEL = 10;
public const int MAX_EMPLOYEE_LEVEL = 100;
public const int MAX_APP_LEVEL = 50;
public const int MAX_GACHA_LEVEL = 5;
public static Dictionary<String, long[]> valueCost;
public static long[] clickLevelUpCost;
public static long[] hpLevelUpCost;
public static String[] nameList;
public static int[] expCost;
public static int[] maxDay;
public static List<(string, string, double)> newsInfo;
public static List<(string, string, double, string, double, string, double, string, double, string, double, string, double, string, double, string, double)> AllApps;
public static List<(string, string, double, string, double, string, double, string, double, string, double, string, double, string, double, string, double, long)> AllStocks;
public static int[,] gachaProbability;
public static int[,] teamBalance;
static DataBase()
{
clickLevelUpCost = new long[MAX_LEVEL + 1];
clickLevelUpCost[0] = 10;
for (int i = 1; i <= MAX_LEVEL; i++)
clickLevelUpCost[i] = (int)(clickLevelUpCost[i - 1] * 1.15);
hpLevelUpCost = new long[MAX_LEVEL + 1];
hpLevelUpCost[0] = 10;
for (int i = 1; i <= MAX_LEVEL; i++)
hpLevelUpCost[i] = (int)(hpLevelUpCost[i - 1] * 1.15);
expCost = new int[MAX_LEVEL + 1];
for (int i = 1; i <= MAX_LEVEL; i++)
expCost[i] = 100 * i;
maxDay = new int[13] { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
gachaProbability = new int[MAX_GACHA_LEVEL + 1, 7] {
{ 0, 0, 0, 0, 0, 0, 0},
{500, 300, 150, 50, 0, 0, 0}, // 레벨 1
{350, 250, 200, 150, 50, 0, 0}, // 레벨 2
{200, 200, 250, 200, 100, 50, 0}, // 레벨 3
{100, 100, 150, 250, 200, 150, 50}, // 레벨 4
{ 50, 50, 100, 200, 250, 200, 150} // 레벨 5
};
teamBalance = new int[11, 3] {
{0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{1, 1, 1}, //3
{1, 1, 1}, //4
{1, 1, 1}, //5
{2, 2, 2}, //6 stat * 2
{2, 2, 2}, //7
{2, 2, 2}, //8
{3, 3, 3}, //9 stat * 3
{3, 3, 3} //10
};
long[] employeeCost = new long[MAX_EMPLOYEE_LEVEL + 1];
employeeCost[0] = 1000;
for (int i = 1; i < MAX_EMPLOYEE_LEVEL; i++)
employeeCost[i] = (long)(employeeCost[i - 1] * 1.2);
long[] teamCost = new long[MAX_TEAM_LEVEL + 1];
teamCost[0] = 1000;
for (int i = 1; i < MAX_TEAM_LEVEL; i++)
teamCost[i] = (long)(teamCost[i - 1] * 10);
long[] appCost = new long[MAX_APP_LEVEL + 1];
appCost[0] = 1000;
for (int i = 1; i < MAX_APP_LEVEL; i++)
appCost[i] = (long)(appCost[i - 1] * 1.3);
valueCost = new Dictionary<string, long[]>
{
{ "Employee", employeeCost },
{ "Team", teamCost },
{ "App", appCost }
};
}
}