Exemple #1
0
        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);
            }
        }
Exemple #2
0
 internal static void OnPlayerSpawned(Player player)
 {
     PlayerSpawned?.Invoke(player, new PlayerEventArgs()
     {
         Player = player
     });
 }
Exemple #3
0
        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);
    }
Exemple #5
0
    /// <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);
    }
Exemple #6
0
        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);
        }
Exemple #7
0
    private void Spawn()
    {
        Player player = Instantiate(_player, transform.position, Quaternion.identity);

        PlayerSpawned?.Invoke(player);
    }
Exemple #8
0
 void SpawnPlayer()
 {
     PlayerSpawned?.Invoke(_playerSpawnPoints[Random.Range(0, _playerSpawnPoints.Count - 1)].SpawnPlayer());
 }
 public void OnPlayerSpawned(IPlayerSpawnedEvent evt) => PlayerSpawned?.Invoke(evt);