コード例 #1
0
        //Use this for initialization
        void Start()
        {
            try
            {
                StickyStickStuck stickyStickStuck = stickyStickStuckGameObject.GetComponent <StickyStickStuck>();

                toggleEnable    = stickyStickStuck.enable;
                toggleFixed     = false;
                toggleCharacter = false;
                stickyTypeLable = "Sticky Type: " + stickyStickStuck.stickProperties.stickType.ToString();

                if (breakProperties.defaultAllowStickyBreak)
                {
                    toggleAllowStickyBreak = true;
                }
                else
                {
                    toggleAllowStickyBreak = false;
                }

                toggleIsTrigger          = stickyStickStuck.onColliderStickProperties.isTrigger;
                toggleRecursiveInfection = stickyStickStuck.infectionProperties.recursiveInfection;
                toggleAffectInfected     = stickyStickStuck.infectionProperties.affectInfected;
                toggleStickNonRigidbodys = stickyStickStuck.stickProperties.stickNonRigidbodys;
                hMaxSticked     = stickyStickStuck.stickProperties.maxStuck;
                hSceneTimeScale = defaultSceneTimeScale;
            }
            catch (System.Exception)
            {
                Debug.LogWarning("Error reading StickyStickStuck GameObject");
            }
        }
コード例 #2
0
        private void TaggingCleanup()
        {
            foreach (var item in connectedObjectDataList)
            {
                if (item.gameObject != null)
                {
                    StickyStickStuck stickyStickStuck = item.gameObject.GetComponent <StickyStickStuck>();

                    if (stickyStickStuck != null && stickyStickStuck.taggingProperties.useTagging)
                    {
                        item.gameObject.tag = taggingProperties.BackupTag;
                    }
                }
            }
        }
コード例 #3
0
        //Cleans up the infected
        private void InfectCleanUp()
        {
            foreach (var item in connectedObjectDataList)
            {
                if (item.gameObject != null)
                {
                    StickyStickStuck stickyStickStuck = item.gameObject.GetComponent <StickyStickStuck>();

                    if (stickyStickStuck != null)
                    {
                        if (stickyStickStuck.isInfectParent == false)
                        {
                            stickyStickStuck.enable = false;
                        }
                    }
                }
            }
        }
