백로그
1. 자원 시스템 구현
2. 기초 UI 구현
3. 우주선 내부 맵 구현
4. 내부 이동(WASD)
5. Add-on 시스템 기본 구현
6. 조타실 이동 및 성간지도 구현
7. 갈래형 맵 생성 (DFS 기반)
8. Encounter 시스템 설계
9. Encounter 관리 클래스 구현
10. 장비 파견 시스템 구현
11. 게임오버/승리 조건 구현
12. 게임 루프 설계 및 흐름 통합
13. 랜덤 인카운터 배치
14. Add-on 효과 적용
15. 텍스트 로그 개선
16. 유틸 클래스 구현
17. 은하계 정보 씬 구현
18. 씬 스택 구조 기반 뒤로 가기 구현
19. 성간 지도에서 현재 위치 표현
20. 뒤로가기 시 현재 위치 저장 및 불러오기
기본
1, 2, 3, 4, 5, 6, 11, 12, 15
응용
8, 9, 10, 13, 16, 17, 18, 19, 20
도전
7, 14
연료와 산소를 관리하여 게임오버를 결정짓는 시스템이다.
ResourceManager 클래스에서 Oxygen, Fuel, MaxOxygen, MaxFuel을 static 프로퍼티로 관리ChargeOxygen(), ChargeFuel() 메서드를 통해 최대치를 넘지 않도록 충전■, □로 자원 상태 시각화 (PrintFuel(), PrintOxygen() 메서드)콘솔 출력 예시
연료: ■■■■■■□□□□□□
산소: ■■■■■■□□□□□□
Console.SetCursorPosition 사용해 맵 아래 자원 상태 출력탑다운 형식의 우주선 내부 구조를 char 2차원 배열로 표현하여 시각화
Ship 클래스 내 char[,] MapData와 bool[,] Map 구현'#')과 내부(' ') 구분, Add-on실과 Cockpit에 문자 삽입 ('A', 'C')플레이어가 우주선 내부를 움직일 수 있게 구현
Player 클래스에 Move() 메서드 작성IsMovableMap으로 판단하여 벽을 통과하지 않도록 제어우주선 내 조타실에서 성간지도로 진입 가능한 구조 구현
Game.PushScene("Cockpit") 호출CockpitScene에서는 성간 맵을 출력하고 포인터로 탐색여러 클래스에서 공통적으로 활용할 수 있는 메서드 구현
Util.EscapeScene() 함수 정의해 Z 또는 ESC 입력 시 PopScene() 호출하도록 함
성간지도에서 은하 정보를 확인 및 이동 여부 결정할 수 있는 별도의 씬 구현
GalaxyInfoScene에서 GalaxyNodeInfo 객체 받아 출력Y/N 입력 시 이동 여부 결정 및 자원 충전 기능 구현이전 씬으로 돌아가는 기능을 스택 구조로 관리
Game.PushScene(BaseScene) / Game.PopScene() 구현Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at OOPConsoleProject.Scenes.GalaxyScene..ctor() in GalaxyScene.cs:line 23
public class GalaxyScene : BaseScene
{
private ConsoleKey input;
GalaxyMapPointer galaxyMapPointer;
GalaxyMap galaxyMap;
public GalaxyScene()
{
name = "Galaxy";
galaxyMapPointer = new GalaxyMapPointer(5, 1);
galaxyMapPointer.PointerPosition = new Vector2(5, 1);
galaxyMapPointer.IsMovableMap = galaxyMap.Map; // 객체 생성 전 호출
}
public override void Render()
{
Console.Clear();
galaxyMap.PrintGalaxyMap();
galaxyMapPointer.Print();
}
// ...
}
galaxyMap 객체를 생성하기 전에 galaxyMap.Map에 접근하여 NullReferenceException 발생함. 아직 new GalaxyMap()을 호출하지 않았으므로 galaxyMap은 null 상태이며 이후galaxyMap = new GalaxyMap();으로 galaxyMap을 먼저 초기화 하여 문제를 해결하였다.Unhandled exception. System.Collections.Generic.KeyNotFoundException: The given key 'Cockpit' was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at OOPConsoleProject.Game.ChangeScene(String sceneName)
at OOPConsoleProject.Scenes.ShipScene.Result()
// ShipScene.cs
public override void Result()
{
var playerPos = (player.position.x, player.position.y);
if (ship.Room.TryGetValue(playerPos, out ShipRoomLocation room))
{
switch (room)
{
case ShipRoomLocation.Cockpit:
Game.ChangeScene("Cockpit"); // sceneDic에 아직 등록하지 않은 키
break;
case ShipRoomLocation.AddonBay:
Game.ChangeScene("AddonBay");
break;
}
}
}
// Game.cs
public static void Start()
{
sceneDic = new Dictionary<string, BaseScene>();
sceneDic.Add("Title", new TitleScene());
sceneDic.Add("Ship", new ShipScene());
}
"Cockpit"키를 sceneDic에 등록하지 않고 ChangeScene("Cockpit")을 호출하여 KeyNotFoundException 발생함. 이후 sceneDic.Add("Cockpit", new CockpitScene());으로 해결하였다.#######
# # # #
# #
#A P C#
연료: ■■■■■■□□□□□□□□□
산소: ■■■■■■□□□□□□□□□
#######
public override void Render()
{
Console.Clear();
ship.PrintMap();
player.Print();
Console.WriteLine(); // 출력 위치 지정 X
ResourceManager.PrintFuel();
Console.WriteLine();
ResourceManager.PrintOxygen();
}
Console.WriteLine()으로 PrintFuel();, PrintOxygen(); 등의 UI를 출력하였을 때 현재 커서 위치를 기준으로 출력되어 Console.SetCursorPosition(0, 9);으로 수동 지정하여 해결하였다.Encounter종류 구현 및 랜덤으로 조우하게 하는 방법 찾기