일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- GetComponent
- removeAll
- dfs
- list clear
- sparkmain(clone) 무한생성
- 너비탐색
- articulation body
- unity korea
- navisworks api
- Unity
- 오블완
- 패스트캠퍼스 #환급챌린지 #패스트캠퍼스후기 #습관형성 #직장인자기계발 #오공완
- 유니티
- sparkmain(clone)
- 행동트리
- 깊이탐색
- Simulation
- dropdown
- 최단거리 알고리즘
- C#
- raycast
- 최소신장트리 mst
- 유니티 sparkmain(clone)
- 크루스칼
- 트리구조
- unity sparkmain(clone)
- 드롭다운
- 디지털트윈
- readonly
- 티스토리챌린지
- Today
- Total
목록C# (29)
낑깡의 게임 프로그래밍 도전기
제네릭은 일반화 프로그래밍이라고도한다.List strings = new List();List ints = new List();위와 같이 동적으로 자료형을 할달할 수 있는 것을 제네릭이라고 할 수 있다.활용제네릭 메서드도 만들 수 있었다. 예를 들면 T라는 타입을 써서 어떤 자료형이 들어오든 동작하게 만들 수 있었다. 예를 들면 이런 식이다.처음엔 특정 타입의 Actor 목록을 가져오려고 할 때, List를 순회하면서 원하는 타입만 따로 골라내야 했다.그런데 이걸 매번 캐스팅하고 검사하려면 코드도 중복되고 귀찮았다.그래서 제네릭을 써서 재사용 가능한 메서드로 만들게 됐다.Public List GetActors() where T : ActorBase //T 는 ActorBase를 상속 받은 애들만 쓸수 있다..
링큐Where, First List ints = new List();ints.Add(1);ints.Add(2);ints.Add(3);ints.Add(4);ints.Add(5);ints.Add(6)ints.Add(7);ints.Add(8);ints.Add(9);ints.Add(10);이렇게 리스트가 있을때 5이상의 값을 출력하려면 foreach(int i in ints){ if(i>=5) intOver.Add(i);}이렇게 쓰겠지만 Where를 써서 줄이면 Func func = (int value) => value >= 5;//람다식//int.Where(CheckOverValue);//int.Where((int value) => value >= 5);//int.Where(value => value ..
Func func = (int actorCount) => { Console.WriteLine(); return actorCount > 1000;};=>화살표 뒤에는 리턴값이 된다.private static void PrintActorCount(int actorCount){ Console.WriteLine(actorCount);}private static bool IsActorCountCheck(int actorCount){ if(actorCount > 1000) return true; return false;}이것을 람다식으로 만들면 아래 처럼 된다.private static void PrintActorCount(int actorCount) => Console.WriteLine(actorCoun..
서브 클래스internal은 public과 같이 프로젝트 내에서도 공유가된다.솔루션에 프로젝트를 새로만들어서 서로 종속성을 연결해서 다른 프로젝트 끼리 쓸수가 있는데 그럴때 internal로 하면 공유가 안된다. public은 가능internal class ActorBase{ public class Info { public int OptionType{get; private set;} public int MoveDirection { get; private set;} public Info(int optionTypr, int moneDirection) { OPtionType = optionType; MoveDirection =..
static스태틱은 인스턴트 선언 없이 바로 접근 가능인스턴스로 만들어진 것 과는 차이가 있다인스턴스는 범위내에서만 쓸수있고 스태틱은 수동으로 초기화해주기전까진 시스템이 끝날때까지 살아있다.그래서 스태틱을 쓰면 다 기억을 하고있어야함 deepcapy클래스와 큰 연관이 있음주소만 복사하는 것을 쉘로우카피라고 한다.internal class ActorBase{ public string Name { get; protected set; } public string Description { get; protected set; } public ActorBase(string name) { Name = name; } public ActorBase DeepCopy(..
디자인패턴으로 구분하기도 하지만 구조를 만드는데 있어서 중요하다config, configuration 파일(설정 값)설정을 밖에서 하자 -> 의존성 주입internak class ActorMnanger{ public List actorBases = new List(); private ActorBase boss; public ActorManager(Actorbase boss) { this.boss = boss; } public void AddName(string value) { this.voss.AddName(value); }}ActorManager actorManager = new actorManager(boss: new MainA..
자료형은 부모로 쓸수 있으나 전용함수는 못씀ExtraActor exteaActor = new ExtraActor(name : "민수");MainActor mainActor = new MainActor(name : "철수");extraActor.MoveOffCamera();mainActor.MoveInCamera(); 이것을 아래 처럼,,ActorBase exteaActor = new ExtraActor(name : "민수");ActorBase mainActor = new MainActor(name : "철수");//extraActor.MoveOffCamera();//mainActor.MoveInCamera();자료형 부모로 가지고 있지만 각 자식이다. 그래서 오버라이드 된 함수가 있으면 그것부터 실행된다..
생성자(constructor), readonly, 한정자(private, public), this 생성자 : 클래스를 생성될때 같이 생성되는 것, 클래스와 같은 이름으로 만들어 주면됨private를 쓰는 것을 캡슐화 은닉화라고 한다readonly : 처음에만 값을 설정할 수있고 그다음엔 바꿀수 없다.internal class ActorA{ //캡슐화, 은닉화 private readonly string name; pubic ActorA(string name) { this.name = name }}초기적인 모습프로그램마다 달라지겠지만 처음에만 초기화를 세팅해 놓고 쓰는 클래스들이 많다.어떤 서버쪽에서는 초기화를 다시켜놓고 클래스는 그 역할로만 쓰는 경우가 많다interna..
프로그래밍을 설명할때 영화에 빗대어 설명하는 것이 좋다a배우와 b배우가 잇다고 가정해보자 남자여자 배우가 포용하는 장면을 찍을걸 코드로 찍기clasee ActorA{ public void Action() { Console.WriteLine("A가 포옹한다") }}clasee ActorB{ public void Action() { Console.WriteLine("B가 포옹한다") }}class Camera{ public void PickupCamera() { Console.WriteLine("카메라를 든다") }}pulic void Action{ Consloe.WriteLine("B기 포옹한다") Camera camera = new ..

가변파라미터 static void printPopUp(string message)static void printPopUp(params string[] message) 선택적 인수매개변수가 엄청 많을 경우 함수작성할때 마다 다 입력하기 힘들때 일부분만 입력하는 것static void PrintPopup(string title, string message, string etc, string type = "type3")마지막 값을 써주지 않아도 됨static void PrintPopup(string title, string message, string etc = "기타", string type = "type3")중간에 선택적 인수를 사용하면 그 다음에도 선택적 인수를 사용해줘야한다 명명된 인수PrintPopu..