Added PlayerMovement and other
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
using UnityEngine;
|
||||
using Unity.Netcode;
|
||||
using System.Collections;
|
||||
|
||||
public class PlayerFacade : NetworkBehaviour
|
||||
{
|
||||
// [SerializeField] private PlayerController playerController;
|
||||
[SerializeField] private PlayerMovement playerMovement;
|
||||
[SerializeField] private PlayerHealth playerHealth;
|
||||
[SerializeField] private PlayerShoot playerShoot;
|
||||
[SerializeField] private PlayerUIController playerUIController;
|
||||
|
||||
public PlayerHealth PlayerHealth => playerHealth;
|
||||
|
||||
public override void OnNetworkSpawn()
|
||||
{
|
||||
if(IsOwner)
|
||||
{
|
||||
StartCoroutine(InitPlayerUIController());
|
||||
|
||||
if(playerMovement != null)
|
||||
{
|
||||
playerMovement.Init();
|
||||
}
|
||||
|
||||
if(playerShoot != null)
|
||||
{
|
||||
playerShoot.Init();
|
||||
}
|
||||
}
|
||||
|
||||
if(playerHealth != null)
|
||||
{
|
||||
playerHealth.Init(IsServer);
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator InitPlayerUIController()
|
||||
{
|
||||
yield return new WaitUntil(() =>
|
||||
{
|
||||
playerUIController = FindFirstObjectByType<PlayerUIController>();
|
||||
return playerUIController != null;
|
||||
});
|
||||
|
||||
if(playerUIController != null)
|
||||
{
|
||||
playerUIController.Init(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user