private void OnCollisionEnter(Collision collision) { if (collision.other.tag.Equals("Street")) { GlobalAccess.GetCity().Buildings.Remove(this.GetComponent <Building>()); GameObject.Destroy(this.gameObject); } }
public void Navigate() { this.GetComponentInChildren <DetectAhead>().enabled = true; this.GetComponentInChildren <Rigidbody>().isKinematic = false; this.GetComponent <CapsuleCollider>().enabled = true; navigator.enabled = true; parking.enabled = false; takeoff.enabled = false; navigator.SetTarget(GlobalAccess.GetRandomGarage()); }
// Update is called once per frame void FixedUpdate() { if (intervalElapsed < 0) { var mesh = this.GetComponent <MeshRenderer>(); var mats = mesh.materials; mats[MaterialIndex] = GlobalAccess.GetReferences().AdLights.PickOne(); mesh.materials = mats; ResetInterval(); } intervalElapsed -= Time.fixedDeltaTime; }
void SpawnCar() { try { var spawnPoint = GlobalAccess.GetRandomGarage(); var car = Instantiate(HovercarPfs.PickOne(), spawnPoint.transform.position, spawnPoint.transform.rotation); car.transform.SetParent(traffic); spawnElapsed = SpawnTimer; car.GetComponent <AICoordinator>().TakeOff(spawnPoint); } catch (Exception e) { DebugConsole.LogMessage(e.Message); } }
void Fork() { var existingForks = new List <Vector3>(); while (forkCount > 0) { var pos = sgm.GetPointInSegment(); if (!existingForks.Any() || existingForks.Any(x => Vector3.Distance(pos, x) < MinDistance)) { var fork = Instantiate(GlobalAccess.GetReferences().SmallSegmentPf, this.transform) .GetComponent <Segment>(); var length = Random.Range(sgm.Length / 1.5f, sgm.Length); existingForks.Add(pos); if (MathHelper.DiceRoll(IntersectionChance)) { if (MathHelper.DiceRoll(50)) { pos.x = length / 2; } else { pos.x = -length / 2; } } fork.Length = length; fork.transform.localPosition = pos; fork.transform.localEulerAngles = new Vector3(0, 90, 0); GlobalAccess.GetCity().Segments.Add(fork); fork.transform.SetParent(GlobalAccess.GetCity().transform); } forkCount--; } }
void Start() { refs = GlobalAccess.GetReferences(); city = GlobalAccess.GetCity(); sgm = this.GetComponent <Segment>(); }