Exemplo n.º 1
0
        public void Initialize(SkyscraperManager skyscraper)
        {
            var decos = skyscraper.Builder.Decos;

            this.buffer?.Release();
            this.timesBuffer?.Release();

            if (decos.Count <= 0)
            {
                this.timers = new float[0];

                return;
            }

            this.buffer = new ComputeBuffer(decos.Count, Marshal.SizeOf(typeof(DecorationData)), ComputeBufferType.Default);
            this.buffer.SetData(decos.ToArray());

            this.timesBuffer = new ComputeBuffer(decos.Count, Marshal.SizeOf(typeof(Times)), ComputeBufferType.Default);
            this.timers      = new float[this.buffer.count];
            this.times       = new Times[this.buffer.count];

            for (var i = 0; i < this.times.Length; i++)
            {
                this.timers[i]     = Random.value;
                this.times[i].time = this.curve.Evaluate(this.timers[i]);
            }

            this.timesBuffer.SetData(this.times);

            this.material.SetColor(PropNightColor, this.nightColor);
            this.material.SetColor(PropNoonColor, this.noonColor);
        }
Exemplo n.º 2
0
        public void Initialize(SkyscraperManager skyscraper)
        {
            var roads = skyscraper.CityArea.Roads.Values.Select(r => (SimpleRoad)r);

            this.geomBuffer = new ComputeBuffer(roads.Count(), Marshal.SizeOf(typeof(SimpleRoad)), ComputeBufferType.Default);
            this.geomBuffer.SetData(roads.ToArray());

            var step = skyscraper.CityArea.MaxDistance / skyscraper.CityArea.Interval;

            this.vertsCount = Mathf.CeilToInt(step / MaxPointPerGeom);
        }
Exemplo n.º 3
0
        public void Initialize(SkyscraperManager skyscraper)
        {
            this.skyscraper = skyscraper;

            var roads = skyscraper.CityArea.Roads;
            var ids   = roads.Keys;

            this.cars       = new Car[this.num];
            this.simpleCars = new SimpleCar[this.num];

            for (var i = 0; i < this.num; i++)
            {
                var id = ids.ElementAt(Random.Range(0, ids.Count));

                this.cars[i] = new Car(roads[id], this.offset);
                this.cars[i].Update(this.skyscraper.CityArea, this.speed, this.straightRate);

                this.simpleCars[i] = this.cars[i];
            }

            this.geomBuffer = new ComputeBuffer(this.cars.Length, Marshal.SizeOf(typeof(SimpleCar)), ComputeBufferType.Default);
            this.geomBuffer.SetData(this.simpleCars.ToArray());
        }