public void Setup()
        {
            foreach (DreamBlock block in AdventureHelperModule.Session.DreamBlocksToCombine)
            {
                var particles = new DreamParticle[(int)(block.Width / 8f * (block.Height / 8f) * 0.7f)];
                allParticles[block] = particles;
                for (int i = 0; i < particles.Length; i++)
                {
                    particles[i].Position   = new Vector2(Calc.Random.NextFloat(block.Width), Calc.Random.NextFloat(block.Height));
                    particles[i].Layer      = Calc.Random.Choose(0, 1, 1, 2, 2, 2);
                    particles[i].TimeOffset = Calc.Random.NextFloat();
                    particles[i].Color      = Color.LightGray * (0.5f + (float)particles[i].Layer / 2f * 0.5f);
                    if (playerHasDreamDash)
                    {
                        switch (particles[i].Layer)
                        {
                        case 0:
                            particles[i].Color = Calc.Random.Choose(Calc.HexToColor("FFEF11"), Calc.HexToColor("FF00D0"), Calc.HexToColor("08a310"));
                            break;

                        case 1:
                            particles[i].Color = Calc.Random.Choose(Calc.HexToColor("5fcde4"), Calc.HexToColor("7fb25e"), Calc.HexToColor("E0564C"));
                            break;

                        case 2:
                            particles[i].Color = Calc.Random.Choose(Calc.HexToColor("5b6ee1"), Calc.HexToColor("CC3B3B"), Calc.HexToColor("7daa64"));
                            break;
                        }
                    }
                }
            }
        }
        public void Setup()
        {
            particles = new DreamParticle[(int)(Width / 8f * (Height / 8f) * 0.7f)];
            for (int i = 0; i < particles.Length; i++)
            {
                particles[i].Position   = new Vector2(Calc.Random.NextFloat(Width), Calc.Random.NextFloat(Height));
                particles[i].Layer      = Calc.Random.Choose(0, 1, 1, 2, 2, 2);
                particles[i].TimeOffset = Calc.Random.NextFloat();
                particles[i].Color      = Color.LightGray * (0.5f + particles[i].Layer / 2f * 0.5f);
                bool flag = playerHasDreamDash;
                if (flag)
                {
                    switch (particles[i].Layer)
                    {
                    case 0:
                        particles[i].Color = Calc.Random.Choose(Calc.HexToColor("FFEF11"), Calc.HexToColor("FF00D0"), Calc.HexToColor("08a310"));
                        break;

                    case 1:
                        particles[i].Color = Calc.Random.Choose(Calc.HexToColor("5fcde4"), Calc.HexToColor("7fb25e"), Calc.HexToColor("E0564C"));
                        break;

                    case 2:
                        particles[i].Color = Calc.Random.Choose(Calc.HexToColor("5b6ee1"), Calc.HexToColor("CC3B3B"), Calc.HexToColor("7daa64"));
                        break;
                    }
                }
            }
        }
示例#3
0
        public virtual void SetupCustomParticles(float canvasWidth, float canvasHeight)
        {
            float countFactor = (FeatherMode ? 0.5f : 0.7f) * RefillCount != -1 ? 1.2f : 1;

            particles             = new DreamParticle[(int)(canvasWidth / 8f * (canvasHeight / 8f) * 0.7f * countFactor)];
            baseData["particles"] = Array.CreateInstance(DreamParticle.t_DreamParticle, particles.Length);

            // Necessary to get the player's spritemode
            if (!awake && RefillCount != -1)
            {
                delayedSetupParticles = true;
                return;
            }

            Color[] dashColors = new Color[3];
            if (RefillCount != -1)
            {
                dashColors[0] = Scene.Tracker.GetEntity <Player>()?.GetHairColor(RefillCount) ?? Color.White;
                dashColors[1] = Color.Lerp(dashColors[0], Color.White, 0.5f);
                dashColors[2] = Color.Lerp(dashColors[1], Color.White, 0.5f);
            }

            for (int i = 0; i < particles.Length; i++)
            {
                int layer = Calc.Random.Choose(0, 1, 1, 2, 2, 2);
                particles[i] = new DreamParticle(this, i)
                {
                    Position   = new Vector2(Calc.Random.NextFloat(canvasWidth), Calc.Random.NextFloat(canvasHeight)),
                    Layer      = layer,
                    Color      = GetParticleColor(layer, dashColors),
                    TimeOffset = Calc.Random.NextFloat()
                };

                #region Feather particle stuff

                if (FeatherMode)
                {
                    particles[i].Speed           = Calc.Random.Range(6f, 16f);
                    particles[i].Spin            = Calc.Random.Range(8f, 12f) * 0.2f;
                    particles[i].RotationCounter = Calc.Random.NextAngle();
                    particles[i].MaxRotate       = Calc.Random.Range(0.3f, 0.6f) * ((float)Math.PI / 2f);
                }

                #endregion
            }
        }
        private void Teleport(Player player, float dx)
        {
            Vector2 asVector = new Vector2(dx, 0);
            Level   level    = SceneAs <Level>();

            foreach (TrailManager.Snapshot snapshot in level.Tracker.GetEntities <TrailManager.Snapshot>())
            {
                snapshot.X += dx;
            }
            foreach (SlashFx slash in level.Tracker.GetEntities <SlashFx>())
            {
                slash.X += dx;
            }
            foreach (SpeedRing ring in level.Tracker.GetEntities <SpeedRing>())
            {
                ring.X += dx;
            }
            player.X += dx;
            player.Hair.MoveHairBy(asVector);
            level.Camera.Position += asVector;
            foreach (Backdrop backdrop in level.Background.Backdrops)
            {
                backdrop.Position += new Vector2(dx * backdrop.Scroll.X, 0);
            }
            foreach (Backdrop backdrop in level.Foreground.Backdrops)
            {
                backdrop.Position += new Vector2(dx * backdrop.Scroll.X, 0);
            }

            DynData <ParticleSystem> fgParticles = new DynData <ParticleSystem>(level.ParticlesFG);

            Particle[] particles = fgParticles.Get <Particle[]>("particles");
            for (int i = 0; i < particles.Length; i++)
            {
                particles[i].Position += asVector;
            }
            DynData <ParticleSystem> bgParticles = new DynData <ParticleSystem>(level.ParticlesBG);

            particles = bgParticles.Get <Particle[]>("particles");
            for (int i = 0; i < particles.Length; i++)
            {
                particles[i].Position += asVector;
            }
            DynData <ParticleSystem> particlesParticles = new DynData <ParticleSystem>(level.Particles);

            particles = particlesParticles.Get <Particle[]>("particles");
            for (int i = 0; i < particles.Length; i++)
            {
                particles[i].Position += asVector;
            }

            foreach (DreamBlock db in level.Tracker.GetEntities <DreamBlock>())
            {
                DynamicData dbData        = new DynamicData(db);
                DynamicData particlesData = new DynamicData(dbData.Get("particles"));
                for (int i = 0; i < particlesData.Get <int>("Length"); i++)
                {
                    DreamParticle particleProxy = new DreamParticle(db, i);
                    //Console.WriteLine(db.Position + " " + (particleProxy.Position + (level.Camera.Position - asVector) * (0.3f + 0.25f * particleProxy.Layer)) + " " +
                    //(particleProxy.Position + (level.Camera.Position) * (0.3f + 0.25f * particleProxy.Layer)) + " " + asVector * (0.3f + 0.25f * particleProxy.Layer));
                    particleProxy.Position -= (asVector) * .5f * (0.3f + 0.25f * particleProxy.Layer);
                }
            }
        }