浏览代码

More Runtime Anchor refactoring, other SO additions

Also fixed bug with RuntimeAnchors
Fixed BardHare state machine (error on Animator parameter)
/main
Ciro Continisio 3 年前
当前提交
b74f3140
共有 26 个文件被更改,包括 124 次插入111 次删除
  1. 1
      UOP1_Project/Assets/AddressableAssetsData/AssetGroups/Localization-Asset-Tables-French (fr).asset
  2. 12
      UOP1_Project/Assets/Art/Characters/BardHare/Animation/BardHare.controller
  3. 1
      UOP1_Project/Assets/LocalizationFiles/AssetTables/Inventory/LocalizedDish Shared Data.asset
  4. 2
      UOP1_Project/Assets/LocalizationFiles/AssetTables/Inventory/LocalizedDish.asset
  5. 6
      UOP1_Project/Assets/LocalizationFiles/AssetTables/Inventory/LocalizedDish_fr.asset
  6. 2
      UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/BardHare/BardHare_TransitionTable.asset
  7. 4
      UOP1_Project/Assets/Scripts/Camera/CameraManager.cs
  8. 6
      UOP1_Project/Assets/Scripts/Characters/Config/HealthConfigSO.cs
  9. 6
      UOP1_Project/Assets/Scripts/Characters/Damageable.cs
  10. 14
      UOP1_Project/Assets/Scripts/Gameplay/SpawnSystem.cs
  11. 30
      UOP1_Project/Assets/Scripts/RuntimeAnchors/RuntimeAnchorBase.cs
  12. 10
      UOP1_Project/Assets/Scripts/Systems/Settings/UISettingsLanguageComponent.cs
  13. 40
      UOP1_Project/Assets/Scripts/UI/UIHealthBarManager.cs
  14. 15
      UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/BardHare/States/Idle.asset
  15. 8
      UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/BardHare/States/Idle.asset.meta
  16. 8
      UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/Shared.meta
  17. 39
      UOP1_Project/Assets/Scripts/Characters/HealthSO.cs
  18. 31
      UOP1_Project/Assets/Scripts/Characters/Config/HealthSO.cs
  19. 0
      /UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/Shared/Actions.meta
  20. 0
      /UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/Shared/Conditions.meta
  21. 0
      /UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/Shared/States.meta
  22. 0
      /UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/Shared/Actions
  23. 0
      /UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/Shared/Conditions
  24. 0
      /UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/Shared/States
  25. 0
      /UOP1_Project/Assets/Scripts/Characters/HealthSO.cs.meta

1
UOP1_Project/Assets/AddressableAssetsData/AssetGroups/Localization-Asset-Tables-French (fr).asset


m_ReadOnly: 1
m_SerializedLabels:
- Locale-fr
- Preload
m_ReadOnly: 1
m_Settings: {fileID: 11400000, guid: bffab80dc16c4464b92b2e97b6a1964c, type: 2}
m_SchemaSet:

12
UOP1_Project/Assets/Art/Characters/BardHare/Animation/BardHare.controller


m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer

1
UOP1_Project/Assets/LocalizationFiles/AssetTables/Inventory/LocalizedDish Shared Data.asset


- m_KeyId: 14284742656
m_TableCodes:
- en
- fr
- it
m_TypeString: UnityEngine.Sprite, UnityEngine.CoreModule, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null

2
UOP1_Project/Assets/LocalizationFiles/AssetTables/Inventory/LocalizedDish.asset


m_SharedTableData: {fileID: 11400000, guid: e7e5ada6333974625b639508f505d755, type: 2}
m_Tables:
- {fileID: 11400000, guid: bbe77d261724c4e3b9bb399b76921202, type: 2}
- {fileID: 11400000, guid: 47bf9ef1f2afb43c1b39b47408349016, type: 2}
- {fileID: 11400000, guid: 47bf9ef1f2afb43c1b39b47408349016, type: 2}
m_Extensions: []
m_Group: Asset Table
references:

6
UOP1_Project/Assets/LocalizationFiles/AssetTables/Inventory/LocalizedDish_fr.asset


m_SharedData: {fileID: 11400000, guid: e7e5ada6333974625b639508f505d755, type: 2}
m_Metadata:
m_Items: []
m_TableData:
- m_Id: 14284742656
m_Localized: 53b3650512f0645c7a47a2c36271e215
m_Metadata:
m_Items: []
m_TableData: []
references:
version: 1

2
UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/BardHare/BardHare_TransitionTable.asset


m_Name: BardHare_TransitionTable
m_EditorClassIdentifier:
_transitions:
- FromState: {fileID: 11400000, guid: 7aedcd9c179a4824eaf24451ab5689ba, type: 2}
- FromState: {fileID: 11400000, guid: 0739bae51cc5c43729309c4977455722, type: 2}
ToState: {fileID: 11400000, guid: e8445f4dd402c244d8f2e2e0440bd834, type: 2}
Conditions:
- ExpectedResult: 0

