예제 #1
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.other.tag.Equals("Street"))
     {
         GlobalAccess.GetCity().Buildings.Remove(this.GetComponent <Building>());
         GameObject.Destroy(this.gameObject);
     }
 }
예제 #2
0
    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--;
        }
    }
예제 #3
0
 void Start()
 {
     refs = GlobalAccess.GetReferences();
     city = GlobalAccess.GetCity();
     sgm  = this.GetComponent <Segment>();
 }