나 개발자 진짜 되냐?

[ 12月 9日 ] 오늘 내가 배운 것 _ 60日次 본문

오늘 공부를 정리해봐요!

[ 12月 9日 ] 오늘 내가 배운 것 _ 60日次

Snow Rabbit 2024. 12. 9. 23:32
반응형

 

 

오늘은..

 

심신미약이 이어져서

공부를 제대로 하지 못했다.

 

심지어 내일까지 데이터를 마무리하라는

미션을 받았다

...

너무너무너무너무

걱정된다.

 

 

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public abstract class DataBase<T>
{
    //public int index;

    public abstract void SetData(T metaData);
}

public abstract class DataBaseList<T1, T2, T3>
{
    public Dictionary<T1, T2> datas = new Dictionary<T1, T2>();

    public abstract void SetData(List<T3> metaDataList);

    public T2 LoadData(T1 key)
    {
        if (!datas.ContainsKey(key)) return default; // 널과 같움
        return datas[key];
    }
}

[System.Serializable]
public class ItemData : DataBase<MetaItemData>
{
    public int index;
    public string name;
    public string id;
    public string KOR_Name;
    
    public Status status;

    public override void SetData(MetaItemData metaItemData)
    {
        this.index = metaItemData.index;
        this.id = metaItemData.id;
        this.name = metaItemData.name;
        this.KOR_Name = metaItemData.kor_Name;
        this.status = new Status(metaItemData.attack, metaItemData.defense);
        /// <summary>
        /// 힘, 크리티컬 제외
        /// </summary>
        //this.status = new Status(metaItemData.attack, metaItemData.defense, metaItemData.str, metaItemData.crt);
    }
}

[System.Serializable]
public class ItemDataList : DataBaseList<string, ItemData, MetaItemData> // key, 리스트 안에 들어가있는 데이터, 어떤 데이터를 가져올건지
{
    public override void SetData(List<MetaItemData> metaItemDatas)
    {
        datas = new Dictionary<string, ItemData>(metaItemDatas.Count);

        metaItemDatas.ForEach(obj =>
        {
            ItemData item = new ItemData();
            item.SetData(obj);
            datas.Add(item.id, item);
        });
    }
}

[System.Serializable]
public struct Status
{
    public int attack;
    public int defense;
    /// <summary>
    /// 힘, 크리티컬 제외
    /// </summary>
    //public int str;
    //public int crt;

    public Status(int atk, int def)//(int atk, int def, int str, int crt)
    {
        this.attack = atk;
        this.defense = def;
        /// <summary>
        /// 힘, 크리티컬 제외
        /// </summary>
        //this.str = str;
        //this.crt = crt;
    }

}

 

데이터베이스를 만들어주었다.

이유는 가공을 위해

 

그 친구들을 상속받아

만들어준다.

 

일단, 내일

만져보면서 조금씩 고쳐봐야겠다.

 

이게 다냐구요?

네.

반응형