コード例 #4
0
        private void AddStickyJoint(GameObject parent, Collision whatThisHit)
        {
            if (CheckIfOkToStick(whatThisHit, parent))
            {
                ConnectedObjectData newConnectedObject = new ConnectedObjectData();
                newConnectedObject.gameObject = whatThisHit.gameObject;

                //If the isTrigger is checked
                if (onColliderStickProperties.isTrigger)
                {
                    parent.GetComponent <Collider>().isTrigger = true;
                }

                //Finds out what Stick Type was used
                switch (stickProperties.stickType)
                {
                case StickProperties.StickType.Fixed:

                    //Sets up the Fixed joint properties
                    FixedJoint fixedJoint = new FixedJoint();
                    fixedJoint = parent.AddComponent <FixedJoint>();
                    newConnectedObject.fixedJoint = fixedJoint;

                    newConnectedObject.fixedJoint.connectedBody = newConnectedObject.gameObject.GetComponent <Rigidbody>();

                    newConnectedObject.fixedJoint.breakForce  = this.stickProperties.fixedProperties.breakForce;
                    newConnectedObject.fixedJoint.breakTorque = this.stickProperties.fixedProperties.breakTorque;

                    break;

                case StickProperties.StickType.Character:

                    //Sets up the Character joint properties
                    CharacterJoint characterJoint = new CharacterJoint();
                    characterJoint = parent.AddComponent <CharacterJoint>();
                    newConnectedObject.characterJoint = characterJoint;

                    newConnectedObject.characterJoint.connectedBody = newConnectedObject.gameObject.GetComponent <Rigidbody>();

                    newConnectedObject.characterJoint.anchor    = this.stickProperties.characterProperties.anchor;
                    newConnectedObject.characterJoint.axis      = this.stickProperties.characterProperties.axis;
                    newConnectedObject.characterJoint.swingAxis = this.stickProperties.characterProperties.swingAxis;
                    SoftJointLimit lowTwistLimit = new SoftJointLimit();
                    lowTwistLimit.limit      = this.stickProperties.characterProperties.lowTwistLimit.limit;
                    lowTwistLimit.bounciness = this.stickProperties.characterProperties.lowTwistLimit.bounciness;
//                        lowTwistLimit.spring = this.stickProperties.characterProperties.lowTwistLimit.spring;
//                        lowTwistLimit.damper = this.stickProperties.characterProperties.lowTwistLimit.damper;
                    newConnectedObject.characterJoint.lowTwistLimit = lowTwistLimit;
                    SoftJointLimit highTwistLimit = new SoftJointLimit();
                    highTwistLimit.limit      = this.stickProperties.characterProperties.highTwistLimit.limit;
                    highTwistLimit.bounciness = this.stickProperties.characterProperties.highTwistLimit.bounciness;
//                        highTwistLimit.spring = this.stickProperties.characterProperties.highTwistLimit.spring;
//                        highTwistLimit.damper = this.stickProperties.characterProperties.highTwistLimit.damper;
                    newConnectedObject.characterJoint.highTwistLimit = highTwistLimit;
                    SoftJointLimit swing1Limit = new SoftJointLimit();
                    swing1Limit.limit      = this.stickProperties.characterProperties.swing1Limit.limit;
                    swing1Limit.bounciness = this.stickProperties.characterProperties.swing1Limit.bounciness;
//                        swing1Limit.spring = this.stickProperties.characterProperties.swing1Limit.spring;
//                        swing1Limit.damper = this.stickProperties.characterProperties.swing1Limit.damper;
                    newConnectedObject.characterJoint.swing1Limit = swing1Limit;
                    SoftJointLimit swing2Limit = new SoftJointLimit();
                    swing2Limit.limit      = this.stickProperties.characterProperties.swing2Limit.limit;
                    swing2Limit.bounciness = this.stickProperties.characterProperties.swing2Limit.bounciness;
//                        swing2Limit.spring = this.stickProperties.characterProperties.swing2Limit.spring;
//                        swing2Limit.damper = this.stickProperties.characterProperties.swing2Limit.damper;
                    newConnectedObject.characterJoint.swing2Limit = swing2Limit;
                    newConnectedObject.characterJoint.breakForce  = this.stickProperties.characterProperties.breakForce;
                    newConnectedObject.characterJoint.breakTorque = this.stickProperties.characterProperties.breakTorque;

                    break;
                }

                //Creates the special effect if setup
                if (specialEffectsProperties.specialEffect != null)
                {
                    CreateAttachedGameObject(newConnectedObject.gameObject);
                }

                //Used for when Recursive Infection is checked
                if (infectionProperties.recursiveInfection)
                {
                    if (newConnectedObject.gameObject.GetComponent <StickyStickStuck>() == null)
                    {
                        StickyStickStuck stickyStickStuck = newConnectedObject.gameObject.AddComponent <StickyStickStuck>();

                        stickyStickStuck.enable = this.enable;

                        stickyStickStuck.stickProperties.stickType          = this.stickProperties.stickType;
                        stickyStickStuck.stickProperties.stickNonRigidbodys = this.stickProperties.stickNonRigidbodys;

                        //Fixed Properties
                        stickyStickStuck.stickProperties.fixedProperties.breakForce  = this.stickProperties.fixedProperties.breakForce;
                        stickyStickStuck.stickProperties.fixedProperties.breakTorque = this.stickProperties.fixedProperties.breakTorque;

                        //Character Properties
                        stickyStickStuck.stickProperties.characterProperties.anchor                    = this.stickProperties.characterProperties.anchor;
                        stickyStickStuck.stickProperties.characterProperties.axis                      = this.stickProperties.characterProperties.axis;
                        stickyStickStuck.stickProperties.characterProperties.swingAxis                 = this.stickProperties.characterProperties.swingAxis;
                        stickyStickStuck.stickProperties.characterProperties.lowTwistLimit.limit       = this.stickProperties.characterProperties.lowTwistLimit.limit;
                        stickyStickStuck.stickProperties.characterProperties.lowTwistLimit.bounciness  = this.stickProperties.characterProperties.lowTwistLimit.bounciness;
                        stickyStickStuck.stickProperties.characterProperties.lowTwistLimit.spring      = this.stickProperties.characterProperties.lowTwistLimit.spring;
                        stickyStickStuck.stickProperties.characterProperties.lowTwistLimit.damper      = this.stickProperties.characterProperties.lowTwistLimit.damper;
                        stickyStickStuck.stickProperties.characterProperties.highTwistLimit.limit      = this.stickProperties.characterProperties.highTwistLimit.limit;
                        stickyStickStuck.stickProperties.characterProperties.highTwistLimit.bounciness = this.stickProperties.characterProperties.highTwistLimit.bounciness;
                        stickyStickStuck.stickProperties.characterProperties.highTwistLimit.spring     = this.stickProperties.characterProperties.highTwistLimit.spring;
                        stickyStickStuck.stickProperties.characterProperties.highTwistLimit.damper     = this.stickProperties.characterProperties.highTwistLimit.damper;
                        stickyStickStuck.stickProperties.characterProperties.swing1Limit.limit         = this.stickProperties.characterProperties.swing1Limit.limit;
                        stickyStickStuck.stickProperties.characterProperties.swing1Limit.bounciness    = this.stickProperties.characterProperties.swing1Limit.bounciness;
                        stickyStickStuck.stickProperties.characterProperties.swing1Limit.spring        = this.stickProperties.characterProperties.swing1Limit.spring;
                        stickyStickStuck.stickProperties.characterProperties.swing1Limit.damper        = this.stickProperties.characterProperties.swing1Limit.damper;
                        stickyStickStuck.stickProperties.characterProperties.swing2Limit.limit         = this.stickProperties.characterProperties.swing2Limit.limit;
                        stickyStickStuck.stickProperties.characterProperties.swing2Limit.bounciness    = this.stickProperties.characterProperties.swing2Limit.bounciness;
                        stickyStickStuck.stickProperties.characterProperties.swing2Limit.spring        = this.stickProperties.characterProperties.swing2Limit.spring;
                        stickyStickStuck.stickProperties.characterProperties.swing2Limit.damper        = this.stickProperties.characterProperties.swing2Limit.damper;
                        stickyStickStuck.stickProperties.characterProperties.breakForce                = this.stickProperties.characterProperties.breakForce;
                        stickyStickStuck.stickProperties.characterProperties.breakTorque               = this.stickProperties.characterProperties.breakTorque;

                        stickyStickStuck.stickProperties.maxStuck = this.stickProperties.maxStuck;

                        stickyStickStuck.specialEffectsProperties.specialEffect       = this.specialEffectsProperties.specialEffect;
                        stickyStickStuck.specialEffectsProperties.AffectNonRigidbodys = this.specialEffectsProperties.AffectNonRigidbodys;

                        stickyStickStuck.infectionProperties.recursiveInfection = this.infectionProperties.recursiveInfection;
                        stickyStickStuck.infectionProperties.affectInfected     = this.infectionProperties.affectInfected;

                        stickyStickStuck.taggingProperties.useTagging     = this.taggingProperties.useTagging;
                        stickyStickStuck.taggingProperties.TagNameOnStick = this.taggingProperties.TagNameOnStick;

                        //Sets the children isInfectParent to false
                        stickyStickStuck.isInfectParent = false;
                    }
                }

                if (taggingProperties.useTagging)
                {
                    taggingProperties.BackupTag       = newConnectedObject.gameObject.tag;
                    newConnectedObject.gameObject.tag = taggingProperties.TagNameOnStick;
                }

                connectedObjectDataList.Add(newConnectedObject);
            }
        }
