public void StartSpawn(ServerPlayer player, MsgAlive spawnRequest) { MsgAlive spawnPostion = new MsgAlive(); spawnPostion.IsSpawn = false; // TODO, run a thread task to find a spawn. bool ret = false; if (ComputeSpawn != null) { ret = ComputeSpawn(player, World, ref player.Info.LastSpawnState.Position, ref player.Info.LastSpawnState.Azimuth); } if (ret) { player.Info.Alive = true; PlayerSpawned?.Invoke(this, player); spawnPostion.PlayerID = player.PlayerID; spawnPostion.Position = player.Info.LastSpawnState.Position; spawnPostion.Azimuth = player.Info.LastSpawnState.Azimuth; SendToAll(spawnPostion, false); } }
internal static void OnPlayerSpawned(Player player) { PlayerSpawned?.Invoke(player, new PlayerEventArgs() { Player = player }); }
private void Start() { GameObject player = Instantiate(_playerData.Prefab, _point.position, Quaternion.identity); player.GetComponent <PlayerWeapons>().Current.Construct(); player.GetComponent <PlayerAnimator>().Construct(); PlayerSpawned?.Invoke(player); }
private void Spawn() { _astronaut = Instantiate(_astronautPrefab, transform); _astronaut.Died += OnDied; _astronaut.Despawned += OnDespawned; PlayerSpawned?.Invoke(this); }
/// <summary> /// Spawn a new player at start position /// </summary> public Player SpawnPlayer(Vector3 spawnPosition) { //Debug.Log("Spawn Player"); // if there's already a player, remove it if (_player != null) { RemoveExistingPlayer(); } _player = Instantiate(_playerPrefab, spawnPosition, Quaternion.identity); //TODO look into a way to pass this information before instantiating (it calls awake before initialize) _player.Initialize(_levelController.GameplayInput); _player.Health.Died.AddListener(OnPlayerDied); PlayerSpawned?.Invoke(_player); _cameraController.PlayerCamera.Follow = _player.transform; return(_player); }
public void HandleAlive(NetworkMessage msg) { MsgAlive alive = msg as MsgAlive; Player player = GetPlayerByID(alive.PlayerID); if (player == null) { return; } player.Active = true; player.PlayerSpawnTime = Clock.StepTime; player.SetTeleport(-1, null, null); player.Spawn(alive.Position, alive.Azimuth); if (alive.PlayerID == LocalPlayerID) { SelfSpawned?.Invoke(this, player); } PlayerSpawned?.Invoke(this, player); }
private void Spawn() { Player player = Instantiate(_player, transform.position, Quaternion.identity); PlayerSpawned?.Invoke(player); }
void SpawnPlayer() { PlayerSpawned?.Invoke(_playerSpawnPoints[Random.Range(0, _playerSpawnPoints.Count - 1)].SpawnPlayer()); }
public void OnPlayerSpawned(IPlayerSpawnedEvent evt) => PlayerSpawned?.Invoke(evt);