protected override void AfterUpdate() { if (Vector2.Distance(transform.position, Vector2.zero) > 100) { var position = SpawnHelper.RandomPositionInArea(GameScript.Game.Spawnarea); if (position != null) { transform.position = position.Value; } else { transform.position = Vector3.zero; } lb.Force.AddTorque(Random.Range(0, 360)); } }
private void SpawnBarrier() { var spawnArea = Spawnarea; if (spawnArea != null) { var position = SpawnHelper.RandomPositionInArea(spawnArea); if (position != null) { var b = SpawnHelper.TrySpawn(BarrierPrefab, position.Value, Quaternion.identity); if (b != null) { InitBarrier(b); UpdateLoadingPanel(); } } } }
public void PlaceBomb() { if (FindObjectsOfType <HelpItemScript>().Length >= 5) { return; } Vector2?position; do { position = SpawnHelper.RandomPositionInArea(GameScript.Game.Spawnarea); } while (position == null); var bomb = Instantiate(gameObject, position.Value, Quaternion.identity); var rotationspeed = Random.Range(0, 30) - Random.Range(0, 30); var rb = GetRigidbody(bomb); rb.AddTorque(rotationspeed * Time.deltaTime); rb.AddForce(Vector2.up * 10 * Time.deltaTime); }