浏览代码

[Bot] Automated dotnet-format update

/main
itsLevi0sa 4 年前
当前提交
5a4b5e30
共有 25 个文件被更改,包括 529 次插入527 次删除
  1. 4
      UOP1_Project/Assets/Scripts/Characters/Protagonist.cs
  2. 2
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/DropRewardSO.cs
  3. 10
      UOP1_Project/Assets/Scripts/Cutscenes/CutsceneManager.cs
  4. 30
      UOP1_Project/Assets/Scripts/Dialogues/DialogueManager.cs
  5. 40
      UOP1_Project/Assets/Scripts/Gameplay/GameManager.cs
  6. 38
      UOP1_Project/Assets/Scripts/Gameplay/GameStateSO.cs
  7. 653
      UOP1_Project/Assets/Scripts/Input/GameInput.cs
  8. 4
      UOP1_Project/Assets/Scripts/Input/InputReader.cs
  9. 10
      UOP1_Project/Assets/Scripts/Inventory/CollectableItem.cs
  10. 12
      UOP1_Project/Assets/Scripts/Inventory/InventoryItemFiller.cs
  11. 20
      UOP1_Project/Assets/Scripts/Inventory/InventoryListFiller.cs
  12. 52
      UOP1_Project/Assets/Scripts/Inventory/InventoryManager.cs
  13. 48
      UOP1_Project/Assets/Scripts/Inventory/UIInventoryManager.cs
  14. 9
      UOP1_Project/Assets/Scripts/Quests/QuestManagerSO.cs
  15. 12
      UOP1_Project/Assets/Scripts/Quests/StepController.cs
  16. 2
      UOP1_Project/Assets/Scripts/SaveSystem/SaveSystem.cs
  17. 4
      UOP1_Project/Assets/Scripts/SceneManagement/SceneLoader.cs
  18. 18
      UOP1_Project/Assets/Scripts/SceneManagement/StartGame.cs
  19. 12
      UOP1_Project/Assets/Scripts/SpawnSystem.cs
  20. 12
      UOP1_Project/Assets/Scripts/UI/InventoryButtonFiller.cs
  21. 4
      UOP1_Project/Assets/Scripts/UI/UIButtonPromptSetter.cs
  22. 6
      UOP1_Project/Assets/Scripts/UI/UIDialogueManager.cs
  23. 26
      UOP1_Project/Assets/Scripts/UI/UIHealthBarManager.cs
  24. 10
      UOP1_Project/Assets/Scripts/UI/UIInteractionItemFiller.cs
  25. 18
      UOP1_Project/Assets/Scripts/UI/UIManager.cs

4
UOP1_Project/Assets/Scripts/Characters/Protagonist.cs


{
// This is used to set the speed to the maximum if holding the Shift key,
// to allow keyboard players to "run"
if(isRunning)
if (isRunning)
targetSpeed = 1f;
if (attackInput)

private void OnStartedRunning() => isRunning = true;
private void OnStartedAttack() => attackInput = true;
// Triggered from Animation Event

2
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/DropRewardSO.cs


position + itemPrefab.transform.localPosition +
_dropRewardConfig.ScatteringDistance * (Mathf.Cos(randAngle) * Vector3.forward + Mathf.Sin(randAngle) * Vector3.right),
Quaternion.identity);
collectibleItem.GetComponent<CollectableItem>().AnimateItem();
collectibleItem.GetComponent<CollectableItem>().AnimateItem();
}
}

10
UOP1_Project/Assets/Scripts/Cutscenes/CutsceneManager.cs


}
private void Start()
{
_playCutsceneEvent.OnEventRaised += PlayCutscene;
_playDialogueEvent.OnEventRaised += PlayDialogueFromClip;
_pauseTimelineEvent.OnEventRaised += PauseTimeline;
_playCutsceneEvent.OnEventRaised += PlayCutscene;
_playDialogueEvent.OnEventRaised += PlayDialogueFromClip;
_pauseTimelineEvent.OnEventRaised += PauseTimeline;
_gameState.UpdateGameState(GameState.Cutscene);
_gameState.UpdateGameState(GameState.Cutscene);
_activePlayableDirector = activePlayableDirector;
_isPaused = false;

void CutsceneEnded()
{
_gameState.ResetToPreviousGameState();
_gameState.ResetToPreviousGameState();
if (_activePlayableDirector != null)
_activePlayableDirector.stopped -= HandleDirectorStopped;

30
UOP1_Project/Assets/Scripts/Dialogues/DialogueManager.cs


private void Start()
{
_startDialogue.OnEventRaised += DisplayDialogueData;
_startDialogue.OnEventRaised += DisplayDialogueData;
}
/// <summary>

public void DisplayDialogueData(DialogueDataSO dialogueDataSO)
{
if(_gameState.CurrentGameState != GameState.Cutscene)
_gameState.UpdateGameState(GameState.Dialogue);
if (_gameState.CurrentGameState != GameState.Cutscene)
_gameState.UpdateGameState(GameState.Dialogue);
BeginDialogueData(dialogueDataSO);
DisplayDialogueLine(_currentDialogue.DialogueLines[_counter], dialogueDataSO.Actor);
}

/// <param name="dialogueLine"></param>
public void DisplayDialogueLine(LocalizedString dialogueLine, ActorSO actor)
{
_openUIDialogueEvent.RaiseEvent(dialogueLine, actor);
_openUIDialogueEvent.RaiseEvent(dialogueLine, actor);
}
private void OnAdvance()

private void DisplayChoices(List<Choice> choices)
{
_inputReader.advanceDialogueEvent -= OnAdvance;
_makeDialogueChoiceEvent.OnEventRaised += MakeDialogueChoice;
_showChoicesUIEvent.RaiseEvent(choices);
_makeDialogueChoiceEvent.OnEventRaised += MakeDialogueChoice;
_showChoicesUIEvent.RaiseEvent(choices);
_makeDialogueChoiceEvent.OnEventRaised -= MakeDialogueChoice;
_makeDialogueChoiceEvent.OnEventRaised -= MakeDialogueChoice;
if (choice.ActionType == ChoiceActionType.continueWithStep)
{
if (_continueWithStep != null)

}
public void DialogueEndedAndCloseDialogueUI()
{
_gameState.ResetToPreviousGameState();
_gameState.ResetToPreviousGameState();
_inputReader.advanceDialogueEvent -= OnAdvance;
_inputReader.EnableGameplayInput();

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


public class GameManager : MonoBehaviour
{
[SerializeField]
private QuestManagerSO _questManager = default;
[SerializeField]
private QuestManagerSO _questManager = default;
[SerializeField]
private GameStateSO _gameState = default;
[SerializeField]
private InputReader _inputReader = default;
[SerializeField]
private GameStateSO _gameState = default;
[SerializeField]
private InputReader _inputReader = default;
private void Start()
private void Start()
StartGame();
StartGame();
_inputReader.pauseEvent += PauseGame;
_inputReader.pauseEvent += PauseGame;
}
}
{
_gameState.UpdateGameState(GameState.Gameplay);
_questManager.StartGame();
}
public void PauseGame()
_gameState.UpdateGameState(GameState.Pause);
_gameState.UpdateGameState(GameState.Gameplay);
_questManager.StartGame();
public void UnauseGame()
{
_gameState.ResetToPreviousGameState();
}
public void PauseGame()
{
_gameState.UpdateGameState(GameState.Pause);
}
public void UnauseGame()
{
_gameState.ResetToPreviousGameState();
}
}

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


using UnityEngine;
public enum GameState
{
Gameplay,// regular state: player moves, attacks, can perform actions
Pause,// pause menu is opened, the whole game world is frozen
Inventory, //when inventory UI or cooking UI are open
Dialogue,
Cutscene,
LocationTransition,// when the character steps into LocationExit trigger, fade to black begins and control is removed from the player
Combat,//enemy is nearby and alert, player can't open Inventory or initiate dialogues, but can pause the game
Gameplay,// regular state: player moves, attacks, can perform actions
Pause,// pause menu is opened, the whole game world is frozen
Inventory, //when inventory UI or cooking UI are open
Dialogue,
Cutscene,
LocationTransition,// when the character steps into LocationExit trigger, fade to black begins and control is removed from the player
Combat,//enemy is nearby and alert, player can't open Inventory or initiate dialogues, but can pause the game
public class GameStateSO : ScriptableObject
public class GameStateSO : ScriptableObject
private GameState _currentGameState = default;
private GameState _previousGameState = default;
public GameState CurrentGameState => CurrentGameState;
private GameState _currentGameState = default;
private GameState _previousGameState = default;
public GameState CurrentGameState => CurrentGameState;
public void UpdateGameState( GameState newGameState)
public void UpdateGameState(GameState newGameState)
_previousGameState = _currentGameState;
_currentGameState = newGameState;
_previousGameState = _currentGameState;
_currentGameState = newGameState;
}
public void ResetToPreviousGameState()
{
_currentGameState = _previousGameState;
}
public void ResetToPreviousGameState()
{
_currentGameState = _previousGameState;
}
}
}

