53 lines
1.4 KiB
C#
53 lines
1.4 KiB
C#
using Lights;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class Player : MonoBehaviour
|
|
{
|
|
[Header("Оружие")]
|
|
public List<Weapon> weaponsContainer;
|
|
private int weaponIndex = 0;
|
|
public Weapon ActiveWeapon => weaponsContainer[weaponIndex];
|
|
|
|
[Header("Система ныряния")]
|
|
public PlayerDiveSystem DiveSystem;
|
|
|
|
[Header("Здоровье")]
|
|
public Health HealthComponent;
|
|
[SerializeField] private List<Hitbox> hitboxes;
|
|
[SerializeField] private float maxHp = 500;
|
|
|
|
[Header("Прицеливание врагов")]
|
|
[Tooltip("Точка в которую будут целиться враги")] public Transform EnemiesTarget;
|
|
|
|
private void Awake()
|
|
{
|
|
foreach (var hitbox in hitboxes)
|
|
hitbox.Initialize(gameObject);
|
|
HealthComponent.Initialize(maxHp, hitboxes);
|
|
HealthComponent.Damaged += HealthComponent_Damaged;
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
if(HealthComponent != null)
|
|
HealthComponent.Damaged -= HealthComponent_Damaged;
|
|
}
|
|
|
|
private void HealthComponent_Damaged(float obj)
|
|
{
|
|
LightSystem.Ef_Alarm();
|
|
}
|
|
|
|
public void _NextWeapon()
|
|
{
|
|
weaponIndex = (weaponIndex + 1) % weaponsContainer.Count;
|
|
G.WeaponModel.WeaponChangeHandler(ActiveWeapon);
|
|
}
|
|
|
|
public void _Shoot()
|
|
{
|
|
ActiveWeapon.Shoot();
|
|
}
|
|
} |