[내일 배움 캠프 Unity 4기] W3D1 04.29 TIL

김용준·2024년 4월 29일
0

내일배움캠프

목록 보기
6/47

Goals

  • Organize team project (role, base code, conventions & game flow)
  • Trim the project on last week

Team project from the previous project

Github
The upcoming team project is determined to add new features based on the 'Console Text RPG' on last week. Before to implement the feature, we have to discuss the details. Each team member have the different results. Among them, my result is elected with the good classification of the script. Even the result has developed to my own flavor, this is good for using 'Git'. Trimming some features, I made the base of team project pretty well. The game contains these features.

  1. Player could be only one from the game. So I made it to the singleton.
  2. The Items owned by Player has the feature of hierachy, which can be affected to the Equipable items.
  3. Shop also sell the items which is loaded from the ItemList.csv file
  4. The move to the other scene is determined with Choice method. The attached script has complex condition on while, which will be addressed on the Q & A session
        public static int Choice(int min, int max, int cutmin = -1, int cutmax = -1)
        {
            // 1 3 (-1 -1 ) 4
            string in_str = Console.ReadLine();
            int choice;
            while(!int.TryParse(in_str, out choice) || !(choice >= min && choice <=max) || ((cutmin==-1&&cutmax==-1)?false:(choice >= cutmin && choice <= cutmax)))
            {
                if(cutmin == -1 && cutmax == -1)
                {
                    Console.SetCursorPosition(5, 22);
                    Console.WriteLine("원하시는 행동을 입력해주세요 ({0} ~ {1}중에서 골라주세요)",min, max);
                }
                else
                {
                    Console.SetCursorPosition(5, 22);
                    Console.WriteLine("{0} ~ {1} 제외한 {2} ~ {3}중에서 골라주세요,",cutmin,cutmax,min, max);
                }
                Console.SetCursorPosition(5, 23);
                Console.Write(">>");
                Console.SetCursorPosition(8, 23);
                in_str = Console.ReadLine();
            }
            return choice;
        }

With the base on the project, we discussed each role of the project. In order to avoid the confilcts when merging the result via git, the classification was done with the files.

  1. Battle system (Battle.cs)
  2. Database of monster (MonsterList.csv & Monster.cs)
  3. Quest and additional items (ItemList.csv,Item.cs & Quest.cs)
  4. Job and skills for character (Player.cs & Skill.cs)

After the decision of role, we have to build the flow of the game. Since the game is based on the Console Text RPG of last project, we simply made game flow chart and properties for the battle like below figure.


Q & A

Q. When the condition is written like the below script, it doesn't work well. What is the error and How to solve it?

while(false || false || true?false:true)
{
...
}

A. The error could be occur from the Ternary operator. When the script is running, the compiler understood this like below flow

while( (false || false || true?)false:true)
{
...
}

If you want to make the script to work normally, you should wrap up the ternary condition like (false || (true?false:true))

profile
꿈이큰개발자지망생

0개의 댓글