/// <summary>Sends the client into the game and informs other clients of the new player.</summary> /// <param name="_playerName">The username of the new player.</param> public void SendIntoGame(string _playerName) { player = NetworkManager.instance.InstantiatePlayer(); player.Initialize(id, _playerName); Debug.Log($"id: {id}, "); // Send all players to the new player foreach (Client _client in Server.clients.Values) { if (_client.player != null) { if (_client.id != id) { ServerSend.Spawn(id, _client.player); } } } // Send the new player to all players (including himself) foreach (Client _client in Server.clients.Values) { if (_client.player != null) { ServerSend.Spawn(_client.id, player); } } }
public void SpawnProjectile(Vector3 _position, Vector3 _direction, float _damage, float _speed, bool _ofPlayer) { Projectile _projectile = Instantiate(projectilePrefab); _projectile.Initialize(_position, _direction, _damage, _speed, _ofPlayer); ServerSend.Spawn(_projectile); }
private void Update() { if (Input.GetKeyDown(KeyCode.P)) { Enemy _enemy = Instantiate(enemyPrefab, Vector3.zero, Quaternion.identity); _enemy.Initialize(50); ServerSend.Spawn(_enemy); } if (Input.GetKeyDown(KeyCode.O)) { SpawnDestructibleBlock(Vector3.up); } }
public void SpawnDestructibleBlock(Vector3 position) { DestructibleBlock _destructibleBlock = Instantiate(destructibleBlockPrefab, position, Quaternion.identity); ServerSend.Spawn(_destructibleBlock); }