Example #1
0
    void Awake()
    {
        if (dynamicType == Type_Dynamic.Door)
        {
            if (interactType == Type_Interact.Mouse)
            {
                if (GetComponent <HingeJoint>())
                {
                    Joint = GetComponent <HingeJoint>();
                }
                else
                {
                    Debug.LogError(transform.parent.gameObject.name + " requires Hinge Joint Component!");
                    return;
                }
            }

            if (GetLockStatus())
            {
                if (interactType == Type_Interact.Mouse)
                {
                    GetComponent <Rigidbody>().freezeRotation = true;
                    Joint.useLimits = false;
                }
                isLocked = true;
            }
            else if (useType == Type_Use.Normal)
            {
                if (interactType == Type_Interact.Mouse)
                {
                    GetComponent <Rigidbody>().freezeRotation = false;
                    Joint.useLimits = true;
                }
                isLocked = false;
            }
        }
        else if (dynamicType == Type_Dynamic.Drawer)
        {
            IgnoreColliders.Add(PlayerController.Instance.gameObject.GetComponent <Collider>());
            isLocked = useType != Type_Use.Normal;
        }
        else if (dynamicType == Type_Dynamic.Lever)
        {
            isLocked = false;
        }
        else if (dynamicType == Type_Dynamic.MovableInteract)
        {
            useType      = Type_Use.Normal;
            interactType = Type_Interact.Mouse;
            isLocked     = false;
        }

        if (IgnoreColliders.Count > 0)
        {
            for (int i = 0; i < IgnoreColliders.Count; i++)
            {
                Physics.IgnoreCollision(GetComponent <Collider>(), IgnoreColliders[i]);
            }
        }

        defaultAngle  = transform.eulerAngles.y;
        minCloseAngle = defaultAngle - 10f;
        maxCloseAngle = defaultAngle + 10f;

        inventory = Inventory.Instance;
    }