コード例 #5
0
        //Draws the GUI
        void OnGUI()
        {
            float i        = 0;
            float spacerXY = 25.0f;

            GUIStyle labelGUIStyle = new GUIStyle();

            labelGUIStyle.normal.textColor = Color.white;
            labelGUIStyle.alignment        = TextAnchor.MiddleLeft;

            GUI.Label(new Rect(guiLocation.x, guiLocation.y + ((spacerXY) * i++), 50, 20), stickyTypeLable, labelGUIStyle);
            toggleFixed            = GUI.Button(new Rect((guiLocation.x), guiLocation.y + ((spacerXY) * i), 70, 20), "Fixed");
            toggleCharacter        = GUI.Button(new Rect((guiLocation.x + 75f), guiLocation.y + ((spacerXY) * i++), 70, 20), "Character");
            toggleEnable           = GUI.Toggle(new Rect(guiLocation.x, guiLocation.y + ((spacerXY) * i++), 300, 20), toggleEnable, "Enable");
            toggleIsTrigger        = GUI.Toggle(new Rect(guiLocation.x, guiLocation.y + ((spacerXY) * i++), 300, 20), toggleIsTrigger, "Is Trigger on Collision");
            toggleAllowStickyBreak = GUI.Toggle(new Rect(guiLocation.x, guiLocation.y + ((spacerXY) * i++), 300, 20), toggleAllowStickyBreak, "Allow Sticky Break");
            specialEffectProperties.toggleSpecialEffect = GUI.Toggle(new Rect(guiLocation.x, guiLocation.y + ((spacerXY) * i++), 300, 20), specialEffectProperties.toggleSpecialEffect, "Special Effect");
            toggleRecursiveInfection = GUI.Toggle(new Rect(guiLocation.x, guiLocation.y + ((spacerXY) * i++), 300, 20), toggleRecursiveInfection, "Recursive Infection");
            toggleAffectInfected     = GUI.Toggle(new Rect(guiLocation.x, guiLocation.y + ((spacerXY) * i++), 300, 20), toggleAffectInfected, "Affect Infected");

            if (toggleRecursiveInfection)
            {
                toggleStickNonRigidbodys = false;
                GUI.Label(new Rect(guiLocation.x + 15f, guiLocation.y + ((spacerXY) * i++), 300, 20), "Stick NonRigidbodys is Dissabled for Recursive Infection");
            }
            else
            {
                toggleStickNonRigidbodys = GUI.Toggle(new Rect(guiLocation.x, guiLocation.y + ((spacerXY) * i++), 300, 20), toggleStickNonRigidbodys, "Stick NonRigidbodys");
            }

            GUI.Label(new Rect(guiLocation.x, guiLocation.y + ((spacerXY) * i), 300, 20), "Max Stuck: " + Mathf.Round(hMaxSticked).ToString(), labelGUIStyle);
            hMaxSticked = GUI.HorizontalSlider(new Rect(guiLocation.x + 100f, guiLocation.y + ((spacerXY + .5f) * i++), 123, 20), hMaxSticked, maxStickedProperties.min, maxStickedProperties.max);

            GUI.Label(new Rect(guiLocation.x, guiLocation.y + ((spacerXY) * i), 300, 20), "Time Scale: ", labelGUIStyle);
            hSceneTimeScale = GUI.HorizontalSlider(new Rect(guiLocation.x + 100f, guiLocation.y + ((spacerXY + .5f) * i++), 123, 20), hSceneTimeScale, sceneTimeScale.min, sceneTimeScale.max);

            if (GUI.Button(new Rect(guiLocation.x + 160f, guiLocation.y + ((spacerXY) * i++), 63, 20), "Reset"))
            {
                Application.LoadLevel(Application.loadedLevelName);

                hSceneTimeScale = 1f;
            }

            try
            {
                StickyStickStuck stickyStickStuck = stickyStickStuckGameObject.GetComponent <StickyStickStuck>();

                stickyStickStuck.enable = toggleEnable;
                stickyStickStuck.onColliderStickProperties.isTrigger = toggleIsTrigger;

                if (toggleAllowStickyBreak)
                {
                    stickyStickStuck.stickProperties.fixedProperties.breakForce      = breakProperties.defaultBreakForce;
                    stickyStickStuck.stickProperties.fixedProperties.breakTorque     = breakProperties.defaultBreakTorque;
                    stickyStickStuck.stickProperties.characterProperties.breakForce  = breakProperties.defaultBreakForce;
                    stickyStickStuck.stickProperties.characterProperties.breakTorque = breakProperties.defaultBreakTorque;
                }
                else
                {
                    stickyStickStuck.stickProperties.fixedProperties.breakForce      = Mathf.Infinity;
                    stickyStickStuck.stickProperties.fixedProperties.breakTorque     = Mathf.Infinity;
                    stickyStickStuck.stickProperties.characterProperties.breakForce  = Mathf.Infinity;
                    stickyStickStuck.stickProperties.characterProperties.breakTorque = Mathf.Infinity;
                }

                if (specialEffectProperties.toggleSpecialEffect)
                {
                    if (specialEffectProperties.defaultSpecialEffectGameObject != null)
                    {
                        stickyStickStuck.specialEffectsProperties.specialEffect = specialEffectProperties.defaultSpecialEffectGameObject;
                    }
                }
                else
                {
                    stickyStickStuck.specialEffectsProperties.specialEffect = null;
                }

                if (toggleFixed)
                {
                    stickyStickStuck.stickProperties.stickType = StickyStickStuck.StickProperties.StickType.Fixed;
                    toggleFixed = false;
                }
                if (toggleCharacter)
                {
                    stickyStickStuck.stickProperties.stickType = StickyStickStuck.StickProperties.StickType.Character;
                    toggleCharacter = false;
                }

                stickyTypeLable = "Sticky Type: " + stickyStickStuck.stickProperties.stickType.ToString();
                stickyStickStuck.infectionProperties.recursiveInfection = toggleRecursiveInfection;
                stickyStickStuck.stickProperties.stickNonRigidbodys     = !toggleRecursiveInfection;
                stickyStickStuck.infectionProperties.affectInfected     = toggleAffectInfected;
                stickyStickStuck.stickProperties.stickNonRigidbodys     = toggleStickNonRigidbodys;
                stickyStickStuck.stickProperties.maxStuck = Mathf.Round(hMaxSticked);

                Time.timeScale = hSceneTimeScale;
            }
            catch (System.Exception)
            {
                Debug.LogWarning("Error reading StickyStickStuck GameObject");
            }
        }