Menu
CoddyTech

복습: 전리품 테이블

Coddy Unity 여정의 Unity 게임 아키텍처 섹션에 포함된 레슨. 64개 중 21번째.

challenge icon

챌린지

쉬움

장면에 맞게 상자의 전리품 테이블을 채우세요.

  1. public enum Rarity { Common, Rare, Epic, Legendary }를 선언하고, [System.Serializable] 클래스 LootEntry를 만들어 공개 string itemName, GameObject prefab, Rarity rarity를 포함하세요.
  2. 상자에 public List<LootEntry> table;을 추가하세요.
  3. public int WeightOf(Rarity rarity)를 작성하세요. Common은 10, Rare는 4, Epic은 2, Legendary는 1입니다. public int TotalWeight()는 table의 값을 더합니다.

‘플레이’를 누르세요. 아직 아무것도 떨어지지 않습니다. 그런 다음 ‘확인’을 누르세요.

직접 해보기

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class LootChest : MonoBehaviour
{
}

Unity 게임 아키텍처의 모든 레슨

직접 연습해 보세요: Unity 플레이그라운드