Files
project-reset/Assets/Scripts/Units/Player.cs

52 lines
1.2 KiB
C#

using System;
using System.Collections;
using Drawing;
using Reset;
using Reset.Core;
using Reset.Core.Tools;
using Reset.Units;
using UnityEngine;
using Sirenix.OdinInspector;
using Sirenix.Serialization;
using Unity.Netcode;
public class Player : Unit, IKillable{
[HideInInspector] public PlayerControls controls;
float IKillable.maxHealth{ get; set; }
float IKillable.currentHealth{ get; set; }
void Awake(){
GameManager.Player = gameObject;
controls = GetComponent<PlayerControls>();
}
public override void UnitStart(){
base.UnitStart();
((IKillable)this).IKillableInitialize();
}
// Update is called once per frame
void Update(){
GetComponent<IKillable>().DrawHealthDebug();
}
public void TakeDamage(DamageSource[] sources){
foreach (DamageSource source in sources) {
TakeDamage(source);
}
}
public void TakeDamage(DamageSource source){
((IKillable)this).currentHealth -= source.damageDealt;
if (((IKillable)this).currentHealth <= 0) {
Kill();
}
}
public void Kill(){
throw new NotImplementedException();
}
}