Trineks Manager - WIP implementation

This commit is contained in:
2025-11-20 20:51:58 +01:00
parent 78ed61380e
commit 66d4e8b4b2
13 changed files with 3798 additions and 1034 deletions

View File

@@ -23,27 +23,14 @@ namespace Beyond
{
[SerializeField] private List<PlayerAttribute> m_playerAttributes = new List<PlayerAttribute>();
/// <summary>
/// This array defines thresholds for brightness points. It is used to define multiplier applied to player brightness point on guild. Please see code.
/// </summary>
public static readonly int[] BrightnessPoints_Th =
{
30, 20, 0,
};
public static readonly int[] BrightnessPoints_Th = { 30, 20, 0 };
public List<PlayerAttribute> Attributes => m_playerAttributes;
public GameObject audioSource;
public AudioClip[] m_onHitClips,
m_noFaithClips,
m_cantDoThatYetClips,
m_BrightnessLostClips,
m_BrightnessGainedClips,
m_deathClips;
public AudioClip[] consumeDefaultSounds, consumeFaithSounds, consumeGemstoneSounds, equipWeaponSounds, equipConsumablesSounds, equipPowerSounds, unequipWeaponSounds, unequipConsumablesSounds, unequipPowerSounds, changePageSounds, changeCategorySounds, openMenuSounds,
acceptGuiltSounds, declineGuiltSounds, fullyChargedSounds;
public AudioClip[] m_onHitClips, m_noFaithClips, m_cantDoThatYetClips, m_BrightnessLostClips, m_BrightnessGainedClips, m_deathClips;
public AudioClip[] consumeDefaultSounds, consumeFaithSounds, consumeGemstoneSounds, equipWeaponSounds, equipConsumablesSounds, equipPowerSounds, unequipWeaponSounds, unequipConsumablesSounds, unequipPowerSounds, changePageSounds, changeCategorySounds, openMenuSounds, acceptGuiltSounds, declineGuiltSounds, fullyChargedSounds;
private List<bItemType> weaponTypes = new List<bItemType> { bItemType.Swords, bItemType.Axes };
private List<bItemType> consumablesTypes = new List<bItemType> { bItemType.Consumable, bItemType.ConsumablesFaith };
@@ -84,7 +71,36 @@ namespace Beyond
private bMeleeCombatInput m_meleeCombatInput;
public MagicAttacks Magic => m_magicAttacks;
public bMeleeCombatInput MeleeCombatInput => m_meleeCombatInput;
public bMeleeCombatInput MeleeCombatInput => m_meleeCombatInput;
// --- TRINKET SYSTEM INTEGRATION START ---
private TrinketManager.TrinketStats m_trinketStats = new TrinketManager.TrinketStats
{
healthMult = 1f,
defenseMult = 1f,
faithMult = 1f,
damageMult = 1f,
speedMult = 1f,
faithRegenMult = 1f,
attackSpeedMult = 1f,
thornDamageMult = 1f
};
public TrinketManager.TrinketStats CurrentTrinketStats => m_trinketStats;
public void UpdateTrinketStats(TrinketManager.TrinketStats newStats)
{
m_trinketStats = newStats;
// Force stats recalculation
UodatePlayerStatistics();
// Apply immediate effects
if (m_vController)
{
m_vController.speedMultiplier = m_trinketStats.speedMult;
}
}
// --- TRINKET SYSTEM INTEGRATION END ---
public PlayerAttribute MaturityAttribute
{
@@ -115,35 +131,21 @@ namespace Beyond
private void SetMaturityAttributeIfNull()
{
if (maturityAttribute == null)
{
maturityAttribute = GetAttribute("Maturity");
}
if (maturityAttribute == null) maturityAttribute = GetAttribute("Maturity");
}
private void SetBrightnessAttributeIfNull()
{
if (brightnessAttribute == null)
{
brightnessAttribute = GetAttribute("BrightnessPoints");
}
if (brightnessAttribute == null) brightnessAttribute = GetAttribute("BrightnessPoints");
}
private void SetFaithAttributeIfNull()
{
if (maturityAttribute == null)
{
faithAttribute = GetAttribute("Faith");
}
if (maturityAttribute == null) faithAttribute = GetAttribute("Faith");
}
[SerializeField] public MenuScroll menuScroll;
// [SerializeField]
//private int faithRegenValue = 1;
// private float faithRegenTime = 1f;
// private float faithCurrentTime = 0f;
public float sceneDependantFaithRegenMultiplier = 1f, faithRegenMultiplier = 1f;
private float healthBaseMaxValue = 200;
@@ -155,7 +157,7 @@ namespace Beyond
private System.Action onMenuScrollClosed;
public System.Action<float> onStatsUpdated;
private UnityAction<Transform> onDialogueEnded;
private bLockOn m_lockOn; //cached lock on component
private bLockOn m_lockOn;
public bLockOn LockOn => m_lockOn;
private vLadderAction ladderAction;
@@ -167,10 +169,7 @@ namespace Beyond
private void Awake()
{
if (s_instance == null)
{
s_instance = this;
}
if (s_instance == null) s_instance = this;
else
{
Debug.LogError($"Player instance already exists! Destroying...({gameObject.name})");
@@ -192,13 +191,10 @@ namespace Beyond
m_meleeCombatInput = GetComponent<bMeleeCombatInput>();
}
private void OnEnable()
{
//InitAttributesValues();
HideUI.SetActive += OnCustcene;
if (m_vInputs)
m_vInputs.forceWalking = false;
if (m_vInputs) m_vInputs.forceWalking = false;
}
protected void Start()
@@ -209,10 +205,7 @@ namespace Beyond
DialogueManager.instance.conversationStarted += OnConversationStarted;
DialogueManager.instance.conversationEnded += OnConversationEnded;
m_Respawner.m_onRespawned.AddListener(ResetInputs);
// m_Respawner.m_onRespawnedStart.AddListener(ResetAnimator);
m_vController.onDead.AddListener(ResetAnimator);
//CheckAttributesValues();
if (m_meleeManager)
{
m_meleeManager.onDamageHit.AddListener(OnDamageHit);
@@ -221,11 +214,28 @@ namespace Beyond
private void OnDamageHit(vHitInfo arg0)
{
// Slow motion logic (existing)
if (slowMoOnHtScale < 1f - float.Epsilon)
{
//TimeController.Instance.SetTimeScaleForSec(slowMoOnHtScale, slowMoOnHitTime);
TimeController.Instance.Reset();
}
// 1. Health Vampirism
if (m_trinketStats.effectHealthVampirism)
{
// Logic: Heal 2% of Player's Max Health per hit
// Mathf.Max ensures we always heal at least 1 HP
int healAmount = Mathf.Max(1, (int)(MaxHealth * 0.02f));
m_vController.ChangeHealth(healAmount);
}
// 2. Faith Vampirism
if (m_trinketStats.effectFaithVampirism)
{
// Logic: Add 1 Faith point per hit
UpdateFaithCurrentValue(1);
}
// ----------------------------
}
private void OnConversationStarted(Transform transform)
@@ -247,15 +257,14 @@ namespace Beyond
{
RemoveAttributeListeners();
UnregisterLuaFunctions();
if (menuScroll != null)
menuScroll.OnClosed -= onMenuScrollClosed;
if (menuScroll != null) menuScroll.OnClosed -= onMenuScrollClosed;
if (DialogueManager.instance != null)
{
DialogueManager.instance.conversationStarted -= OnConversationStarted;
if (DialogueManager.instance != null)
DialogueManager.instance.conversationEnded -= OnConversationEnded;
}
m_Respawner.m_onRespawned.RemoveListener(ResetInputs);
m_Respawner.m_onRespawnedStart.RemoveListener(ResetAnimator);
// m_vController.onDead.RemoveListener(ResetAnimatior);
}
protected void Update()
@@ -263,37 +272,11 @@ namespace Beyond
float faith = faithAttribute.AttributeCurrentValue;
faith += Time.deltaTime * faithRegenMultiplier;
faithAttribute.SetValue(faith);
/*
faithCurrentTime += Time.deltaTime;
if (faithCurrentTime > faithRegenTime / faithRegenMultiplier)
{
faithCurrentTime -= faithCurrentTime;
float newVal = faithAttribute.AttributeCurrentValue + 1;
if (newVal > faithAttribute.AttributeMaxValue)
{
newVal = faithAttribute.AttributeMaxValue;
}
else if (newVal < faithAttribute.AttributeMinValue)
{
newVal = faithAttribute.AttributeMinValue;
}
faithAttribute.SetValue(newVal);
}
*/
// bThirdPersonController controller = (bThirdPersonController)m_vController;
// controller.animatorStateInfos.stateInfos.vToList().ForEach(info => { Debug.Log(info.layer); Debug.Log(info.tags.Count); info.tags.ForEach(tag => Debug.Log(tag)); });
}
public void ResetInputs()
{
// ResetAnimator();
bThirdPersonController controller = (bThirdPersonController)m_vController;
//controller.triggerDieBehaviour = false;
//m_vInputs.SetLockAllInput(false);
//controller.EnableGravityAndCollision();
//controller.StopCharacter();
//controller.disableAnimations = false;
controller.triggerDieBehaviour = false;
ladderAction = GetComponent<vLadderAction>();
ladderAction.ResetPlayerSettings();
@@ -311,18 +294,11 @@ namespace Beyond
controller.RemoveAnimatorTags();
}
public void PlayNoFaithClip()
{
PlayRandomSound(m_noFaithClips);
}
// ... [Audio Play Methods - kept same] ...
public void PlayNoFaithClip() { PlayRandomSound(m_noFaithClips); }
private void PlayRandomSound(AudioClip[] sounds)
{
//so we do not get bunch of sounds at the game start
if (Time.timeSinceLevelLoad < 1f)
{
return;
}
if (Time.timeSinceLevelLoad < 1f) return;
int soundsCount = sounds.Length;
if (audioSource != null && soundsCount > 0)
{
@@ -331,161 +307,76 @@ namespace Beyond
audioObject.GetComponent<AudioSource>().PlayOneShot(clip);
}
}
public void PlayICantDoThatYet()
{
PlayRandomSound(m_cantDoThatYetClips);
}
public void PlayBrightnessLost()
{
PlayRandomSound(m_BrightnessLostClips);
}
public void PlayBrightnessGained()
{
PlayRandomSound(m_BrightnessGainedClips);
}
public void PlayMaturityGained()
{
PlayRandomSound(m_BrightnessGainedClips);
}
public void PlayICantDoThatYet() { PlayRandomSound(m_cantDoThatYetClips); }
public void PlayBrightnessLost() { PlayRandomSound(m_BrightnessLostClips); }
public void PlayBrightnessGained() { PlayRandomSound(m_BrightnessGainedClips); }
public void PlayMaturityGained() { PlayRandomSound(m_BrightnessGainedClips); }
public void PlayConsumeSound(bItem consumedItem)
{
if (consumedItem.type == bItemType.ConsumablesFaith)
{
PlayRandomSound(consumeFaithSounds);
}
else if (consumedItem.type == bItemType.Gemstones)
{
PlayRandomSound(consumeGemstoneSounds);
}
else if (consumedItem.type == bItemType.PowerScroll)
{
}
else
{
PlayRandomSound(consumeDefaultSounds);
}
if (consumedItem.type == bItemType.ConsumablesFaith) PlayRandomSound(consumeFaithSounds);
else if (consumedItem.type == bItemType.Gemstones) PlayRandomSound(consumeGemstoneSounds);
else if (consumedItem.type == bItemType.PowerScroll) { }
else PlayRandomSound(consumeDefaultSounds);
}
public void PlayFullyChargedSound()
{
PlayRandomSound(fullyChargedSounds);
}
public void PlayFullyChargedSound() { PlayRandomSound(fullyChargedSounds); }
public void PlayEquipSound(bEquipArea equipArea, bItem item)
{
if (consumablesTypes.Contains(item.type))
{
PlayRandomSound(equipConsumablesSounds);
}
else if (weaponTypes.Contains(item.type))
{
PlayRandomSound(equipWeaponSounds);
}
else
{
PlayRandomSound(equipPowerSounds);
}
if (consumablesTypes.Contains(item.type)) PlayRandomSound(equipConsumablesSounds);
else if (weaponTypes.Contains(item.type)) PlayRandomSound(equipWeaponSounds);
else PlayRandomSound(equipPowerSounds);
}
public void PlayUnequipSound(bEquipArea equipArea, bItem item)
{
if (consumablesTypes.Contains(item.type))
{
PlayRandomSound(unequipConsumablesSounds);
}
else if (weaponTypes.Contains(item.type))
{
PlayRandomSound(unequipWeaponSounds);
}
else
{
PlayRandomSound(unequipPowerSounds);
}
}
public void PlayCategoryChangeSound()
{
PlayRandomSound(changeCategorySounds);
}
public void PlayChangePageSound()
{
PlayRandomSound(changePageSounds);
}
public void PlayOpenMenuSound()
{
PlayRandomSound(openMenuSounds);
}
public void PlayAcceptGuiltSound()
{
PlayRandomSound(acceptGuiltSounds);
}
public void PlayDeclineGuiltSound()
{
PlayRandomSound(declineGuiltSounds);
}
public void PlayOnHitSound()
{
PlayRandomSound(m_onHitClips);
}
public void PlayOnDeathSound()
{
PlayRandomSound(m_deathClips);
if (consumablesTypes.Contains(item.type)) PlayRandomSound(unequipConsumablesSounds);
else if (weaponTypes.Contains(item.type)) PlayRandomSound(unequipWeaponSounds);
else PlayRandomSound(unequipPowerSounds);
}
public void PlayCategoryChangeSound() { PlayRandomSound(changeCategorySounds); }
public void PlayChangePageSound() { PlayRandomSound(changePageSounds); }
public void PlayOpenMenuSound() { PlayRandomSound(openMenuSounds); }
public void PlayAcceptGuiltSound() { PlayRandomSound(acceptGuiltSounds); }
public void PlayDeclineGuiltSound() { PlayRandomSound(declineGuiltSounds); }
public void PlayOnHitSound() { PlayRandomSound(m_onHitClips); }
public void PlayOnDeathSound() { PlayRandomSound(m_deathClips); }
private void OnCustcene(bool b)
{
m_audioSource.Stop();
m_audioSource.clip = null;
//on ui show player should be killable and vice versa
m_cutScenePlaying = !b;
m_vController.isImmortal = !b;
// Debug.LogError("is immortal: " + m_vController.isImmortal);
}
public void OnReceivedDamage(vDamage damage)
{
if (m_cutScenePlaying)
return;
if (m_cutScenePlaying) return;
// --- TRINKET DEFENSE CALCULATION ---
// defenseMult of 0.9 means 90% damage taken (10% reduction)
if (Mathf.Abs(m_trinketStats.defenseMult - 1f) > float.Epsilon)
{
damage.damageValue = (int)(damage.damageValue * m_trinketStats.defenseMult);
}
// -----------------------------------
#if UNITY_IOS && !UNITY_EDITOR
HapticEngine.ImpactFeedbackHeavy();
#endif
if (m_onHitClips != null && m_onHitClips.Length > 0)
PlayOnHitSound();
if (m_onHitClips != null && m_onHitClips.Length > 0) PlayOnHitSound();
}
/// <summary>
/// death sound canceled as of now
/// </summary>
/// <param name="gameObject"></param>
public void OnDead(GameObject gameObject)
{
if (m_cutScenePlaying)
return;
if (m_cutScenePlaying) return;
#if UNITY_IOS && !UNITY_EDITOR
HapticEngine.ImpactFeedbackHeavy();
#endif
if (m_deathClips != null && m_deathClips.Length > 0)
PlayOnDeathSound();
if (m_deathClips != null && m_deathClips.Length > 0) PlayOnDeathSound();
}
public void OnCheckpoint()
{
if (m_Respawner)
{
m_Respawner.SaveRespawnPoint();
}
if (m_Respawner) m_Respawner.SaveRespawnPoint();
}
public List<Quest> GetAllGuilts()
@@ -495,18 +386,14 @@ namespace Beyond
Debug.LogError("There is no Players Journal component on player game object");
return null;
}
List<Quest> guilts = new List<Quest>();
for (int i = 0; i < m_questJournal.questList.Count; i++)
{
if (m_questJournal.questList[i].isTrackable ==
false) // if in future will be not trackable quest we also should check quest group
if (m_questJournal.questList[i].isTrackable == false)
{
guilts.Add(m_questJournal.questList[i]);
}
}
return guilts;
}
@@ -514,7 +401,6 @@ namespace Beyond
public void Debug_DisplayAllGuilts()
{
var guilts = GetAllGuilts();
guilts.ForEach(x => Debug.LogError(x.title));
}
@@ -522,12 +408,8 @@ namespace Beyond
{
for (int i = 0; i < m_playerAttributes.Count; i++)
{
if (m_playerAttributes[i].AttributeName == name)
{
return m_playerAttributes[i];
}
if (m_playerAttributes[i].AttributeName == name) return m_playerAttributes[i];
}
Debug.LogError("There is no player attribute such " + name);
return null;
}
@@ -535,22 +417,14 @@ namespace Beyond
public void SetAttribute(string name, int value)
{
PlayerAttribute playerAttribute = GetAttribute(name);
if (playerAttribute == null)
{
return;
}
if (playerAttribute == null) return;
playerAttribute.SetValue(value);
}
public void SetAttribute(PlayerAttribute attribute)
{
PlayerAttribute playerAttribute = GetAttribute(attribute.AttributeName);
if (playerAttribute == null)
{
return;
}
if (playerAttribute == null) return;
playerAttribute.SetValue(attribute);
}
@@ -566,24 +440,16 @@ namespace Beyond
private void InitAttributListeners()
{
//add listener
brightnessAttribute = GetAttribute("BrightnessPoints");
if (brightnessAttribute != null)
{
brightnessAttribute.OnValueChanged.AddListener(OnBrightnessPointsValueChanged);
brightnessAttribute.OnValueChanged.AddListener(UpdatePlayerStatisticsOnBrightnessChange);
}
else
{
Debug.LogError("Couldnt get Brightness attribute ");
}
else Debug.LogError("Couldnt get Brightness attribute ");
faithAttribute = GetAttribute("Faith");
if (faithAttribute == null)
{
Debug.LogError("Couldnt get Faith attribute ");
}
if (faithAttribute == null) Debug.LogError("Couldnt get Faith attribute ");
maturityAttribute = GetAttribute("Maturity");
if (maturityAttribute != null)
@@ -591,10 +457,7 @@ namespace Beyond
maturityAttribute.OnValueChanged.AddListener(UpdatePlayerStatisticsOnMaturityChange);
maturityAttribute.OnValueChanged.AddListener(OnMaturityPointsValueChanged);
}
else
{
Debug.LogError("Couldnt get Maturity attribute ");
}
else Debug.LogError("Couldnt get Maturity attribute ");
}
private void RemoveAttributeListeners()
@@ -622,9 +485,7 @@ namespace Beyond
public void UodatePlayerStatistics()
{
float maturityMupltiplier = (float)(1 +
(float)(0.5f * maturityAttribute.AttributeCurrentValue /
maturityAttribute.AttributeMaxValue));
float maturityMupltiplier = (float)(1 + (float)(0.5f * maturityAttribute.AttributeCurrentValue / maturityAttribute.AttributeMaxValue));
float maxBrightness = brightnessAttribute.AttributeMaxValue;
float halfB = maxBrightness / 2;
float brightnessMultiplier = 1 + (brightnessAttribute.AttributeCurrentValue - halfB) / halfB;
@@ -634,9 +495,7 @@ namespace Beyond
public void UpdatePlayerStatisticsOnBrightnessChange(float val = 0, float prevVal = 0)
{
float maturityMupltiplier = (float)(1 +
(float)(0.5f * maturityAttribute.AttributeCurrentValue /
maturityAttribute.AttributeMaxValue));
float maturityMupltiplier = (float)(1 + (float)(0.5f * maturityAttribute.AttributeCurrentValue / maturityAttribute.AttributeMaxValue));
float maxBrightness = brightnessAttribute.AttributeMaxValue;
float halfB = maxBrightness / 2;
float brightnessMultiplier = 1 + (val - halfB) / halfB;
@@ -646,18 +505,34 @@ namespace Beyond
private void SetPlayerStatisticsBasedOn(float finalMultiplier)
{
faithRegenMultiplier = sceneDependantFaithRegenMultiplier * finalMultiplier;
faithAttribute.AttributeMaxValue = Mathf.RoundToInt(faithBaseMaxValue * finalMultiplier);
m_vController.maxHealth = Mathf.RoundToInt(finalMultiplier * healthBaseMaxValue);
// --- TRINKET INTEGRATION IN STATS CALCULATION ---
// Faith Regen
faithRegenMultiplier = sceneDependantFaithRegenMultiplier * finalMultiplier * m_trinketStats.faithRegenMult;
// Max Faith
float totalFaithMult = finalMultiplier * m_trinketStats.faithMult;
faithAttribute.AttributeMaxValue = Mathf.RoundToInt(faithBaseMaxValue * totalFaithMult);
// Max Health
float totalHealthMult = finalMultiplier * m_trinketStats.healthMult;
m_vController.maxHealth = Mathf.RoundToInt(totalHealthMult * healthBaseMaxValue);
// Reset health if caps changed downwards
if (m_vController.maxHealth < m_vController.currentHealth)
{
m_vController.ResetHealth();
}
// Health Recovery
m_vController.SetHealthRecovery(finalMultiplier * healthBaseRegenValue);
// Stamina (assuming no trinket mult for stamina yet, if needed add m_trinketStats.staminaMult)
m_vController.maxStamina = Mathf.Round(finalMultiplier * staminaBaseMaxValue);
m_vController.staminaRecovery = (finalMultiplier * staminaBaseRegenValue);
// ------------------------------------------------
onStatsUpdated?.Invoke(finalMultiplier);
}
@@ -675,51 +550,17 @@ namespace Beyond
public void UpdateMaturityCurrentValue(int valueChange, int prevVal)
{
float newVal = maturityAttribute.AttributeCurrentValue + valueChange;
if (newVal > maturityAttribute.AttributeMaxValue)
{
newVal = maturityAttribute.AttributeMaxValue;
}
else if (newVal < maturityAttribute.AttributeMinValue)
{
newVal = maturityAttribute.AttributeMinValue;
}
if (newVal > maturityAttribute.AttributeMaxValue) newVal = maturityAttribute.AttributeMaxValue;
else if (newVal < maturityAttribute.AttributeMinValue) newVal = maturityAttribute.AttributeMinValue;
maturityAttribute.SetValue(newVal);
}
public float GetCurrentMaturityValue()
{
return maturityAttribute.AttributeCurrentValue;
}
public double GetBrightness()
{
var attr = GetAttribute("BrightnessPoints");
return (double)attr.AttributeCurrentValue;
}
public void SetBrightness(double value)
{
brightnessAttribute.SetValue((int)value);
//attr.CheckValueWithDatabase();
}
public double GetMaturity()
{
var attr = GetAttribute("Maturity");
return (double)attr.AttributeCurrentValue;
}
public void SetMaturity(double value)
{
maturityAttribute.SetValue((int)value);
}
public void UpdateBrightnessCurrentValue(int points)
{
UpdateBrightnessCurrentValue((float)points);
}
public float GetCurrentMaturityValue() { return maturityAttribute.AttributeCurrentValue; }
public double GetBrightness() { var attr = GetAttribute("BrightnessPoints"); return (double)attr.AttributeCurrentValue; }
public void SetBrightness(double value) { brightnessAttribute.SetValue((int)value); }
public double GetMaturity() { var attr = GetAttribute("Maturity"); return (double)attr.AttributeCurrentValue; }
public void SetMaturity(double value) { maturityAttribute.SetValue((int)value); }
public void UpdateBrightnessCurrentValue(int points) { UpdateBrightnessCurrentValue((float)points); }
[Button]
public void UpdateBrightnessCurrentValue(float points)
@@ -729,26 +570,14 @@ namespace Beyond
float multiplier = 1f;
for (int i = 0; i < BrightnessPoints_Th.Length; i++)
{
if (brightnessAttribute.AttributeCurrentValue < BrightnessPoints_Th[i])
{
multiplier *= 0.5f;
}
else
{
break;
}
if (brightnessAttribute.AttributeCurrentValue < BrightnessPoints_Th[i]) multiplier *= 0.5f;
else break;
}
brightnessAttribute.SetValue(brightnessAttribute.AttributeCurrentValue + (int)(points * multiplier));
}
else
{
//add only 50% of points if player is not confesed
if (brightnessAttribute.AttributeCurrentValue < 50)
{
points = points / 2;
}
if (brightnessAttribute.AttributeCurrentValue < 50) points = points / 2;
brightnessAttribute.SetValue(brightnessAttribute.AttributeCurrentValue + points);
}
}
@@ -765,16 +594,11 @@ namespace Beyond
else if (DialogueManager.instance.IsConversationActive)
{
onMenuScrollClosed = () => { BarkBrightnessChange(value, prevValues); };
// DialogueManager.instance.OnEndConversation += onMenuScrollClosed;
var events = DialogueManager.instance.GetComponent<DialogueSystemEvents>();
onMenuScrollClosed = () => { BarkBrightnessChange(value, prevValues); };
// UnityEvent<Transform> ev= (transform) => { BarkBrightnessChange(value, prevValues); };
onDialogueEnded = (transform) => { BarkBrightnessChange(value, prevValues); };
// events.onConversationEnd += onDialogueEnded;
events.conversationEvents.onConversationEnd.AddListener(onDialogueEnded);
return;
}
BarkBrightnessChange(value, prevValues);
}
@@ -787,20 +611,9 @@ namespace Beyond
public void BarkBrightnessChange(float value, float prevValues)
{
float difference = Mathf.Abs(value - prevValues);
if (difference < 1f)
{
//to not spam with small gains
}
else if (value > prevValues)
{
DialogueManager.BarkString("Brightness Points Gained!", Player.Instance.transform);
}
else
{
DialogueManager.BarkString("Brightness Points Lost!", Player.Instance.transform);
}
if (difference < 1f) { }
else if (value > prevValues) DialogueManager.BarkString("Brightness Points Gained!", Player.Instance.transform);
else DialogueManager.BarkString("Brightness Points Lost!", Player.Instance.transform);
ClearOnMenuScrollClosed();
}
@@ -808,7 +621,6 @@ namespace Beyond
{
menuScroll.OnClosed -= onMenuScrollClosed;
onMenuScrollClosed = null;
if (onDialogueEnded != null)
{
var events = DialogueManager.instance.GetComponent<DialogueSystemEvents>();
@@ -817,16 +629,8 @@ namespace Beyond
}
}
public float GetCurrentFaithValue()
{
return faithAttribute.AttributeCurrentValue;
}
public void UpdateFaithCurrentValue(int valueChange)
{
UpdateFaithCurrentValue((float)valueChange);
}
public float GetCurrentFaithValue() { return faithAttribute.AttributeCurrentValue; }
public void UpdateFaithCurrentValue(int valueChange) { UpdateFaithCurrentValue((float)valueChange); }
public void UpdateFaithCurrentValue(float valueChange)
{
float newVal = faithAttribute.AttributeCurrentValue + valueChange;
@@ -835,31 +639,19 @@ namespace Beyond
public void SetInteractableButtonImage(Sprite image)
{
if (!defaultInteractionImage)
{
defaultInteractionImage = interactionImage.sprite;
}
if (!defaultInteractionImage) defaultInteractionImage = interactionImage.sprite;
interactionImage.sprite = image;
}
public void ResetIntaractableButtonImage()
{
if (!defaultInteractionImage)
{
defaultInteractionImage = interactionImage.sprite;
}
if (!defaultInteractionImage) defaultInteractionImage = interactionImage.sprite;
interactionImage.sprite = defaultInteractionImage;
}
public void SetDialogueIntaractableButtonImage()
{
if (!defaultInteractionImage)
{
defaultInteractionImage = interactionImage.sprite;
}
if (!defaultInteractionImage) defaultInteractionImage = interactionImage.sprite;
interactionImage.sprite = dialogueInteractionImage;
}
@@ -871,49 +663,24 @@ namespace Beyond
public void PlaySingleSound(AudioClip clipToPlay, bool destroyAfterPlaying = true)
{
// Opcjonalne op<6F>nienie na starcie poziomu, aby unikn<6B><6E> "spamowania" d<>wi<77>kami
if (Time.timeSinceLevelLoad < 0.5f && clipToPlay != null)
if (Time.timeSinceLevelLoad < 0.5f && clipToPlay != null) { }
if (this.audioSource == null)
{
// Mo<4D>esz chcie<69> to odkomentowa<77>, je<6A>li d<>wi<77>ki na starcie s<> problemem
// return;
}
if (this.audioSource == null) // this.audioSource to pole GameObject (prefab) w Player.cs
{
Debug.LogWarning("Player's 'audioSource' (GameObject prefab) is not assigned in Inspector. Cannot play sound: " + (clipToPlay ? clipToPlay.name : "Unknown clip"));
return;
}
if (clipToPlay == null)
{
Debug.LogWarning("Attempted to play a null AudioClip.");
Debug.LogWarning("Player's 'audioSource' is not assigned.");
return;
}
if (clipToPlay == null) return;
// Instancjonowanie prefabu d<>wi<77>kowego
// Upewnij si<73>, <20>e prefab 'audioSource' ma komponent AudioSource
GameObject audioObjectInstance = Instantiate(this.audioSource, transform.position, transform.rotation);
AudioSource sourceComponent = audioObjectInstance.GetComponent<AudioSource>();
if (sourceComponent != null)
{
// PlayOneShot jest dobre dla efekt<6B>w, nie przerywa innych d<>wi<77>k<EFBFBD>w na tym samym source,
// je<6A>li s<> one odtwarzane przez .Play() i nie u<>ywaj<61> tego samego kana<6E>u.
sourceComponent.PlayOneShot(clipToPlay);
if (destroyAfterPlaying)
{
// Niszczymy obiekt GameObject zawieraj<61>cy AudioSource po zako<6B>czeniu odtwarzania klipu.
// Dodajemy ma<6D>y bufor czasowy, aby upewni<6E> si<73>, <20>e d<>wi<77>k zd<7A><64>y si<73> odtworzy<7A> w ca<63>o<EFBFBD>ci.
Destroy(audioObjectInstance, clipToPlay.length + 0.1f);
}
}
else
{
Debug.LogWarning("The instantiated 'audioSource' prefab (from Player.cs) does not have an AudioSource component. Destroying instance.");
Destroy(audioObjectInstance); // Posprz<72>taj, je<6A>li co<63> posz<73>o nie tak
if (destroyAfterPlaying) Destroy(audioObjectInstance, clipToPlay.length + 0.1f);
}
else Destroy(audioObjectInstance);
}
}
[System.Serializable]
@@ -921,16 +688,13 @@ namespace Beyond
{
public string AttributeName;
public float AttributeCurrentValue;
public float AttributeMaxValue;
public float AttributeMinValue = 0;
public UnityEvent<float, float> OnValueChanged;
public void SetValue(PlayerAttribute attribute)
{
if (attribute.AttributeName != AttributeName)
return;
if (attribute.AttributeName != AttributeName) return;
AttributeMaxValue = attribute.AttributeMaxValue;
AttributeMinValue = attribute.AttributeMinValue;
SetValue(attribute.AttributeCurrentValue);
@@ -938,8 +702,6 @@ namespace Beyond
public void Init()
{
//var variable = DialogueLua.GetVariable(AttributeName).asInt;
//AttributeCurrentValue = variable;
DialogueLua.SetVariable(AttributeName, AttributeCurrentValue);
}
@@ -947,36 +709,14 @@ namespace Beyond
{
if (value != AttributeCurrentValue)
{
/*
if (value > AttributeMaxValue || value < AttributeMinValue)
{
Debug.LogWarning(
$"Can't set variable. Out of range. AttributeName={AttributeName} with value want to be set to: {value}");
return;
}
*/
value = value > AttributeMaxValue ? AttributeMaxValue : value;
value = value < AttributeMinValue ? AttributeMinValue : value;
OnValueChanged?.Invoke(value, AttributeCurrentValue);
AttributeCurrentValue = value;
DialogueLua.SetVariable(AttributeName, value);
}
}
/*
public void CheckValueWithDatabase()
{
var variable = DialogueLua.GetVariable(AttributeName).asInt;
if (variable == AttributeCurrentValue)
{
return;
}
AttributeCurrentValue = variable;
OnValueChangedDatabase?.Invoke(variable);
}
*/
public void ClearValue()
{
AttributeCurrentValue = AttributeMinValue;

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c25b2a968165e4343811e5c63654e77b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: