maint: moving around methods to work better with Unit/Player/Enemy classes
This commit is contained in:
@@ -21,53 +21,14 @@ public class Player : Unit, IKillable{
|
||||
controls = GetComponent<PlayerControls>();
|
||||
}
|
||||
|
||||
void Start(){
|
||||
if (((IKillable)this).maxHealth == 0f) {
|
||||
Debug.LogError($"Max health is not set for type of <b>{name}</b>. Setting to 100.");
|
||||
((IKillable)this).currentHealth = 10000f;
|
||||
} else {
|
||||
((IKillable)this).currentHealth = ((IKillable)this).maxHealth;
|
||||
}
|
||||
|
||||
|
||||
if (!NetworkManager.Singleton.IsConnectedClient && !NetworkManager.Singleton.IsHost) {
|
||||
Attach();
|
||||
} else {
|
||||
StartCoroutine(WaitForOnline());
|
||||
}
|
||||
public override void UnitStart(){
|
||||
base.UnitStart();
|
||||
((IKillable)this).IKillableInitialize();
|
||||
}
|
||||
|
||||
private IEnumerator WaitForOnline(){
|
||||
while (!NetworkManager.Singleton.didAwake) {
|
||||
Debug.Log("waiting");
|
||||
yield return null;
|
||||
}
|
||||
|
||||
// Debug.Log($"{IsHost}, {IsClient}, {IsLocalPlayer}");
|
||||
if (IsLocalPlayer){
|
||||
GameManager.Player = gameObject;
|
||||
Attach();
|
||||
}
|
||||
}
|
||||
|
||||
public void Attach(){
|
||||
if (GameManager.Player == gameObject){
|
||||
GameManager.RequestNewController();
|
||||
GetComponent<LockOnManager>().AttachCamera(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnNetworkPostSpawn(){
|
||||
// GetComponent<LockOnManager>().AttachCamera(gameObject);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
using (Draw.WithColor(Color.blue)) {
|
||||
Draw.ingame.Label2D(transform.position + Vector3.up * 2.2f, ((IKillable)this).currentHealth.ToString(),
|
||||
Color.blue);
|
||||
}
|
||||
GetComponent<IKillable>().DrawHealthDebug();
|
||||
}
|
||||
|
||||
public void TakeDamage(DamageSource[] sources){
|
||||
|
||||
Reference in New Issue
Block a user