퀘스트 시스템을 만들려고합니다. QuestCreator, Quest 및 인터페이스 (TalkObjective, LocationObjective 등)를 상속하는 여러 객관적인 클래스가 있습니다.여러 유형의 데이터 저장
퀘스트 클래스의 생성자에서 List<IObjective>
과 같은 목록을 생성했습니다. 작동하지 않았습니다.
그런 다음 모든 유형의 목록을 보유 할 클래스를 만들었습니다. 그러나 나는 나의 목표를 주문하는 능력을 잃어 버렸다.
내 질문은; 거기에 더 좋은 방법/디자인을 할 수 있습니까?
[편집]
나는 그것을 충분히 설명하지 않았다 미안 해요. 코드를 변경 한 이후로 여기에 게시 할 수 없습니다. 같은 코드를 만들려고했으나 이번에는 코드가 오류를주지 않습니다. 그래서 나는 스스로 문제를 해결한다.
완료/포기되지 않은 자습서를 사용하고있었습니다. Here is the link to github
필자는 추상 클래스를 사용하여 내 Item/Inventory 시스템을 구축했으며 이것이 내 마음에 처음으로 나타났습니다. 그러나 나의 의도는 튜토리얼의 제작자가 설계 한 방법으로이 퀘스트 시스템을 만들어서 그의 길을 배울 수있게하는 것이 었습니다.
일반적인 목적으로 사용하는 인터페이스가있는 다른 목표 클래스의 개체를 목록에 넣기를 원했습니다. 모든 게임 프로그래밍에 먼저
public class QuestCreator : MonoBehaviour {
#region fields
private List<IQuestObjective> objectives;
private GameObject itemManager;
private ItemDatabase itemdb;
private Location location;
private Quest quest;
//For Saving Quest
private Quest_data quests;
#endregion
void Update()
{
//Just for the test purpose
if (Input.GetKeyDown (KeyCode.E))
{
itemManager = GameObject.Find ("GameManager");
itemdb = itemManager.GetComponent<ItemDatabase>();
Item item = new Item();
Item item2 = new Item();
item = itemdb.weapon_database[0];
item2 = itemdb.weapon_database [1];
CollectionObjective collectionObjective = new CollectionObjective ("Find", 3, item, "Find this precious item");
CollectionObjective collectionObjective2 = new CollectionObjective ("Find", 1, item2, "Find Sword of Warrior from Dark Passage");
LocationObjective locationObjective = new LocationObjective ("Go to Green Valley", "Go to " + location, location, false);
objectives = new List<IQuestObjective>();
objectives.Add(collectionObjective);
objectives.Add (collectionObjective2);
objectives.Add (locationObjective);
QuestText questText = new QuestText();
QuestIdentifier questIdentifier = new QuestIdentifier();
questText.Title = "Finding Sword of Warrior";
questText.DescriptionSummary = "Summary...";
questText.Hint = "Hint...";
questIdentifier.QuestID = 1;
questIdentifier.SourceID = 1;
quest = new Quest (questIdentifier, questText, objectives);
Debug.Log (quest.Objectives[1].Description);
Debug.Log (quest.Objectives.Count);
}
}
몇 가지 코드를 표시하도록 질문을 수정, 또한, 당신이 "작동하지 않는"무슨 뜻인지 설명해주십시오. –
리스트으로 올바른 방향으로 가고있는 것 같습니다. 그러나 Zohar가 저에게 말씀 드렸듯이, 귀하의 코드를 보여주고 수신 한 오류를 알려주십시오. –
Ben