Ejemplo n.º 1
0
    void TakeOutObject()
    {
        if (!isHoldingObject)
        {
            instantiatedPrefab = Instantiate(linkedPrefab) as GameObject;
            interactionObject  = instantiatedPrefab.GetComponentInChildren <SimpleInteractionObject>();

            if (isLeftHand)
            {
                character.HoldObject(interactionObject.gameObject, Hand.Left);
                SetHoldPositionRotation(interactionObject.gameObject.transform, interactionObject.leftHoldPosition);
            }
            if (isRightHand)
            {
                character.HoldObject(interactionObject.gameObject, Hand.Right);
                SetHoldPositionRotation(interactionObject.gameObject.transform, interactionObject.rightHoldPosition);
            }

            isHoldingObject = true;
            PlaySFXSound(inventoryClipToPlay);
        }
        else
        {
            Debug.Log("You can't take out another object until you drop the one you're holding.");
        }
    }
        override public void AssignValues(List <ActionParameter> parameters)
        {
            interactionObject    = AssignFile <SimpleInteractionObject>(parameters, objectParameterID, objectConstantID, interactionObject);
            interactionCharacter = AssignFile <Char>(parameters, intCharParameterID, intCharConstantID, interactionCharacter);

            if (isPlayer)
            {
                interactionCharacter = KickStarter.player;
            }
        }
        override public void AssignValues(List <ActionParameter> parameters)
        {
            intObject       = AssignFile <SimpleInteractionObject>(parameters, objParameterID, objConstantID, intObject);
            objectPrefab    = AssignFile(parameters, prefabParameterID, prefabConstantID, objectPrefab);
            rightHoldPosRot = AssignFile(parameters, rHoldParameterID, rHoldConstantID, rightHoldPosRot);
            leftHoldPosRot  = AssignFile(parameters, lHoldParameterID, lHoldConstantID, leftHoldPosRot);
            invID           = AssignInvItemID(parameters, parameterID, invID);

            if (!isPlayer)
            {
                interactionController = AssignFile <SimpleInteractionSystem>(parameters, controlParameterID, controlConstantID, interactionController);
            }
        }
Ejemplo n.º 4
0
 public void ClearData()
 {
     this.interactionObject     = null;
     this.linkedPrefab          = null;
     this.sceneParent           = null;
     this.objectBeingHeld       = null;
     this.noHandIK              = true;
     this.isRightHand           = false;
     this.isLeftHand            = false;
     this.isBothHands           = false;
     this.inventoryClipToPlay   = null;
     this.holdClipToPlay        = null;
     this.dropClipToPlay        = null;
     this.interactionClipToPlay = null;
 }
        public void PopulateValues(SimpleInteractionSystem simpleIntSystem)
        {
            GameObject selectedParentItem = AC.KickStarter.inventoryManager.GetItem(invID).linkedPrefab;

            simpleIntSystem.linkedPrefab = selectedParentItem;

            SimpleInteractionObject intObject = selectedParentItem.GetComponentInChildren <SimpleInteractionObject>();

            simpleIntSystem.interactionObject = intObject;

            //The left hand hold position is the only one we need here
            simpleIntSystem.leftHoldPosition = intObject.leftHoldPosition;

            //The right hand hold position can be set to null
            simpleIntSystem.rightHoldPosition = null;

            //The drop position
            simpleIntSystem.dropMarker = intObject.dropPosition;

            //The sounds if effects will be used
            if (intObject.holdSound != null)
            {
                simpleIntSystem.holdSound = intObject.holdSound;
            }
            if (intObject.dropSound != null)
            {
                simpleIntSystem.dropSound = intObject.dropSound;
            }
            if (intObject.interactionSound != null)
            {
                simpleIntSystem.interactionSound = intObject.interactionSound;
            }

            if (intObject.inventorySound != null)
            {
                simpleIntSystem.inventorySound = intObject.inventorySound;
            }

            InteractionAnimation();
        }
