관리 메뉴

STIKA-DEV

D+24일 TIL < Unity 입문 / 팀 프로젝트 > 본문

프로그래밍/Unity + C#

D+24일 TIL < Unity 입문 / 팀 프로젝트 >

STIKA 2024. 1. 26. 02:09

24.01.26 Fri

D+24

 

❤️ TIL

Today I Learned

❤️하루에 1%씩만 나아가도 4개월 동안 쌓이면 꽤 덩치가 커진답니다 :)


✏️ 작업 내용

✔️ 팀 프로젝트 맡은부분 구현


✔️  Obstacle

public class StopRain : MonoBehaviour
{
    public GameObject OnTrigger;
    private void OnTriggerEnter2D(Collider2D coll)
    { 
        if (coll.gameObject.tag == "Player")
        {
            Destroy(OnTrigger);
            Destroy(this.gameObject);
        }
    }
}
public class RainCollision : MonoBehaviour
{
    UIManager uiManager;

    private string youtubeStr = "유튜브의 알고리즘이 나를 현혹시킨다...\n12시간동안 유튜브에서 헤어나오지 못했다...";

    private void Start()
    {
        uiManager = GameObject.FindGameObjectWithTag("UI").GetComponent<UIManager>();
    }
    private void OnCollisionEnter2D(Collision2D coll)
    {
        string[] tags = { "JumpGround", "Player", "MapOut", "Nag", "Bed" };

        if(tags.Contains(coll.gameObject.tag))
        {
            if (coll.gameObject.tag == "Player")
            {
                coll.gameObject.GetComponentInChildren<Animator>().enabled = false;
                coll.gameObject.GetComponent<PlayerInput>().enabled = false;

                if (this.gameObject.tag == "YouTube")
                    uiManager.endResult(youtubeStr);

                Debug.Log($"{gameObject.tag} rain이랑 Player부딪힘");
            }

            Destroy(gameObject);
        }
    }
}
public class Obstacle : ModeChoice
{
    UIManager uiManager;

    private string bedStr = "폭신한 침대의 유혹에 지고 말았다.\n시계를 보니 밤 12시가 지났다....\n더 무서운건 퇴실버튼을 못 눌러서 매니저님이 찾아왔다..";
    private string nintendoStr = "몰래 게임을 하다가 걸려서 한효승 매니저님한테 진실의 방으로 끌려갔다...";
    private string clearStr = "  퇴  실  성  공  ! ! !\n\n모든 유혹을 뿌리치고 무사히 오늘의 공부와 TIL작성을 끝내고 퇴실에 성공했다!!!";
    private string mapOut = "공부를 때려치고 놀고싶은 욕망과\n주변의 많은 유혹들을 이겨내지 못하고 탈주를 해버렸다...";

    protected override void Start()
    {
        uiManager = GameObject.FindGameObjectWithTag("UI").GetComponent<UIManager>();
        base.Start();
    }

    private void OnCollisionEnter2D(Collision2D coll)
    {
        if (choice != Mode.Fix && choice != Mode.Hide)//drop fly모드
        {
            if(coll.gameObject.tag == "MapOut")
                Destroy(gameObject);

            if(coll.gameObject.tag == "Nag")
                Destroy(coll.gameObject);

            if(choice == Mode.Fly && coll.gameObject.tag == "Ground")//wallTile
                Destroy(gameObject);

            if (coll.gameObject.tag == "Player")
            {
                coll.gameObject.GetComponentInChildren<Animator>().enabled = false;
                coll.gameObject.GetComponent<PlayerInput>().enabled = false;

                if (this.gameObject.tag == "Clear")
                    uiManager.endResult(clearStr);
                if (this.gameObject.tag == "Bed")
                    uiManager.endResult(bedStr);
                if (this.gameObject.tag == "Nintendo")
                    uiManager.endResult(nintendoStr);

                Debug.Log($"{gameObject.tag} drop or fly랑 Player부딪힘");
            }
        }          
        else
        {
            if (coll.gameObject.tag == "Player") //Fix인 Obstacle이랑 부딪혔을때
            {
                coll.gameObject.GetComponentInChildren<Animator>().enabled = false;
                coll.gameObject.GetComponent<PlayerInput>().enabled = false;

                if (this.gameObject.tag == "Clear")
                    uiManager.endResult(clearStr);
                if(this.gameObject.tag == "Bed")
                    uiManager.endResult(bedStr);
                if (this.gameObject.tag == "Nintendo")
                    uiManager.endResult(nintendoStr);
                if (this.gameObject.tag == "MapOut")
                    uiManager.endResult(mapOut);

                Debug.Log($"{gameObject.tag} fix랑 Player부딪힘");
            }
        }
    }
}

 

 

 

 

 

https://github.com/STlCA/Platformer

 

GitHub - STlCA/Platformer: NBC 게임개발 입문주차 17조의 Repos

NBC 게임개발 입문주차 17조의 Repos. Contribute to STlCA/Platformer development by creating an account on GitHub.

github.com

 

 


 

✏️ 스스로 어제보다 한 발 더 나아갔다는 것을 자각하기

✏️ TIL을 쓰기 위해서라도, 오늘 반드시 단 하나라도 배우기

✏️ 꾸준히 기록을 남기는 습관 가지기

 

📕 오늘의 학습 키워드

📕  공부한 내용 본인의 언어로 정리하기

📕  오늘의 회고

📕  12시간 중 얼마나 몰입했는지

📕  더 나은 미래를 위해 내일 어떤 공부를 진행할 것인지

'프로그래밍 > Unity + C#' 카테고리의 다른 글

D+26일 TIL < Contains >  (0) 2024.01.31
D+25일 TIL < Invoke >  (0) 2024.01.29
D+23일 TIL < Unity 입문 >  (0) 2024.01.25
D+22일 TIL < Unity 1주차 / 팀 프로젝트 회의>  (1) 2024.01.24
D+21일 TIL < Unity 사전 5주차 >  (0) 2024.01.23