refactor: moved a lot of player related scripts to the Reset.Units namespace
This commit is contained in:
@@ -10,43 +10,61 @@ using Sirenix.OdinInspector;
|
||||
using Sirenix.Serialization;
|
||||
using Unity.Netcode;
|
||||
|
||||
public class Player : Unit, IKillable{
|
||||
[HideInInspector] public PlayerControls controls;
|
||||
namespace Reset.Units{
|
||||
public class Player : Unit, IKillable{
|
||||
[HideInInspector] public PlayerControls controls;
|
||||
|
||||
float IKillable.maxHealth{ get; set; }
|
||||
float IKillable.currentHealth{ get; set; }
|
||||
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);
|
||||
void Awake(){
|
||||
controls = GetComponent<PlayerControls>();
|
||||
}
|
||||
}
|
||||
|
||||
public void TakeDamage(DamageSource source){
|
||||
((IKillable)this).currentHealth -= source.damageDealt;
|
||||
public void Attach(){
|
||||
name = "Player";
|
||||
name += IsLocalPlayer ? ", Local" : ", Network";
|
||||
|
||||
if (((IKillable)this).currentHealth <= 0) {
|
||||
Kill();
|
||||
if (IsLocalPlayer || !UnitIsNetworked()) { //
|
||||
PlayerManager.Player = gameObject;
|
||||
|
||||
Debug.Log($"Player is set to {PlayerManager.Player.name}");
|
||||
PlayerManager.RequestNewController();
|
||||
GetComponent<LockOnManager>().AttachCamera(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public override void UnitStart(){
|
||||
base.UnitStart();
|
||||
|
||||
Attach();
|
||||
((IKillable)this).IKillableInitialize();
|
||||
}
|
||||
|
||||
protected override void Update(){
|
||||
base.Update();
|
||||
|
||||
GetComponent<IKillable>().DrawHealthDebug();
|
||||
Debug.Log(PlayerManager.Player);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
public void Kill(){
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user