|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
using UnityEngine.EventSystems;
|
|
|
|
|
using UnityEngine.Events;
|
|
|
|
|
using SiegeSong;
|
|
|
|
|
|
|
|
|
|
namespace SiegeSong
|
|
|
|
|
{
|
|
|
|
|
public class ActorStatistics : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public ActorLoader ActorLoader;
|
|
|
|
|
|
|
|
|
|
public int ID;
|
|
|
|
|
public string InstanceID;
|
|
|
|
|
|
|
|
|
|
public string FirstName = "Human";
|
|
|
|
|
public string LastName = "Being";
|
|
|
|
|
|
|
|
|
|
public bool Alive = true;
|
|
|
|
|
|
|
|
|
|
public InventoryManager Inventory;
|
|
|
|
|
public Selectable LootSelectable;
|
|
|
|
|
public AudioSource AudioSource;
|
|
|
|
|
public ThreatAwareness Awareness;
|
|
|
|
|
public FactionManager FactionManager;
|
|
|
|
|
|
|
|
|
|
public Dictionary<int, int> RespectForActor;
|
|
|
|
|
public Dictionary<int, int> AdmirationForActor;
|
|
|
|
|
public Dictionary<int, int> SuspicionOfActor;
|
|
|
|
|
|
|
|
|
|
public Dictionary<int, int> FactionRank;
|
|
|
|
|
public Dictionary<int, int> RegionalBounty;
|
|
|
|
|
public Dictionary<int, int> RegionalFame;
|
|
|
|
|
|
|
|
|
|
public Dictionary<int, int> QuestStates;
|
|
|
|
|
|
|
|
|
|
public Dictionary<int, int> Attributes;
|
|
|
|
|
|
|
|
|
|
public Dictionary<int, Dictionary<int, int>> SkillValueCategories;
|
|
|
|
|
|
|
|
|
|
public Dictionary<string, float> Blendshapes;
|
|
|
|
|
|
|
|
|
|
public int HairstyleID;
|
|
|
|
|
public int FacialHairID;
|
|
|
|
|
public int FacialDetailID;
|
|
|
|
|
public int HairColorR;
|
|
|
|
|
public int HairColorG;
|
|
|
|
|
public int HairColorB;
|
|
|
|
|
public int HairColorA;
|
|
|
|
|
|
|
|
|
|
public bool Recoil;
|
|
|
|
|
|
|
|
|
|
public int NoiseBeingProduced = 2; // in decibels
|
|
|
|
|
public int VisualStealthRating;
|
|
|
|
|
|
|
|
|
|
public float StaminaRecoveryRate = 0.2f;
|
|
|
|
|
public float MagicRecoveryRate = 0.2f;
|
|
|
|
|
public float HealthRecoveryRate = 0.2f;
|
|
|
|
|
|
|
|
|
|
public int MaxHealth = 100;
|
|
|
|
|
public int MaxStamina = 100;
|
|
|
|
|
public int MaxMagic = 100;
|
|
|
|
|
|
|
|
|
|
public float Health = 100.0f;
|
|
|
|
|
public float Stamina = 100.0f;
|
|
|
|
|
public float Magic = 100.0f;
|
|
|
|
|
|
|
|
|
|
public int SprintCost = 2;
|
|
|
|
|
|
|
|
|
|
public bool InCombat;
|
|
|
|
|
|
|
|
|
|
public bool Staggered;
|
|
|
|
|
public bool OffBalance;
|
|
|
|
|
public bool Fallen;
|
|
|
|
|
public bool Invincible;
|
|
|
|
|
|
|
|
|
|
public int Hunger;
|
|
|
|
|
public int Thirst;
|
|
|
|
|
public int Exhaustion;
|
|
|
|
|
public int Heat;
|
|
|
|
|
|
|
|
|
|
public int CarryWeight;
|
|
|
|
|
public int MaxCarryWeight = 100;
|
|
|
|
|
public int Gold;
|
|
|
|
|
|
|
|
|
|
public int Level = 1;
|
|
|
|
|
public int Experience = 0;
|
|
|
|
|
public int ExperienceToNextLevel = 1000;
|
|
|
|
|
|
|
|
|
|
public bool CanHealH = true;
|
|
|
|
|
public bool CanHealS = true;
|
|
|
|
|
public bool CanHealM = true;
|
|
|
|
|
|
|
|
|
|
public HUDManager hudManager;
|
|
|
|
|
|
|
|
|
|
private float criticalBlowMultiplier = 10.0f;
|
|
|
|
|
private float momentumToDamageMultiplier = 0.2f;
|
|
|
|
|
private float partialProtectionMultiplier = 0.5f;
|
|
|
|
|
private float fullProtectionMultiplier = 0.75f;
|
|
|
|
|
private int defaultSkillValue = 5;
|
|
|
|
|
private int defaultAttributeValue = 10;
|
|
|
|
|
|
|
|
|
|
private List<int> StaminaTemporarilyRemovedIncrements = new List<int>();
|
|
|
|
|
private List<int> MagicTemporarilyRemovedIncrements = new List<int>();
|
|
|
|
|
private List<int> HealthTemporarilyRemovedIncrements = new List<int>();
|
|
|
|
|
|
|
|
|
|
public void ReceiveCriticalBlow(float damage, float momentum, AparrelSlot slot, DamageType damageType)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ReceiveStagger(bool canHitUnbalance = true)
|
|
|
|
|
{
|
|
|
|
|
if (OffBalance && canHitUnbalance)
|
|
|
|
|
Fallen = true;
|
|
|
|
|
|
|
|
|
|
if (Staggered)
|
|
|
|
|
{
|
|
|
|
|
if(canHitUnbalance)
|
|
|
|
|
OffBalance = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Staggered = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ReceiveHit(int baseDamage, float momentum, int skillValue, ProtectionLevel protection, DamageType damageType, AparrelSlot slot, UnityEvent weaponHitEvent, UnityEvent gripHitEvent)
|
|
|
|
|
{
|
|
|
|
|
var damage = 0.0f;
|
|
|
|
|
switch (protection)
|
|
|
|
|
{
|
|
|
|
|
case ProtectionLevel.Unprotected:
|
|
|
|
|
damage = (int)((float)baseDamage * (momentum * momentumToDamageMultiplier) * (OffBalance ? criticalBlowMultiplier : 1));
|
|
|
|
|
if (OffBalance)
|
|
|
|
|
ReceiveCriticalBlow(damage, momentum, slot, damageType);
|
|
|
|
|
if (weaponHitEvent != null)
|
|
|
|
|
weaponHitEvent.Invoke();
|
|
|
|
|
break;
|
|
|
|
|
case ProtectionLevel.Partial:
|
|
|
|
|
damage = (int)((float)partialProtectionMultiplier * (baseDamage + momentum * momentumToDamageMultiplier));
|
|
|
|
|
break;
|
|
|
|
|
case ProtectionLevel.Full:
|
|
|
|
|
damage = (int)((float)fullProtectionMultiplier * (baseDamage + momentum * momentumToDamageMultiplier));
|
|
|
|
|
if (damage > Health)
|
|
|
|
|
damage = Health - 1.0f;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
Health -= damage;
|
|
|
|
|
if (Health <= 0)
|
|
|
|
|
Kill();
|
|
|
|
|
if (Stamina <= 0)
|
|
|
|
|
ReceiveStagger(false);
|
|
|
|
|
updateStatusUI();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateStatusUI()
|
|
|
|
|
{
|
|
|
|
|
if (hudManager != null)
|
|
|
|
|
{
|
|
|
|
|
hudManager.HealthDisplayValue = Health;
|
|
|
|
|
hudManager.StaminaDisplayValue = Stamina;
|
|
|
|
|
hudManager.MagicDisplayValue = Magic;
|
|
|
|
|
hudManager.DisplayUIGroup(HUDGroup.StatBarArea);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ExpendStamina(float amount, bool increment = false)
|
|
|
|
|
{
|
|
|
|
|
if (!increment)
|
|
|
|
|
{
|
|
|
|
|
if (Stamina > amount)
|
|
|
|
|
{
|
|
|
|
|
Stamina -= amount;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (amount < 0)
|
|
|
|
|
{
|
|
|
|
|
if (StaminaTemporarilyRemovedIncrements.Contains(-(int)amount))
|
|
|
|
|
StaminaTemporarilyRemovedIncrements.Remove(-(int)amount);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
StaminaTemporarilyRemovedIncrements.Add((int)amount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
updateStatusUI();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ClearStaminaIncrements()
|
|
|
|
|
{
|
|
|
|
|
updateStatusUI();
|
|
|
|
|
StaminaTemporarilyRemovedIncrements.Clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ClearMagicIncrements()
|
|
|
|
|
{
|
|
|
|
|
updateStatusUI();
|
|
|
|
|
MagicTemporarilyRemovedIncrements.Clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ClearHealthIncrements()
|
|
|
|
|
{
|
|
|
|
|
updateStatusUI();
|
|
|
|
|
HealthTemporarilyRemovedIncrements.Clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ExpendMagic(int amount, bool increment = false)
|
|
|
|
|
{
|
|
|
|
|
updateStatusUI();
|
|
|
|
|
if (!increment)
|
|
|
|
|
{
|
|
|
|
|
if (Magic > amount)
|
|
|
|
|
{
|
|
|
|
|
Magic -= amount;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (amount < 0)
|
|
|
|
|
{
|
|
|
|
|
if (MagicTemporarilyRemovedIncrements.Contains(-amount))
|
|
|
|
|
MagicTemporarilyRemovedIncrements.Remove(-amount);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MagicTemporarilyRemovedIncrements.Add(amount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Kill()
|
|
|
|
|
{
|
|
|
|
|
Alive = false;
|
|
|
|
|
LootSelectable.Name = $"{FirstName} {LastName}";
|
|
|
|
|
LootSelectable.enabled = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void InitializeStats()
|
|
|
|
|
{
|
|
|
|
|
if (SkillValueCategories == null)
|
|
|
|
|
SkillValueCategories = new Dictionary<int, Dictionary<int, int>>();
|
|
|
|
|
if (Attributes == null)
|
|
|
|
|
Attributes = new Dictionary<int,int>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (RespectForActor == null)
|
|
|
|
|
RespectForActor = new Dictionary<int,int>();
|
|
|
|
|
if (AdmirationForActor == null)
|
|
|
|
|
AdmirationForActor = new Dictionary<int,int>();
|
|
|
|
|
if (SuspicionOfActor == null)
|
|
|
|
|
SuspicionOfActor = new Dictionary<int, int>();
|
|
|
|
|
|
|
|
|
|
if (FactionRank == null)
|
|
|
|
|
FactionRank = new Dictionary<int,int>();
|
|
|
|
|
if (RegionalBounty == null)
|
|
|
|
|
RegionalBounty = new Dictionary<int,int>();
|
|
|
|
|
if (RegionalFame == null)
|
|
|
|
|
RegionalFame = new Dictionary<int,int>();
|
|
|
|
|
|
|
|
|
|
if (QuestStates == null)
|
|
|
|
|
QuestStates = new Dictionary<int,int>();
|
|
|
|
|
|
|
|
|
|
if (Blendshapes == null)
|
|
|
|
|
Blendshapes = new Dictionary<string, float>();
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < 5; i++)
|
|
|
|
|
{
|
|
|
|
|
if (i != 4)
|
|
|
|
|
{
|
|
|
|
|
var initializedSkills = new Dictionary<int, int>();
|
|
|
|
|
for (var j = 0; j < 9; j++)
|
|
|
|
|
{
|
|
|
|
|
if (!initializedSkills.ContainsKey(j))
|
|
|
|
|
initializedSkills.Add(j, defaultSkillValue);
|
|
|
|
|
else
|
|
|
|
|
initializedSkills[j] = defaultSkillValue;
|
|
|
|
|
}
|
|
|
|
|
if (!SkillValueCategories.ContainsKey(i))
|
|
|
|
|
SkillValueCategories.Add(i, initializedSkills);
|
|
|
|
|
else
|
|
|
|
|
SkillValueCategories[i] = initializedSkills;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (var j = 0; j < 9; j++)
|
|
|
|
|
{
|
|
|
|
|
if (!Attributes.ContainsKey(j))
|
|
|
|
|
Attributes.Add(j, defaultAttributeValue);
|
|
|
|
|
else
|
|
|
|
|
Attributes[j] = defaultAttributeValue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
InitializeStats();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
if (CanHealH)
|
|
|
|
|
{
|
|
|
|
|
if (Health < MaxHealth)
|
|
|
|
|
Health += HealthRecoveryRate;
|
|
|
|
|
else
|
|
|
|
|
Health = (float)MaxHealth;
|
|
|
|
|
updateStatusUI();
|
|
|
|
|
}
|
|
|
|
|
if (CanHealS && Stamina < MaxStamina)
|
|
|
|
|
{
|
|
|
|
|
if (Stamina < MaxStamina)
|
|
|
|
|
Stamina += StaminaRecoveryRate;
|
|
|
|
|
else
|
|
|
|
|
Stamina = (float)MaxStamina;
|
|
|
|
|
updateStatusUI();
|
|
|
|
|
}
|
|
|
|
|
if (CanHealM && Magic < MaxMagic)
|
|
|
|
|
{
|
|
|
|
|
if (Magic < MaxMagic)
|
|
|
|
|
Magic += MagicRecoveryRate;
|
|
|
|
|
else
|
|
|
|
|
Magic = (float)MaxMagic;
|
|
|
|
|
updateStatusUI();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|