示例#1
0
 //Load particle colors for given item
 private ParticleColor[] GetParticleColors(int id)
 {
     ParticleColor[] particleColors = new ParticleColor[3];
     if (id == 0)
     {
         return(particleColors);
     }
     using (SqliteCommand command = connection.CreateCommand())
     {
         int start, mid, end;
         command.CommandType = CommandType.Text;
         command.CommandText = "SELECT * FROM ParticleColors WHERE ID = " + id + ";";
         SqliteDataReader reader = command.ExecuteReader();
         while (reader.Read())
         {
             start             = reader.GetInt32(1);
             mid               = reader.GetInt32(4);
             end               = reader.GetInt32(7);
             particleColors[0] = new ParticleColor(start, mid, end);
             start             = reader.GetInt32(2);
             mid               = reader.GetInt32(5);
             end               = reader.GetInt32(8);
             particleColors[1] = new ParticleColor(start, mid, end);
             start             = reader.GetInt32(3);
             mid               = reader.GetInt32(6);
             end               = reader.GetInt32(9);
             particleColors[2] = new ParticleColor(start, mid, end);
         }
     }
     return(particleColors);
 }
示例#2
0
    IEnumerator Decay()
    {
        decayTimer = decayTime;
        while (true)
        {
            while (decayTimer > 0)
            {
                decayTimer -= Time.deltaTime;
                yield return(null);
            }

            decayTimer = decayTime;
            if (color == ParticleColor.Red)
            {
                color = ParticleColor.Blue;
            }
            else if (color == ParticleColor.Green)
            {
                color = ParticleColor.Red;
            }
            else if (color == ParticleColor.Blue)
            {
                color = ParticleColor.Green;
            }
            yield return(null);

            print(color);

            ChangeColor(color);
        }
    }
示例#3
0
 //Setup particle effects for rendering
 private void ParticleEffects()
 {
     ParticleSystem[] particles = GetComponentsInChildren <ParticleSystem>();
     particles = particles.OrderBy(x => x.name).ToArray();
     for (int i = 0; i < particles.Length; i++)
     {
         particles[i].transform.localEulerAngles = new Vector3(-90f, 0f, 0f);
         ParticleSystem.EmissionModule emission = particles[i].emission;
         emission.rateOverTimeMultiplier = 4f;
         if (Model.Particles[i].ColorIndex != 0)
         {
             ParticleSystem.ColorOverLifetimeModule colorOverLifetime = particles[i].colorOverLifetime;
             ParticleColor particleColors = ParticleColors[Model.Particles[i].ColorIndex - 11];
             if (particleColors != null)
             {
                 Gradient           gradient  = new Gradient();
                 GradientColorKey[] colorKeys = new GradientColorKey[3];
                 colorKeys[0] = new GradientColorKey(particleColors.Start, 0f);
                 colorKeys[1] = new GradientColorKey(particleColors.Mid, 0.5f);
                 colorKeys[2] = new GradientColorKey(particleColors.End, 1f);
                 GradientAlphaKey[] alphaKeys = new GradientAlphaKey[3];
                 alphaKeys[0] = new GradientAlphaKey(particleColors.Start.a, 0f);
                 alphaKeys[1] = new GradientAlphaKey(particleColors.Mid.a, 0.5f);
                 alphaKeys[2] = new GradientAlphaKey(particleColors.End.a, 1f);
                 gradient.SetKeys(colorKeys, alphaKeys);
                 colorOverLifetime.color = gradient;
             }
         }
         ParticleSystem.LimitVelocityOverLifetimeModule limitVelocityOverLifetime = particles[i].limitVelocityOverLifetime;
         limitVelocityOverLifetime.enabled = true;
         limitVelocityOverLifetime.drag    = Model.Particles[i].Drag;
         limitVelocityOverLifetime.multiplyDragByParticleSize     = false;
         limitVelocityOverLifetime.multiplyDragByParticleVelocity = true;
         ParticleSystemRenderer renderer = particles[i].GetComponent <ParticleSystemRenderer>();
         Material material = ParticleMaterial(Model.Particles[i].Blend);
         particles[i].transform.localScale = transform.lossyScale;
         if (name.Contains("right") && (Model.Particles[i].Flags & 512) == 0)
         {
             renderer.flip = new Vector3(1f, 0f, 0f);
         }
         renderer.material.shader = material.shader;
         renderer.material.CopyPropertiesFromMaterial(material);
         Texture2D temp    = textures[Model.Particles[i].Textures[0]];
         Texture2D texture = new Texture2D(temp.width, temp.height, TextureFormat.ARGB32, false);
         texture.SetPixels32(temp.GetPixels32());
         texture.Apply();
         renderer.material.SetTexture("_MainTex", texture);
         renderer.material.renderQueue = 3100;
     }
 }
    void Start()
    {
        color = color.SetRandomGrayColor(alpha);

        ps        = GetComponent <ParticleSystem>();
        particles = new ParticleSystem.Particle[ps.main.maxParticles];
        int partCount = ps.GetParticles(particles);

        setParticleColors(partCount);
        setParticleSizes(partCount);

        var trails = ps.trails;

        trails.enabled = true;

        var psr = GetComponent <ParticleSystemRenderer>();

        psr.trailMaterial = new Material(Shader.Find("Sprites/Default"));
    }
