public static void RegisterPlayer(string playerID, GameObject player) { players.Add(playerID, player); if (instance.isRoyale) { RoyaleManager.AddPlayer(playerID); } Debug.Log(playerID); }
// Update is called once per frame void Update() { if (isServer) { if (targetPlayer != null) { Vector3 player = targetPlayer.transform.position; agent.SetDestination(player); if (Vector3.Distance(player, transform.position) <= (agent.stoppingDistance + 0.1f)) { // Attack Attack(); FaceTarget(); } } else { if (!isPatrolling) { isPatrolling = true; StartCoroutine(Patrol()); } // Check if any players are within lookRadius Collider[] hitColliders = Physics.OverlapSphere(transform.position, lookRadius, layerMask); foreach (Collider collider in hitColliders) { // If royale, only target human players if (GameManager.instance.isRoyale) { if (RoyaleManager.GetStatus(collider.name) != Player.PlayerStatus.Alive) { continue; } } // Set player as new pathing target targetPlayer = collider.gameObject; isPatrolling = false; targetPlayer.GetComponent <Player>().playerDied += ResetPlayer; break; } } currVelocity = agent.velocity.magnitude; } else { // Animate movement on client animator.SetFloat("Speed_f", currVelocity); } }
void Awake() { // Ensure only one GameManager exists if (instance != null) { Debug.Log("Error: more than one RoyaleManager in scene."); Destroy(gameObject); return; } else { instance = this; } }
public void Die(string sourceID) { if (getStatus == PlayerStatus.Dead) { return; } else if (getStatus == PlayerStatus.Alive) { if (GameManager.instance.isRoyale) { if (isServer) { RoyaleManager.PlayerDied(netId.ToString()); } Zombify(); } } getStatus = PlayerStatus.Dead; if (isServer && playerDied != null) { playerDied.Invoke(); } // Show kill feed event if (!isServer) { GameManager.instance.onPlayerKilledCallback.Invoke(username, sourceID); } DisableComponents(); // Activate death screen if (isLocalPlayer) { GetComponent <PlayerComponents>().playerUIInstance.deathScreen.SetActive(true); } StartCoroutine(Respawn()); }
void PlayersToSpawnEnemy() { players = GameManager.GetAllPlayers(); System.Guid randomId = enemyIds[Random.Range(0, enemies.Length)]; if (GameManager.instance.isRoyale) { foreach (GameObject player in players) { if (RoyaleManager.GetStatus(player.name) == Player.PlayerStatus.Alive) { SpawnEnemy(player, randomId); } } } else { foreach (GameObject player in players) { SpawnEnemy(player, randomId); } } }