浏览代码

Code formatting and tweaks

/main
Ciro Continisio 3 年前
当前提交
27ebfa55
共有 10 个文件被更改,包括 113 次插入155 次删除
  1. 5
      UOP1_Project/Assets/Scripts/Cutscenes/CutsceneSceneLoader.cs
  2. 15
      UOP1_Project/Assets/Scripts/Cutscenes/CutsceneTrigger.cs
  3. 14
      UOP1_Project/Assets/Scripts/Dialogues/DialogueDataSO.cs
  4. 44
      UOP1_Project/Assets/Scripts/Gameplay/GameManager.cs
  5. 5
      UOP1_Project/Assets/Scripts/Gameplay/GameStateSO.cs
  6. 77
      UOP1_Project/Assets/Scripts/Quests/QuestManagerSO.cs
  7. 50
      UOP1_Project/Assets/Scripts/UI/UICreditsRoller.cs
  8. 22
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsInSpecificGameStateSO.cs
  9. 36
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsInParticualGameStateSO.cs
  10. 0
      /UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsInSpecificGameStateSO.cs.meta

5
UOP1_Project/Assets/Scripts/Cutscenes/CutsceneSceneLoader.cs


using System.Collections;
using System.Collections.Generic;
//Used to load a location from a custscene
//Used to load a location or menu from a cutscene
public void LoadScene()
{
_sceneLoadChannel.RaiseEvent(_sceneToLoad, false, true);

15
UOP1_Project/Assets/Scripts/Cutscenes/CutsceneTrigger.cs


/// <summary>
/// Class to trigger a cutscene.
/// </summary>
public class CutsceneTrigger : MonoBehaviour
{
private PlayableDirector _playableDirector = default;

//Check if we are playing a new game, we should play the intro cutscene
if (_questManager)
{
if (_questManager.isNewGame())
if (_questManager.IsNewGame())
{
_playableDirector.Play();
}

private void OnEnable()
{
_playSpeceficCutscene.OnEventRaised += PlaySpeceficCutscene;
_playSpeceficCutscene.OnEventRaised += PlaySpecificCutscene;
_playSpeceficCutscene.OnEventRaised -= PlaySpeceficCutscene;
_playSpeceficCutscene.OnEventRaised -= PlaySpecificCutscene;
void PlaySpeceficCutscene()
void PlaySpecificCutscene()
{
if (_playCutsceneEvent != null)
_playCutsceneEvent.RaiseEvent(_playableDirector);

{
//Fake event raise to test quicker
_playSpeceficCutscene.RaiseEvent();
//if (_playCutsceneEvent != null)
// _playCutsceneEvent.RaiseEvent(_playableDirector);
//if (_playOnce)
// Destroy(this);
}
}

14
UOP1_Project/Assets/Scripts/Dialogues/DialogueDataSO.cs


using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Timeline;
using UnityEngine.Localization.Settings;
using UnityEngine.Localization.Metadata;
#if UNITY_EDITOR
using UnityEngine.Localization.Settings;
using UnityEngine.Localization.Metadata;
#endif
public enum DialogueType
{

[SerializeField] private VoidEventChannelSO _endOfDialogueEvent = default;
public VoidEventChannelSO EndOfDialogueEvent => _endOfDialogueEvent;
public List<Line> _Lines => _lines;
public DialogueType DialogueType
{
get { return _dialogueType; }

//_actor = newActor;
}
public DialogueDataSO()
{
}

_dialogueType = dialogue.DialogueType;
*/
}
public void FinishDialogue()
{
if (EndOfDialogueEvent != null)

_lines.Add(_dialogueLine);
} while (_dialogueLine.TextList != null);
/// <summary>
/// This function is only useful for the Questline Tool in Editor to remove a Questline

44
UOP1_Project/Assets/Scripts/Gameplay/GameManager.cs


public class GameManager : MonoBehaviour
{
[SerializeField]
private QuestManagerSO _questManager = default;
[SerializeField]
private GameStateSO _gameState = default;
[SerializeField]
private VoidEventChannelSO _addRockCandyRecipeEvent = default;
[SerializeField]
private VoidEventChannelSO _cerisesMemoryEvent = default;
[SerializeField]
private VoidEventChannelSO _decideOnDishesEvent = default;
[SerializeField] private QuestManagerSO _questManager = default;
[SerializeField] private GameStateSO _gameState = default;
[SerializeField]
private ItemSO _rockCandyRecipe = default;
[SerializeField]
private ItemSO _sweetDoughRecipe = default;
[SerializeField]
private ItemSO[] _finalRecipes = default;
[SerializeField] private VoidEventChannelSO _addRockCandyRecipeEvent = default;
[SerializeField] private VoidEventChannelSO _cerisesMemoryEvent = default;
[SerializeField] private VoidEventChannelSO _decideOnDishesEvent = default;
[SerializeField]
private InventorySO _inventory = default;
[SerializeField] private ItemSO _rockCandyRecipe = default;
[SerializeField] private ItemSO _sweetDoughRecipe = default;
[SerializeField] private ItemSO[] _finalRecipes = default;
[SerializeField] private InventorySO _inventory = default;
}
}
private void OnEnable()
{
_addRockCandyRecipeEvent.OnEventRaised += AddRockCandyRecipe;

void AddFinalRecipes()
{
foreach (ItemSO item in _finalRecipes)

// Start is called before the first frame update
}

5
UOP1_Project/Assets/Scripts/Gameplay/GameStateSO.cs


[SerializeField] BoolEventChannelSO _setAggroEvent = default;
public GameState CurrentGameState => _currentGameState;
List<Transform> _enemiesInCombat = new List<Transform>();
public void ChangeStateToCombat(Transform enemy)
{
if (!_enemiesInCombat.Exists(o => o == enemy))

UpdateGameState(GameState.Combat);
}
public void ChangeStateFromCombat(Transform enemy)
{

}
}
}
public void UpdateGameState(GameState newGameState)
{

_currentGameState = newGameState;
}
}
public void ResetToPreviousGameState()
{
if (_previousGameState != CurrentGameState)

77
UOP1_Project/Assets/Scripts/Quests/QuestManagerSO.cs


using System.Collections;
using System.Collections.Generic;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Serialization;

[Header("Data")]
[SerializeField] private List<QuestlineSO> _questlines = default;
[SerializeField] private InventorySO _inventory = default;
[SerializeField] private ItemSO _winningItem = default;
[SerializeField] private ItemSO _losingItem = default;

[Header("Broadcasting on channels")]
[SerializeField] private VoidEventChannelSO _playCompletionDialogueEvent = default;
[SerializeField] private VoidEventChannelSO _playIncompleteDialogueEvent = default;
private QuestSO _currentQuest = null;
private QuestlineSO _currentQuestline;
private StepSO _currentStep;

public void OnDisable()
{
_continueWithStepEvent.OnEventRaised -= CheckStepValidity;

}
void StartQuestline()
{
if (_questlines != null)

if (_currentQuestlineIndex >= 0)
_currentQuestline = _questlines.Find(o => !o.IsDone);
}
}
}
bool CheckQuestlineForQuestWithActor(ActorSO actorToCheckWith)
{
if (_currentQuest == null)//check if there's a current quest

{
StartQuest(actor);
}
}
if (HasStep(actor))

