85 lines
3.6 KiB
C#
85 lines
3.6 KiB
C#
using CodeStage.AntiCheat.ObscuredTypes;
|
|
using MiniJSON;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public enum ChapterQuestObjType { None, PickUp, Harvester, TractorOld, Tractor, Trailer_Tank, FireOff, Flag }
|
|
|
|
public class ChapterQuestTableData : TableDataBase
|
|
{
|
|
public ObscuredInt Chapter, MaxStage, ChestID, MobID, Count, RewardID, RewardAmount;
|
|
public ePurpose Purpose;
|
|
public ChapterQuestObjType ObjType;
|
|
public string Title, Desc, Prefab;
|
|
public eItem Reward;
|
|
|
|
// 테이블에 없는 값
|
|
public string PurposeText;
|
|
}
|
|
|
|
public class table_chapterquest : MonoBehaviour
|
|
{
|
|
public static table_chapterquest Ins;
|
|
|
|
public TextAsset m_json;
|
|
|
|
private List<TableDataBase> list_Data = new List<TableDataBase>();
|
|
|
|
private void Awake()
|
|
{
|
|
Ins = this;
|
|
|
|
Dictionary<string, object> jsonData = Json.Deserialize(m_json.text) as Dictionary<string, object>;
|
|
|
|
// ["items"]은 items.txt 안의 items를 가리킨다. 툴 우측 하단 파일 종류란에서 설정 가능.
|
|
List<object> obj = jsonData[GetType().Name] as List<object>;
|
|
|
|
foreach (object objt in obj)
|
|
{
|
|
var temp = new ChapterQuestTableData();
|
|
Dictionary<string, object> json = objt as Dictionary<string, object>;
|
|
|
|
temp.Chapter = int.Parse(json["Chapter"].ToString());
|
|
temp.MaxStage = int.Parse(json["MaxStage"].ToString());
|
|
temp.ID = int.Parse(json["ID"].ToString());
|
|
temp.ChestID = int.Parse(json["ChestID"].ToString());
|
|
temp.MobID = int.Parse(json["MobID"].ToString());
|
|
temp.Count = int.Parse(json["Count"].ToString());
|
|
temp.Purpose = DSUtil.StringToEnum<ePurpose>(json["Purpose"].ToString());
|
|
temp.ObjType = DSUtil.StringToEnum<ChapterQuestObjType>(json["ObjType"].ToString());
|
|
temp.Title = json["Title"].ToString();
|
|
temp.Desc = json["Desc"].ToString();
|
|
temp.Prefab = json["Prefab"].ToString();
|
|
|
|
temp.RewardID = int.Parse(json["RewardID"].ToString());
|
|
temp.RewardAmount = int.Parse(json["RewardAmount"].ToString());
|
|
temp.Reward = DSUtil.StringToEnum<eItem>(json["Reward"].ToString());
|
|
|
|
temp.PurposeText = json["PurposeText"].ToString();
|
|
list_Data.Add(temp);
|
|
}
|
|
}
|
|
|
|
public List<TableDataBase> Get_DataList() { return list_Data.FindAll(f => f.ID > 0); }
|
|
public List<TableDataBase> Get_DataList(int _chapter) { return list_Data.FindAll(f => (f as ChapterQuestTableData).Chapter == _chapter); }
|
|
public ChapterQuestTableData Get_Data(int _chapter, int _id) { return list_Data.Find(f => f.ID == _id && (f as ChapterQuestTableData).Chapter == _chapter) as ChapterQuestTableData; }
|
|
//int chap = 0;
|
|
public ChapterQuestTableData Get_RandomData()
|
|
{
|
|
var sdata = ServerInfo.Ins.m_ServerData;
|
|
var curChapter = MyValue.MyChoiceMapData.n_MapID;
|
|
//return Get_DataList(curChapter)[chap++] as ChapterQuestTableData; // 테스트 : 챕터 퀘스트
|
|
|
|
//if (sdata.Get_Common(eCommon.GuideStep) <= 2 && sdata.Get_Common(eCommon.GuideCount) < 1)
|
|
// return list_Data[0] as ChapterQuestTableData;
|
|
|
|
//var maxchapter = sdata.Get_Common(eCommon.MaxMapID);
|
|
//var maxstage = sdata.Get_Common(eCommon.MaxStage);
|
|
//var maxStage = Mathf.Max(1, maxchapter > curChapter ? 10 : maxstage);
|
|
//var list = list_Data.FindAll(f => (f as ChapterQuestTableData).Chapter == curChapter && (f as ChapterQuestTableData).MaxStage <= maxStage);
|
|
//return list[Random.Range(0, list.Count)] as ChapterQuestTableData;
|
|
return null;
|
|
}
|
|
}
|