SPRT BootCamp Unity : Day12

강동현·2025년 10월 15일

SpartaCodingClub_Unity_12th

목록 보기
17/23

0. 서론

금일은 배운 것 말고 코드만 작성하여 오늘 작성한 것 중 시스템에서 주요한 것만을 다룰 것 이다.

1. 금일 학습 내용

 public enum QuestType
 {
     KillMonster,
     Collect,
     Equip,
     ReachLevel,
 }

 public QuestType Type { get; set; }    
 public string? TargetName { get; set; }
 public int TargetCount { get; set; }
 public int CurrentCount { get; set; }

 public bool IsCompleted 
 { 
     get
     {
         return CurrentCount >= TargetCount;
     }
 }

퀘스트 대상(ex. 슬라임 5마리 잡기 같이) 관리

public string Name { get; set; }
public string Description { get; set; }
public int Reward { get; set; }//아이템 보상 추가하면 변경해야 됨
public bool IsAccepted { get; set; }

public List<QuestCondition> Conditions { get; set; }
public bool IsCompleted => Conditions.All(c => c.IsCompleted);

public static List<QuestList> quests = new List<QuestList>()
{
    new QuestList(
        "마을을 위협하는 미니언 처치",
        "이봐! 마을 근처에 미니언들이 너무 많아졌다고 생각하지 않나?\r\n마을주민들의 안전을 위해서라도 저것들 수를 좀 줄여야 한다고!\r\n모험가인 자네가 좀 처치해주게!\r\n",            
        100,
        false,
        new List<QuestCondition>
        {
            new QuestCondition
            {
                Type = QuestCondition.QuestType.KillMonster,
                TargetName = "미니언",
                TargetCount = 5,
                CurrentCount = 0
            }
        }),
    
};

public QuestList(string name, string description, int reward, bool IsAccepted, List<QuestCondition> conditions)
{
    Name = name;
    Description = description;
    Reward = reward;
    IsAccepted = false;
}

이 위에 퀘스트 대상 및 이름, 설명, 수락 여부 담겨져있는 List

 public static void ShowProgress(int index)
 {
     string targetName = QuestList.quests[index].Conditions[0].TargetName; //목표 대상
     int targetCount = QuestList.quests[index].Conditions[0].TargetCount; //목표 수
     int currentCount = QuestList.quests[index].Conditions[0].CurrentCount; //현재 수

     QuestCondition.QuestType type = QuestList.quests[index].Conditions[0].Type; 
     switch (type)
     {
        case QuestCondition.QuestType.KillMonster: //몬스터 처치 퀘스트 일 때 출력문
             Console.WriteLine($" {targetName} {targetCount}마리 처치 " +
                 "("+currentCount+"/"+targetCount + ")\n");
             break;
        case QuestCondition.QuestType.Equip: //장비 장착 퀘스트 일 때 출력문
             Console.WriteLine($" {targetName} 장착 " +
                 "("+currentCount+"/"+targetCount + ")\n");
             break;
        case QuestCondition.QuestType.ReachLevel: //레벨 도달 퀘스트 일 때 출력문
             Console.WriteLine($" {targetCount}레벨 도달 " +
                 "("+currentCount+"/"+targetCount + ")\n");
             break;           
     }

위 두 클래스를 이용하여 조건(target)에 맞게 퀘스트 종류를 출력을 해준다.

2. 어려웠던 점

3. 다음 학습 내용

  • 팀프로젝트 진행

4. 느낀 점

 금일 코디 작성 중 퀘스트는 보상 수령, 달성 여부 등등 사소한 거 제외 구현이 끝났고 저장, 시작 화면 등등도 끝냈다. 허나 문제가 씬(각 역할마다 class를 다르게 나눠둠) 전환인데 기존에 기본으로 있던 command(조원 한 분이 base로 깔고 가면 편하다고 하셔서 채택됨)에 있던 걸 활용할려고 하다보니 진행이 많이 되지 않았다. 마지막에는 그냥 편한대로 하자 하고 절반 정도 진행하였다. 내일은 최대한 다 끝내는 걸 목표로 해야겠다.

0개의 댓글