if (isValid)
{
return _currentStep.CompleteDialogue;

return _currentStep.IncompleteDialogue;
}
//When Interacting with a character, we ask the quest manager if there's a quest that starts with a step with a certain character
void StartQuest(ActorSO actorToCheckWith)
{

StartStep();
}
}
void MakeWinningChoice()
{
//check if has sweet recipe

}
void MakeLosingChoice()
{
_currentStep.Item = _losingItem;

void StartStep()
{
if (_currentQuest.Steps != null)

}
}
void CheckStepValidity()

switch (_currentStep.Type)
{
case StepType.CheckItem:
if (_inventory.Contains(_currentStep.Item))
{
//Trigger win dialogue

_playIncompleteDialogueEvent.RaiseEvent();
}
break;
case StepType.GiveItem:
if (_inventory.Contains(_currentStep.Item))
{

EndStep();
}
break;
void EndDialogue(int dialogueType)
{

break;
default:
break;
if (_currentQuest.Steps.Count > _currentStepIndex)
if (_currentQuest.Steps.Count > _currentStepIndex)
{
_currentQuest.Steps[_currentStepIndex].FinishStep();
saveSystem.SaveDataToDisk();
if (_currentQuest.Steps.Count > _currentStepIndex + 1)
_currentQuest.Steps[_currentStepIndex].FinishStep();
saveSystem.SaveDataToDisk();
if (_currentQuest.Steps.Count > _currentStepIndex + 1)
{
_currentStepIndex++;
StartStep();
_currentStepIndex++;
StartStep();
}
else
{
EndQuest();
}
else
{
EndQuest();
}
}
void EndQuest()
{

}
void EndQuestline()
{
if (_questlines != null)

}
public List<string> GetFinishedQuestlineItemsGUIds()
{
List<string> finishedItemsGUIds = new List<string>();

}
return finishedItemsGUIds;
}
public void SetFinishedQuestlineItemsFromSave(List<string> finishedItemsGUIds)
{

//Start Questline with the new data
StartQuestline();
}
foreach (var questline in _questlines)
{
questline.IsDone = false;

//Start Questline with the new data
StartQuestline();
}
public bool isNewGame()
public bool IsNewGame()
{
bool isNew = false;
isNew = (!_questlines.Exists(o => o.Quests.Exists(j => j.Steps.Exists(k => k.IsDone))));

50
UOP1_Project/Assets/Scripts/UI/UICreditsRoller.cs


using UnityEngine;
using TMPro;
using UnityEngine.Serialization;
using System.Collections.Generic;
using System.Collections;
[SerializeField, Tooltip("Set speed of a rolling effect")] private float _speedPreset = 100f;//normal rolling speed
[FormerlySerializedAs("speed")]
[SerializeField, Tooltip("This is actuall speed of rolling")] private float _speed = 100f;//actual speed of rolling
[SerializeField, Tooltip("Set speed of a rolling effect")] private float _speedPreset = 100f; //normal rolling speed
[SerializeField, Tooltip("This is actuall speed of rolling")] private float _speed = 100f; //actual speed of rolling
[FormerlySerializedAs("inputReader")]
[FormerlySerializedAs("textCredits")]
[FormerlySerializedAs("mask")]
private float expectedFinishingPoint;
private float _expectedFinishingPoint;
// Start is called before the first frame update
Invoke("offsetStart", 0.01f);//This offset is needed to get true informations about rectangle and his mask
StartCoroutine(InitialOffset()); //This offset is needed to get true informations about rectangle and his mask
// Update is called once per frame
if (_textCredits.anchoredPosition.y < expectedFinishingPoint)
if (_textCredits.anchoredPosition.y < _expectedFinishingPoint)
else if (expectedFinishingPoint != 0)//this happend when rolling reach to end
else if (_expectedFinishingPoint != 0) //this happend when rolling reach to end
private void offsetStart()
private IEnumerator InitialOffset()
yield return new WaitForSecondsRealtime(0.02f);
expectedFinishingPoint = (_textCredits.rect.height + _mask.rect.height) / 2;
_expectedFinishingPoint = (_textCredits.rect.height + _mask.rect.height) / 2;
}
}
if (direction.y == 0f)//no horizontal movment
if (direction.y == 0f) //no horizontal movment
else if (direction.y > 0f)//upward movment
else if (direction.y > 0f) //upward movment
else//downward movment
else //downward movment
{ //reset postion of an element
{
//reset postion of an element
_textCredits.anchoredPosition = new Vector2(_textCredits.anchoredPosition.x, -((_textCredits.rect.height + _mask.rect.height) / 2));
}
else

}
}

