void LoadEffect()
 {
     Object[] objs = Resources.LoadAll("Effects/");          //读取所有特效文件,可以根据情况改变地址
     for (int i = 0; i < objs.Length; i++)
     {
         GameObject go = PrefabUtility.InstantiatePrefab(objs[i]) as GameObject;             //创建实例
         if (go == null)
         {
             continue;
         }
         ParticleRenderer[] renderers = go.GetComponentsInChildren <ParticleRenderer>(true);             //获取特效实例下的所有ParticleRenderer组件
         foreach (ParticleRenderer render in renderers)
         {
             EffectParticle  effect  = new EffectParticle();
             ParticleEmitter emitter = render.GetComponent <ParticleEmitter>();                  //获取ParticleEmitter组件
             effect.name     = objs[i].name;
             effect.material = render.sharedMaterial;
             if (emitter != null)
             {
                 effect.maxEmission = emitter.maxEmission;                       //最大发射粒子数赋值
             }
             effect.prefab = objs[i];
             listEffect.Add(effect);
         }
         DestroyImmediate(go);                                                       //销毁实例
     }
     listEffect.Sort((x, y) => { return(y.maxEmission.CompareTo(x.maxEmission)); }); //从大到小排序
     style.normal.textColor = Color.red;
     style.fixedWidth       = 120;
 }
Esempio n. 2
0
    public void InstantEffect(EffectId effectId, Vector3 position)
    {
        EffectParticle func = (particle, pos, audioClip) => {
            GameObject obj = Instantiate(particle, pos, Quaternion.Euler(Vector3.zero)) as GameObject;
            Destroy(obj, destroyInterval);
            audioSource.PlayOneShot(audioClip);
        };

        switch (effectId)
        {
        case EffectId.GetItem:
            func(getItem.particle, position, getItem.se);
            break;

        case EffectId.KillEnemy:
            func(killEnemy.particle, position, killEnemy.se);
            break;

        case EffectId.GetSweet:
            func(getSweet.particle, position, getSweet.se);
            break;

        case EffectId.GameOver:
            func(checkPoint.particle, position, checkPoint.se);
            break;
        }
    }
Esempio n. 3
0
    /**
     * function that handles absorbing the nutrients (aka the effect particles) in a certain range of the glow segment
     */
    private void absorbNutrients(Vector3 center, float radius)
    {
        // set a minimum radius to make sure it's large enough to absorb some nutrients
        if (radius < 3.5f)
        {
            radius = 3.5f;
        }
        //move the center to the same height as the particles we want to check for collisions with
        center = new Vector3(center.x, .5f, center.z);

        // gather all collisions.  use radius * .75 because the collider seems larger than the value you assign it
        // this value was chosen by trial and error
        UnityEngine.Collider[] nutrientHits = Physics.OverlapSphere(center, radius * .75f,
                                                                    1 << LayerMask.NameToLayer("Ignore Raycast"));

        // iterate over all nutrients found by the collider to handle absorbing them
        for (int i = 0; i < nutrientHits.Length; i++)
        {
            if (nutrientHits[i].gameObject.name.Equals("EffectParticle(Clone)"))                        // first make sure the hit particle
            // if of the correct type (effect
            // particles only)
            {
                effectParticle = nutrientHits[i].GetComponent <EffectParticle>();
                if (!effectParticle.getMoveAndDie() && !effectParticle.getFinalMove())                  // make sure the particle isn't already in the killing process
                {
                    // start the absorbing of the particle asynchronously. this helps reduce performance impact
                    StartCoroutine(effectParticle.killParticle(center));
                }
            }
        }
    }
Esempio n. 4
0
    private void getHandLocation()
    {
        EffectParticle[] nutrients = FindObjectsOfType(typeof(EffectParticle)) as EffectParticle[];
        EffectParticle   target    = null;

        for (int i = 0; i < nutrients.Length; i++)
        {
            if (nutrients[i].transform.position.z > 1.7)
            {
                target             = nutrients[i];
                chooseHandLocation = true;
                break;
            }
        }

        handRectangle = new Rect((target.transform.position.x + 26) / 52f * Screen.width - .1f * Screen.width,
                                 Screen.height - ((target.transform.position.z + 19) / 38f * Screen.height) - .12f * Screen.height,
                                 .25f * Screen.width, .415f * Screen.height);
    }
        public void UpdateControls()
        {
            UpdateThrust();
            UpdateTurn();

            void UpdateThrust()
            {
                if (thrusting)
                {
                    var rotationRads = rotationDegrees * Math.PI / 180;

                    var exhaust = new EffectParticle(Position + XY.Polar(rotationRads, -1),
                                                     Velocity + XY.Polar(rotationRads, -thrust),
                                                     new ColoredGlyph(Color.Yellow, Color.Transparent, '.'),
                                                     4);
                    World.AddEffect(exhaust);

                    Velocity += XY.Polar(rotationRads, thrust);
                    thrusting = false;
                }
            }

            void UpdateTurn()
            {
                if (rotating != Rotating.None)
                {
                    if (rotating == Rotating.CCW)
                    {
                        rotationDegrees += turningSpeed;
                    }
                    else if (rotating == Rotating.CW)
                    {
                        rotationDegrees -= turningSpeed;
                    }
                    rotating = Rotating.None;
                }
            }
        }
