Example #1
0
    public XffectComponent AddXffect(string name)
    {
        Transform baseobj = transform.Find(name);

        if (baseobj == null)
        {
            Debug.Log("object:" + name + "doesn't exist!");
            return(null);
        }
        Transform newobj = Instantiate(baseobj, Vector3.zero, Quaternion.identity) as Transform;

        newobj.parent = transform;
        XffectComponent.SetActive(newobj.gameObject, false);

        newobj.gameObject.name = baseobj.gameObject.name;

        XffectComponent xft = newobj.GetComponent <XffectComponent>();

        EffectDic[name].Add(xft);
        if (xft != null)
        {
            xft.Initialize();
        }
        return(xft);
    }
Example #2
0
 public void Active()
 {
     if (!XffectComponent.IsActive(gameObject))
     {
         XffectComponent.SetActive(gameObject, true);
     }
     foreach (XffectComponent xft in XffectList)
     {
         xft.Active();
     }
 }
Example #3
0
 void LateUpdate()
 {
     for (int i = 0; i < XffectList.Count; i++)
     {
         XffectComponent xft = (XffectComponent)XffectList[i];
         if (XffectComponent.IsActive(xft.gameObject))
         {
             return;
         }
     }
     //if all children is done, then set to non-active.
     XffectComponent.SetActive(gameObject, false);
 }
Example #4
0
    void LateUpdate()
    {
        // if no collision needed, hide the colliders.
        if (!XffectComponent.IsActive(XCollisionTest1.gameObject) && !XffectComponent.IsActive(XCollisionTest2.gameObject))
        {
            if (Colliders.gameObject == true)
            {
                foreach (Transform child in Colliders)
                {
                    XffectComponent.SetActive(child.gameObject, false);
                }
            }
            XffectComponent.SetActive(Colliders.gameObject, false);
        }

        //auto deactive background
        m_checkTime += Time.deltaTime;
        if (m_checkTime > 5f)
        {
            XffectComponent.SetActive(BackgroundWallBottom.gameObject, false);
        }
    }
Example #5
0
    //useful for only-one effect cache and the effect is looping.
    public void DeActiveEffect(string eftName)
    {
        List <XffectComponent> cache = EffectDic[eftName];

        if (cache == null)
        {
            Debug.LogError(name + ": cache doesnt exist!");
            return;
        }
        if (cache.Count > 1)
        {
            Debug.LogWarning("DeActive() only support one Xffect cache!");
        }
        XffectComponent xft = cache[0];

        if (!XffectComponent.IsActive(xft.gameObject))
        {
            return;
        }
        xft.DeActive();
        xft.Reset();
        XffectComponent.SetActive(xft.gameObject, false);
    }
Example #6
0
    void Update()
    {
        if (ShowLightBeams)
        {
            XLightBeams.Active();
        }
        else
        {
            XLightBeams.DeActive();
        }
        if (ShowRaining)
        {
            XRaining.Active();
        }
        else
        {
            XRaining.DeActive();
        }

        if (ShowVolumeFog)
        {
            XffectComponent.SetActive(XVolumeFog.gameObject, true);
        }
        else
        {
            XffectComponent.SetActive(XVolumeFog.gameObject, false);
        }

        if (ShowWaterfall)
        {
            XWaterfall.Active();
        }
        else
        {
            XWaterfall.DeActive();
        }
        if (ShowPortalCone)
        {
            XPortalCone.Active();
        }
        else
        {
            XPortalCone.DeActive();
        }

        if (ShowTadpoleGate)
        {
            XTadpoleGate.Active();
        }
        else
        {
            XTadpoleGate.DeActive();
        }

        if (ShowCrystalEnergy)
        {
            XCrystalEnergy.Active();
        }
        else
        {
            XCrystalEnergy.DeActive();
        }

        if (ShowSurroundSoul)
        {
            XSurroundSoul.Active();
        }
        else
        {
            XSurroundSoul.DeActive();
        }

        if (ShowPhantomSwordSlash)
        {
            XPhantomSwordSlash.Active();
        }
        else
        {
            XPhantomSwordSlash.DeActive();
        }

        if (ShowPhantomSword)
        {
            XPhantomSword.Active();
        }
        else
        {
            XPhantomSword.DeActive();
        }

        if (ShowTransformSpell)
        {
            XTransformSpell.Active();
        }
        else
        {
            XTransformSpell.DeActive();
        }

        if (ShowSpreadSlash)
        {
            XSpreadSlash.Active();
        }
        else
        {
            XSpreadSlash.DeActive();
        }

        if (ShowPinkSoul)
        {
            XPinkSoul.Active();
        }
        else
        {
            XPinkSoul.DeActive();
        }

        if (ShowSakura)
        {
            XSakura.Active();
        }
        else
        {
            XSakura.DeActive();
        }

        if (ShowIceImpact)
        {
            XIceImpact.Active();
        }
        else
        {
            XIceImpact.DeActive();
        }

        if (ShowWindowLight)
        {
            XWindowLight.Active();
        }
        else
        {
            XWindowLight.DeActive();
        }

        if (ShowVolumetricLight1)
        {
            XVolumetricLight1.Active();
        }
        else
        {
            XVolumetricLight1.DeActive();
        }

        if (ShowVolumetricLight2)
        {
            XVolumetricLight2.Active();
        }
        else
        {
            XVolumetricLight2.DeActive();
        }

        if (ShowSuckBlood)
        {
            XSuckBlood.Active();
        }
        else
        {
            XSuckBlood.DeActive();
        }

        if (ShowCyclone2)
        {
            Cyclone2.Active();
        }
        else
        {
            Cyclone2.DeActive();
        }

        if (ShowCyclone3)
        {
            Cyclone3.Active();
        }
        else
        {
            Cyclone3.DeActive();
        }

        if (ShowDevilTrigger)
        {
            DevilTrigger.Active();
        }
        else
        {
            DevilTrigger.DeActive();
        }

        if (ShowMeshFogVolume)
        {
            MeshFogVolume.Active();
        }
        else
        {
            MeshFogVolume.DeActive();
        }

        if (ShowGlowTrails)
        {
            GlowTrails.Active();
        }
        else
        {
            GlowTrails.DeActive();
        }
    }
