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

김용준·2024년 4월 26일
0

내일배움캠프

목록 보기
5/47

Goals

  1. Implement additonal features on the project
  2. KPT review of this week

Additional features on project

Change the color of text on console in C#

Previous attempt is just to change the size and style of font on console not change its color. The text color can be changed with following script

Console.ForegroundColor = ConsoleColor.Yellow; // assign the color to the `Text`
Console.BackgroundColor = ConsoleColor.White; // assign the background color of the `Text`
Console.WriteLine("Text");
Console.ResetColor(); // if you do not write this, the whole text and its BG changed to the `Text` color(Yellow) and BG(white).

Hierachy system for each item type

Reminding the concept of the game, the matryoshka, I aims to add some component to the Item class by applying the bit calculator.

public class Item
{
	... // private variables for other feature
    // the value should be set to binary for bit calculation
    int fHierachy; // the level which represent the size of item
    ItemType fType; // to distinguish the weapon, armor, else
    int fRank; // the rarity of item (Normal,Rare,Unique,Legend)
    
    ... // Functions to `Get`, `Set` the variables
}
public enum ItemType
{
	None, Weapon, Armor, Ring
}

Bringing these updates, the Player.cs have to be modifed to get and set the hierachy and rank

public class Player
{
	... // variables for other feature
    int fWeaponLvl;
    int fArmorLvl;
    int fRingLvl;
    
    ... // Functions
    public Player(/*arguments*/)
    {
    	... // initialization
    	foreach(var item in list_items)
    	{
    		if(item.GetType() == ItemType.Weapon && (fWeaponLvl & item.GetHierachy() != 0)
        		fWeaponLvl += item.GetHierachy();
        	if(item.GetType() == ItemType.Armor && (fArmorLvl & item.GetHierachy() != 0)
        		fArmorLvl += item.GetHierachy();
        	if(item.GetType() == ItemType.Ring && (fRingLvl & item.GetHierachy() != 0)
        		fRingLvl += item.GetHierachy();
    	}
    }
    
    public void Equip(int idx) // For the `UnEquip()` the operator `+=` should be changed to `-=`
    {
    	ItemType type = list_items[idx].GetItemType();
        switch(type)
        {
        	case ItemType.Weapon:
            	fWeaponLvl += list_items[idx].GetHierachy();
            	break;
            case ItemType.Armor:
            	fArmorLvl += list_items[idx].GetHierachy();
            	break;
            case ItemType.Ring:
            	fRingLvl += list_items[idx].GetHierachy();
            	break;
        }
    }
}

To make the character similar to matryoshka, the player cannot access the inner size item when the bigger size item was equipped. These feature can be made by bit calculation.

public class Scene
{
	... // scripts before equip/unequip session
    if(...)
    	...
    else if ((Player.instance.GetHierachyLvl(ItemType.Weapon) >> (ToMaxBit(item.GetHierachy())) != 0)
    // imagine the player have weapon (4 for its hierachy)
    // when the player try to equip weapon that have smaller or same size(2,8),
    // the left term of bit calculation can be expressed like ( 4>>((1),(3)) =1(cannot equip),0(can equip))
    {
    	Console.WriteLine("Cannot equip due to the size");
    }
    ...
    else if()
    	Player.instance.Equip(idx);
    else if()
    	Player.instance.UnEquip(idx);
    
    int ToMaxBit(int a)
    {
    	... // find the maximum number of bit
    }
}

KPT review

  1. Keep:

    • Enhance the skill by trying new grammar which didn't used previous
    • Experience could be stacked to solve the problem by searching and sharing
    • Reduced the time to solve the problem by visiting tutor. also the experience of similar problem could be shared
  2. Problem:

    • Due to unorganized the project, I spend more times at the repeating and checking the status
    • Since the project is assigned personal, team sharing wasn't done well
    • Because I invest lots of time to implement features, i didn't give good feedback to our team member.
  3. Try:

    • Make the process clear to reduce the repeated time
    • Manage time to improve the result of team
    • Ask to team member the status more often and share my result clearly
profile
꿈이큰개발자지망생

0개의 댓글