void Start() { if (!isLocalPlayer) { GetComponent<PlayerMovement>().enabled = false; GetComponent<PlayerWeapon>().enabled = false; } targetPlayer = gameObject.GetComponent<PlayerBase>(); }
IEnumerator SpawnPlayer(PlayerBase player, float time, DeathReason type) { yield return new WaitForSeconds(time); var availablePositions = player.Team == Team.Suicidials ? SuicidialSpawnPoints : RescuerSpawnPoints; var length = availablePositions.Count; var newPosition = availablePositions[Random.Range(0, length)].position; if (type == DeathReason.Net) { var weapon = GameObject.FindObjectOfType<PlayerWeapon>(); weapon.CmdSpawnBullet(player.transform.position, new Vector2()); } player.transform.position = newPosition; player.GetComponent<PlayerMovement>().alive = true; }
private void OnPlayerDeath(PlayerBase player, DeathReason type) { player.GetComponent<PlayerMovement>().alive = false; StartCoroutine(SpawnPlayer(player, SpawnTimeInSeconds, type)); }
public void Register(PlayerBase player) { player.OnDeath += OnPlayerDeath; }
public void SubscribePlayer(PlayerBase player) { if (targetPlayer == null) targetPlayer = player; }
private void PlayerOnOnDeath(PlayerBase player, DeathReason type) { switch (type) { case DeathReason.TrapSpike: PlayDieAnimation(AnimationDeathType.DieSpike); break; case DeathReason.Net: break; default: throw new ArgumentOutOfRangeException("type"); } }