Example #2
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        EditorGUILayout.PropertyField(sp_dynamicType);
        Type_Dynamic  dynamic  = (Type_Dynamic)sp_dynamicType.enumValueIndex;
        Type_Use      useType  = (Type_Use)sp_useType.enumValueIndex;
        Type_Interact int_type = (Type_Interact)sp_interactType.enumValueIndex;
        Type_Key      keyType  = (Type_Key)sp_keyType.enumValueIndex;

        switch (dynamic)
        {
        case Type_Dynamic.Door:
            EditorGUILayout.PropertyField(sp_useType, new GUIContent("Use Type"));
            EditorGUILayout.PropertyField(sp_interactType, new GUIContent("Interact Type"));

            if (useType == Type_Use.Locked)
            {
                EditorGUILayout.PropertyField(sp_keyType, new GUIContent("Key Type"));

                if (keyType == Type_Key.Inventory)
                {
                    EditorGUILayout.PropertyField(sp_keyID, new GUIContent("Inventory KeyID:"));
                }
            }

            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(sp_IgnoreColliders, new GUIContent("Ignore Colliders"), true);
            EditorGUILayout.PropertyField(sp_customText, new GUIContent("Custom Locked Text"));

            if (useType == Type_Use.Jammed)
            {
                EditorGUILayout.Space();
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Jammed Door Planks", EditorStyles.boldLabel);
                EditorGUILayout.PropertyField(sp_useJammedPlanks, new GUIContent("Use Planks"));
                EditorGUILayout.PropertyField(sp_Planks, new GUIContent("Planks"), true);
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Animation", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(sp_Animation, new GUIContent("Animation Object"));

            if (int_type == Type_Interact.Animation)
            {
                EditorGUILayout.PropertyField(sp_useAnim, new GUIContent("Open Anim"));
                EditorGUILayout.PropertyField(sp_backUseAnim, new GUIContent("Close Anim"));
            }

            EditorGUILayout.PropertyField(sp_knobAnim, new GUIContent("Knob Animation"));

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Door Properties", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(sp_Open, new GUIContent("Open Sound"));
            EditorGUILayout.PropertyField(sp_Close, new GUIContent("Close Sound"));
            EditorGUILayout.PropertyField(sp_UnlockSound, new GUIContent("Unlock Sound"));
            EditorGUILayout.PropertyField(sp_LockedTry, new GUIContent("Locked Try Sound"));
            EditorGUILayout.PropertyField(sp_Volume, new GUIContent("Sound Volume"));

            if (int_type == Type_Interact.Mouse)
            {
                EditorGUILayout.Space();
                EditorGUILayout.PropertyField(sp_useSR, new GUIContent("Use Start Rotation"));
                if (sp_useSR.boolValue)
                {
                    EditorGUILayout.PropertyField(sp_startRot, new GUIContent("Starting Rotation"));
                }

                EditorGUILayout.PropertyField(sp_DebugAngle, new GUIContent("Debug Door Angle"));
            }
            break;

        case Type_Dynamic.Drawer:
            EditorGUILayout.PropertyField(sp_useType, new GUIContent("Use Type"));
            EditorGUILayout.PropertyField(sp_interactType, new GUIContent("Interact Type"));

            if (useType == Type_Use.Locked)
            {
                EditorGUILayout.PropertyField(sp_keyType, new GUIContent("Key Type"));

                if (keyType == Type_Key.Inventory)
                {
                    EditorGUILayout.PropertyField(sp_keyID, new GUIContent("Inventory KeyID:"));
                }
            }

            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(sp_IgnoreColliders, new GUIContent("Ignore Colliders"), true);
            EditorGUILayout.PropertyField(sp_customText, new GUIContent("Custom Locked Text"));

            if (int_type == Type_Interact.Animation)
            {
                EditorGUILayout.Space();
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Animation", EditorStyles.boldLabel);
                EditorGUILayout.PropertyField(sp_Animation, new GUIContent("Animation Object"));
                EditorGUILayout.PropertyField(sp_useAnim, new GUIContent("Open Anim"));
                EditorGUILayout.PropertyField(sp_backUseAnim, new GUIContent("Close Anim"));
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Drawer Properties", EditorStyles.boldLabel);

            if (int_type == Type_Interact.Mouse)
            {
                EditorGUILayout.PropertyField(sp_minMaxMove, new GUIContent("Min Max Move"));
                EditorGUILayout.PropertyField(sp_moveWithX, new GUIContent("Move With X"));
                EditorGUILayout.PropertyField(sp_reverseMove, new GUIContent("Reverse Move"));
                EditorGUILayout.PropertyField(sp_UnlockSound, new GUIContent("Unlock Sound"));
                EditorGUILayout.PropertyField(sp_LockedTry, new GUIContent("Locked Try Sound"));
            }
            else
            {
                EditorGUILayout.PropertyField(sp_Open, new GUIContent("Open Sound"));
                EditorGUILayout.PropertyField(sp_Close, new GUIContent("Close Sound"));
                EditorGUILayout.PropertyField(sp_UnlockSound, new GUIContent("Unlock Sound"));
                EditorGUILayout.PropertyField(sp_LockedTry, new GUIContent("Locked Try Sound"));
            }
            EditorGUILayout.PropertyField(sp_Volume, new GUIContent("Sound Volume"));
            break;

        case Type_Dynamic.Lever:
            EditorGUILayout.PropertyField(sp_interactType, new GUIContent("Interact Type"));
            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(sp_IgnoreColliders, new GUIContent("Ignore Colliders"), true);

            if (int_type == Type_Interact.Animation)
            {
                EditorGUILayout.Space();
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Animation", EditorStyles.boldLabel);
                EditorGUILayout.PropertyField(sp_Animation, new GUIContent("Animation Object"));
                EditorGUILayout.PropertyField(sp_useAnim, new GUIContent("SwitchUp Anim"));
                EditorGUILayout.PropertyField(sp_backUseAnim, new GUIContent("SwitchDown Anim"));
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Lever Properties", EditorStyles.boldLabel);

            EditorGUILayout.PropertyField(sp_InteractEvent, new GUIContent("Interact Event"));
            EditorGUILayout.PropertyField(sp_DisabledEvent, new GUIContent("Disabled Event"));
            EditorGUILayout.PropertyField(sp_LeverUpSound, new GUIContent("Lever Up Sound"));
            EditorGUILayout.PropertyField(sp_lockOnUp, new GUIContent("Up Lock"));
            EditorGUILayout.PropertyField(sp_reverseMove, new GUIContent("Reverse Rotation"));
            if (int_type == Type_Interact.Mouse)
            {
                EditorGUILayout.PropertyField(sp_stopAngle, new GUIContent("Lever Stop Angle"));
                EditorGUILayout.PropertyField(sp_DebugAngle, new GUIContent("Debug Lever Angle"));
            }
            EditorGUILayout.PropertyField(sp_Volume, new GUIContent("Sound Volume"));
            break;

        case Type_Dynamic.Valve:
            EditorGUILayout.PropertyField(sp_IgnoreColliders, new GUIContent("Ignore Colliders"), true);
            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(sp_InteractEvent, new GUIContent("Interact Event"));

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Valve Properties", EditorStyles.boldLabel);

            EditorGUILayout.PropertyField(sp_valveTurnSounds, new GUIContent("Turn Sounds"), true);
            EditorGUILayout.PropertyField(sp_Volume, new GUIContent("Turn Volume"));
            EditorGUILayout.PropertyField(sp_valveSoundAfter, new GUIContent("Turn Sound After"));
            EditorGUILayout.PropertyField(sp_valveTurnSpeed, new GUIContent("Turn Speed"));
            EditorGUILayout.PropertyField(sp_valveTurnTime, new GUIContent("Turn Time"));
            break;

        case Type_Dynamic.MovableInteract:
            EditorGUILayout.PropertyField(sp_IgnoreColliders, new GUIContent("Ignore Colliders"), true);
            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(sp_InteractEvent, new GUIContent("Interact Event"));

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Movable Interact Properties", EditorStyles.boldLabel);

            EditorGUILayout.PropertyField(sp_minMaxMove, new GUIContent("Min Max Move"));
            EditorGUILayout.PropertyField(sp_InteractPos, new GUIContent("Interact Position"));
            EditorGUILayout.PropertyField(sp_moveWithX, new GUIContent("Move With X"));
            EditorGUILayout.PropertyField(sp_reverseMove, new GUIContent("Reverse Move"));
            break;
        }

        serializedObject.ApplyModifiedProperties();
    }