653
UOP1_Project/Assets/Scripts/Input/GameInput.cs


public class @GameInput : IInputActionCollection, IDisposable
{
public InputActionAsset asset { get; }
public @GameInput()
{
asset = InputActionAsset.FromJson(@"{
public InputActionAsset asset { get; }
public @GameInput()
{
asset = InputActionAsset.FromJson(@"{
""name"": ""GameInput"",
""maps"": [
{

}
]
}");
// Gameplay
m_Gameplay = asset.FindActionMap("Gameplay", throwIfNotFound: true);
m_Gameplay_Move = m_Gameplay.FindAction("Move", throwIfNotFound: true);
m_Gameplay_Jump = m_Gameplay.FindAction("Jump", throwIfNotFound: true);
m_Gameplay_Attack = m_Gameplay.FindAction("Attack", throwIfNotFound: true);
m_Gameplay_Interact = m_Gameplay.FindAction("Interact", throwIfNotFound: true);
m_Gameplay_Pause = m_Gameplay.FindAction("Pause", throwIfNotFound: true);
m_Gameplay_OpenInventory = m_Gameplay.FindAction("OpenInventory", throwIfNotFound: true);
m_Gameplay_RotateCamera = m_Gameplay.FindAction("RotateCamera", throwIfNotFound: true);
m_Gameplay_MouseControlCamera = m_Gameplay.FindAction("MouseControlCamera", throwIfNotFound: true);
m_Gameplay_Run = m_Gameplay.FindAction("Run", throwIfNotFound: true);
// Menus
m_Menus = asset.FindActionMap("Menus", throwIfNotFound: true);
m_Menus_MoveSelection = m_Menus.FindAction("MoveSelection", throwIfNotFound: true);
m_Menus_Confirm = m_Menus.FindAction("Confirm", throwIfNotFound: true);
m_Menus_Cancel = m_Menus.FindAction("Cancel", throwIfNotFound: true);
m_Menus_MouseMove = m_Menus.FindAction("MouseMove", throwIfNotFound: true);
m_Menus_Unpause = m_Menus.FindAction("Unpause", throwIfNotFound: true);
m_Menus_ClosePopupEvent = m_Menus.FindAction("ClosePopupEvent", throwIfNotFound: true);
m_Menus_ChangeTab = m_Menus.FindAction("ChangeTab", throwIfNotFound: true);
m_Menus_InventoryActionButton = m_Menus.FindAction("InventoryActionButton", throwIfNotFound: true);
// Dialogues
m_Dialogues = asset.FindActionMap("Dialogues", throwIfNotFound: true);
m_Dialogues_MoveSelection = m_Dialogues.FindAction("MoveSelection", throwIfNotFound: true);
m_Dialogues_AdvanceDialogue = m_Dialogues.FindAction("AdvanceDialogue", throwIfNotFound: true);
}
// Gameplay
m_Gameplay = asset.FindActionMap("Gameplay", throwIfNotFound: true);
m_Gameplay_Move = m_Gameplay.FindAction("Move", throwIfNotFound: true);
m_Gameplay_Jump = m_Gameplay.FindAction("Jump", throwIfNotFound: true);
m_Gameplay_Attack = m_Gameplay.FindAction("Attack", throwIfNotFound: true);
m_Gameplay_Interact = m_Gameplay.FindAction("Interact", throwIfNotFound: true);
m_Gameplay_Pause = m_Gameplay.FindAction("Pause", throwIfNotFound: true);
m_Gameplay_OpenInventory = m_Gameplay.FindAction("OpenInventory", throwIfNotFound: true);
m_Gameplay_RotateCamera = m_Gameplay.FindAction("RotateCamera", throwIfNotFound: true);
m_Gameplay_MouseControlCamera = m_Gameplay.FindAction("MouseControlCamera", throwIfNotFound: true);
m_Gameplay_Run = m_Gameplay.FindAction("Run", throwIfNotFound: true);
// Menus
m_Menus = asset.FindActionMap("Menus", throwIfNotFound: true);
m_Menus_MoveSelection = m_Menus.FindAction("MoveSelection", throwIfNotFound: true);
m_Menus_Confirm = m_Menus.FindAction("Confirm", throwIfNotFound: true);
m_Menus_Cancel = m_Menus.FindAction("Cancel", throwIfNotFound: true);
m_Menus_MouseMove = m_Menus.FindAction("MouseMove", throwIfNotFound: true);
m_Menus_Unpause = m_Menus.FindAction("Unpause", throwIfNotFound: true);
m_Menus_ClosePopupEvent = m_Menus.FindAction("ClosePopupEvent", throwIfNotFound: true);
m_Menus_ChangeTab = m_Menus.FindAction("ChangeTab", throwIfNotFound: true);
m_Menus_InventoryActionButton = m_Menus.FindAction("InventoryActionButton", throwIfNotFound: true);
// Dialogues
m_Dialogues = asset.FindActionMap("Dialogues", throwIfNotFound: true);
m_Dialogues_MoveSelection = m_Dialogues.FindAction("MoveSelection", throwIfNotFound: true);
m_Dialogues_AdvanceDialogue = m_Dialogues.FindAction("AdvanceDialogue", throwIfNotFound: true);
}
public void Dispose()
{
UnityEngine.Object.Destroy(asset);
}
public void Dispose()
{
UnityEngine.Object.Destroy(asset);
}
public InputBinding? bindingMask
{
get => asset.bindingMask;
set => asset.bindingMask = value;
}
public InputBinding? bindingMask
{
get => asset.bindingMask;
set => asset.bindingMask = value;
}
public ReadOnlyArray<InputDevice>? devices
{
get => asset.devices;
set => asset.devices = value;
}
public ReadOnlyArray<InputDevice>? devices
{
get => asset.devices;
set => asset.devices = value;
}
public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes;
public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes;
public bool Contains(InputAction action)
{
return asset.Contains(action);
}
public bool Contains(InputAction action)
{
return asset.Contains(action);
}
public IEnumerator<InputAction> GetEnumerator()
{
return asset.GetEnumerator();
}
public IEnumerator<InputAction> GetEnumerator()
{
return asset.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public void Enable()
{
asset.Enable();
}
public void Enable()
{
asset.Enable();
}
public void Disable()
{
asset.Disable();
}
public void Disable()
{
asset.Disable();
}
// Gameplay
private readonly InputActionMap m_Gameplay;
private IGameplayActions m_GameplayActionsCallbackInterface;
private readonly InputAction m_Gameplay_Move;
private readonly InputAction m_Gameplay_Jump;
private readonly InputAction m_Gameplay_Attack;
private readonly InputAction m_Gameplay_Interact;
private readonly InputAction m_Gameplay_Pause;
private readonly InputAction m_Gameplay_OpenInventory;
private readonly InputAction m_Gameplay_RotateCamera;
private readonly InputAction m_Gameplay_MouseControlCamera;
private readonly InputAction m_Gameplay_Run;
public struct GameplayActions
{
private @GameInput m_Wrapper;
public GameplayActions(@GameInput wrapper) { m_Wrapper = wrapper; }
public InputAction @Move => m_Wrapper.m_Gameplay_Move;
public InputAction @Jump => m_Wrapper.m_Gameplay_Jump;
public InputAction @Attack => m_Wrapper.m_Gameplay_Attack;
public InputAction @Interact => m_Wrapper.m_Gameplay_Interact;
public InputAction @Pause => m_Wrapper.m_Gameplay_Pause;
public InputAction @OpenInventory => m_Wrapper.m_Gameplay_OpenInventory;
public InputAction @RotateCamera => m_Wrapper.m_Gameplay_RotateCamera;
public InputAction @MouseControlCamera => m_Wrapper.m_Gameplay_MouseControlCamera;
public InputAction @Run => m_Wrapper.m_Gameplay_Run;
public InputActionMap Get() { return m_Wrapper.m_Gameplay; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(GameplayActions set) { return set.Get(); }
public void SetCallbacks(IGameplayActions instance)
{
if (m_Wrapper.m_GameplayActionsCallbackInterface != null)
{
@Move.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMove;
@Move.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMove;
@Move.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMove;
@Jump.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnJump;
@Jump.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnJump;
@Jump.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnJump;
@Attack.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnAttack;
@Attack.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnAttack;
@Attack.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnAttack;
@Interact.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnInteract;
@Interact.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnInteract;
@Interact.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnInteract;
@Pause.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnPause;
@Pause.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnPause;
@Pause.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnPause;
@OpenInventory.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnOpenInventory;
@OpenInventory.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnOpenInventory;
@OpenInventory.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnOpenInventory;
@RotateCamera.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRotateCamera;
@RotateCamera.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRotateCamera;
@RotateCamera.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRotateCamera;
@MouseControlCamera.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMouseControlCamera;
@MouseControlCamera.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMouseControlCamera;
@MouseControlCamera.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMouseControlCamera;
@Run.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRun;
@Run.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRun;
@Run.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRun;
}
m_Wrapper.m_GameplayActionsCallbackInterface = instance;
if (instance != null)
{
@Move.started += instance.OnMove;
@Move.performed += instance.OnMove;
@Move.canceled += instance.OnMove;
@Jump.started += instance.OnJump;
@Jump.performed += instance.OnJump;
@Jump.canceled += instance.OnJump;
@Attack.started += instance.OnAttack;
@Attack.performed += instance.OnAttack;
@Attack.canceled += instance.OnAttack;
@Interact.started += instance.OnInteract;
@Interact.performed += instance.OnInteract;
@Interact.canceled += instance.OnInteract;
@Pause.started += instance.OnPause;
@Pause.performed += instance.OnPause;
@Pause.canceled += instance.OnPause;
@OpenInventory.started += instance.OnOpenInventory;
@OpenInventory.performed += instance.OnOpenInventory;
@OpenInventory.canceled += instance.OnOpenInventory;
@RotateCamera.started += instance.OnRotateCamera;
@RotateCamera.performed += instance.OnRotateCamera;
@RotateCamera.canceled += instance.OnRotateCamera;
@MouseControlCamera.started += instance.OnMouseControlCamera;
@MouseControlCamera.performed += instance.OnMouseControlCamera;
@MouseControlCamera.canceled += instance.OnMouseControlCamera;
@Run.started += instance.OnRun;
@Run.performed += instance.OnRun;
@Run.canceled += instance.OnRun;
}
}
}
public GameplayActions @Gameplay => new GameplayActions(this);
// Gameplay
private readonly InputActionMap m_Gameplay;
private IGameplayActions m_GameplayActionsCallbackInterface;
private readonly InputAction m_Gameplay_Move;
private readonly InputAction m_Gameplay_Jump;
private readonly InputAction m_Gameplay_Attack;
private readonly InputAction m_Gameplay_Interact;
private readonly InputAction m_Gameplay_Pause;
private readonly InputAction m_Gameplay_OpenInventory;
private readonly InputAction m_Gameplay_RotateCamera;
private readonly InputAction m_Gameplay_MouseControlCamera;
private readonly InputAction m_Gameplay_Run;
public struct GameplayActions
{
private @GameInput m_Wrapper;
public GameplayActions(@GameInput wrapper) { m_Wrapper = wrapper; }
public InputAction @Move => m_Wrapper.m_Gameplay_Move;
public InputAction @Jump => m_Wrapper.m_Gameplay_Jump;
public InputAction @Attack => m_Wrapper.m_Gameplay_Attack;
public InputAction @Interact => m_Wrapper.m_Gameplay_Interact;
public InputAction @Pause => m_Wrapper.m_Gameplay_Pause;
public InputAction @OpenInventory => m_Wrapper.m_Gameplay_OpenInventory;
public InputAction @RotateCamera => m_Wrapper.m_Gameplay_RotateCamera;
public InputAction @MouseControlCamera => m_Wrapper.m_Gameplay_MouseControlCamera;
public InputAction @Run => m_Wrapper.m_Gameplay_Run;
public InputActionMap Get() { return m_Wrapper.m_Gameplay; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(GameplayActions set) { return set.Get(); }
public void SetCallbacks(IGameplayActions instance)
{
if (m_Wrapper.m_GameplayActionsCallbackInterface != null)
{
@Move.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMove;
@Move.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMove;
@Move.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMove;
@Jump.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnJump;
@Jump.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnJump;
@Jump.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnJump;
@Attack.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnAttack;
@Attack.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnAttack;
@Attack.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnAttack;
@Interact.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnInteract;
@Interact.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnInteract;
@Interact.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnInteract;
@Pause.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnPause;
@Pause.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnPause;
@Pause.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnPause;
@OpenInventory.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnOpenInventory;
@OpenInventory.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnOpenInventory;
@OpenInventory.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnOpenInventory;
@RotateCamera.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRotateCamera;
@RotateCamera.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRotateCamera;
@RotateCamera.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRotateCamera;
@MouseControlCamera.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMouseControlCamera;
@MouseControlCamera.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMouseControlCamera;
@MouseControlCamera.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMouseControlCamera;
@Run.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRun;
@Run.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRun;
@Run.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnRun;
}
m_Wrapper.m_GameplayActionsCallbackInterface = instance;
if (instance != null)
{
@Move.started += instance.OnMove;
@Move.performed += instance.OnMove;
@Move.canceled += instance.OnMove;
@Jump.started += instance.OnJump;
@Jump.performed += instance.OnJump;
@Jump.canceled += instance.OnJump;
@Attack.started += instance.OnAttack;
@Attack.performed += instance.OnAttack;
@Attack.canceled += instance.OnAttack;
@Interact.started += instance.OnInteract;
@Interact.performed += instance.OnInteract;
@Interact.canceled += instance.OnInteract;
@Pause.started += instance.OnPause;
@Pause.performed += instance.OnPause;
@Pause.canceled += instance.OnPause;
@OpenInventory.started += instance.OnOpenInventory;
@OpenInventory.performed += instance.OnOpenInventory;
@OpenInventory.canceled += instance.OnOpenInventory;
@RotateCamera.started += instance.OnRotateCamera;
@RotateCamera.performed += instance.OnRotateCamera;
@RotateCamera.canceled += instance.OnRotateCamera;
@MouseControlCamera.started += instance.OnMouseControlCamera;
@MouseControlCamera.performed += instance.OnMouseControlCamera;
@MouseControlCamera.canceled += instance.OnMouseControlCamera;
@Run.started += instance.OnRun;
@Run.performed += instance.OnRun;
@Run.canceled += instance.OnRun;
}
}
}
public GameplayActions @Gameplay => new GameplayActions(this);
// Menus
private readonly InputActionMap m_Menus;
private IMenusActions m_MenusActionsCallbackInterface;
private readonly InputAction m_Menus_MoveSelection;
private readonly InputAction m_Menus_Confirm;
private readonly InputAction m_Menus_Cancel;
private readonly InputAction m_Menus_MouseMove;
private readonly InputAction m_Menus_Unpause;
private readonly InputAction m_Menus_ClosePopupEvent;
private readonly InputAction m_Menus_ChangeTab;
private readonly InputAction m_Menus_InventoryActionButton;
public struct MenusActions
{
private @GameInput m_Wrapper;
public MenusActions(@GameInput wrapper) { m_Wrapper = wrapper; }
public InputAction @MoveSelection => m_Wrapper.m_Menus_MoveSelection;
public InputAction @Confirm => m_Wrapper.m_Menus_Confirm;
public InputAction @Cancel => m_Wrapper.m_Menus_Cancel;
public InputAction @MouseMove => m_Wrapper.m_Menus_MouseMove;
public InputAction @Unpause => m_Wrapper.m_Menus_Unpause;
public InputAction @ClosePopupEvent => m_Wrapper.m_Menus_ClosePopupEvent;
public InputAction @ChangeTab => m_Wrapper.m_Menus_ChangeTab;
public InputAction @InventoryActionButton => m_Wrapper.m_Menus_InventoryActionButton;
public InputActionMap Get() { return m_Wrapper.m_Menus; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(MenusActions set) { return set.Get(); }
public void SetCallbacks(IMenusActions instance)
{
if (m_Wrapper.m_MenusActionsCallbackInterface != null)
{
@MoveSelection.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnMoveSelection;
@MoveSelection.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnMoveSelection;
@MoveSelection.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnMoveSelection;
@Confirm.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnConfirm;
@Confirm.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnConfirm;
@Confirm.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnConfirm;
@Cancel.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnCancel;
@Cancel.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnCancel;
@Cancel.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnCancel;
@MouseMove.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnMouseMove;
@MouseMove.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnMouseMove;
@MouseMove.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnMouseMove;
@Unpause.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnUnpause;
@Unpause.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnUnpause;
@Unpause.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnUnpause;
@ClosePopupEvent.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnClosePopupEvent;
@ClosePopupEvent.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnClosePopupEvent;
@ClosePopupEvent.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnClosePopupEvent;
@ChangeTab.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnChangeTab;
@ChangeTab.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnChangeTab;
@ChangeTab.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnChangeTab;
@InventoryActionButton.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnInventoryActionButton;
@InventoryActionButton.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnInventoryActionButton;
@InventoryActionButton.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnInventoryActionButton;
}
m_Wrapper.m_MenusActionsCallbackInterface = instance;
if (instance != null)
{
@MoveSelection.started += instance.OnMoveSelection;
@MoveSelection.performed += instance.OnMoveSelection;
@MoveSelection.canceled += instance.OnMoveSelection;
@Confirm.started += instance.OnConfirm;
@Confirm.performed += instance.OnConfirm;
@Confirm.canceled += instance.OnConfirm;
@Cancel.started += instance.OnCancel;
@Cancel.performed += instance.OnCancel;
@Cancel.canceled += instance.OnCancel;
@MouseMove.started += instance.OnMouseMove;
@MouseMove.performed += instance.OnMouseMove;
@MouseMove.canceled += instance.OnMouseMove;
@Unpause.started += instance.OnUnpause;
@Unpause.performed += instance.OnUnpause;
@Unpause.canceled += instance.OnUnpause;
@ClosePopupEvent.started += instance.OnClosePopupEvent;
@ClosePopupEvent.performed += instance.OnClosePopupEvent;
@ClosePopupEvent.canceled += instance.OnClosePopupEvent;
@ChangeTab.started += instance.OnChangeTab;
@ChangeTab.performed += instance.OnChangeTab;
@ChangeTab.canceled += instance.OnChangeTab;
@InventoryActionButton.started += instance.OnInventoryActionButton;
@InventoryActionButton.performed += instance.OnInventoryActionButton;
@InventoryActionButton.canceled += instance.OnInventoryActionButton;
}
}
}
public MenusActions @Menus => new MenusActions(this);
// Menus
private readonly InputActionMap m_Menus;
private IMenusActions m_MenusActionsCallbackInterface;
private readonly InputAction m_Menus_MoveSelection;
private readonly InputAction m_Menus_Confirm;
private readonly InputAction m_Menus_Cancel;
private readonly InputAction m_Menus_MouseMove;
private readonly InputAction m_Menus_Unpause;
private readonly InputAction m_Menus_ClosePopupEvent;
private readonly InputAction m_Menus_ChangeTab;
private readonly InputAction m_Menus_InventoryActionButton;
public struct MenusActions
{
private @GameInput m_Wrapper;
public MenusActions(@GameInput wrapper) { m_Wrapper = wrapper; }
public InputAction @MoveSelection => m_Wrapper.m_Menus_MoveSelection;
public InputAction @Confirm => m_Wrapper.m_Menus_Confirm;
public InputAction @Cancel => m_Wrapper.m_Menus_Cancel;
public InputAction @MouseMove => m_Wrapper.m_Menus_MouseMove;
public InputAction @Unpause => m_Wrapper.m_Menus_Unpause;
public InputAction @ClosePopupEvent => m_Wrapper.m_Menus_ClosePopupEvent;
public InputAction @ChangeTab => m_Wrapper.m_Menus_ChangeTab;
public InputAction @InventoryActionButton => m_Wrapper.m_Menus_InventoryActionButton;
public InputActionMap Get() { return m_Wrapper.m_Menus; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(MenusActions set) { return set.Get(); }
public void SetCallbacks(IMenusActions instance)
{
if (m_Wrapper.m_MenusActionsCallbackInterface != null)
{
@MoveSelection.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnMoveSelection;
@MoveSelection.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnMoveSelection;
@MoveSelection.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnMoveSelection;
@Confirm.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnConfirm;
@Confirm.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnConfirm;
@Confirm.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnConfirm;
@Cancel.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnCancel;
@Cancel.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnCancel;
@Cancel.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnCancel;
@MouseMove.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnMouseMove;
@MouseMove.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnMouseMove;
@MouseMove.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnMouseMove;
@Unpause.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnUnpause;
@Unpause.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnUnpause;
@Unpause.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnUnpause;
@ClosePopupEvent.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnClosePopupEvent;
@ClosePopupEvent.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnClosePopupEvent;
@ClosePopupEvent.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnClosePopupEvent;
@ChangeTab.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnChangeTab;
@ChangeTab.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnChangeTab;
@ChangeTab.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnChangeTab;
@InventoryActionButton.started -= m_Wrapper.m_MenusActionsCallbackInterface.OnInventoryActionButton;
@InventoryActionButton.performed -= m_Wrapper.m_MenusActionsCallbackInterface.OnInventoryActionButton;
@InventoryActionButton.canceled -= m_Wrapper.m_MenusActionsCallbackInterface.OnInventoryActionButton;
}
m_Wrapper.m_MenusActionsCallbackInterface = instance;
if (instance != null)
{
@MoveSelection.started += instance.OnMoveSelection;
@MoveSelection.performed += instance.OnMoveSelection;
@MoveSelection.canceled += instance.OnMoveSelection;
@Confirm.started += instance.OnConfirm;
@Confirm.performed += instance.OnConfirm;
@Confirm.canceled += instance.OnConfirm;
@Cancel.started += instance.OnCancel;
@Cancel.performed += instance.OnCancel;
@Cancel.canceled += instance.OnCancel;
@MouseMove.started += instance.OnMouseMove;
@MouseMove.performed += instance.OnMouseMove;
@MouseMove.canceled += instance.OnMouseMove;
@Unpause.started += instance.OnUnpause;
@Unpause.performed += instance.OnUnpause;
@Unpause.canceled += instance.OnUnpause;
@ClosePopupEvent.started += instance.OnClosePopupEvent;
@ClosePopupEvent.performed += instance.OnClosePopupEvent;
@ClosePopupEvent.canceled += instance.OnClosePopupEvent;
@ChangeTab.started += instance.OnChangeTab;
@ChangeTab.performed += instance.OnChangeTab;
@ChangeTab.canceled += instance.OnChangeTab;
@InventoryActionButton.started += instance.OnInventoryActionButton;
@InventoryActionButton.performed += instance.OnInventoryActionButton;
@InventoryActionButton.canceled += instance.OnInventoryActionButton;
}
}
}
public MenusActions @Menus => new MenusActions(this);
// Dialogues
private readonly InputActionMap m_Dialogues;
private IDialoguesActions m_DialoguesActionsCallbackInterface;
private readonly InputAction m_Dialogues_MoveSelection;
private readonly InputAction m_Dialogues_AdvanceDialogue;
public struct DialoguesActions
{
private @GameInput m_Wrapper;
public DialoguesActions(@GameInput wrapper) { m_Wrapper = wrapper; }
public InputAction @MoveSelection => m_Wrapper.m_Dialogues_MoveSelection;
public InputAction @AdvanceDialogue => m_Wrapper.m_Dialogues_AdvanceDialogue;
public InputActionMap Get() { return m_Wrapper.m_Dialogues; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(DialoguesActions set) { return set.Get(); }
public void SetCallbacks(IDialoguesActions instance)
{
if (m_Wrapper.m_DialoguesActionsCallbackInterface != null)
{
@MoveSelection.started -= m_Wrapper.m_DialoguesActionsCallbackInterface.OnMoveSelection;
@MoveSelection.performed -= m_Wrapper.m_DialoguesActionsCallbackInterface.OnMoveSelection;
@MoveSelection.canceled -= m_Wrapper.m_DialoguesActionsCallbackInterface.OnMoveSelection;
@AdvanceDialogue.started -= m_Wrapper.m_DialoguesActionsCallbackInterface.OnAdvanceDialogue;
@AdvanceDialogue.performed -= m_Wrapper.m_DialoguesActionsCallbackInterface.OnAdvanceDialogue;
@AdvanceDialogue.canceled -= m_Wrapper.m_DialoguesActionsCallbackInterface.OnAdvanceDialogue;
}
m_Wrapper.m_DialoguesActionsCallbackInterface = instance;
if (instance != null)
{
@MoveSelection.started += instance.OnMoveSelection;
@MoveSelection.performed += instance.OnMoveSelection;
@MoveSelection.canceled += instance.OnMoveSelection;
@AdvanceDialogue.started += instance.OnAdvanceDialogue;
@AdvanceDialogue.performed += instance.OnAdvanceDialogue;
@AdvanceDialogue.canceled += instance.OnAdvanceDialogue;
}
}
}
public DialoguesActions @Dialogues => new DialoguesActions(this);
private int m_KeyboardOrGamepadSchemeIndex = -1;
public InputControlScheme KeyboardOrGamepadScheme
{
get
{
if (m_KeyboardOrGamepadSchemeIndex == -1) m_KeyboardOrGamepadSchemeIndex = asset.FindControlSchemeIndex("KeyboardOrGamepad");
return asset.controlSchemes[m_KeyboardOrGamepadSchemeIndex];
}
}
public interface IGameplayActions
{
void OnMove(InputAction.CallbackContext context);
void OnJump(InputAction.CallbackContext context);
void OnAttack(InputAction.CallbackContext context);
void OnInteract(InputAction.CallbackContext context);
void OnPause(InputAction.CallbackContext context);
void OnOpenInventory(InputAction.CallbackContext context);
void OnRotateCamera(InputAction.CallbackContext context);
void OnMouseControlCamera(InputAction.CallbackContext context);
void OnRun(InputAction.CallbackContext context);
}
public interface IMenusActions
{
void OnMoveSelection(InputAction.CallbackContext context);
void OnConfirm(InputAction.CallbackContext context);
void OnCancel(InputAction.CallbackContext context);
void OnMouseMove(InputAction.CallbackContext context);
void OnUnpause(InputAction.CallbackContext context);
void OnClosePopupEvent(InputAction.CallbackContext context);
void OnChangeTab(InputAction.CallbackContext context);
void OnInventoryActionButton(InputAction.CallbackContext context);
}
public interface IDialoguesActions
{
void OnMoveSelection(InputAction.CallbackContext context);
void OnAdvanceDialogue(InputAction.CallbackContext context);
}
// Dialogues
private readonly InputActionMap m_Dialogues;
private IDialoguesActions m_DialoguesActionsCallbackInterface;
private readonly InputAction m_Dialogues_MoveSelection;
private readonly InputAction m_Dialogues_AdvanceDialogue;
public struct DialoguesActions
{
private @GameInput m_Wrapper;
public DialoguesActions(@GameInput wrapper) { m_Wrapper = wrapper; }
public InputAction @MoveSelection => m_Wrapper.m_Dialogues_MoveSelection;
public InputAction @AdvanceDialogue => m_Wrapper.m_Dialogues_AdvanceDialogue;
public InputActionMap Get() { return m_Wrapper.m_Dialogues; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(DialoguesActions set) { return set.Get(); }
public void SetCallbacks(IDialoguesActions instance)
{
if (m_Wrapper.m_DialoguesActionsCallbackInterface != null)
{
@MoveSelection.started -= m_Wrapper.m_DialoguesActionsCallbackInterface.OnMoveSelection;
@MoveSelection.performed -= m_Wrapper.m_DialoguesActionsCallbackInterface.OnMoveSelection;
@MoveSelection.canceled -= m_Wrapper.m_DialoguesActionsCallbackInterface.OnMoveSelection;
@AdvanceDialogue.started -= m_Wrapper.m_DialoguesActionsCallbackInterface.OnAdvanceDialogue;
@AdvanceDialogue.performed -= m_Wrapper.m_DialoguesActionsCallbackInterface.OnAdvanceDialogue;
@AdvanceDialogue.canceled -= m_Wrapper.m_DialoguesActionsCallbackInterface.OnAdvanceDialogue;
}
m_Wrapper.m_DialoguesActionsCallbackInterface = instance;
if (instance != null)
{
@MoveSelection.started += instance.OnMoveSelection;
@MoveSelection.performed += instance.OnMoveSelection;
@MoveSelection.canceled += instance.OnMoveSelection;
@AdvanceDialogue.started += instance.OnAdvanceDialogue;
@AdvanceDialogue.performed += instance.OnAdvanceDialogue;
@AdvanceDialogue.canceled += instance.OnAdvanceDialogue;
}
}
}
public DialoguesActions @Dialogues => new DialoguesActions(this);
private int m_KeyboardOrGamepadSchemeIndex = -1;
public InputControlScheme KeyboardOrGamepadScheme
{
get
{
if (m_KeyboardOrGamepadSchemeIndex == -1)
m_KeyboardOrGamepadSchemeIndex = asset.FindControlSchemeIndex("KeyboardOrGamepad");
return asset.controlSchemes[m_KeyboardOrGamepadSchemeIndex];
}
}
public interface IGameplayActions
{
void OnMove(InputAction.CallbackContext context);
void OnJump(InputAction.CallbackContext context);
void OnAttack(InputAction.CallbackContext context);
void OnInteract(InputAction.CallbackContext context);
void OnPause(InputAction.CallbackContext context);
void OnOpenInventory(InputAction.CallbackContext context);
void OnRotateCamera(InputAction.CallbackContext context);
void OnMouseControlCamera(InputAction.CallbackContext context);
void OnRun(InputAction.CallbackContext context);
}
public interface IMenusActions
{
void OnMoveSelection(InputAction.CallbackContext context);
void OnConfirm(InputAction.CallbackContext context);
void OnCancel(InputAction.CallbackContext context);
void OnMouseMove(InputAction.CallbackContext context);
void OnUnpause(InputAction.CallbackContext context);
void OnClosePopupEvent(InputAction.CallbackContext context);
void OnChangeTab(InputAction.CallbackContext context);
void OnInventoryActionButton(InputAction.CallbackContext context);
}
public interface IDialoguesActions
{
void OnMoveSelection(InputAction.CallbackContext context);
void OnAdvanceDialogue(InputAction.CallbackContext context);
}
}

4
UOP1_Project/Assets/Scripts/Input/InputReader.cs


public void OnClosePopupEvent(InputAction.CallbackContext context)
{
if (context.phase == InputActionPhase.Performed)
closePopupEvent.Invoke();
closePopupEvent.Invoke();
}

public void OnChangeTab(InputAction.CallbackContext context)
{
if (context.phase == InputActionPhase.Performed)
menuSwitchTab.Invoke(context.ReadValue<float>());
menuSwitchTab.Invoke(context.ReadValue<float>());
}

10
UOP1_Project/Assets/Scripts/Inventory/CollectableItem.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using DG.Tweening;
[SerializeField] private GameObject _itemGO = default;
[SerializeField] private GameObject _itemGO = default;
AnimateItem();
AnimateItem();
}
public Item GetItem()

public void AnimateItem()
{
if(_itemGO!=null)
if (_itemGO != null)
_itemGO.transform.DORotate(Vector3.one * 180, 5, RotateMode.Fast).SetLoops(-1,LoopType.Incremental);
_itemGO.transform.DORotate(Vector3.one * 180, 5, RotateMode.Fast).SetLoops(-1, LoopType.Incremental);
}
}

12
UOP1_Project/Assets/Scripts/Inventory/InventoryItemFiller.cs


[SerializeField] private Button _itemButton = default;
[SerializeField] private Image _bgInactiveImage = default;
ItemEventChannelSO _currentItemEvent;
ItemEventChannelSO _currentItemEvent;
[SerializeField] private LocalizeSpriteEvent _bgLocalizedImage = default;
[SerializeField] private LocalizeSpriteEvent _bgLocalizedImage = default;
public void SetItem(ItemStack itemStack, bool isSelected, ItemEventChannelSO selectItemEvent)
{

_imgSelected.gameObject.SetActive(true);
_itemButton.gameObject.SetActive(true);
_bgInactiveImage.gameObject.SetActive(false);
_currentItemEvent = selectItemEvent;
_currentItemEvent = selectItemEvent;
_currentItem = itemStack;
_imgSelected.gameObject.SetActive(isSelected);

_itemCount.text = itemStack.Amount.ToString();
_bgImage.color = itemStack.Item.ItemType.TypeColor;
}
public void SetInactiveItem()
{

public void SelectFirstElement()
{
_itemButton.Select();
SelectItem();
SelectItem();
}
public void HoverItem()

20
UOP1_Project/Assets/Scripts/Inventory/InventoryListFiller.cs


public class InventoryListFiller : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Start is called before the first frame update
void Start()
{
// Update is called once per frame
void Update()
{
}
}
// Update is called once per frame
void Update()
{
}
}

52
UOP1_Project/Assets/Scripts/Inventory/InventoryManager.cs


private void OnEnable()
{
//Check if the event exists to avoid errors
_cookRecipeEvent.OnEventRaised += CookRecipeEventRaised;
_useItemEvent.OnEventRaised += UseItemEventRaised;
_equipItemEvent.OnEventRaised += EquipItemEventRaised;
_addItemEvent.OnEventRaised += AddItem;
_removeItemEvent.OnEventRaised += RemoveItem;
_rewardItemEvent.OnEventRaised += AddItem;
_giveItemEvent.OnEventRaised += RemoveItem;
_cookRecipeEvent.OnEventRaised += CookRecipeEventRaised;
_useItemEvent.OnEventRaised += UseItemEventRaised;
_equipItemEvent.OnEventRaised += EquipItemEventRaised;
_addItemEvent.OnEventRaised += AddItem;
_removeItemEvent.OnEventRaised += RemoveItem;
_rewardItemEvent.OnEventRaised += AddItem;
_giveItemEvent.OnEventRaised += RemoveItem;
_cookRecipeEvent.OnEventRaised -= CookRecipeEventRaised;
_useItemEvent.OnEventRaised -= UseItemEventRaised;
_equipItemEvent.OnEventRaised -= EquipItemEventRaised;
_addItemEvent.OnEventRaised -= AddItem;
_removeItemEvent.OnEventRaised -= RemoveItem;
_cookRecipeEvent.OnEventRaised -= CookRecipeEventRaised;
_useItemEvent.OnEventRaised -= UseItemEventRaised;
_equipItemEvent.OnEventRaised -= EquipItemEventRaised;
_addItemEvent.OnEventRaised -= AddItem;
_removeItemEvent.OnEventRaised -= RemoveItem;
}

48
UOP1_Project/Assets/Scripts/Inventory/UIInventoryManager.cs


private VoidEventChannelSO _onInteractionEndedEvent = default;
[SerializeField]
private InputReader _inputReader = default;
private InputReader _inputReader = default;
_actionButtonClicked.OnEventRaised += ActionButtonEventRaised;
_changeTabEvent.OnEventRaised += ChangeTabEventRaised;
_selectItemEvent.OnEventRaised += InspectItem;
_onInteractionEndedEvent.OnEventRaised += InteractionEnded;
_actionButtonClicked.OnEventRaised += ActionButtonEventRaised;
_changeTabEvent.OnEventRaised += ChangeTabEventRaised;
_selectItemEvent.OnEventRaised += InspectItem;
_onInteractionEndedEvent.OnEventRaised += InteractionEnded;
_actionButtonClicked.OnEventRaised -= ActionButtonEventRaised;
_changeTabEvent.OnEventRaised -= ChangeTabEventRaised;
_selectItemEvent.OnEventRaised -= InspectItem;
_actionButtonClicked.OnEventRaised -= ActionButtonEventRaised;
_changeTabEvent.OnEventRaised -= ChangeTabEventRaised;
_selectItemEvent.OnEventRaised -= InspectItem;
if(orientation!=0)
if (orientation != 0)
{
bool isLeft = orientation < 0;
int initialIndex = _tabTypesList.FindIndex(o => o == _selectedTab);

initialIndex++;
}
initialIndex= Mathf.Clamp(initialIndex, 0, _tabTypesList.Count-1);
initialIndex = Mathf.Clamp(initialIndex, 0, _tabTypesList.Count - 1);
ChangeTabEventRaised(_tabTypesList[initialIndex]);
ChangeTabEventRaised(_tabTypesList[initialIndex]);
}

FillTypeTabs(_tabTypesList, _selectedTab);
List<ItemStack> listItemsToShow = new List<ItemStack>();
listItemsToShow = _currentInventory.Items.FindAll(o => o.Item.ItemType.TabType == _selectedTab);
FillItems(listItemsToShow);
}
else

{
_instanciatedItems[0].SelectFirstElement();
}
}
public void UpdateOnItemInInventory(ItemStack itemToUpdate, bool removeItem)
{

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


public void StartGame()
{//Add code for saved information
_checkStepValidityEvent.OnEventRaised += CheckStepValidity;
_endDialogueEvent.OnEventRaised += EndDialogue;
_checkStepValidityEvent.OnEventRaised += CheckStepValidity;
_endDialogueEvent.OnEventRaised += EndDialogue;
StartQuestline();
}
void StartQuestline()

}
public DialogueDataSO InteractWithCharacter(ActorSO actor, bool isCheckValidity, bool isValid)
{ if (_currentQuest == null)
{
if (_currentQuest == null)
{
if (CheckQuestlineForQuestWithActor(actor))
{

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


//check if character is actif. An actif character is the character concerned by the step.
private DialogueDataSO _currentDialogue;
public bool IsInDialogue = false;
public bool IsInDialogue = false;
_loseDialogueEvent.OnEventRaised += PlayLoseDialogue;
_loseDialogueEvent.OnEventRaised += PlayLoseDialogue;
}

void StartDialogue()
{
_startDialogueEvent.RaiseEvent(_currentDialogue);
_startDialogueEvent.RaiseEvent(_currentDialogue);
_endDialogueEvent.OnEventRaised += EndDialogue;
_endDialogueEvent.OnEventRaised += EndDialogue;
}

}
void PlayLoseDialogue()
void PlayLoseDialogue()
{
if (_questData != null)
{

2
UOP1_Project/Assets/Scripts/SaveSystem/SaveSystem.cs


saveData._itemStacks.Clear();
foreach (var itemStack in _playerInventory.Items)
{
// saveData._itemStacks.Add(new SerializedItemStack(itemStack.Item.Guid, itemStack.Amount));
// saveData._itemStacks.Add(new SerializedItemStack(itemStack.Item.Guid, itemStack.Amount));
}
if (FileManager.MoveFile(saveFilename, backupSaveFilename))

4
UOP1_Project/Assets/Scripts/SceneManagement/SceneLoader.cs


/// </summary>
private void UnloadPreviousScene()
{
if(_currentlyLoadedScene != null) //would be null if the game was started in Initialisation
if (_currentlyLoadedScene != null) //would be null if the game was started in Initialisation
if(_currentlyLoadedScene.sceneReference.OperationHandle.IsValid())
if (_currentlyLoadedScene.sceneReference.OperationHandle.IsValid())
{
//Unload the scene through its AssetReference, i.e. through the Addressable system
_currentlyLoadedScene.sceneReference.UnLoadScene();

18
UOP1_Project/Assets/Scripts/SceneManagement/StartGame.cs


/// This class contains the function to call when play button is pressed
/// </summary>
public class StartGame : MonoBehaviour
{
{
private bool _showLoadScreen = default;
private bool _showLoadScreen = default;
private SaveSystem _saveSystem = default ;
private SaveSystem _saveSystem = default;
private bool _hasSaveData;
[Header("Broadcasting on ")]
[SerializeField]

{
_hasSaveData = _saveSystem.LoadSaveDataFromDisk();
_startNewGameEvent.OnEventRaised += StartNewGame;
_continueGameEvent.OnEventRaised += ContinuePreviousGame;
_continueGameEvent.OnEventRaised += ContinuePreviousGame;
}
void StartNewGame()
{

_startGameEvent.RaiseEvent(_locationsToLoad, _showLoadScreen);
void OnResetSaveDataPress()
void OnResetSaveDataPress()
IEnumerator LoadSaveGame()
IEnumerator LoadSaveGame()
{
yield return StartCoroutine(_saveSystem.LoadSavedInventory());

12
UOP1_Project/Assets/Scripts/SpawnSystem.cs


private void OnEnable()
{
_OnSceneReady.OnEventRaised += SpawnPlayer;
_OnSceneReady.OnEventRaised += SpawnPlayer;
_OnSceneReady.OnEventRaised -= SpawnPlayer;
_OnSceneReady.OnEventRaised -= SpawnPlayer;
}
private void SpawnPlayer()

12
UOP1_Project/Assets/Scripts/UI/InventoryButtonFiller.cs


[SerializeField]
VoidEventChannelSO _inventoryActionEvent = default;
bool hasEvent = false;
bool hasEvent = false;
public void FillInventoryButtons(ItemType itemType, bool isInteractable = true)

//bool isKeyboard = !(Input.GetJoystickNames() != null && Input.GetJoystickNames().Length > 0);
bool isKeyboard =true;
bool isKeyboard = true;
buttonPromptSetter.SetButtonPrompt(isKeyboard);
if (isInteractable)
{

else
{
if (_inputReader != null)
if (hasEvent )
_inputReader.inventoryActionButtonEvent -= ActionButtonEventRaised;
if (hasEvent)
_inputReader.inventoryActionButtonEvent -= ActionButtonEventRaised;
}

if(_inventoryActionEvent!=null)
if (_inventoryActionEvent != null)
_inventoryActionEvent.RaiseEvent();
_inventoryActionEvent.RaiseEvent();
}

4
UOP1_Project/Assets/Scripts/UI/UIButtonPromptSetter.cs


if (!isKeyboard)
{
_interactionKeyBG.sprite = _controllerSprite;
_interactionKeyText.text = _interactionJoystickKeyCode;
_interactionKeyText.text = _interactionJoystickKeyCode;
_interactionKeyText.text = _interactionKeyboardCode;
_interactionKeyText.text = _interactionKeyboardCode;
}

6
UOP1_Project/Assets/Scripts/UI/UIDialogueManager.cs


[SerializeField] private DialogueChoicesChannelSO _showChoicesEvent = default;
private void Start()
{
_showChoicesEvent.OnEventRaised += ShowChoices;
_showChoicesEvent.OnEventRaised += ShowChoices;
}
public void SetDialogue(LocalizedString dialogueLine, ActorSO actor)
{

26
UOP1_Project/Assets/Scripts/UI/UIHealthBarManager.cs


public class UIHealthBarManager : MonoBehaviour
{
Transform target;
int maxHealth=0;
int currentHealth=0;
int maxHealth = 0;
int currentHealth = 0;
[SerializeField] private Slider _healthBar = default;
[Header("Listening to")]

private void OnEnable()
{
if((GetComponent<Canvas>()!=null)&&(Camera.main!=null))
if ((GetComponent<Canvas>() != null) && (Camera.main != null))
target = Camera.main.transform;
target = Camera.main.transform;
_setHealthBar.OnEventRaised += SetHealthBar;
_inflictDamage.OnEventRaised += InflictDamage;
_restoreHealth.OnEventRaised += RestoreHealth;
_setHealthBar.OnEventRaised += SetHealthBar;
_inflictDamage.OnEventRaised += InflictDamage;
_restoreHealth.OnEventRaised += RestoreHealth;
}
private void OnDestroy()
{

{
maxHealth = _maxHealth;
currentHealth = _maxHealth;
setSlider();
setSlider();
}
public void InflictDamage(int _damage)

//find new slider value
float sliderValue = 0;
sliderValue = currentHealth / maxHealth;
_healthBar.value = sliderValue;
_healthBar.value = sliderValue;
}

10
UOP1_Project/Assets/Scripts/UI/UIInteractionItemFiller.cs


[SerializeField] LocalizeStringEvent _interactionName = default;
[SerializeField]
UIButtonPromptSetter buttonPromptSetter = default;
UIButtonPromptSetter buttonPromptSetter = default;
bool isKeyboard = true;
// bool isKeyboard = !(Input.GetJoystickNames() != null && Input.GetJoystickNames().Length > 0);
buttonPromptSetter.SetButtonPrompt(isKeyboard);
bool isKeyboard = true;
// bool isKeyboard = !(Input.GetJoystickNames() != null && Input.GetJoystickNames().Length > 0);
buttonPromptSetter.SetButtonPrompt(isKeyboard);
}

18
UOP1_Project/Assets/Scripts/UI/UIManager.cs


_onSceneReady.OnEventRaised += ResetUI;
_inputReader.pauseEvent += OpenUIPause;
_closeSettingScreenEvent.OnEventRaised += CloseSettingScreen;
_closeSettingScreenEvent.OnEventRaised += CloseSettingScreen;
}
private void OnDestroy()

}
void BackToMenu()
{
Debug.Log("Back to Menu ");
Debug.Log("Back to Menu ");
}
void OpenUIPause()
{

_pauseScreen.gameObject.SetActive(true);
_pauseScreen.SetPauseScreen();
_pauseScreen.SetPauseScreen();
_inputReader.pauseEvent += OpenUIPause;
_inputReader.pauseEvent -= CloseUIPause;
_pauseScreen.gameObject.SetActive(false);

{
CloseUIDialogue();
CloseInventoryScreen();
SetInteractionPanel(false, InteractionType.None);
SetInteractionPanel(false, InteractionType.None);
}
public void OpenUIDialogue(LocalizedString dialogueLine, ActorSO actor)

_inputReader.EnableMenuInput();
_inputReader.closeInventoryEvent += CloseInventoryScreen;
_gameState.UpdateGameState(GameState.Inventory);
_gameState.UpdateGameState(GameState.Inventory);
if (isForCooking)
{

}
void CloseInventoryScreen()
void CloseInventoryScreen()
{
_inventoryPanel.gameObject.SetActive(false);

}
}
正在加载...
取消
保存