Example #7
0
    void OnGUI()
    {
        GUI.Label(new Rect(150, 0, 350, 25), "left button to rotate, middle button to pan, wheel to zoom.");
        GUI.Label(new Rect(200, 18, 200, 25), "xffect pro version 3.0.0");

        ScrollPosition    = GUI.BeginScrollView(new Rect(0, 0, 140, 600), ScrollPosition, new Rect(0, 0, 140, 800));
        ShowLightBeams    = GUI.Toggle(new Rect(10, 0, 80, 20), ShowLightBeams, "LightBeams");
        ShowRaining       = GUI.Toggle(new Rect(10, 20, 80, 20), ShowRaining, "Raining");
        ShowVolumeFog     = GUI.Toggle(new Rect(10, 40, 80, 20), ShowVolumeFog, "VolumeFog");
        ShowWaterfall     = GUI.Toggle(new Rect(10, 60, 80, 20), ShowWaterfall, "Waterfall");
        ShowPortalCone    = GUI.Toggle(new Rect(10, 100, 80, 20), ShowPortalCone, "PortalCone");
        ShowTadpoleGate   = GUI.Toggle(new Rect(10, 120, 80, 20), ShowTadpoleGate, "TadpoleGate");
        ShowCrystalEnergy = GUI.Toggle(new Rect(10, 140, 120, 20), ShowCrystalEnergy, "CrystalEnergy");
        ShowSurroundSoul  = GUI.Toggle(new Rect(10, 160, 120, 20), ShowSurroundSoul, "SwingAround");

        if (GUI.Button(new Rect(10, 80, 120, 20), "RadialEnergy"))
        {
            XffectComponent.SetActive(BackgroundWallBottom.gameObject, true);
            m_checkTime = 0f;
            XRadialEnergy.Active();
        }


        if (GUI.Button(new Rect(10, 190, 80, 20), "collision1"))
        {
            XCollisionTest1.Active();
            //show colliders.
            foreach (Transform child in Colliders)
            {
                XffectComponent.SetActive(child.gameObject, true);
            }
            XffectComponent.SetActive(Colliders.gameObject, true);
        }

        if (GUI.Button(new Rect(10, 210, 80, 20), "collision2"))
        {
            XCollisionTest2.Active();
            //set collision goal.
            XCollisionTest2.SetCollisionGoalPos(CollisionGoal);
            //show colliders.
            foreach (Transform child in Colliders)
            {
                XffectComponent.SetActive(child.gameObject, true);
            }
            XffectComponent.SetActive(Colliders.gameObject, true);
        }

        if (GUI.Button(new Rect(10, 240, 80, 20), "missile1"))
        {
            XMissile1.Active();
            XMissile1.transform.position = new Vector3(0, 0, 50);
            SimpleMissile smile = XMissile1.transform.GetComponent <SimpleMissile>();
            smile.Reset();
        }
        if (GUI.Button(new Rect(10, 260, 80, 20), "missile2"))
        {
            XMissile2.Active();
            XMissile2.transform.position = new Vector3(0, 0, 40);
            SimpleMissile smile = XMissile2.transform.GetComponent <SimpleMissile>();
            smile.Reset();
        }
        if (GUI.Button(new Rect(10, 280, 80, 20), "missile3"))
        {
            XMissile3.Active();
            XMissile3.transform.position = new Vector3(0, 0, 40);
            SimpleMissile smile = XMissile3.transform.GetComponent <SimpleMissile>();
            smile.Reset();
        }
        if (GUI.Button(new Rect(10, 300, 80, 20), "missile4"))
        {
            XMissile4.transform.position = new Vector3(0, 0, 40);
            XMissile4.Active();
            SimpleMissile smile = XMissile4.transform.GetComponent <SimpleMissile>();
            smile.Reset();
        }


        if (GUI.Button(new Rect(10, 330, 80, 20), "explosion1"))
        {
            XffectComponent.SetActive(BackgroundWallBottom.gameObject, true);
            m_checkTime = 0f;
            XExplode1.Active();
        }
        if (GUI.Button(new Rect(10, 350, 80, 20), "explosion2"))
        {
            XExplode2.Active();
        }
        if (GUI.Button(new Rect(10, 370, 80, 20), "explosion3"))
        {
            XExplode3.Active();
        }

        if (GUI.Toggle(new Rect(10, 390, 120, 20), ShowPhantomSwordSlash, "PhantomSlash"))
        {
            ShowPhantomSwordSlash = true;
            m_checkTime           = 0f;
            XffectComponent.SetActive(BackgroundWallBottom.gameObject, true);
        }
        else
        {
            ShowPhantomSwordSlash = false;
        }
        ShowPhantomSword = GUI.Toggle(new Rect(10, 410, 120, 20), ShowPhantomSword, "PhantomSword");

        ShowTransformSpell = GUI.Toggle(new Rect(10, 430, 120, 20), ShowTransformSpell, "TransformSpell");

        if (GUI.Button(new Rect(10, 450, 100, 20), "BombAffector"))
        {
            XBombAffector.Active();
        }
        //ver 1.2.1
        ShowSpreadSlash = GUI.Toggle(new Rect(10, 470, 120, 20), ShowSpreadSlash, "SpreadSlash");
        ShowPinkSoul    = GUI.Toggle(new Rect(10, 490, 120, 20), ShowPinkSoul, "PinkSoul");
        ShowSakura      = GUI.Toggle(new Rect(10, 510, 120, 20), ShowSakura, "Sakura");

        //ver 1.2.2
        if (GUI.Button(new Rect(10, 530, 100, 20), "LevelUp"))
        {
            XLevelUp.Active();
        }

        //ver 1.2.3
        ShowIceImpact = GUI.Toggle(new Rect(10, 550, 120, 20), ShowIceImpact, "IceImpact");


        //ver 1.3.1
        if (GUI.Button(new Rect(10, 570, 80, 20), "Dissolve"))
        {
            XffectComponent.SetActive(BackgroundWallBottom.gameObject, true);
            m_checkTime = 0f;
            XDissolve.Active();
        }

        ShowWindowLight      = GUI.Toggle(new Rect(10, 590, 120, 20), ShowWindowLight, "WindowLight");
        ShowVolumetricLight1 = GUI.Toggle(new Rect(10, 610, 120, 20), ShowVolumetricLight1, "VolumetricLight1");
        ShowVolumetricLight2 = GUI.Toggle(new Rect(10, 630, 120, 20), ShowVolumetricLight2, "VolumetricLight2");

        ShowSuckBlood = GUI.Toggle(new Rect(10, 650, 120, 20), ShowSuckBlood, "SuckBlood");

        if (GUI.Button(new Rect(10, 670, 120, 20), "Cyclone1"))
        {
            Cyclone1.Active();
        }

        ShowCyclone2      = GUI.Toggle(new Rect(10, 690, 120, 20), ShowCyclone2, "Cyclone2");
        ShowCyclone3      = GUI.Toggle(new Rect(10, 710, 120, 20), ShowCyclone3, "Cyclone3");
        ShowDevilTrigger  = GUI.Toggle(new Rect(10, 730, 120, 20), ShowDevilTrigger, "Devil Trigger");
        ShowMeshFogVolume = GUI.Toggle(new Rect(10, 750, 120, 20), ShowMeshFogVolume, "MeshFogVolume");
        ShowGlowTrails    = GUI.Toggle(new Rect(10, 770, 120, 20), ShowGlowTrails, "GlowTrails");

        GUI.EndScrollView();
    }