22
UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsInSpecificGameStateSO.cs


using UnityEngine;
using UOP1.StateMachine;
using UOP1.StateMachine.ScriptableObjects;
[CreateAssetMenu(menuName = "State Machines/Conditions/Is In Particular GameState")]
public class IsInSpecificGameStateSO : StateConditionSO<IsInSpecificGameStateCondition>
{
[UnityEngine.Serialization.FormerlySerializedAs("_currentGameState")] public GameState gameStateToCheck;
[UnityEngine.Serialization.FormerlySerializedAs("gameStateManager")] public GameStateSO gameStateSO;
protected override Condition CreateCondition() => new IsInSpecificGameStateCondition();
}
public class IsInSpecificGameStateCondition : Condition
{
private IsInSpecificGameStateSO _originSO => (IsInSpecificGameStateSO)base.OriginSO; // The SO this Condition spawned from
protected override bool Statement()
{
return _originSO.gameStateToCheck == _originSO.gameStateSO.CurrentGameState;
}
}

36
UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsInParticualGameStateSO.cs


using UnityEngine;
using UOP1.StateMachine;
using UOP1.StateMachine.ScriptableObjects;
[CreateAssetMenu(menuName = "State Machines/Conditions/Is In Particular GameState")]
public class IsInParticualGameStateSO : StateConditionSO<IsInParticualGameStateCondition>
{
public GameState _currentGameState;
public GameStateSO _gameStateManager;
protected override Condition CreateCondition() => new IsInParticualGameStateCondition();
}
public class IsInParticualGameStateCondition : Condition
{
private IsInParticualGameStateSO _originSO => (IsInParticualGameStateSO)base.OriginSO; // The SO this Condition spawned from
public override void Awake(StateMachine stateMachine)
{
}
protected override bool Statement()
{
return _originSO._currentGameState == _originSO._gameStateManager.CurrentGameState;
}
private void EventReceived()
{
}
public override void OnStateExit()
{
}
}

/UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsInParticualGameStateSO.cs.meta → /UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsInSpecificGameStateSO.cs.meta

正在加载...
取消
保存