동구의_C# & Unity_개발일지
2024.01.30 내일배움캠프 27일차 TIL_Unity (입문, 알고리즘) 본문
내일이 팀 과제 제출일이기 때문에 오늘 거의 마무리하려고 한다!
오브젝트 생성과 톱늬바퀴, 캐릭터가 죽는 것까지 구현을 완료하였다.
전체적으로 병합과정을 거쳤으며 다행히 큰 오류는 없었다
알고리즘 코드카타 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();
}
}
}
}
깃 허브 사용
'Unity' 카테고리의 다른 글
2024.02.05 내일배움캠프 30일차 TIL_Unity (숙련, 알고리즘) (0) | 2024.02.05 |
---|---|
2024.02.01 내일배움캠프 29일차 TIL_Unity (숙련, 알고리즘) (0) | 2024.02.01 |
2024.01.29 내일배움캠프 26일차 TIL_Unity (입문, 알고리즘) (0) | 2024.01.29 |
2024.01.26 내일배움캠프 25일차 TIL_Unity (입문, 알고리즘) (0) | 2024.01.26 |
2024.01.25 내일배움캠프 24일차 TIL_Unity (입문, 알고리즘) (0) | 2024.01.25 |