80 lines
3.1 KiB
C#
80 lines
3.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Code.OfficeGame.BattleMode.HitBoxes;
|
|
using R3;
|
|
using UnityEngine;
|
|
|
|
namespace Code.OfficeGame.BattleMode.Health
|
|
{
|
|
public class EntityHealth : MonoBehaviour
|
|
{
|
|
[SerializeField] private HealthData healthData;
|
|
|
|
private ReactiveProperty<HealthData> _healthData;
|
|
|
|
public ReadOnlyReactiveProperty<HealthData> HealthData => _healthData;
|
|
|
|
public bool IsDead => _healthData.CurrentValue.CurrentHealth <= 0;
|
|
|
|
[SerializeField]
|
|
public Dictionary<HitBoxPartType, int> hitBoxPartModifier = new();
|
|
|
|
private void Awake()
|
|
{
|
|
_healthData = new ReactiveProperty<HealthData>(healthData);
|
|
}
|
|
|
|
public virtual void GetDamage(int damage, HitBoxPartType hitBoxPart)
|
|
{
|
|
if (damage < 0)
|
|
{
|
|
GetHeal(-damage);
|
|
return;
|
|
}
|
|
|
|
var newCurrentHealth = _healthData.CurrentValue.CurrentHealth - damage * hitBoxPartModifier[hitBoxPart];
|
|
|
|
_healthData.Value = new HealthData()
|
|
{
|
|
MaxHealth = _healthData.CurrentValue.MaxHealth,
|
|
CurrentHealth = newCurrentHealth
|
|
};
|
|
|
|
Debug.Log($"{GetEntityId()} got {damage} damage in {hitBoxPart} and have {newCurrentHealth} health");
|
|
}
|
|
|
|
public virtual void GetHeal(int heal)
|
|
{
|
|
if (heal < 0) return;
|
|
|
|
var newCurrentHealth = _healthData.CurrentValue.CurrentHealth + heal;
|
|
|
|
_healthData.Value = new HealthData()
|
|
{
|
|
MaxHealth = _healthData.CurrentValue.MaxHealth,
|
|
CurrentHealth = newCurrentHealth
|
|
};
|
|
}
|
|
|
|
public virtual void SetHealthData(HealthData newHealthData)
|
|
{
|
|
_healthData.Value = newHealthData;
|
|
}
|
|
}
|
|
|
|
[Serializable]
|
|
public struct HealthData
|
|
{
|
|
public int MaxHealth;
|
|
public int CurrentHealth;
|
|
}
|
|
|
|
/// Социальные метрики
|
|
/// 1 субъективная оценка NPS Net Promotion Score (вероятность, что человек порекомендует игру другим людям)
|
|
/// 2 как распространяется (каким способом) k-factor заразность игры k = i * c * 100%
|
|
/// i - ср кол-во приглашений отправленных одним пользователем (кол-во приглашений/ колво отправителей)
|
|
/// c - средняя конверсия из приглашения в установку (колво установок/уол-во приглашений)
|
|
/// k = орг-установок за период N / актив уп в период N - 1
|
|
/// Создать форму и выбрать что-то, что касается игровой отрасли и для одногруппников запустить опрос с вероятностью.
|
|
///
|
|
} |