public void DisplayObject(InteractionObject interactionObject) { // Run world behaviors resulting from interaction interactionObject.onInteractionBegin.Invoke(interactionObject); if (interactionObject.objectDialog != null) { dialog.SetDialogQueue(interactionObject.objectDialog); dialog.DisplayNextCard(); } else if(interactionObject.objectConversation != null) { FindObjectOfType<ConversationManager>().RunConversation(interactionObject.objectConversation); } GameObject currentInspectedObject = null; if (interactionObject.isInspectable) { currentInspectedObject = (GameObject)Instantiate(interactionObject.objectToInspect, this.transform.position, Quaternion.Euler(interactionObject.interactionRotation)); currentInspectedObject.transform.parent = this.transform; PlaceObjectToFit(currentInspectedObject); camera.enabled = true; cameraGrayscale.effectAmount = 1; } StartCoroutine(CloseInteractionCamera(interactionObject, currentInspectedObject)); }
protected Node ST_Approach(Transform target1, Transform target2, InteractionObject cp) { //foreach (GameObject n in chara) { Val<Vector3> position1 = Val.V (() => target1.position); Val<Vector3> position2 = Val.V (() => target2.position); //print ("hello"); return new SequenceParallel (participant2.GetComponent<BehaviorMecanim> ().Node_GoTo (position1), participant1.GetComponent<BehaviorMecanim> ().Node_GoTo (position1)); }
public InteractionPoint() { _referenceOffset = Vector3.zero; _globalPosition = Vector3.zero; _previousGlobalPosition = Vector3.zero; _interactionObject = null; _isConnected = false; }
private void OnInteractionTrigger( FullBodyBipedEffector effector, InteractionObject obj) { if (this.triggers == null) this.triggers = new Dictionary<FullBodyBipedEffector, bool>(); if (this.triggers.ContainsKey(effector)) this.triggers[effector] = true; }
private void OnInteractionFinish( FullBodyBipedEffector effector, InteractionObject obj) { if (this.finish == null) this.finish = new Dictionary<FullBodyBipedEffector, bool>(); if (this.finish.ContainsKey(effector)) this.finish[effector] = true; }
void YeetTheThing() { Vector3 mousePos = Input.mousePosition; Vector2 dir = Camera.main.ScreenToWorldPoint(mousePos) - transform.position; Vector2 v = dir.normalized * m_timeMouseWasDownFor * m_yeetSpeedMultiplier; m_objectInHands.OnYeeted(gameObject, v); m_objectInHands = null; }
private void OnInteractionTrigger( CrossfadeInteractionHandler handler, FullBodyBipedEffector effectorType, InteractionObject interactionObject) { if (this.BodyTrigger != null) { this.BodyTrigger(effectorType, interactionObject); } }
private void OnInteractionRelease( CrossfadeInteractionHandler handler, FullBodyBipedEffector effectorType, InteractionObject interactionObject) { if (this.BodyRelease != null) { this.BodyRelease(effectorType, interactionObject); } }
/// <summary> /// Saves the interaction settings to file. /// </summary> /// <param name="_object">Object.</param> /// <param name="owner">Owner.</param> public static void SaveInteractionToFile(InteractionObject _object, string owner) { m_Path = Save(owner, "cc_interactions"); if (m_Path.Length == 0) { return; } SaveObjectToFile <InteractionObject>(_object); }
public override bool CanUse(Player player, InteractionObject target) { if (target.objectType != ObjectType.Stump) { return(false); } TreeStump treeStump = target.GetComponent <TreeStump>(); return(treeStump != null && player.Stamina >= treeStump.staminaCost); }
void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("interObject")) { Debug.Log(other.name); currentInterObj = other.gameObject; // Get script to check type currentInterObjScript = currentInterObj.GetComponent <InteractionObject>(); } }
/// <summary> /// Loads the interaction settings from file. /// </summary> /// <returns>The interaction from file.</returns> /// <param name="_object">Object.</param> public static InteractionObject LoadInteractionFromFile(InteractionObject _object) { m_Path = Load("cc_interactions"); if (m_Path.Length == 0) { return(_object); } return(LoadObjectFromFile <InteractionObject>(_object)); }
void OnTriggerEnter2D(Collider2D item) { // Se inicializa el objeto actual cuando el player coliciona con el item. if (item.gameObject.tag == "Item") { //Debug.Log (item.name); currentItem = item.gameObject; interactionObjectScript = currentItem.GetComponent <InteractionObject> (); } }
public float PickUpObject(InteractionObject whichIO) { if (!holding) { interactionSystem.StartInteraction(FullBodyBipedEffector.LeftHand, whichIO, false); interactionSystem.StartInteraction(FullBodyBipedEffector.RightHand, whichIO, false); } ObjectWhenUpright = whichIO.transform.localEulerAngles; return(holdWeight); // lerps from 0 to 1 }
private void OnTriggerExit2D(Collider2D collision) { if (collision.gameObject.CompareTag("Interactable")) { inInteractionZone = !inInteractionZone; interactionObject = collision.gameObject; InteractionObject interactionScript = interactionObject.GetComponent <InteractionObject>(); interactionScript.Triggered("exit"); } }
public void OnTriggerExit2D(Collider2D collision) { if (collision.CompareTag("interactObject")) { if (collision.gameObject == currentInterObj) { currentInterObj = null; currentInterObjScript = null; } } }
public static InteractionObject getInteractionObject(GameObject obj) { InteractionObject interactionObject; if (!_instanceMap.TryGetValue(obj, out interactionObject)) { interactionObject = new InteractionObject(obj); _instanceMap[obj] = interactionObject; } return(interactionObject); }
private void ActionLeft() { if (target != null) { if (target.GetComponent <InteractionObject>() != null) { InteractionObject interactionObject = target.GetComponent <InteractionObject>(); interactionObject.LeftAction(); } } }
private void Update() { if (GameMarager.Single.State != State.Game) { return; } //player旋转 transform.Rotate(0, InputMarager.Horizontal * RotationSpeed * Time.deltaTime, 0); //player移动 方向 if (InputMarager.Space) { UpSpeed = 1; Invoke("ResetUpSpeed", 0.2f); } Vector3 Direction = new Vector3(InputMarager.LeftRight, UpSpeed, InputMarager.ForwardBack); //把方向改变为自己的移动方向 Direction = transform.TransformDirection(Direction); //角色控制器 控制移动 MoveController.Move(Direction * MoveSpeed * Time.deltaTime); //发射线检测是否有交互物体 InteractionObject = null; RaycastHit hit; if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.TransformDirection(Vector3.forward), out hit, 4f, InteractionLayerMask)) { InteractionObject = hit.collider.gameObject.GetComponent <IInteraction>(); //如果找到的物体不为空 并且是未激活 if (InteractionObject != null && InteractionObject.IsActive == false) { InteractionObject = null; } if (InteractionObject != null && InteractionObject != LastInteractionObject) { OnInteraction(InteractionObject); } //如果不为空 并且按下E 展开交互的ui if (InteractionObject != null) { if (InputMarager.Use) { InteractionObject.Use(); } } } else { OnInteraction(InteractionObject); } LastInteractionObject = InteractionObject; }
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); //Get the asset file interactionList = (InteractionObjectList)EditorGUILayout.ObjectField("Interaction Object List:", interactionList, typeof(InteractionObjectList), true); if (interactionList) { //Create a string list for the objects in the list List <string> objects = new List <string>(); int index = 0; if (interactionList.objectList.Count > 0) { foreach (InteractionObjectData datas in interactionList.objectList) { objects.Add(datas.myObject.objectName); index++; } string label = "Object:"; objectNum = EditorGUILayout.Popup(label, objectNum, objects.ToArray()); interactionObject = interactionList.objectList[objectNum].myObject; } } AfterRunningOption(); }
private void Interaction() { if (isInteraction) { return; } InteractionObject targetObject = GetAvailableInteractionObject(); targetObject?.Interaction(() => { isInteraction = false; }); }
// Update is called once per frame void Update() { if (inInteractionZone) { if (Input.GetKeyDown(KeyCode.E)) { InteractionObject interactionScript = interactionObject.GetComponent <InteractionObject>(); interactionScript.Triggered("click"); } } }
private void ActionStart() { if (target != null) { if (target.GetComponent <InteractionObject>() != null) { InteractionObject interactionObject = target.GetComponent <InteractionObject>(); interactionObject.StartAction(character); } } }
void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("interObject")) { currentInterObj = other.gameObject; currentInterObjScript = currentInterObj.GetComponent <InteractionObject> (); Color tmp = currentInterObj.GetComponent <Renderer> ().material.color; tmp.a = 0.75f; currentInterObj.GetComponent <Renderer> ().material.color = tmp; } }
public void AttemptExitEnd(InteractionObject obj) { if (numberOfPapers == 0) { var closeSound = obj.GetComponent<AudioSource>(); if (closeSound != null) closeSound.Play(); StartCoroutine(ExitCoroutine()); } }
void OnTriggerExit2D(Collider2D other) { if (other.CompareTag("InteractionObject")) { if (other.gameObject == currentInterObj) { currentInterObj = null; currentInterObjScript = null; } } }
private static Node TakeOutGun(GameObject participant) { InteractionObject gun = participant.GetComponentInChildren <InteractionObject>(); return(new Sequence( participant.GetComponent <BehaviorMecanim>().Node_StartInteraction(FullBodyBipedEffector.RightHand, gun), new LeafWait(500), new LeafInvoke(() => PickUpGun(gun.gameObject)), participant.GetComponent <BehaviorMecanim>().Node_StopInteraction(FullBodyBipedEffector.RightHand) )); }
private void Interact() { if (Physics.Raycast(camera.transform.position, camera.transform.forward, out RaycastHit hit, 5)) { InteractionObject target = hit.transform.GetComponent <InteractionObject>(); if (target) { target.Execute(); } } }
private void OnTriggerExit2D(Collider2D other) { if (other.CompareTag("InterObject") || other.CompareTag("NPC") || other.CompareTag("GrandmaMerchant")) { if (other.gameObject == currentInterObj) { currentInterObj = null; currentInterObjScript = null; currentNPCScript = null; } } }
private void Update() { if (Input.GetButtonDown("Interact") && currentInterobj) { if (currentInterobjScript.inventory) { inventory.AddItem(currentInterobj); currentInterobj = null; currentInterobjScript = null; } } }
public void GoToHallwayEnd(InteractionObject obj) { // Only load hallway if keycard has been found if (keycardFound) { StartCoroutine(ExitToHallwayCoroutine()); } else { convoManager.RunConversation(keycardNotFoundConvo); } }
private void Update() { if (Input.GetButtonDown("Interact") && currentInterObj) { //Check if able to store object in inventory if (currentInterObjScript.inventory) { inventory.addItem(currentInterObj); } //Nulify the objects so the player cannot //keep adding duplicates to inventory currentInterObj = null; currentInterObjScript = null; } // Use a health potion if (Input.GetButtonDown("Potion")) { //Check the inventory for a potion GameObject potion = inventory.FindItemByType("HealthPotion"); if (potion != null) { //Use the potion - apply its effect //Remove the potion from inventory inventory.RemoveItem(potion); Debug.Log("Health potion was used"); stat.addHealth(2); } else { Debug.Log("Cannot find potion in inventory"); } } // Use a Power potion if (Input.GetButtonDown("PowerPotion")) { //Check the inventory for a potion GameObject potion1 = inventory.FindItemByType("PowerPotion"); if (potion1 != null) { // Use the potion - apply it effects //Remove the potion from inventory inventory.RemoveItem(potion1); Debug.Log("Power Potion was used"); stat.addDamage(1); } else { Debug.Log("Cannot find power potion in inventory"); } } }
void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("InterObject")) { currentInterObj = other.gameObject; currentInterObjScript = currentInterObj.GetComponent <InteractionObject>(); if (currentInterObjScript.inventory) { inventory.AddItem(currentInterObj); } } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("interObject")) { currentInterObject = collision.gameObject; currentInterObjScript = currentInterObject.GetComponent <InteractionObject>(); currentSentenceOriginal = currentInterObjScript.currentSentence; if (currentInterObjScript.textFile) { currentInterObjScript.sentences = currentInterObjScript.textFile.text.Split('\n'); } } }
private void OnInteractionTrigger( FullBodyBipedEffector effector, InteractionObject obj) { if (this.triggers == null) { this.triggers = new Dictionary <FullBodyBipedEffector, bool>(); } if (this.triggers.ContainsKey(effector)) { this.triggers[effector] = true; } }
private void OnInteractionFinish( FullBodyBipedEffector effector, InteractionObject obj) { if (this.finish == null) { this.finish = new Dictionary <FullBodyBipedEffector, bool>(); } if (this.finish.ContainsKey(effector)) { this.finish[effector] = true; } }
private void OnStart(FullBodyBipedEffector effectorType, InteractionObject interactionObject) { if (effectorType != FullBodyBipedEffector.LeftHand) { return; } if (interactionObject != this.obj) { return; } this.RotatePivot(); this.holdPoint.rotation = this.obj.transform.rotation; }
public void connectToObject(InteractionObject obj, InteractionPointConnectMethod connectMode = InteractionPointConnectMethod.MIRROR) { _interactionObject = obj; if (connectMode == InteractionPointConnectMethod.MIRROR) { connectToObjectMirror(obj); } else { if (connectMode == InteractionPointConnectMethod.SURFACE) { connectToObjectSurface(obj); } else { if (obj.isInsideW(_globalPosition, InteractionHand.SIZE) == (connectMode == InteractionPointConnectMethod.INSIDE)) { connectToObjectMirror(obj); } else { connectToObjectSurface(obj); } } } _isConnected = true; }
void PickUp() { if(Input.GetKeyDown(KeyCode.P))//Input.GetKey("PickUp")) { float x = Screen.width /2; float y = Screen.height/2; Ray ray = mainCam.ScreenPointToRay(new Vector3(x,y)); RaycastHit hit; if(Physics.Raycast(ray, out hit)) { selectedObject = hit.collider.GetComponent<InteractionObject>(); if(selectedObject != null) { carrying = true; carryingObject = selectedObject.RBody; } } } }
private void OnEffectorResume( FullBodyBipedEffector effectorType, InteractionObject interactionObject) { if (this.InteractionResume != null) this.InteractionResume(this, effectorType, interactionObject); }
private void OnEffectorPickUp( FullBodyBipedEffector effectorType, InteractionObject interactionObject) { if (this.InteractionPickUp != null) this.InteractionPickUp(this, effectorType, interactionObject); }
protected Node ST_PickUp(GameObject ball, InteractionObject obj) { FullBodyBipedEffector hand = FullBodyBipedEffector.RightHand; Val<Vector3> position = Val.V(() => ball.transform.position); return new SelectorShuffle( new Sequence(participant1.GetComponent<BehaviorMecanim>().Node_GoToUpToRadius(position, 1f), participant1.GetComponent<BehaviorMecanim>().Node_StartInteraction(hand, obj), new LeafWait(2000)), new Sequence(participant2.GetComponent<BehaviorMecanim>().Node_GoToUpToRadius(position, 1f), participant2.GetComponent<BehaviorMecanim>().Node_StartInteraction(hand, obj), new LeafWait(2000)), new Sequence(participant3.GetComponent<BehaviorMecanim>().Node_GoToUpToRadius(position, 1f), participant3.GetComponent<BehaviorMecanim>().Node_StartInteraction(hand, obj), new LeafWait(2000))); }
private void OnEffectorStart( FullBodyBipedEffector effectorType, InteractionObject interactionObject) { if (this.InteractionStart != null) this.InteractionStart(this, effectorType, interactionObject); }
protected Node ST_Get_Ball(GameObject picker, FullBodyBipedEffector effector, InteractionObject ball, string tracer) { Val<FullBodyBipedEffector> eff = Val.V(() => effector); Val<InteractionObject> ba = Val.V(() => ball); return new Sequence( new LeafTrace(tracer), picker.GetComponent<BehaviorMecanim>().Node_StartInteraction(eff, ba), new LeafWait(1000)); }
public void LoadTheScene(InteractionObject obj) { SceneManager.LoadScene(scene); }
void drop(Rigidbody x) { x.isKinematic = false; carrying = false; carryingObject = null; selectedObject = null; }
private void OnInteractionTrigger( CrossfadeInteractionHandler handler, FullBodyBipedEffector effectorType, InteractionObject interactionObject) { if (this.BodyTrigger != null) this.BodyTrigger(effectorType, interactionObject); }
public void StartInteraction( FullBodyBipedEffector effector, InteractionObject obj) { this.bodyController.StartInteraction(effector, obj); this.lookController.HeadOnly(this.DefaultDelay); }
private void OnInteractionRelease( FullBodyBipedEffector effectorType, InteractionObject interactionObject) { if (this.InteractionRelease != null) this.InteractionRelease(effectorType, interactionObject); }
public void AttemptExitStart(InteractionObject obj) { obj.objectDialog = numberOfPapers == 0 ? exitAllowed : exitNotAllowed; }
public void StartInteraction(FullBodyBipedEffector effector, InteractionObject obj) { if (this.state == BodyIKState.Offline) { this.primaryEffectors.Add(effector, obj); this.handlerPrimary.StartInteraction(effector, obj, true); this.state = BodyIKState.Online; } else if (this.state == BodyIKState.Online || this.state == BodyIKState.Swapping) { // Is this effector already being used? if (this.primaryEffectors.ContainsKey(effector)) { this.PerformSwap(effector, obj); } else { this.primaryEffectors.Add(effector, obj); this.handlerPrimary.StartInteraction(effector, obj, true); } } else if (this.state == BodyIKState.Stopping) { this.primaryEffectors.Add(effector, obj); this.handlerPrimary.StartInteraction(effector, obj, true); this.state = BodyIKState.Online; } }
private void OnInteractionResume( CrossfadeInteractionHandler handler, FullBodyBipedEffector effectorType, InteractionObject interactionObject) { if (this.BodyResume != null) this.BodyResume(effectorType, interactionObject); }
/// <summary> /// Starts the interaction between an effector and an interaction object. /// </summary> public void StartInteraction( FullBodyBipedEffector effectorType, InteractionObject interactionObject, bool interrupt) { if (!IsValid(true)) return; for (int i = 0; i < interactionEffectors.Length; i++) { if (interactionEffectors[i].effectorType == effectorType) { interactionEffectors[i].Start( interactionObject, targetTag, fadeInTime, interrupt); return; } } }
protected Node ST_ShakeHands(InteractionObject handShake, Val<FullBodyBipedEffector> effector1, Val<FullBodyBipedEffector> effector2) { return new SequenceParallel( numberOfParticipants[0].GetComponent<BehaviorMecanim>().Node_StartInteraction(effector1, handShake), numberOfParticipants[1].GetComponent<BehaviorMecanim>().Node_StartInteraction(effector2, handShake), new LeafWait(1000)); }
protected Node ST_Press_Button(GameObject agent, FullBodyBipedEffector effector, InteractionObject button) { Val<FullBodyBipedEffector> eff = Val.V(() => effector); Val<InteractionObject> butt = Val.V(() => button); return new Sequence(new LeafTrace("Interaction"), agent.GetComponent<BehaviorMecanim>().Node_StartInteraction(eff, butt), new LeafWait(1000)); }
private void PerformSwap(FullBodyBipedEffector effector, InteractionObject obj) { // Move all the effectors to the secondary IK solver foreach (var kv in this.primaryEffectors) { if (kv.Key != effector) { this.handlerSecondary.StartInteraction(kv.Key, kv.Value, true); this.secondaryEffectors[kv.Key] = kv.Value; } } this.handlerSecondary.StartInteraction(effector, obj, true); this.secondaryEffectors[effector] = obj; // Swap solvers this.Swap(); // Store the intermediate state float time = Time.time; this.swapTimeFinish = time + this.SwapTime; this.state = BodyIKState.Swapping; }
private void OnInteractionTrigger( FullBodyBipedEffector effectorType, InteractionObject interactionObject) { if (this.InteractionTrigger != null) this.InteractionTrigger(effectorType, interactionObject); }
public void FoundKeycard(InteractionObject obj) { keycardFound = true; }
private void OnInteractionStop( FullBodyBipedEffector effectorType, InteractionObject interactionObject) { if (this.InteractionStop != null) this.InteractionStop(effectorType, interactionObject); }
public void GoToHallwayBegin(InteractionObject obj) { // Make sure no dialog runs obj.objectDialog = null; }