override public float Run() { interactionSystem = interactionCharacter.GetComponent <SimpleInteractionSystem>(); if (interactionSystem != null) { if (interactionSystem.objectBeingHeld) { if (interactionSystem.handsUsed == SimpleInteractionSystem.HandsUsed.LeftHand) { interactionCharacter.GetComponent <Animator>().SetTrigger("PutAwayLeft"); interactionSystem.ClearData(); } if (interactionSystem.handsUsed == SimpleInteractionSystem.HandsUsed.RightHand) { interactionCharacter.GetComponent <Animator>().SetTrigger("PutAwayRight"); interactionSystem.ClearData(); } } } else { Debug.Log("There is no interaction system attached to this character."); } return(0f); }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { player = AC.KickStarter.player; ik = player.GetComponent <FullBodyBipedIK>(); interactionSys = player.GetComponent <SimpleInteractionSystem>(); rightHandTarget = player.GetComponent <SimpleInteractionSystem>().rightHandTarget; leftHandTarget = player.GetComponent <SimpleInteractionSystem>().leftHandTarget; }
override public float Run() { if (isPlayer) { interactionController = KickStarter.player.GetComponent <SimpleInteractionSystem>(); if (interactionController == null) { Debug.Log("There is no Object Interaction Control script assigned to this character!"); } } if (interactionType == InteractionType.PickUp || interactionType == InteractionType.Use) { if (interactionController.isHoldingObject == true) { Debug.Log("You need to put down the object you're holding first."); } else { interactionController.interactionObject = intObject; interactionController.rightHoldPosition = rightHoldPosRot; interactionController.leftHoldPosition = leftHoldPosRot; } } else if (interactionType == InteractionType.Drop) { if (interactionController.interactionObject == null || interactionController.isHoldingObject == false) { Debug.Log("You aren't holding anything to drop."); } else { interactionController.dropMarker = dropMarker; } } else if (interactionType == InteractionType.TakeOut) { objectPrefab = AC.KickStarter.runtimeInventory.GetItem(invID).linkedPrefab; if (interactionController.objectBeingHeld == true) { Debug.Log("You are already holding an object."); } else { interactionController.linkedPrefab = objectPrefab; interactionController.rightHoldPosition = rightHoldPosRot; interactionController.leftHoldPosition = leftHoldPosRot; } } return(0f); }
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); } }
override public float Run() { interactionSystem = interactionCharacter.GetComponent <SimpleInteractionSystem>(); if (interactionSystem != null) { //Clear the existing values interactionSystem.ClearData(); //Send the new values PopulateValues(interactionSystem); } else { Debug.Log("There is no interaction system attached to this character."); } return(0f); }
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(); }
public void PopulateValues(SimpleInteractionSystem simpleIntSystem) { trigger = animator.parameters[animatorNum]; //The object to pick up simpleIntSystem.interactionObject = interactionObject; if (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; } if (interactionObject.inventorySound != null) { simpleIntSystem.inventorySound = interactionObject.inventorySound; } InteractionAnimation(trigger.name); }
public override void OnInspectorGUI() { SimpleInteractionSystem myTarget = (SimpleInteractionSystem)target; GUILayout.Space(20); myTarget.isMainCharacter = EditorGUILayout.Toggle("Main Character?", myTarget.isMainCharacter, EditorStyles.radioButton); if (myTarget.isMainCharacter == true) { EditorGUILayout.LabelField("SETTINGS APPLIED FOR MAIN CHARACTER", EditorStyles.whiteMiniLabel); } else { EditorGUILayout.LabelField("SETTINGS APPLIED FOR NPC CHARACTER", EditorStyles.whiteMiniLabel); } GUILayout.Space(10); if (myTarget.objectBeingHeld == true) { EditorGUILayout.ObjectField("You are currently holding:", myTarget.interactionObject, typeof(GameObject), true); } else { EditorGUILayout.LabelField("You are not currently holding anything.", EditorStyles.helpBox); } if (myTarget.toPlay != null) { EditorGUILayout.ObjectField("The interaction sound assigned is:", myTarget.toPlay, typeof(AudioClip), true); } GUILayout.Space(10); if (myTarget.interactionObject == null) { EditorGUILayout.LabelField("THERE IS NO INTERACTION OBJECT SET.", EditorStyles.miniBoldLabel); } else { EditorGUILayout.LabelField("OBJECT INFORMATION", EditorStyles.miniBoldLabel); GUILayout.Space(10); EditorGUILayout.BeginToggleGroup("Hand(s) Used:", handToggleGroupEnabled); myTarget.noHandIK = EditorGUILayout.ToggleLeft("No Hand IK Used", myTarget.noHandIK); myTarget.isRightHand = EditorGUILayout.ToggleLeft("Right Hand", myTarget.isRightHand); myTarget.isLeftHand = EditorGUILayout.ToggleLeft("Left Hand", myTarget.isLeftHand); myTarget.isBothHands = EditorGUILayout.ToggleLeft("Both Hands", myTarget.isBothHands); EditorGUILayout.EndToggleGroup(); } if (myTarget.objectBeingHeld == true) { EditorGUILayout.LabelField("THIS OBJECT IS CURRENTLY BEING HELD.", EditorStyles.helpBox); } if (myTarget.instantiatedPrefab != null) { EditorGUILayout.ObjectField("The instantiated prefab is: ", myTarget.instantiatedPrefab, typeof(GameObject), true); } /*if (myTarget.interactionObject.rightHoldPosition != null) * { * EditorGUILayout.ObjectField("Right Hold Transform:", myTarget.interactionObject.rightHoldPosition, typeof(Transform), true); * } * else * { * EditorGUILayout.LabelField("There is no right hold transform set for this object!", EditorStyles.helpBox); * } * * GUILayout.Space(5); * * if (myTarget.interactionObject.leftHoldPosition != null) * { * EditorGUILayout.ObjectField("Left Hold Transform:", myTarget.interactionObject.leftHoldPosition, typeof(Transform), true); * } * else * { * EditorGUILayout.LabelField("There is no left hold transform set for this object!", EditorStyles.helpBox); * } * * GUILayout.Space(5); * * if (myTarget.interactionObject.emptyParent != null) * { * EditorGUILayout.ObjectField("Parent Transform:", myTarget.interactionObject.emptyParent, typeof(Transform), true); * } * else * { * EditorGUILayout.LabelField("There is no hold transform set for this object!", EditorStyles.helpBox); * } * * GUILayout.Space(5); * * if (myTarget.interactionObject.dropPosition != null) * { * EditorGUILayout.LabelField("Drop Marker:", myTarget.interactionObject.dropPosition.name); * } * else * { * EditorGUILayout.LabelField("There is no drop marker set for this object.", EditorStyles.helpBox); * } * * GUILayout.Space(5); * * if (myTarget.interactionObject.rightHandTarget != null) * { * EditorGUILayout.ObjectField("Right Hand Target:", myTarget.interactionObject.rightHandTarget, typeof(Transform), true); * } * else * { * EditorGUILayout.LabelField("There is no right hand target set for this object.", EditorStyles.helpBox); * } * * GUILayout.Space(5); * * if (myTarget.interactionObject.leftHandTarget != null) * { * EditorGUILayout.ObjectField("Left Hand Target:", myTarget.interactionObject.leftHandTarget, typeof(Transform), true); * } * else * { * EditorGUILayout.LabelField("There is no left hand target set for this object.", EditorStyles.helpBox); * } * * GUILayout.Space(5); * * if (myTarget.linkedPrefab != null) * { * EditorGUILayout.ObjectField("Linked Prefab:", myTarget.linkedPrefab, typeof(GameObject), true); * } * * GUILayout.Space(5); * * if (myTarget.interactionObject.holdSound != null) * { * EditorGUILayout.ObjectField("Hold Sound:", myTarget.interactionObject.holdSound, typeof(AudioClip), true); * } * else * { * EditorGUILayout.LabelField("There is no audio clip assigned for holding.", EditorStyles.helpBox); * } * * GUILayout.Space(5); * * if (myTarget.interactionObject.dropSound != null) * { * EditorGUILayout.ObjectField("Drop Sound:", myTarget.interactionObject.dropSound, typeof(AudioClip), true); * } * else * { * EditorGUILayout.LabelField("There is no audio clip assigned for dropping.", EditorStyles.helpBox); * } * * GUILayout.Space(5); * * if (myTarget.interactionObject.interactionSound != null) * { * EditorGUILayout.ObjectField("Interaction Sound:", myTarget.interactionObject.interactionSound, typeof(AudioClip), true); * } * else * { * EditorGUILayout.LabelField("There is no audio clip assigned for interaction.", EditorStyles.helpBox); * } * * if (myTarget.interactionObject.inventorySound != null) * { * EditorGUILayout.ObjectField("Inventory Sound:", myTarget.interactionObject.inventorySound, typeof(AudioClip), true); * } * else * { * 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) { //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(); }