Example #8
0
    //in editor mode, Awake() method called twice, why?.
    public void Initialize()
    {
        if (EflList.Count > 0)
        {//already inited.
            return;
        }
        //fixed : 2012.5.25. can't add child game object during foreach..
        //ArrayList tobeAdded = new ArrayList();

        foreach (Transform child in transform)
        {
            EffectLayer el = (EffectLayer)child.GetComponent(typeof(EffectLayer));
            if (el == null)
            {
                continue;
            }

            if (el.Material == null)
            {
                Debug.LogWarning("effect layer: " + el.gameObject.name + " has no material, please assign a material first!");
                continue;
            }

            SetActive(el.gameObject, true);

            Material mat = el.Material;
            //ver 1.2.1
            mat.renderQueue  = mat.shader.renderQueue;
            mat.renderQueue += el.Depth;
            EflList.Add(el);
            MeshFilter   Meshfilter;
            MeshRenderer Meshrenderer;

            Transform oldMesh = transform.Find("xftmesh " + mat.name);
            if (oldMesh != null)
            {//already instaniate by object cache.just recreate vertex pool.\
                Meshfilter            = (MeshFilter)oldMesh.GetComponent(typeof(MeshFilter));
                Meshrenderer          = (MeshRenderer)oldMesh.GetComponent(typeof(MeshRenderer));
                Meshfilter.sharedMesh = new Mesh();
                Meshfilter.sharedMesh.Clear();
                MatDic[mat.name] = new VertexPool(Meshfilter.sharedMesh, mat);
                //fixed 2012.7.20 if already exist, Add to MeshList too.
                if (!MeshList.Contains(oldMesh.gameObject))
                {
                    MeshList.Add(oldMesh.gameObject);
                }
            }
            if (!MatDic.ContainsKey(mat.name))
            {
                GameObject obj = new GameObject("xftmesh " + mat.name);
                obj.layer = gameObject.layer;
                //obj.transform.parent = this.transform;
                //tobeAdded.Add(obj);
                MeshList.Add(obj);
                obj.AddComponent <MeshFilter>();
                obj.AddComponent <MeshRenderer>();
                SetActive(obj, IsActive(gameObject));

#if UNITY_EDITOR
                if (!EditorApplication.isPlaying)
                {
                    XffectComponent.SetActive(obj, true);
                }
#endif


                Meshfilter                  = (MeshFilter)obj.GetComponent(typeof(MeshFilter));
                Meshrenderer                = (MeshRenderer)obj.GetComponent(typeof(MeshRenderer));
                Meshrenderer.castShadows    = false;
                Meshrenderer.receiveShadows = false;
                Meshrenderer.GetComponent <Renderer>().sharedMaterial = mat;
                Meshfilter.sharedMesh = new Mesh();
                MatDic[mat.name]      = new VertexPool(Meshfilter.sharedMesh, mat);
            }
        }

        //now set each gameobject's parent.
        foreach (GameObject obj in MeshList)
        {
            obj.transform.parent = this.transform;

            //fixed 2012.6.25,
            obj.transform.position = Vector3.zero;
            obj.transform.rotation = Quaternion.identity;

            //fixed 2012.7.11, avoid the lossy scale influence the mesh object.
            Vector3 realLocalScale = Vector3.zero;
            realLocalScale.x = 1 / obj.transform.parent.lossyScale.x;
            realLocalScale.y = 1 / obj.transform.parent.lossyScale.y;
            realLocalScale.z = 1 / obj.transform.parent.lossyScale.z;

            obj.transform.localScale = realLocalScale * Scale;
        }


        //start each effect layer.
        foreach (EffectLayer efl in EflList)
        {
            efl.Vertexpool = MatDic[efl.Material.name];
        }
        //this.transform.position = Vector3.zero;
        //this.transform.rotation = Quaternion.identity;
        this.transform.localScale = Vector3.one;

        foreach (EffectLayer el in EflList)
        {
            el.StartCustom();
        }

        //add events
        EventList.Clear();
        foreach (Transform child in transform)
        {
            XftEventComponent xftevent = child.GetComponent <XftEventComponent>();
            if (xftevent == null)
            {
                continue;
            }
            EventList.Add(xftevent);
            xftevent.Initialize();
        }
        Initialized = true;
    }