Esempio n. 6
0
    public static void SetDrawObjects()
    {
        // 画像の読み込み
        DrawObject scr     = new DrawObject("scr.png", DrawObject.EnumAlign.RIGHTCENTER, 2, 1);    //スクラッチの左右向き緑
        DrawObject scrbad  = new DrawObject("scrbad.png", DrawObject.EnumAlign.RIGHTCENTER, 2, 1); //スクラッチの左右向き緑
        DrawObject scrcore = new DrawObject("scrcore.png", DrawObject.EnumAlign.CENTERCENTER);     //スクラッチの左右向き緑
        DrawObject bar     = new DrawObject("bar.png", DrawObject.EnumAlign.CENTERBOTTOM);
        DrawObject baroff  = new DrawObject("baroff.png", DrawObject.EnumAlign.CENTERBOTTOM);

        DrawObject disk    = new DrawObject("disk.png", DrawObject.EnumAlign.CENTERCENTER);
        DrawObject light   = new DrawObject("disklight.png", DrawObject.EnumAlign.CENTERCENTER);
        DrawObject NGXMark = new DrawObject("xDisk.png", DrawObject.EnumAlign.CENTERCENTER);

        DrawObject disklightl = new DrawObject("disklightl.png", DrawObject.EnumAlign.CENTERCENTER);
        DrawObject disklightr = new DrawObject("disklightr.png", DrawObject.EnumAlign.CENTERCENTER);

        DrawObject cutinL = new DrawObject("cutinL.png", DrawObject.EnumAlign.CENTERBOTTOM);
        DrawObject cutinR = new DrawObject("cutinR.png", DrawObject.EnumAlign.CENTERBOTTOM);

        DrawObject diskshadowL = new DrawObject("diskshadowL.png", DrawObject.EnumAlign.CENTERBOTTOM, 1, 2); //アクティブ皿の裏ののびーる赤と紫
        DrawObject diskshadowR = new DrawObject("diskshadowR.png", DrawObject.EnumAlign.CENTERBOTTOM, 1, 2); //アクティブ皿の裏ののびーる赤と紫

        DrawObject barL = new DrawObject("playlinel.png", DrawObject.EnumAlign.CENTERBOTTOM);
        DrawObject barR = new DrawObject("playliner.png", DrawObject.EnumAlign.CENTERBOTTOM);

        DrawObject cue  = new DrawObject("cue.png", DrawObject.EnumAlign.CENTERCENTER, 1, 36);
        DrawObject cueL = new DrawObject("cueL.png", DrawObject.EnumAlign.CENTERCENTER, 1, 37);
        DrawObject cueR = new DrawObject("cueR.png", DrawObject.EnumAlign.CENTERCENTER, 1, 37);

        DrawObject fader  = new DrawObject("fader.png", DrawObject.EnumAlign.CENTERBOTTOM);
        DrawObject faderC = new DrawObject("faderC.png", DrawObject.EnumAlign.CENTERBOTTOM);
        DrawObject faderL = new DrawObject("faderL.png", DrawObject.EnumAlign.CENTERBOTTOM);
        DrawObject faderR = new DrawObject("faderR.png", DrawObject.EnumAlign.CENTERBOTTOM);

        DrawObject particle = new DrawObject("star.png", DrawObject.EnumAlign.CENTERCENTER, 1, 3);

        DrawObject frame   = new DrawObject("frame.png", DrawObject.EnumAlign.LEFTTOP);
        DrawObject rainbow = new DrawObject("Rainbow.png", DrawObject.EnumAlign.LEFTTOP, 1, 8);

        DrawObject barBeat    = new DrawObject("barBeat.png", DrawObject.EnumAlign.LEFTTOP);
        DrawObject barMeasure = new DrawObject("barMeasure.png", DrawObject.EnumAlign.LEFTTOP);

        DrawObject COOL    = new DrawObject("!!!COOL!!!.png", DrawObject.EnumAlign.CENTERCENTER);
        DrawObject PERFECT = new DrawObject("PERFECT.png", DrawObject.EnumAlign.CENTERCENTER);
        DrawObject GREAT   = new DrawObject("GREAT.png", DrawObject.EnumAlign.CENTERCENTER);
        DrawObject GOOD    = new DrawObject("GOOD.png", DrawObject.EnumAlign.CENTERCENTER);
        DrawObject BAD     = new DrawObject("BAD.png", DrawObject.EnumAlign.CENTERCENTER);

        DiscQueCutData.SetDrawObject(disk, cue, null, light, NGXMark);
        DiscQueCutData.SetLDrawObject(cueL, diskshadowL, cutinL, barL);
        DiscQueCutData.SetRDrawObject(cueR, diskshadowR, cutinR, barR);
        ScratchUnit.SetDrawObject(scr, scrbad, scrcore, bar, baroff);

        EffectParticle.SetDrawObject(particle);
        EffectJudge.SetDrawObject(COOL, PERFECT, GREAT, GOOD, BAD);
        EffectRecord.SetDrawObject(disklightl, disklightr);

        drawfader.setdrawobject(fader, faderC, faderL, faderR);
        DrawLowFrame.SetDrawObject(frame, rainbow);
        DrawBeatline.SetDrawObject(barBeat, barMeasure);
    }
