public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        SwitchToggler myScript = (SwitchToggler)target;

        if (GUILayout.Button("Add Path"))
        {
            if (myScript.Paths.Count < myScript.LinkedObjects.Length)
            {
                myScript.AddPath();
            }
        }
        //SwitchToggler myScript = (SwitchToggler)target;
        //myScript.Type = (Assets.CustomScripts.SwitchType)EditorGUILayout.EnumPopup("Type", (System.Enum)myScript.Type);
        //switch(myScript.Type)
        //{
        //	case SwitchType.Toggle:
        //		ToggleSelected();
        //		break;
        //	case SwitchType.Timed:
        //		TimedSelected();
        //		break;
        //	case SwitchType.Pressure:
        //		PressureSelected();
        //		break;
        //	default:
        //		Debug.Log("Error: Switch CustomEditor has more selected than needed");
        //		break;
        //}
    }
Exemple #2
0
    //Handles making adjusting the colors of the path as needed
    private void UpdateColors()
    {
        SwitchToggler origin = transform.parent.GetComponent <SwitchToggler>();

        if (!bIsTimed)                                          //If the door relies on a timer
        {
            if (origin.IsActive)
            {
                startColor = filledColor;
                endColor   = filledColor;
            }
            else
            {
                startColor = drainedColor;
                endColor   = drainedColor;
            }
        }
        else
        {
            if (bTimerRunning)                          //While the door timer is counting down, slowly bleed out the colors
            {
                mTimeRemaining = origin.GetTimeRemaining();
                startColor     = drainedColor;
                endColor       = filledColor;
                BlendColors(ref startColor, ref endColor, mTimeRemaining);
            }
            else
            {
                if (origin.IsActive)
                {
                    startColor = filledColor;
                    endColor   = filledColor;
                }
                else
                {
                    startColor = drainedColor;
                    endColor   = drainedColor;
                }
            }
        }

        theLine.SetColors(startColor, endColor);
    }
    public override bool Activate(Collider other, GameObject flippedSwitch)
    {
        bool          active    = false;
        SwitchToggler theSwitch = flippedSwitch.GetComponent <SwitchToggler>();

        if (theSwitch.IsActive)
        {
            ActiveSwitches++;
        }
        else
        {
            ActiveSwitches--;
        }
        active = theSwitch.IsActive;

        //After modifying it see if the door still needs to be opened
        if (ActiveSwitches - NeededSwitches == 0)
        {
            //open the door on a timer if timedSwitch is true
            if (theSwitch != null &&
                theSwitch.timedSwitch)
            {
                //OpenDoor(theSwitch.TimerLength);

                //open = true;
                if (mWaitforDoor)
                {
                    Invoke("DoorTimer", mWaitTimer);
                }
                else
                {
                    open = true;
                }
                toggleOpen = false;
            }
            //toggle the door if timedSwitch is false
            else if (open == false)
            {
                openedBySwitch = true;
                //open = true;
                if (mWaitforDoor)
                {
                    Invoke("DoorTimer", mWaitTimer);
                }
                else
                {
                    open = true;
                }
                toggleOpen = true;
            }
        }
        else if (ActiveSwitches > NeededSwitches)
        {
            open           = !open;
            openedBySwitch = !openedBySwitch;
            toggleOpen     = !toggleOpen;
        }
        else
        {
            if (open == true && !leaveOpen)
            {
                openedBySwitch = false;
                open           = false;
                toggleOpen     = false;
            }
        }
        base.Activate(other, flippedSwitch);
        return(active);
    }