[TIL] 36일차 - 팀 프로젝트 제작

김유원·2024년 2월 14일
0

📝 24.02.14

오늘도 팀 프로젝트에 참여했다.

가장 주요하게 한 것은 SoundManager을 제작한 것과 35일차 개발 일지에서 언급했던 스킬 트리의 Interactable을 컨트롤하는 스크립트를 작성했다.

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

public class SkillTreeController : MonoBehaviour
{
    [SerializeField] List<GameObject> skillTrees;

    public static SkillTreeController instance;

    private void Awake()
    {
        instance = this;
    }

    void Start()
    {
        UnlockInteract();
    }


    public void UnlockInteract()
    {
        for(int i = 0; i < skillTrees.Count; i++)
        {
            SkillTree tree = skillTrees[i].GetComponent<SkillTree>();
            SkillTree prevTree = tree.prevTree;
            Button btn = skillTrees[i].GetComponent<Button>();

            if(!btn.interactable && prevTree.isUnlocked && !tree.isUnlocked)
            {
                btn.interactable = true;
            }
        }
    }
}

UnlockInteract()SkillTree.csUnLock()에서 사용하도록 하여 이전 스킬 트리가 언락되면 뒤의 스킬 트리가 활성화되도록 구현했다.

프로젝트를 하면 할수록 함수 자체를 구현하는 것은 쉽지만 그 함수를 어느 시점에 사용해야 하는 지 판별하는 것이 가장 어렵다는 생각이 들었다. 항상 가장 많은 고민과 수정을 하게 되는 부분인 것 같다.

profile
개발 공부 블로그

0개의 댓글

관련 채용 정보