浏览代码

Merge branch 'QuestSystem' of https://github.com/UnityTechnologies/open-project-1 into QuestSystem

/main
uChema 3 年前
当前提交
2f8fcd7c
共有 6 个文件被更改,包括 61 次插入61 次删除
  1. 14
      UOP1_Project/Assets/Scripts/Localization/LocalizeComponent_TMProFont.cs
  2. 4
      UOP1_Project/Assets/Scripts/Localization/LocalizeTMProFontEvent.cs
  3. 16
      UOP1_Project/Assets/Scripts/QuestManager.cs
  4. 34
      UOP1_Project/Assets/Scripts/Quests/QuestAncorSO.cs
  5. 52
      UOP1_Project/Assets/Scripts/Quests/StepController.cs
  6. 2
      UOP1_Project/Assets/Scripts/UI/UIDialogueChoiceFiller.cs

14
UOP1_Project/Assets/Scripts/Localization/LocalizeComponent_TMProFont.cs


}
public static MonoBehaviour SetupForStringLocalization(TextMeshProUGUI target)
{
//Avoid adding the component multiple times
{
//Avoid adding the component multiple times
if (target.GetComponent<LocalizeStringEvent>() != null)
return null;

}
public static MonoBehaviour SetupForFontLocalization(TextMeshProUGUI target)
{
//Avoid adding the component multiple times
{
//Avoid adding the component multiple times
if (target.GetComponent<LocalizeTMProFontEvent>() != null)
return null;

Events.UnityEventTools.AddPersistentListener(comp.OnUpdateAsset, methodDelegate);
//Find font table and set it up automatically
Events.UnityEventTools.AddPersistentListener(comp.OnUpdateAsset, methodDelegate);
//Find font table and set it up automatically
var collections = LocalizationEditorSettings.GetAssetTableCollections();
foreach (var tableCollection in collections)
{

4
UOP1_Project/Assets/Scripts/Localization/LocalizeTMProFontEvent.cs


using UnityEngine.Events;
namespace UnityEngine.Localization.Components
{
{
/// <summary>
/// Component that can be used to Localize a TMP_FontAsset asset.
/// </summary>

}
[Serializable]
public class LocalizedTMProFont : LocalizedAsset<TMP_FontAsset>{ }
public class LocalizedTMProFont : LocalizedAsset<TMP_FontAsset> { }
[Serializable]
public class UnityEventFont : UnityEvent<TMP_FontAsset> { }

16
UOP1_Project/Assets/Scripts/QuestManager.cs


[SerializeField] private QuestAncorSO _questAnchor = default;
// Start is called before the first frame update
void Start()
{
_questAnchor.StartGame();
}
{
_questAnchor.StartGame();
}
// Update is called once per frame
void Update()
{
}
// Update is called once per frame
void Update()
{
}
}

34
UOP1_Project/Assets/Scripts/Quests/QuestAncorSO.cs


[SerializeField] private ItemEventChannelSO _giveItemEvent = default;
[SerializeField] private ItemEventChannelSO _rewardItemEvent = default;
private QuestSO _currentQuest=null;
private QuestSO _currentQuest = null;
public void StartGame()
public void StartGame()
{//Add code for saved information
if (_checkStepValidityEvent != null)
{

}
void StartQuestline()
{
if (_questlines != null)
if (_questlines != null)
{
if (_questlines.Exists(o => !o.IsDone))
{

}
bool hasStep(ActorSO actorToCheckWith)
{
if(_currentStep!=null)
if (_currentStep != null)
if(_currentStep.Actor== actorToCheckWith)
if (_currentStep.Actor == actorToCheckWith)
return true;
return true;
return false;
return false;
}
bool CheckQuestlineForQuestWithActor(ActorSO actorToCheckWith)

if (_currentQuestline != null)
{
return _currentQuestline.Quests.Exists(o => !o.IsDone && o.Steps != null && o.Steps[0].Actor == actorToCheckWith);
}

public DialogueDataSO InteractWithCharacter(ActorSO actor, bool isCheckValidity, bool isValid)
{
Debug.Log("current quest"+ _currentQuest);
Debug.Log("current quest" + _currentQuest);
if (_currentQuest == null)
{
if (CheckQuestlineForQuestWithActor(actor))

}
else
{
return _currentStep.DialogueBeforeStep;
return _currentStep.DialogueBeforeStep;
}
}

}
}
void CheckStepValidity()
void CheckStepValidity()
{
if (_currentStep != null)

case stepType.checkItem:
if (_inventory.Contains(_currentStep.Item))
{
_inventory.Contains(_currentStep.Item);

case stepType.rewardItem:
_rewardItemEvent.RaiseEvent(_currentStep.Item);
//no dialogue is needed after Reward Item
if(_currentStep.CompleteDialogue !=null)
if (_currentStep.CompleteDialogue != null)
{
_completeDialogueEvent.RaiseEvent();
}

}
void EndStep()
{
_currentStep = null;
if (_currentQuest != null)

}
else
{
{
EndQuest();
EndQuest();
}
}

52
UOP1_Project/Assets/Scripts/Quests/StepController.cs


private void Start()
{
if (_defaultDialogue != null)
{
_currentDialogue = _defaultDialogue;
StartDialogue();
}
if (_defaultDialogue != null)
{
_currentDialogue = _defaultDialogue;
StartDialogue();
}
DialogueDataSO displayDialogue =_questAnchor.InteractWithCharacter(_actor, false, false);
DialogueDataSO displayDialogue = _questAnchor.InteractWithCharacter(_actor, false, false);
if (displayDialogue !=null)
{
_currentDialogue = displayDialogue;
StartDialogue();
}
else
{
PlayDefaultDialogue();
}
if (displayDialogue != null)
{
_currentDialogue = displayDialogue;
StartDialogue();
}
else
{
PlayDefaultDialogue();
}
void StartDialogue()
{
if (_startDialogueEvent != null)

}
}
void PlayWinDialogue()

}
}
}

2
UOP1_Project/Assets/Scripts/UI/UIDialogueChoiceFiller.cs


}
public void ButtonClicked()
{
{
if (_makeAChoiceEvent != null)
_makeAChoiceEvent.RaiseEvent(currentChoice);
}
正在加载...
取消
保存