示例#5
0
        /// <summary>
        /// 테마에 맞는 기본 파티클 시스템을 생성합니다.
        /// 기본 파티클 시스템은 테마가 바뀔 때까지 사라지지 않고, 키보드 입력에 따라 파티클을 생성합니다.
        /// </summary>
        public ParticleSystem(
            int createNumber, float createRange, CreateFunction createFunction,
            Particle.Type particleType, ParticleColor particleColor, float particleSize, int particleLifetime)
        {
            //Random r = new Random();
            this.startPositionX = () => 0;
            this.startPositionY = () => 0;
            this.positionX      = 0;
            this.positionY      = 0;
            this.velocityX      = 0;
            this.velocityY      = 0;
            this.lifetime       = -1;

            this.createNumber   = createNumber;
            this.createRange    = createRange;
            this.createFunction = createFunction;

            this.particleType     = particleType;
            this.particleColor    = particleColor;
            this.particleSize     = particleSize;
            this.particleLifetime = particleLifetime;

            this.isBasicParticleSystem = true;
        }
示例#6
0
        /// <summary>
        /// 새 파티클 시스템을 생성합니다.
        /// </summary>
        public ParticleSystem(StartPosition startPosX, StartPosition startPosY, float velocityX, float velocityY, int lifetime,
                              int createNumber, float createRange, CreateFunction createFunction,
                              Particle.Type particleType, ParticleColor particleColor, float particleSize, int particleLifetime)
        {
            //Random r = new Random();
            this.startPositionX = startPosX;
            this.startPositionY = startPosY;
            this.positionX      = startPosX();//(float)r.NextDouble() * (maxPosX - minPosX) + minPosX;
            this.positionY      = startPosY();
            this.velocityX      = velocityX;
            this.velocityY      = velocityY;
            this.lifetime       = lifetime;

            this.createNumber   = createNumber;
            this.createRange    = createRange;
            this.createFunction = createFunction;

            this.particleType     = particleType;
            this.particleColor    = particleColor;
            this.particleSize     = particleSize;
            this.particleLifetime = particleLifetime;

            this.isBasicParticleSystem = false;
        }
示例#7
0
    public void ChangeColor(ParticleColor color)
    {
        ColorZone zone = null;

        for (int i = 0; i < zones.Count; i++)
        {
            zone = zones[i] as ColorZone;
            if (zone != null)
            {
                break;
            }
        }

        if (zone == null)
        {
            if (color == ParticleColor.None)
            {
                return;
            }

            zone          = Instantiate(PrefabLibrary.Instance.ColorZone.gameObject).GetComponent <ColorZone>();
            zone.particle = this;
            zone.transform.SetParent(transform);
            zone.transform.localPosition = Vector3.zero;
        }

        switch (color)
        {
        case ParticleColor.None:
            color = ParticleColor.None;
            Destroy(zone.gameObject);
            break;

        case ParticleColor.Beta:
            if (this.color == ParticleColor.Red)
            {
                color = ParticleColor.Green;
            }
            else if (this.color == ParticleColor.Green)
            {
                color = ParticleColor.Blue;
            }
            else if (this.color == ParticleColor.Blue)
            {
                color = ParticleColor.Red;
            }

            decayTimer = decayTime;
            break;
        }

        this.color = color;
        switch (color)
        {
        case ParticleColor.Blue:
            material.color = Color.blue;
            break;

        case ParticleColor.Green:
            material.color = Color.green;
            break;

        case ParticleColor.Red:
            material.color = Color.red;
            break;
        }
    }
示例#8
0
 private static extern void Internal_create0(ParticleColor managedInstance);
示例#9
0
 private static extern void Internal_create(ParticleColor managedInstance, ref ParticleColorOptions desc);