4
UOP1_Project/Assets/Scripts/Camera/CameraManager.cs


_protagonistTransformAnchor.OnAnchorProvided += SetupProtagonistVirtualCamera;
_camShakeEvent.OnEventRaised += impulseSource.GenerateImpulse;
_cameraTransformAnchor.Value = mainCamera.transform;
_cameraTransformAnchor.Provide(mainCamera.transform);
}
private void OnDisable()

_protagonistTransformAnchor.OnAnchorProvided -= SetupProtagonistVirtualCamera;
_camShakeEvent.OnEventRaised -= impulseSource.GenerateImpulse;
_cameraTransformAnchor.Value = null;
_cameraTransformAnchor.Unset();
}
private void Start()

6
UOP1_Project/Assets/Scripts/Characters/Config/HealthConfigSO.cs


[CreateAssetMenu(fileName = "HealthConfig", menuName = "EntityConfig/Health Config")]
public class HealthConfigSO : ScriptableObject
{
[Tooltip("Initial critter health")]
[SerializeField] private int _maxHealth;
[Tooltip("Initial health")]
[SerializeField][UnityEngine.Serialization.FormerlySerializedAs("_maxHealth")] private int _initialHealth;
public int MaxHealth => _maxHealth;
public int InitialHealth => _initialHealth;
}

6
UOP1_Project/Assets/Scripts/Characters/Damageable.cs


