Beispiel #1
0
        public void Update(uint time, int timePassed)
        {
            inputHandler.HandleInput(time);
            Entities.UpdateEntities(time, timePassed);
            Particles.Update(new FrameTime()
            {
                Time = time, TicksPassed = timePassed
            });

            renderer.FollowPlayer(Player, timePassed);
        }
        public Weather(GameObject gameObject, GameObject sunFilter, GameObject darkFilter)
        {
            this.sunFilter  = sunFilter;
            this.darkFilter = darkFilter;

            Tilemap map = gameObject.GetComponent <Tilemap>();

            mapWidth  = map.size.x * map.cellSize.x;
            mapHeight = map.size.y * map.cellSize.y;

            particles = gameObject.AddComponent <ParticleSystem>();
            particles.Stop();
            Particles.InitParticleSystem(particles);

            var main = particles.main;

            main.startSpeed      = new ParticleSystem.MinMaxCurve(1, 1.2f);
            main.startLifetime   = mapWidth / 1.1f;
            main.duration        = mapWidth / 1.1f;
            main.prewarm         = true;
            main.startSize       = 3;
            main.startColor      = Color.white;
            main.simulationSpace = ParticleSystemSimulationSpace.World;
            main.maxParticles    = 2000;

            var emission = particles.emission;

            emission.rateOverTime = 0;

            var shape = particles.shape;

            shape.shapeType            = ParticleSystemShapeType.Box;
            shape.position             = gameObject.transform.position * -1 - new Vector3(mapWidth / 2, 0);
            shape.rotation             = new Vector3(0, 90, 0);
            shape.scale                = new Vector3(2, 1, 1);
            shape.randomPositionAmount = 1;

            var renderer = particles.GetComponent <ParticleSystemRenderer>();

            renderer.sortingLayerName = "Structure";
            renderer.sortingOrder     = 2000;
            Material material = new Material(renderer.material);

            material.mainTexture = Resources.Load <Texture>("Textures/CloudParticle");
            renderer.material    = material;

            particles.Play();
        }