Esempio n. 1
0
    // Use this for initialization
    public void Initialize(X_LB_LightningSource lightningSource)
    {
        this.lightningSource = lightningSource;

        material = GetComponentInChildren <Renderer> ().material;
        sceleton = transform.Find("BranchModel/joint1/joint2");
        points   = sceleton.GetComponentsInChildren <Transform> ();
        SceletonSetup();

        startOffsetY = material.mainTextureOffset.y;

        InPool();
    }
Esempio n. 2
0
    // Use this for initialization
    public void Initialize(X_LB_LightningSource lightningSource)
    {
        this.lightningSource = lightningSource;

        point1   = transform.Find("point1");
        point2   = transform.Find("point1/point2");
        material = GetComponentInChildren <Renderer> ().material;
        lamp     = transform.GetComponentInChildren <Light> ();

        branchCreationCounter = Random.Range(0, lightningSource.branchCreationMoment);

        Coloring();
        Drawing();

        InPool();
    }
    public static void GetPresetValues(X_LB_LightningSource ls, string value, string preset)
    {
        if (preset == "cartoonEnergyStream")
        {
            if (value == "color")
            {
                ls.color = Color.magenta;
            }
            if (value == "thinStyle")
            {
                ls.thinStyle = false;
            }
            if (value == "darkStyle")
            {
                ls.darkStyle = false;
            }
            if (value == "fadeEffect")
            {
                ls.fadeEffect = true;
            }
            if (value == "lightSize")
            {
                ls.lightSize = 60;
            }
            if (value == "freezeShape")
            {
                ls.freezeShape = false;
            }
            if (value == "segmentSize")
            {
                ls.segmentSize = 10;
            }
            if (value == "flickeringStrength")
            {
                ls.flickeringStrength = 1;
            }
            if (value == "streamingSpeed")
            {
                ls.streamingSpeed = 2;
            }
            if (value == "branchAmount")
            {
                ls.branchAmount = 10;
            }
        }

        if (preset == "cartoonImpactBolt")
        {
            if (value == "color")
            {
                ls.color = Color.white;
            }
            if (value == "thinStyle")
            {
                ls.thinStyle = false;
            }
            if (value == "darkStyle")
            {
                ls.darkStyle = false;
            }
            if (value == "fadeEffect")
            {
                ls.fadeEffect = true;
            }
            if (value == "lightSize")
            {
                ls.lightSize = 30;
            }
            if (value == "freezeShape")
            {
                ls.freezeShape = false;
            }
            if (value == "segmentSize")
            {
                ls.segmentSize = 7;
            }
            if (value == "flickeringStrength")
            {
                ls.flickeringStrength = 1;
            }
            if (value == "streamingSpeed")
            {
                ls.streamingSpeed = 0;
            }
            if (value == "branchAmount")
            {
                ls.branchAmount = 10;
            }
        }

        if (preset == "cartoonFeralBolt")
        {
            if (value == "color")
            {
                ls.color = Color.cyan;
            }
            if (value == "thinStyle")
            {
                ls.thinStyle = false;
            }
            if (value == "darkStyle")
            {
                ls.darkStyle = true;
            }
            if (value == "fadeEffect")
            {
                ls.fadeEffect = true;
            }
            if (value == "lightSize")
            {
                ls.lightSize = 50;
            }
            if (value == "freezeShape")
            {
                ls.freezeShape = false;
            }
            if (value == "segmentSize")
            {
                ls.segmentSize = 12f;
            }
            if (value == "flickeringStrength")
            {
                ls.flickeringStrength = 1.5f;
            }
            if (value == "streamingSpeed")
            {
                ls.streamingSpeed = 10;
            }
            if (value == "branchAmount")
            {
                ls.branchAmount = 50;
            }
        }

        if (preset == "realisticLightning")
        {
            if (value == "color")
            {
                ls.color = Color.white;
            }
            if (value == "thinStyle")
            {
                ls.thinStyle = true;
            }
            if (value == "darkStyle")
            {
                ls.darkStyle = false;
            }
            if (value == "fadeEffect")
            {
                ls.fadeEffect = true;
            }
            if (value == "lightSize")
            {
                ls.lightSize = 60;
            }
            if (value == "freezeShape")
            {
                ls.freezeShape = true;
            }
            if (value == "segmentSize")
            {
                ls.segmentSize = 8;
            }
            if (value == "flickeringStrength")
            {
                ls.flickeringStrength = 1.2f;
            }
            if (value == "streamingSpeed")
            {
                ls.streamingSpeed = 1;
            }
            if (value == "branchAmount")
            {
                ls.branchAmount = 30;
            }
        }
    }
    public override void OnInspectorGUI()
    {
        X_LB_LightningSource ls = (X_LB_LightningSource)target;

        //Editor

        EditorGUILayout.LabelField("AUTOPLAY");
        ls.autoplayStrikeOn = EditorGUILayout.ToggleLeft("Autoplay Strike", ls.autoplayStrikeOn);

        EditorGUILayout.LabelField("ACTIONS");
        if (GUILayout.Button("Strike Once"))
        {
            ls.StrikeOnce();
        }
        string r = "Strike";

        if (ls.strikeBool)
        {
            r = "✓ Strike";
        }
        if (GUILayout.Button(r))
        {
            ls.Strike();
        }
        string se = "Strike Randomly";

        if (ls.strikeRandomly)
        {
            se = "✓ Strike Randomly";
        }
        if (GUILayout.Button(se))
        {
            ls.StrikeRandomly();
        }
        if (ls.strikeRandomly == true)
        {
            ls.strikeRandomlyRate = 55 - EditorGUILayout.IntSlider("Randomly rate", ls.strikeRandomlyRate, 5, 50);
        }

        EditorGUILayout.Space();

        //TARGETS
        EditorGUILayout.LabelField("TARGETS");

        if (ls.targets.Count == 0)
        {
            EditorGUILayout.HelpBox("Lightning can not be executed: No targets assigned!", MessageType.Warning);
        }
        else
        {
            for (int i = 0; i < ls.targets.Count; i++)
            {
                Object currentObject = (Object)ls.targets [i];
                currentObject  = EditorGUILayout.ObjectField(currentObject, typeof(Transform), true);
                ls.targets [i] = (Transform)currentObject;
                string currentMethod = (string)ls.callMethodOnImpact[i];
                if (ls.callMethodOnImpactBool[i] == false)
                {
                    ls.callMethodOnImpactBool[i] = EditorGUILayout.ToggleLeft("Call method on impact", ls.callMethodOnImpactBool[i]);
                    if (currentMethod == "")
                    {
                        currentMethod = "(No method)";
                    }
                }
                else
                {
                    if (currentMethod == "")
                    {
                        ls.callMethodOnImpactBool[i] = false;
                    }
                    currentMethod = EditorGUILayout.TextField("Call method: ", currentMethod);
                }
                ls.callMethodOnImpact[i] = (string)currentMethod;
                EditorGUILayout.Space();
            }
            if (GUILayout.Button("Remove last target"))
            {
                if (ls.targets.Count > 0)
                {
                    ls.targets.RemoveAt(ls.targets.Count - 1);
                    ls.callMethodOnImpact.RemoveAt(ls.callMethodOnImpact.Count - 1);
                    ls.callMethodOnImpactBool.RemoveAt(ls.callMethodOnImpactBool.Count - 1);
                }
            }
        }
        if (GUILayout.Button("Add new target"))
        {
            if (ls.targets.Count < 100)
            {
                ls.targets.Add(null);
                ls.callMethodOnImpact.Add("");
                ls.callMethodOnImpactBool.Add(false);
            }
        }

        EditorGUILayout.Space();

        //PERFORMANCE
        EditorGUILayout.LabelField("PERFORMANCE");
        ls.framerate = EditorGUILayout.IntSlider("Framerate", ls.framerate, 10, 60);

        EditorGUILayout.Space();

        //SOUND
        EditorGUILayout.LabelField("SOUND");
        ls.soundOn = EditorGUILayout.ToggleLeft("Sound On", ls.soundOn);

        EditorGUILayout.Space();

        //STYLE
        EditorGUILayout.LabelField("STYLE");
        ls.presets = (X_LB_LightningSource.Presets)EditorGUILayout.EnumPopup(ls.presets);

        EditorGUILayout.Space();

        if (ls.presets == X_LB_LightningSource.Presets.CUSTOM)
        {
            //CUSTOMIZE
            ls.color              = EditorGUILayout.ColorField("Color", ls.color);
            ls.thinStyle          = EditorGUILayout.Toggle("Thin Style", ls.thinStyle);
            ls.darkStyle          = EditorGUILayout.Toggle("Dark Style", ls.darkStyle);
            ls.fadeEffect         = EditorGUILayout.Toggle("Fade Effect", ls.fadeEffect);
            ls.freezeShape        = EditorGUILayout.Toggle("Freeze Shape", ls.freezeShape);
            ls.lightSize          = EditorGUILayout.Slider("Light Size", ls.lightSize, 0f, 100f);
            ls.segmentSize        = EditorGUILayout.Slider("Segment Size", ls.segmentSize, 1f, 20f);
            ls.flickeringStrength = EditorGUILayout.Slider("Flickering Strength", ls.flickeringStrength, 0, 5);
            ls.streamingSpeed     = EditorGUILayout.Slider("Streaming Speed", ls.streamingSpeed, 0, 10);
            ls.branchAmount       = EditorGUILayout.Slider("Branch Amount", ls.branchAmount, 0, 50);
            EditorGUILayout.Space();

            //restrict impossible style combination
            if (ls.darkStyle && ls.thinStyle)
            {
                ls.darkStyle = false;
                ls.thinStyle = false;
            }
        }

        //INFO
        EditorGUILayout.Space();
        if (GUILayout.Button("Need help? Get it here quickly."))
        {
            Application.OpenURL("http://www.game-x.ch/Assets/lightningBoltTest.html");
        }
        EditorGUILayout.HelpBox("Asset by Game Expressions! - www.game-x.ch", MessageType.None);
        EditorGUILayout.HelpBox("You'd help us a lot if you write a review, it pushes our asset, wich pushes your game. Thank you!", MessageType.None);

        if (GUI.changed)
        {
            EditorUtility.SetDirty(ls);
        }
    }
Esempio n. 5
0
 public void Initialize(X_LB_LightningSource lightningSource)
 {
     this.lightningSource = lightningSource;
 }