Ejemplo n.º 6
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            isPlayer = EditorGUILayout.Toggle("Is Player?", isPlayer);

            if (!isPlayer)
            {
                intCharParameterID = Action.ChooseParameterGUI("Character:", parameters, intCharParameterID, ParameterType.GameObject);
                if (intCharParameterID >= 0)
                {
                    intCharConstantID    = 0;
                    interactionCharacter = null;
                }
                else
                {
                    interactionCharacter = (Char)EditorGUILayout.ObjectField("Character:", interactionCharacter, typeof(Char), true);

                    intCharConstantID    = FieldToID(interactionCharacter, intCharConstantID);
                    interactionCharacter = IDToField(interactionCharacter, intCharConstantID, false);
                }
            }
            else
            {
                interactionCharacter = AC.KickStarter.player;
            }

            handsUsed = (HandsUsed)EditorGUILayout.EnumPopup("Which hand(s) to use", handsUsed);

            objectParameterID = Action.ChooseParameterGUI("Interaction Object:", parameters, objectParameterID, ParameterType.GameObject);
            if (objectParameterID >= 0)
            {
                objectConstantID  = 0;
                interactionObject = null;
            }
            else
            {
                interactionObject = (SimpleInteractionObject)EditorGUILayout.ObjectField("Interaction Object:", interactionObject, typeof(SimpleInteractionObject), true);

                objectConstantID  = FieldToID(interactionObject, objectConstantID);
                interactionObject = IDToField(interactionObject, objectConstantID, false);
            }

            if (interactionCharacter != null)
            {
                animator = interactionCharacter.GetComponent <Animator>();
                //Create a string list for the trigger parameters
                List <string> triggerList = new List <string>();

                int i = 0;

                if (animator.parameterCount > 0)
                {
                    foreach (AnimatorControllerParameter parameter in animator.parameters)
                    {
                        triggerList.Add(parameter.name);

                        //If the trigger has been removed for some reason, make sure the variable is still valid
                        if (parameter.nameHash == animatorID)
                        {
                            animatorNum = i;
                        }

                        i++;
                    }

                    if (animatorNum == -1)
                    {
                        Debug.Log("Previously chosen trigger parameter no longer exists!");
                        animatorNum = 0;
                        animatorID  = 0;
                    }

                    string label = "Trigger:";

                    animatorNum = EditorGUILayout.Popup(label, animatorNum, triggerList.ToArray());
                    animatorID  = animator.parameters[animatorNum].nameHash;
                    trigger     = animator.parameters[animatorNum];
                }
            }


            AfterRunningOption();
        }
    public override void OnInspectorGUI()
    {
        SimpleInteractionObject myTarget = (SimpleInteractionObject)target;

        GUILayout.Space(20);

        EditorGUILayout.LabelField("OBJECT INFORMATION", EditorStyles.boldLabel);

        GUILayout.Space(10);

        myTarget.rightHoldPosition = (Transform)EditorGUILayout.ObjectField("RIGHT HOLD TRANSFORM", myTarget.rightHoldPosition, typeof(Transform), true);

        GUILayout.Space(5);

        myTarget.leftHoldPosition = (Transform)EditorGUILayout.ObjectField("LEFT HOLD TRANSFORM", myTarget.leftHoldPosition, typeof(Transform), true);

        GUILayout.Space(5);

        myTarget.dropPosition = (Marker)EditorGUILayout.ObjectField("DROP MARKER", myTarget.dropPosition, typeof(Marker), true);

        GUILayout.Space(5);

        myTarget.emptyParent = (Transform)EditorGUILayout.ObjectField("EMPTY PARENT", myTarget.emptyParent, typeof(Transform), true);

        GUILayout.Space(5);



        myTarget.rightHandTarget = (Transform)EditorGUILayout.ObjectField("RIGHT HAND TARGET:", myTarget.rightHandTarget, typeof(Transform), true);

        GUILayout.Space(5);

        myTarget.leftHandTarget = (Transform)EditorGUILayout.ObjectField("LEFT HAND TARGET:", myTarget.leftHandTarget, typeof(Transform), true);

        GUILayout.Space(5);

        myTarget.holdSound = (AudioClip)EditorGUILayout.ObjectField("HOLD SOUND:", myTarget.holdSound, typeof(AudioClip), true);

        GUILayout.Space(5);

        myTarget.dropSound = (AudioClip)EditorGUILayout.ObjectField("DROP SOUND:", myTarget.dropSound, typeof(AudioClip), true);

        GUILayout.Space(5);

        myTarget.interactionSound = (AudioClip)EditorGUILayout.ObjectField("INTERACTION SOUND:", myTarget.interactionSound, typeof(AudioClip), true);

        GUILayout.Space(15);

        myTarget.inventorySound = (AudioClip)EditorGUILayout.ObjectField("INVENTORY SOUND:", myTarget.inventorySound, typeof(AudioClip), true);

        GUILayout.Space(15);

        if (myTarget.inventorySound == null || myTarget.leftHoldPosition == null || myTarget.rightHoldPosition == null || myTarget.dropPosition == null || myTarget.rightHandTarget == null || myTarget.leftHandTarget == null || myTarget.holdSound == null || myTarget.dropSound == null || myTarget.interactionSound == null)
        {
            EditorGUILayout.LabelField("This object is missing the following assignments:", EditorStyles.whiteBoldLabel);
        }

        GUILayout.Space(10);

        if (myTarget.rightHoldPosition == null)
        {
            EditorGUILayout.LabelField("There is no right hold transform defined.", EditorStyles.helpBox);
        }

        if (myTarget.leftHoldPosition == null)
        {
            EditorGUILayout.LabelField("There is no left hold transform defined.", EditorStyles.helpBox);
        }

        if (myTarget.emptyParent == null)
        {
            EditorGUILayout.LabelField("There is no parent transform defined.", EditorStyles.helpBox);
        }

        if (myTarget.dropPosition == null)
        {
            EditorGUILayout.LabelField("There is no drop marker defined.", EditorStyles.helpBox);
        }

        if (myTarget.rightHandTarget == null)
        {
            EditorGUILayout.LabelField("There is no right hand target defined.", EditorStyles.helpBox);
        }

        if (myTarget.leftHandTarget == null)
        {
            EditorGUILayout.LabelField("There is no left hand target defined.", EditorStyles.helpBox);
        }

        if (myTarget.holdSound == null)
        {
            EditorGUILayout.LabelField("There is no audio clip assigned for 'HOLD'.", EditorStyles.helpBox);
        }

        if (myTarget.dropSound == null)
        {
            EditorGUILayout.LabelField("There is no audio clip assigned for 'DROP'.", EditorStyles.helpBox);
        }

        if (myTarget.interactionSound == null)
        {
            EditorGUILayout.LabelField("There is no audio clip assigned for interaction.", EditorStyles.helpBox);
        }

        if (myTarget.inventorySound == null)
        {
            EditorGUILayout.LabelField("There is no audio clip assigned for inventory.", EditorStyles.helpBox);
        }
    }
        public void PopulateValues(SimpleInteractionSystem simpleIntSystem)
        {
            //The object data
            if (objectType == ObjectType.SceneObject)
            {
                simpleIntSystem.interactionObject = interactionObject;

                //The target data
                simpleIntSystem.emptyParent = interactionObject.emptyParent;

                //The drop position
                simpleIntSystem.dropMarker = interactionObject.dropPosition;

                //The hands and target data used
                if (handsUsed == HandsUsed.Both)
                {
                    simpleIntSystem.handsUsed       = SimpleInteractionSystem.HandsUsed.BothHands;
                    simpleIntSystem.rightHandTarget = interactionObject.rightHandTarget;
                    simpleIntSystem.leftHandTarget  = interactionObject.leftHandTarget;

                    //The right hand hold position
                    simpleIntSystem.rightHoldPosition = interactionObject.rightHoldPosition;
                    //The left hand hold position
                    simpleIntSystem.leftHoldPosition = interactionObject.leftHoldPosition;
                }
                else if (handsUsed == HandsUsed.Right)
                {
                    simpleIntSystem.handsUsed       = SimpleInteractionSystem.HandsUsed.RightHand;
                    simpleIntSystem.rightHandTarget = interactionObject.rightHandTarget;
                    simpleIntSystem.leftHandTarget  = null;

                    //The right hand hold position
                    simpleIntSystem.rightHoldPosition = interactionObject.rightHoldPosition;
                    //The left hand hold position can be set to null
                    simpleIntSystem.leftHoldPosition = null;
                }
                else if (handsUsed == HandsUsed.Left)
                {
                    simpleIntSystem.handsUsed       = SimpleInteractionSystem.HandsUsed.LeftHand;
                    simpleIntSystem.leftHandTarget  = interactionObject.leftHandTarget;
                    simpleIntSystem.rightHandTarget = null;

                    //The right hand hold position can be set to null
                    simpleIntSystem.rightHoldPosition = null;
                    //The left hand hold position
                    simpleIntSystem.leftHoldPosition = interactionObject.leftHoldPosition;
                }

                //The sounds if effects will be used
                if (interactionObject.holdSound != null)
                {
                    simpleIntSystem.holdSound = interactionObject.holdSound;
                }
                if (interactionObject.dropSound != null)
                {
                    simpleIntSystem.dropSound = interactionObject.dropSound;
                }
                if (interactionObject.interactionSound != null)
                {
                    simpleIntSystem.interactionSound = interactionObject.interactionSound;
                }
            }
            else
            {
                GameObject selectedItem = AC.KickStarter.inventoryManager.GetItem(invID).linkedPrefab;
                simpleIntSystem.linkedPrefab = selectedItem;

                SimpleInteractionObject selectedIntItem = selectedItem.GetComponent <SimpleInteractionObject>();

                simpleIntSystem.interactionObject = selectedIntItem;

                //The drop position
                simpleIntSystem.dropMarker = selectedIntItem.dropPosition;

                //The hands and target data used
                if (handsUsed == HandsUsed.Both)
                {
                    simpleIntSystem.handsUsed       = SimpleInteractionSystem.HandsUsed.BothHands;
                    simpleIntSystem.rightHandTarget = interactionObject.rightHandTarget;
                    simpleIntSystem.leftHandTarget  = interactionObject.leftHandTarget;

                    //The right hand hold position
                    simpleIntSystem.rightHoldPosition = interactionObject.rightHoldPosition;
                    //The left hand hold position
                    simpleIntSystem.leftHoldPosition = interactionObject.leftHoldPosition;
                }
                else if (handsUsed == HandsUsed.Right)
                {
                    simpleIntSystem.handsUsed       = SimpleInteractionSystem.HandsUsed.RightHand;
                    simpleIntSystem.rightHandTarget = interactionObject.rightHandTarget;
                    simpleIntSystem.leftHandTarget  = null;

                    //The right hand hold position
                    simpleIntSystem.rightHoldPosition = interactionObject.rightHoldPosition;
                    //The left hand hold position can be set to null
                    simpleIntSystem.leftHoldPosition = null;
                }
                else if (handsUsed == HandsUsed.Left)
                {
                    simpleIntSystem.handsUsed       = SimpleInteractionSystem.HandsUsed.LeftHand;
                    simpleIntSystem.leftHandTarget  = interactionObject.leftHandTarget;
                    simpleIntSystem.rightHandTarget = null;

                    //The right hand hold position can be set to null
                    simpleIntSystem.rightHoldPosition = null;
                    //The left hand hold position
                    simpleIntSystem.leftHoldPosition = interactionObject.leftHoldPosition;
                }

                //The sounds if effects will be used
                if (selectedIntItem.holdSound != null)
                {
                    simpleIntSystem.holdSound = selectedIntItem.holdSound;
                }
                if (selectedIntItem.dropSound != null)
                {
                    simpleIntSystem.dropSound = selectedIntItem.dropSound;
                }
                if (selectedIntItem.interactionSound != null)
                {
                    simpleIntSystem.interactionSound = selectedIntItem.interactionSound;
                }
            }
        }
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            isPlayer = EditorGUILayout.Toggle("Is Player?", isPlayer);

            if (!isPlayer)
            {
                intCharParameterID = Action.ChooseParameterGUI("Character:", parameters, intCharParameterID, ParameterType.GameObject);
                if (intCharParameterID >= 0)
                {
                    intCharConstantID    = 0;
                    interactionCharacter = null;
                }
                else
                {
                    interactionCharacter = (Char)EditorGUILayout.ObjectField("Character:", interactionCharacter, typeof(Char), true);

                    intCharConstantID    = FieldToID(interactionCharacter, intCharConstantID);
                    interactionCharacter = IDToField(interactionCharacter, intCharConstantID, false);
                }
            }

            handsUsed = (HandsUsed)EditorGUILayout.EnumPopup("Which hand(s) to send to interaction", handsUsed);

            objectType = (ObjectType)EditorGUILayout.EnumPopup("Object Type:", objectType);

            if (objectType == ObjectType.SceneObject)
            {
                objectParameterID = Action.ChooseParameterGUI("Interaction Object:", parameters, objectParameterID, ParameterType.GameObject);
                if (objectParameterID >= 0)
                {
                    objectConstantID  = 0;
                    interactionObject = null;
                }
                else
                {
                    interactionObject = (SimpleInteractionObject)EditorGUILayout.ObjectField("Interaction Object:", interactionObject, typeof(SimpleInteractionObject), true);

                    objectConstantID  = FieldToID(interactionObject, objectConstantID);
                    interactionObject = IDToField(interactionObject, objectConstantID, false);
                }
            }
            else if (objectType == ObjectType.InventoryObject)
            {
                if (inventoryManager == null && AdvGame.GetReferences().inventoryManager)
                {
                    inventoryManager = AdvGame.GetReferences().inventoryManager;
                }
                if (settingsManager == null && AdvGame.GetReferences().settingsManager)
                {
                    settingsManager = AdvGame.GetReferences().settingsManager;
                }

                if (inventoryManager)
                {
                    // Create a string List of the field's names (for the PopUp box)
                    List <string> labelList = new List <string>();

                    int i = 0;
                    if (parameterID == -1)
                    {
                        invNumber = -1;
                    }

                    if (inventoryManager.items.Count > 0)
                    {
                        foreach (InvItem _item in inventoryManager.items)
                        {
                            labelList.Add(_item.label);

                            // If an item has been removed, make sure selected variable is still valid
                            if (_item.id == invID)
                            {
                                invNumber = i;
                            }

                            i++;
                        }

                        if (invNumber == -1)
                        {
                            // Wasn't found (item was possibly deleted), so revert to zero
                            ACDebug.LogWarning("Previously chosen item no longer exists!");

                            invNumber = 0;
                            invID     = 0;
                        }

                        //
                        parameterID = Action.ChooseParameterGUI("Inventory item:", parameters, parameterID, ParameterType.InventoryItem);
                        if (parameterID >= 0)
                        {
                            invNumber = Mathf.Min(invNumber, inventoryManager.items.Count - 1);
                            invID     = -1;
                        }
                        else
                        {
                            invNumber = EditorGUILayout.Popup("Inventory item:", invNumber, labelList.ToArray());
                            invID     = inventoryManager.items[invNumber].id;
                        }
                        //
                    }
                }
            }

            AfterRunningOption();
        }
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            //Is this the player?
            isPlayer = EditorGUILayout.Toggle("Is Player?", isPlayer);
            if (!isPlayer)
            {
                controlParameterID = Action.ChooseParameterGUI("Character:", parameters, controlParameterID, ParameterType.GameObject);
                if (controlParameterID >= 0)
                {
                    controlConstantID     = 0;
                    interactionController = null;
                }
                else
                {
                    interactionController = (SimpleInteractionSystem)EditorGUILayout.ObjectField("Character:", interactionController, typeof(SimpleInteractionSystem), true);

                    controlConstantID     = FieldToID(interactionController, controlConstantID);
                    interactionController = IDToField(interactionController, controlConstantID, false);
                }
            }

            rightHandTarget = (Transform)EditorGUILayout.ObjectField("Right Hand Target:", rightHandTarget, typeof(Transform), true);
            leftHandTarget  = (Transform)EditorGUILayout.ObjectField("Left Hand Target:", leftHandTarget, typeof(Transform), true);

            //What kind of interaction is going to happen?
            interactionType = (InteractionType)EditorGUILayout.EnumPopup("Interaction Type:", interactionType);

            //If you're going to be picking up the item, send the item to the interaction controller
            if (interactionType == InteractionType.PickUp || interactionType == InteractionType.Use)
            {
                objParameterID = Action.ChooseParameterGUI("Object to Pick Up:", parameters, objParameterID, ParameterType.GameObject);
                if (objParameterID >= 0)
                {
                    objConstantID = 0;
                    intObject     = null;
                }
                else
                {
                    intObject = (SimpleInteractionObject)EditorGUILayout.ObjectField("Object to Pick Up:", intObject, typeof(SimpleInteractionObject), true);

                    objConstantID = FieldToID(intObject, objConstantID);
                    intObject     = IDToField(intObject, objConstantID, false);
                }
            }
            if (interactionType == InteractionType.PickUp)
            {
                rHoldParameterID = Action.ChooseParameterGUI("Right Hold transform:", parameters, rHoldParameterID, ParameterType.GameObject);
                if (rHoldParameterID >= 0)
                {
                    rHoldConstantID = 0;
                    rightHoldPosRot = null;
                }
                else
                {
                    rightHoldPosRot = (Transform)EditorGUILayout.ObjectField("Right Hold transform:", rightHoldPosRot, typeof(Transform), true);

                    rHoldConstantID = FieldToID(rightHoldPosRot, rHoldConstantID);
                    rightHoldPosRot = IDToField(rightHoldPosRot, rHoldConstantID, false);
                }

                lHoldParameterID = Action.ChooseParameterGUI("Left Hold transform:", parameters, lHoldParameterID, ParameterType.GameObject);
                if (lHoldParameterID >= 0)
                {
                    lHoldConstantID = 0;
                    leftHoldPosRot  = null;
                }
                else
                {
                    leftHoldPosRot = (Transform)EditorGUILayout.ObjectField("Left Hold transform:", leftHoldPosRot, typeof(Transform), true);

                    lHoldConstantID = FieldToID(leftHoldPosRot, lHoldConstantID);
                    leftHoldPosRot  = IDToField(leftHoldPosRot, lHoldConstantID, false);
                }
            }

            //If you're going to drop the item, send the place you want to drop it to the interaction controller
            else if (interactionType == InteractionType.Drop)
            {
                markerParameterID = Action.ChooseParameterGUI("Drop at:", parameters, markerParameterID, ParameterType.GameObject);
                if (markerParameterID >= 0)
                {
                    markerID   = 0;
                    dropMarker = null;
                }
                else
                {
                    dropMarker = (Marker)EditorGUILayout.ObjectField("Drop at:", dropMarker, typeof(Marker), true);

                    markerID   = FieldToID <Marker>(dropMarker, markerID);
                    dropMarker = IDToField <Marker>(dropMarker, markerID, false);
                }
            }

            //If you're going to take out the item, select the item from your inventory
            else if (interactionType == InteractionType.TakeOut)
            {
                if (!inventoryManager)
                {
                    inventoryManager = AdvGame.GetReferences().inventoryManager;
                }
                if (!settingsManager)
                {
                    settingsManager = AdvGame.GetReferences().settingsManager;
                }

                if (inventoryManager)
                {
                    // Create a string List of the field's names (for the PopUp box)
                    List <string> labelList = new List <string>();

                    int i = 0;
                    if (parameterID == -1)
                    {
                        invNumber = -1;
                    }

                    if (inventoryManager.items.Count > 0)
                    {
                        foreach (InvItem _item in inventoryManager.items)
                        {
                            labelList.Add(_item.label);

                            // If an item has been removed, make sure selected variable is still valid
                            if (_item.id == invID)
                            {
                                invNumber = i;
                            }

                            i++;
                        }

                        if (invNumber == -1)
                        {
                            ACDebug.LogWarning("Previously chosen item no longer exists!");
                            invNumber = 0;
                            invID     = 0;
                        }

                        parameterID = Action.ChooseParameterGUI("Inventory item:", parameters, parameterID, ParameterType.InventoryItem);
                        if (parameterID >= 0)
                        {
                            invNumber = Mathf.Min(invNumber, inventoryManager.items.Count - 1);
                            invID     = -1;
                        }
                        else
                        {
                            invNumber = EditorGUILayout.Popup("Inventory item:", invNumber, labelList.ToArray());
                            invID     = inventoryManager.items[invNumber].id;
                        }

                        objectPrefab = AC.KickStarter.runtimeInventory.GetItem(invID).linkedPrefab;
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("No inventory items exist!", MessageType.Info);
                        invID     = -1;
                        invNumber = -1;
                    }
                }
            }
            else if (interactionType == InteractionType.Use)
            {
                EditorGUILayout.HelpBox("This interaction will not be called from an animation event.", MessageType.Info);
            }

            AfterRunningOption();
        }