Notice
Recent Posts
Recent Comments
Link
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

동구의_C# & Unity_개발일지

2024.01.30 내일배움캠프 27일차 TIL_Unity (입문, 알고리즘) 본문

Unity

2024.01.30 내일배움캠프 27일차 TIL_Unity (입문, 알고리즘)

mongle_0l 2024. 1. 30. 17:31

내일이 팀 과제 제출일이기 때문에 오늘 거의 마무리하려고 한다!

오브젝트 생성과 톱늬바퀴, 캐릭터가 죽는 것까지 구현을 완료하였다.

전체적으로 병합과정을 거쳤으며 다행히 큰 오류는 없었다


알고리즘 코드카타 14일차

자연수 뒤집어 배열로 만들기

문제 설명
자연수 n을 뒤집어 각 자리 숫자를 원소로 가지는 배열 형태로 리턴해주세요. 예를들어 n이 12345이면 [5,4,3,2,1]을 리턴합니다.
public class Solution {
    public int[] solution(long n) {
        string a = n.ToString();
        int[] answer = new int[a.Length];
        for(int i = 0;i < a.Length; i++){
            answer[i] = (int)(n % 10);
            n = n / 10;
        }
        return answer;
    }
}


팀 프로젝트

회전하며 올라가는 톱늬바퀴 구현
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Saw_Wheel : MonoBehaviour
{
    public float speed = 2f;

    private Death death;

    void Update()
    {
        MoveUp();
    }

    void MoveUp()
    {
        transform.Translate(Vector3.up * speed * Time.deltaTime);
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Jelly")
        {
            Destroy(collision.gameObject);
        }

        if (collision.gameObject.tag == "player")
        {
            Destroy(collision.gameObject, 2f);
            if (death != null)
            {
                death.GameOver();
            }
        }
    }
}


깃 허브 사용