본문 바로가기

전체 글106

[유니티] 1. (Target, SerializeField) 공부 ✳ Target 을 찾아 이동 구현 → Nav Mesh Agent 추가 → NavMeshAgent 컴포넌트는 목표를 향해 움직일 때 서로를 피해가는 캐릭터 생성에 유용합니다. → Mover 스크립트 추가하기 → Target 에 만들어둔 Target 집어 넣기 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI; // 사용하려면 추가 해야함 public class Mover : MonoBehaviour { [SerializeField] Transform target; void Update() { GetComponent().destination = target.position; } .. 2024. 3. 26.
[C#] 객체지향 using System.Numerics; using System.Security.Cryptography.X509Certificates; namespace CShop { class Player // 상속해주는 부모 / 기반 { // static 오로지 1개만 존재 static public int counter = 1; // public : 공공 없으면 안에서만 사용 가능 public int id; public int hp; public int attack; public Player() { Console.WriteLine("플레이어 호출"); } } class Archer : Player { } class Knight : Player // 자식 혹은 파생 클래스 { Knight() { Console.Writ.. 2024. 3. 22.
직업 선택 1) 직업 선택 및 열거형 using System.Numerics; using System.Security.Cryptography.X509Certificates; namespace CShop { enum ClassType { None = 0, Warrial = 1, Archer = 2, Magition = 3, } class Program { static void Main(string[] args) { ClassType choice = ClassType.None; while (true) { Console.WriteLine("******************"); Console.WriteLine("직업을 골라주세요 !"); Console.WriteLine("[1] 전사"); Console.WriteLine.. 2024. 3. 19.
[C#] 팩토리얼 / 재귀함수 using System.Security.Cryptography.X509Certificates; namespace CShop { class Program { // 팩토리얼 5! = 5 + 4 + 3 + 2 + 1 static int Factorial(int n) { int ret = 1; for (int num = 1; num 2024. 3. 19.
[C#] 피라미드 ✳ 피라미드 using System.Security.Cryptography.X509Certificates; namespace CShop { class Program { static void Main(string[] args) { // 피라미드 별모양 for (int i = 0; i < 6; i++) { for (int q = 0; q 2024. 3. 19.
[C#] 구구단 ✳ 구구단 2 ~ 9단 using System.Security.Cryptography.X509Certificates; namespace CShop { class Program { static void Main(string[] args) { // 구구단 for (int i = 2; i < 10; i++) { for (int q = 1; q < 10; q++) { Console.WriteLine($"{i} * {q} = {i * q}"); } } } } } 2024. 3. 19.
[C#] 함수 오버로딩 ◾ 함수 오버로딩 -> 함수 이름의 재사용 using System.Security.Cryptography.X509Certificates; namespace CShop { class Program { // 함수 이름의 재사용 static int Add(int a, int b) { Console.WriteLine("int 호출"); return a + b; } // 재사용 룰 : 같은 이름을 사용할거면 매개변수가 같으면 안된다! static float Add(float a, float b) { Console.WriteLine("float 호출"); return a + b; } static void Main(string[] args) { int ret = Add(1, 2); float ret2 = Add(2... 2024. 3. 19.
[C#] ref / out ✳ ref → 복사 , 참조 → 기본값은 복사 → 메모리가 딴판 → 포인터같은 느낌 원본을 가져와서 수정할 수 있음 using System.Security.Cryptography.X509Certificates; namespace CShop { class Program { static void AddOne(ref int number) { number = number + 1; } static void Main(string[] args) { // 복사(짭퉁) , 참조(진퉁) int a = 0; AddOne(ref a); // 애가 복사하는 게 아니라 참조하겠다 , 수정 가능! Console.WriteLine(a); } } } // 진퉁 원본으 수정할 수 있음 static void AddOne(ref int n.. 2024. 3. 19.
[C#] 함수 ✳ 함수 → 50만줄 수준 (상용 게임) → Method Function : 메소드 = 함수 → C++ = Function 대부분 함수라고해서 통용함 → 사용법 : 한정자 반환형식 이름(매개변수목록) → void(빈값)을 사용하면 return(반환)값이 없어도 가능 using System.Security.Cryptography.X509Certificates; namespace CShop { class Program { static void HelloWorld() // void 이므로 return(반환) 할 필요없음 { Console.WriteLine("함수 작동"); } static void Main(string[] args) { HelloWorld(); } } } using System.Security.. 2024. 3. 19.