if (_currentHealthSO == null)
{
_currentHealthSO = ScriptableObject.CreateInstance<HealthSO>();
_currentHealthSO.SetMaxHealth(_healthConfigSO.MaxHealth);
_currentHealthSO.SetCurrentHealth(_healthConfigSO.MaxHealth);
_currentHealthSO.SetMaxHealth(_healthConfigSO.InitialHealth);
_currentHealthSO.SetCurrentHealth(_healthConfigSO.InitialHealth);
}
if (_updateHealthEvent != null)
{

public void ResetHealth()
{
_currentHealthSO.SetCurrentHealth(_healthConfigSO.MaxHealth);
_currentHealthSO.SetCurrentHealth(_healthConfigSO.InitialHealth);
if (_updateHealthEvent != null)
{
_updateHealthEvent.RaiseEvent();

14
UOP1_Project/Assets/Scripts/Gameplay/SpawnSystem.cs


{
_onSceneReady.OnEventRaised -= SpawnPlayer;
_playerTransformAnchor.Value = null;
_playerTransformAnchor.Unset();
}
private Transform GetSpawnLocation()

return _spawnLocations[entranceIndex].transform;
}
private Protagonist InstantiatePlayer(Protagonist playerPrefab, Transform spawnLocation)
{
Protagonist playerInstance = Instantiate(playerPrefab, spawnLocation.position, spawnLocation.rotation);
return playerInstance;
}
Protagonist playerInstance = InstantiatePlayer(_playerPrefab, GetSpawnLocation());
Transform spawnLocation = GetSpawnLocation();
Protagonist playerInstance = Instantiate(_playerPrefab, spawnLocation.position, spawnLocation.rotation);
_playerTransformAnchor.Value = playerInstance.transform; //the CameraSystem will pick this up to frame the player
_playerTransformAnchor.Provide(playerInstance.transform); //the CameraSystem will pick this up to frame the player
//TODO: Probably move this to the GameManager once it's up and running
_inputReader.EnableGameplayInput();

30
UOP1_Project/Assets/Scripts/RuntimeAnchors/RuntimeAnchorBase.cs


public T Value
{
get { return _value; }
set
}
public void Provide(T value)
{
if(value == null)
_value = value;
isSet = _value != null;
if(OnAnchorProvided != null
&& isSet)
{
OnAnchorProvided.Invoke();
}
Debug.LogError("A null value was provided to the " + this.name + " runtime anchor.");
return;
_value = value;
isSet = true;
if(OnAnchorProvided != null)
OnAnchorProvided.Invoke();
private void OnDisable()
public void Unset()
}
private void OnDisable()
{
Unset();
}
}

10
UOP1_Project/Assets/Scripts/Systems/Settings/UISettingsLanguageComponent.cs


using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Localization;

_languageField._nextOption += NextOption;
_languageField._previousOption += PreviousOption;
}
private void OnDisable()
{
ResetSettings();

void NextOption()
{
_currentSelectedOption++;
Debug.Log(_currentSelectedOption);
_currentSelectedOption = Mathf.Clamp(_currentSelectedOption, 0, languageList.Count - 1);
OnSelectionChanged();
}

_currentSelectedOption = Mathf.Clamp(_currentSelectedOption, 0, languageList.Count - 1);
OnSelectionChanged();
}
void OnSelectionChanged()
{
// Unsubscribe from SelectedLocaleChanged so we don't get an unnecessary callback from the change we are about to make.

_languageField.FillSettingField(languageList.Count, selectedIndex, languageList[selectedIndex]);
}
public void SaveSettings()
{
Locale _currentLocale = LocalizationSettings.AvailableLocales.Locales[_currentSelectedOption];

public void ResetSettings()
{
_currentSelectedOption = _savedSelectedOption;

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


private void OnEnable()
{
_deathEvent.OnEventRaised += SetHealthBar;
_updateHealthEvent.OnEventRaised += SetHeartImages;
_deathEvent.OnEventRaised += RegisterDeath;
_updateHealthEvent.OnEventRaised += UpdateHeartImages;
_deathEvent.OnEventRaised += UpdateHeartImages;
SetHealthBar();
}

_updateHealthEvent.OnEventRaised -= SetHeartImages;
_deathEvent.OnEventRaised -= SetHealthBar;
_deathEvent.OnEventRaised -= RegisterDeath;
}
private void OnLevelWasLoaded(int level)
{
SetHeartImages();
}
public void SetHealthBar()
{
_currentHealth.SetMaxHealth(_healthConfig.MaxHealth);
_currentHealth.SetCurrentHealth(_healthConfig.MaxHealth);
SetHeartImages();
}
public void InflictDamage(int _damage)
{
SetHeartImages();
_updateHealthEvent.OnEventRaised -= UpdateHeartImages;
_deathEvent.OnEventRaised -= UpdateHeartImages;
public void RestoreHealth(int _healthToAdd)
private void SetHealthBar()
SetHeartImages();
}
_currentHealth.SetMaxHealth(_healthConfig.InitialHealth);
_currentHealth.SetCurrentHealth(_healthConfig.InitialHealth);
public void RegisterDeath()
{
SetHealthBar();
UpdateHeartImages();
void SetHeartImages()
private void UpdateHeartImages()
{
int heartValue = _currentHealth.MaxHealth / _heartImages.Length;
int filledHeartCount = Mathf.FloorToInt((float)_currentHealth.CurrentHealth / heartValue);

15
UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/BardHare/States/Idle.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 35432205b9a6a374bbbfe6b7cac92179, type: 3}
m_Name: Idle
m_EditorClassIdentifier:
_actions: []

8
UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/BardHare/States/Idle.asset.meta


fileFormatVersion: 2
guid: 0739bae51cc5c43729309c4977455722
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

8
UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/Shared.meta


fileFormatVersion: 2
guid: 33e157dfe73cf4a2bbf618a8919625ab
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

39
UOP1_Project/Assets/Scripts/Characters/HealthSO.cs


using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// An instance of the health of a character, be it the player or an NPC.
/// The initial values are usually contained in another SO of type HealthConfigSO.
/// </summary>
[CreateAssetMenu(fileName = "PlayersHealth", menuName = "EntityConfig/Player's Health")]
public class HealthSO : ScriptableObject
{
[Tooltip("The initial health")]
[SerializeField][ReadOnly] private int _maxHealth;
[SerializeField][ReadOnly] private int _currentHealth;
public int MaxHealth => _maxHealth;
public int CurrentHealth => _currentHealth;
public void SetMaxHealth(int newValue)
{
_maxHealth = newValue;
}
public void SetCurrentHealth(int newValue)
{
_currentHealth = newValue;
}
public void InflictDamage(int DamageValue)
{
_currentHealth -= DamageValue;
}
public void RestoreHealth(int HealthValue)
{
_currentHealth += HealthValue;
if(_currentHealth > _maxHealth)
_currentHealth = _maxHealth;
}
}

31
UOP1_Project/Assets/Scripts/Characters/Config/HealthSO.cs


using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "PlayersHealth", menuName = "EntityConfig/Player's Health")]
public class HealthSO : ScriptableObject
{
[Tooltip("Initial health")]
[SerializeField] private int _maxHealth = default;
[Tooltip("current health")]
[SerializeField] private int _currentHealth = default;
public int MaxHealth => _maxHealth;
public int CurrentHealth => _currentHealth;
public void SetMaxHealth(int newValue)
{
_maxHealth = newValue;
}
public void SetCurrentHealth(int newValue)
{
_currentHealth = newValue;
}
public void InflictDamage(int DamageValue)
{
_currentHealth -= DamageValue;
}
public void RestoreHealth(int HealthValue)
{
_currentHealth += HealthValue;
}
}

/UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/Actions.meta → /UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/Shared/Actions.meta

/UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/Conditions.meta → /UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/Shared/Conditions.meta

/UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/States.meta → /UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/Shared/States.meta

/UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/Actions → /UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/Shared/Actions

/UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/Conditions → /UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/Shared/Conditions

/UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/States → /UOP1_Project/Assets/ScriptableObjects/StateMachine/NPCs/Shared/States

/UOP1_Project/Assets/Scripts/Characters/Config/HealthSO.cs.meta → /UOP1_Project/Assets/Scripts/Characters/HealthSO.cs.meta

正在加载...
取消
保存