コード例 #1
0
        private bool TryGetRandomModifier(out ParticleModifier modifier)
        {
            var count = 0;

            modifier = null;
            for (var n = FirstChild; n != null; n = n.NextSibling)
            {
                count += n is ParticleModifier ? 1 : 0;
            }
            if (count == 0)
            {
                return(false);
            }
            var targetIndex = Rng.RandomInt(count);
            var index       = 0;

            for (var n = FirstChild; n != null; n = n.NextSibling)
            {
                if (n is ParticleModifier particleModifier)
                {
                    if (index == targetIndex)
                    {
                        modifier = particleModifier;
                        return(true);
                    }
                    index++;
                }
            }
            return(false);
        }
コード例 #2
0
        // ReSharper disable once UnusedMember.Local
        private void BuildForTangerine()
        {
            var defaultModifier = new ParticleModifier()
            {
                Id = "ParticleModifier"
            };
            var animator = new Color4Animator()
            {
                TargetPropertyPath = "Color"
            };

            animator.ReadonlyKeys.Add(0, new Color4(255, 255, 255, 0));
            animator.ReadonlyKeys.Add(30, new Color4(255, 255, 255, 255));
            animator.ReadonlyKeys.Add(60, new Color4(255, 255, 255, 0));
            defaultModifier.Animators.Add(animator);
            Nodes.Add(defaultModifier);
        }