[TIL] 17일차 - 팀 프로젝트 완성

김유원·2024년 1월 16일
0

📝24.01.17

팀 과제를 마무리 했다. 발표만을 남겨두고 있는데 아쉬운 부분도 많고 만족한 부분도 있다.
팀 프로젝트는 늘 어렵다. 내가 이끌고 가는 입장일 때도, 끌려가는 입장일 때도 늘 어렵다. 하지만 그만큼 배우는게 있으므로 즐겁게 참여하려고 노력하고 있다.

오늘은 팀 프로젝트를 마무리 한 날이므로, 딱히 팀 프로젝트 관련해서 새롭게 습득한 것은 없다. 그래서 '이후는 이전보다'의 수정에 많은 시간을 기울였다.

일단 GameManger.cs를 이렇게 수정하였다.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Yarn.Unity;

public class GameManager : MonoBehaviour
{
    public static GameManager instance;

    public int playerGold;
    public int townAtmosphere;
    public int townDead;

    /*
    public bool haveDismissal; //해임서 들고 있음
    public bool haveWanted;
    public bool haveRock;
    public bool haveDrug;

    public bool employKnight;
    public bool employMercenary;
    public bool employAcrobat;
    public bool employAlchem;

    public int KnightVisited;
    public int MercenaryVisited;
    public int AcrobatVisited;
    public int AlchemVisited; */

    //방문 여부 0 -> 첫방문 / 1 -> 고용 후 재방문 / 2 -> 골드부족으로 미고용 후 재방문
    // 3 -> 방문 불가 / 4 -> 재고용됨 / 5 -> 사망함
    // 이중에 5는 Die로 분리 가능
    //1,2의 경우는 다 방 Class 만들어서 하면 따로 구분 가능할듯?
    public List<Talent> talents;

    public int employCommoner;

    public int getClues;

    public int Days;

    public bool eventAcrobat;
    public bool eventAlchem;

    private DialogueRunner dlg;

    bool interactable = true;

    void Start()
    {
        //GameObject inven = GameObject.Find("go_InventoryBase");
        //inven.SetActive(false);
    }

    void Awake()
    { 
        instance = this;
    }

    public void StartGame() //0 기사 1 용병 2 곡예사 3 연금술사
    {
        //저장 파일 없다면 추가
        talents.Add(new Talent("기사"));
        talents.Add(new Talent("용병"));
        talents.Add(new Talent("곡예사"));
        talents.Add(new Talent("연금술사"));
    }

    public void ObjectClicked(string node)
    {
        GameObject obj = GameObject.Find("Canvas").transform.Find("Dialogue").gameObject;
        dlg = obj.transform.Find("DialogueRunner").GetComponent<DialogueRunner>();

        // if this character is enabled and no conversation is already running
        if (interactable && !dlg.IsDialogueRunning)
        {
            // then run this character's conversation
            dlg.StartDialogue(node);
        }
    }

    public bool TodayVisited()
    {
        bool todayVisited = false;

        foreach (Talent tlt in talents)
        {
            if (tlt.isVisited == true)
            {
                todayVisited = true;
            }
        }

        return todayVisited;
    }

    public void NextDay()
    {

    }
}

가장 주요하게 바뀐 부분은 haveDismisaal, haveWanted 등 약점을 가지고 있는지 여부와 여러 인재의 고용 여부, 그리고 해당 인재방의 방문 여부 등을 삭제한 것이다.

이것들은 전부 List<Talent> talents; 형태로 Talent 클래스에 해당 요소들을 받아오는 것으로 수정하고 있다. 그렇다면 여기서 Talent 클래스는 어떻게 구성했냐면,

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

public class Talent : MonoBehaviour
{
    private string name;
    public bool haveWeakness { get; set; } //약점 취득 여부
    public bool isEmployed { get; set; } // 고용 여부
    public bool isVisited { get; set; } // 방문 여부
    public bool isAlive { get; set; } // 생존 여부

    public Talent(string _name)
    {
        name = _name;
        haveWeakness = false;
        isEmployed = false;
        isVisited = false;
        isAlive = true;
    }
}

이런 형태로 구성하였다. 대부분은 이런 형태로 쉽게 변경이 가능했다. 하지만 GameManager.cs

//방문 여부 0 -> 첫방문 / 1 -> 고용 후 재방문 / 2 -> 골드부족으로 미고용 후 재방문
// 3 -> 방문 불가 / 4 -> 재고용됨 / 5 -> 사망함

이 부분을 활용한 부분이 문제였다. 특히, 골드 부족으로 미고용 후 재방문을 구현하기 위해서 기존의 인재별 Visited 방문을 int로 분류하였는데 이를 bool 로 수정하고자 하니 여러 변수를 받아와 기존의 기능을 수행해야 하는 문제가 발생했다.

아직 이 문제를 해결하지는 못했다. 왜냐하면 이 문제를 해결하기 위해서는 인재의 방 별 클래스를 생성하는 방향으로 수정해야할 것 같기 때문이다. 전체 인재방을 표현하기 위한 부모 클래스를 만들고, 각 인재별 자식 클래스를 만드는 방향으로 구현해 볼 예정이다.




오늘의 알고리즘 문제 풀이

📕
1) [프로그래머스] 두 정수 사이의 합
2) [프로그래머스] 콜라츠 추측

profile
개발 공부 블로그

0개의 댓글

관련 채용 정보