Esempio n. 7
0
    private EffectParticle particle;                            //!< to hold a reference to an individual effect particle

    /**
     * function that handles the creation of the effect particles
     */
    public void createParticles(Color color)
    {
        if (Random.value > .5f)                 // choose a random value between 0 and 1 and make a fair decision based on it
        {
            // if the value was more than .5, then spawn the minimum number of particles
            instantiatedEffectParticles = new GameObject[numParticlesMin];
            numAliveChildren            = numParticlesMin;
        }
        else
        {
            // if the value was less than .5, then spawn the maximum number of particles
            instantiatedEffectParticles = new GameObject[numParticlesMax];
            numAliveChildren            = numParticlesMax;
        }

        particleColor = color;          // assign the proper color to the effect particles

        // spawn particles in a "cloud" formation
        for (int i = 0; i < instantiatedEffectParticles.Length; i++)
        {
            // instantiate the effect particle and assign its attributes
            instantiatedEffectParticles[i] = (GameObject)Instantiate(effectParticle);
            instantiatedEffectParticles[i].GetComponent <Renderer>().material.color = particleColor;
            instantiatedEffectParticles[i].transform.parent = gameObject.transform;

            // choose randomly if the particles go "up" or "down"
            if (Random.Range(0, 2) == 1)
            {
                if (!Application.loadedLevelName.Contains("Tutorial"))
                {
                    // if it's the regular SI game
                    particle = instantiatedEffectParticles[i].GetComponent <EffectParticle>();
                    particle.setDesiredLocation
                        (instantiatedEffectParticles[i].transform.position +
                        new Vector3(Random.Range(-2.5f, -1.5f), 0f, Random.Range(-2f, 2f)));
                }
                else
                {
                    // if it's the SI tutorial game
                    particle = instantiatedEffectParticles[i].GetComponent <EffectParticle>();
                    particle.setDesiredLocation
                        (instantiatedEffectParticles[i].transform.position +
                        new Vector3(Random.Range(-6.0f, -4.5f), 0f, Random.Range(-3f, 3f)));
                }
            }
            else
            {
                if (!Application.loadedLevelName.Contains("Tutorial"))
                {
                    // if it's the regular SI game
                    particle = instantiatedEffectParticles[i].GetComponent <EffectParticle>();
                    particle.setDesiredLocation
                        (instantiatedEffectParticles[i].transform.position +
                        new Vector3(Random.Range(2.5f, 1.5f), 0f, Random.Range(-2f, 2f)));
                }
                else
                {
                    // if it's the SI tutorial game
                    particle = instantiatedEffectParticles[i].GetComponent <EffectParticle>();
                    particle.setDesiredLocation
                        (instantiatedEffectParticles[i].transform.position +
                        new Vector3(Random.Range(6.0f, 4.5f), 0f, Random.Range(-3f, 3f)));
                }
            }
        }
    }