public void Pickup(Transform attachPos) { //Get nearest interactable m_CurrentInteractable = GetNearestInteractable(); //Null check if (!m_CurrentInteractable) { return; } //Already held, check if (m_CurrentInteractable.m_ActiveHand) { m_CurrentInteractable.m_ActiveHand.Drop(); } //Position m_CurrentInteractable.ApplyOffset(attachPos); //Attach to fixed joint on hands Rigidbody targetBody = m_CurrentInteractable.GetComponent <Rigidbody>(); m_Joint.connectedBody = targetBody; //Set active hand m_CurrentInteractable.m_ActiveHand = this; }
private ObjectInteract RaycastForInteractable() { RaycastHit hit; Ray ray = new Ray(transform.position, transform.forward); if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { if (hit.collider.gameObject.GetComponent <ObjectInteract>() != null) { isHover = true; enableHighlight.EnableHighlight(true); ObjectInteract grabItem = hit.collider.gameObject.GetComponent <ObjectInteract>(); return(grabItem); } DisplayLine(true, hit.point); return(null); } else { isHover = false; DisplayLine(false, transform.position); enableHighlight.EnableHighlight(false); return(null); } }
void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("interObject")) { Debug.Log(other.name); currentInterObj = other.gameObject; currentInterObjScript = currentInterObj.GetComponent <ObjectInteract> (); } }
// Start is called before the first frame update private void Start() { interactable = stadium.GetComponent <ObjectInteract>(); teleportFloor.SetActive(false); originalScale = stadium.transform.localScale; originalPos = stadium.transform.position; originalRot = stadium.transform.rotation; targetScale = new Vector3(0.004f, 0.004f, 0.004f); }
void Start() { itemNum = 0; prevNum = 0; for (int i = 0; i < 10; i++) { selected[i] = false; } currentObject = GetComponent <PlayerInteraction>().GetCurrentInterObject(); }
private ObjectInteract GetNearestInteractable() { ObjectInteract nearest = null; float minDistance = float.MaxValue; float distance = 0.0f; foreach (ObjectInteract interactable in m_ContactInteractables) { distance = (interactable.transform.position - transform.position).sqrMagnitude; if (distance < minDistance) { minDistance = distance; nearest = interactable; } } return(nearest); }
public void Drop() { //Null check if (!m_CurrentInteractable) { return; } //Apply veclocity Rigidbody targetBody = m_CurrentInteractable.GetComponent <Rigidbody>(); targetBody.velocity = m_Pose.GetVelocity(); targetBody.angularVelocity = m_Pose.GetAngularVelocity(); //Detach from joint m_Joint.connectedBody = null; //Clear m_CurrentInteractable.m_ActiveHand = null; m_CurrentInteractable = null; }
public PacketHandlers() { setPacketSizes(); PacketHandler temp; temp = new ActionButton(); handlers.Add(PacketId.CLOSE, temp); //Close handlers.Add(PacketId.ACTIONBUTTON, temp); //Actionbutton #1 handlers.Add(PacketId.ACTIONBUTTON2, temp); //Actionbutton #2 handlers.Add(PacketId.ACTIONBUTTON3, temp); //Actionbutton #3 temp = new ClientAction(); handlers.Add(PacketId.IDLE, temp); //Idle handlers.Add(PacketId.MOVE_CAMERA, temp); //Move camera handlers.Add(PacketId.PING, temp); //Ping handlers.Add(PacketId.FOCUS, temp); //Window focus handlers.Add(PacketId.CLICK_MOUSE, temp); //Mouse handlers.Add(PacketId.WINDOW_TYPE, temp); //Window type handlers.Add(PacketId.SOUND_SETTINGS, temp); //Toggle sound (sounds) temp = new Command(); handlers.Add(PacketId.COMMAND, temp); //Commands temp = new Communication(); handlers.Add(PacketId.ADD_FRIEND, temp); //Add friend handlers.Add(PacketId.DELETE_FRIEND, temp); //Delete friend handlers.Add(PacketId.ADD_IGNORE, temp); //Add ignore handlers.Add(PacketId.DELETE_IGNORE, temp); //Delete ignore handlers.Add(PacketId.SEND_PM, temp); //Send PM handlers.Add(PacketId.CLAN_RANKS, temp); //Set clan ranks handlers.Add(PacketId.CLAN_CHAT, temp); //Join clan chat handlers.Add(PacketId.PUBLIC, temp); //Public chat handlers.Add(PacketId.CLAN_KICK, temp); //Clan chat kick handlers.Add(PacketId.PRIVACY_SETTINGS, temp); //public/private/trade chat settings temp = new Walk(); handlers.Add(PacketId.WALK_1, temp); //Walk handlers.Add(PacketId.WALK_2, temp); //Walk handlers.Add(PacketId.WALK_3, temp); //Walk temp = new PlayerInteract(); handlers.Add(PacketId.ATTACK_PLAYER, temp); //Attack handlers.Add(PacketId.FOLLOW, temp); //Follow handlers.Add(PacketId.TRADE, temp); //Trade handlers.Add(PacketId.MAGIC_ON_PLAYER, temp); //Magic on player temp = new NPCInteract(); handlers.Add(PacketId.NPC_FIRST_CLICK, temp); //Attack handlers.Add(PacketId.NPC_SECOND_CLICK, temp); //Second click handlers.Add(PacketId.NPC_THIRD_CLICK, temp); //Third click handlers.Add(PacketId.NPC_FOURTH_CLICK, temp); //Fourth click handlers.Add(PacketId.NPC_FIFTH_CLICK, temp); //Fifth click handlers.Add(PacketId.NPC_EXAMINE, temp); //Examine Npc handlers.Add(PacketId.MAGIC_ON_NPC, temp); //Magic on NPC handlers.Add(PacketId.ITEM_ON_NPC, temp); //Item on NPC temp = new ObjectInteract(); handlers.Add(PacketId.OBJECT_FIRST_CLICK, temp); //First click handlers.Add(PacketId.OBJECT_SECOND_CLICK, temp); //Second click handlers.Add(PacketId.OBJECT_THIRD_CLICK, temp); //Third click handlers.Add(PacketId.OBJECT_FOURTH_CLICK, temp); //Fourth click handlers.Add(PacketId.OBJECT_EXAMINE, temp); //object examine temp = new ItemInteract(); handlers.Add(PacketId.EQUIP, temp); //Equip item handlers.Add(PacketId.ITEM_ON_ITEM, temp); //Item used on item handlers.Add(PacketId.INV_CLICK, temp); //Inventory click item handlers.Add(PacketId.ITEM_ON_OBJECT, temp); //Item used on object handlers.Add(PacketId.ITEM_ON_GROUND_ITEM, temp); //Item used on ground item. handlers.Add(PacketId.INV_OPERATE, temp); //Operate option handlers.Add(PacketId.INV_DROP, temp); //Drop item handlers.Add(PacketId.PICKUP, temp); //Pick up item handlers.Add(PacketId.INV_SWAP_SLOT, temp); //Swap item slot 1 handlers.Add(PacketId.INV_SWAP_SLOT2, temp); //Swap item slot 2 handlers.Add(PacketId.INV_RIGHT_CLICK_OPTION1, temp); //Right click option 1 handlers.Add(PacketId.INV_RIGHT_CLICK_OPTION2, temp); //Right click option 2 handlers.Add(PacketId.INV_EXAMINE_ITEM, temp); //Inventory item examine temp = new InterfaceOptions(); handlers.Add(PacketId.ENTER_AMOUNT, temp); //Enter amount handlers.Add(PacketId.ENTER_TEXT, temp); // Enter text handlers.Add(PacketId.INTERFACE_CLICK_1, temp); //Option 1 handlers.Add(PacketId.INTERFACE_CLICK_2, temp); //Option 2 handlers.Add(PacketId.INTERFACE_CLICK_3, temp); //Option 3 handlers.Add(PacketId.INTERFACE_CLICK_4, temp); //Option 4 handlers.Add(PacketId.INTERFACE_CLICK_5, temp); //Option 5 handlers.Add(PacketId.INTERFACE_CLICK_6, temp); //Option 6 handlers.Add(PacketId.INTERFACE_CLICK_7, temp); //Option 7 handlers.Add(PacketId.INTERFACE_CLICK_8, temp); //Option 8 handlers.Add(PacketId.INTERFACE_CLICK_9, temp); //Option 9 handlers.Add(PacketId.INTERFACE_CLICK_10, temp); //Option 9 handlers.Add(PacketId.GE_SEARCH, temp); //Grand exchange search temp = new Unused(); handlers.Add(PacketId.REIGON_LOADING, temp); //Region loading, varied size handlers.Add(PacketId.PACKET_COUNT, temp); //Sent after any click which increases 'count' in getPackets handlers.Add(PacketId.CLIENT_VARIABLE_30, temp); //Sent if a client variable is 30..unknown handlers.Add(PacketId.DODGY_PACKET, temp); //Caused by a dodgy packet Console.WriteLine("Binded packetHandlers"); }
public PacketHandlers() { setPacketSizes(); PacketHandler temp; temp = new ActionButton(); handlers.Add(PacketId.CLOSE, temp); //Close handlers.Add(PacketId.ACTIONBUTTON, temp); //Actionbutton #1 handlers.Add(PacketId.ACTIONBUTTON2, temp); //Actionbutton #2 handlers.Add(PacketId.ACTIONBUTTON3, temp); //Actionbutton #3 temp = new ClientAction(); handlers.Add(PacketId.IDLE, temp); //Idle handlers.Add(PacketId.MOVE_CAMERA, temp); //Move camera handlers.Add(PacketId.PING, temp); //Ping handlers.Add(PacketId.FOCUS, temp); //Window focus handlers.Add(PacketId.CLICK_MOUSE, temp); //Mouse handlers.Add(PacketId.WINDOW_TYPE, temp); //Window type handlers.Add(PacketId.SOUND_SETTINGS, temp); //Toggle sound (sounds) temp = new Command(); handlers.Add(PacketId.COMMAND, temp); //Commands temp = new Communication(); handlers.Add(PacketId.ADD_FRIEND, temp); //Add friend handlers.Add(PacketId.DELETE_FRIEND, temp); //Delete friend handlers.Add(PacketId.ADD_IGNORE, temp); //Add ignore handlers.Add(PacketId.DELETE_IGNORE, temp); //Delete ignore handlers.Add(PacketId.SEND_PM, temp); //Send PM handlers.Add(PacketId.CLAN_RANKS, temp); //Set clan ranks handlers.Add(PacketId.CLAN_CHAT, temp); //Join clan chat handlers.Add(PacketId.PUBLIC, temp); //Public chat handlers.Add(PacketId.CLAN_KICK, temp); //Clan chat kick handlers.Add(PacketId.PRIVACY_SETTINGS, temp); //public/private/trade chat settings temp = new Walk(); handlers.Add(PacketId.WALK_1, temp); //Walk handlers.Add(PacketId.WALK_2, temp); //Walk handlers.Add(PacketId.WALK_3, temp); //Walk temp = new PlayerInteract(); handlers.Add(PacketId.ATTACK_PLAYER, temp); //Attack handlers.Add(PacketId.FOLLOW, temp); //Follow handlers.Add(PacketId.TRADE, temp); //Trade handlers.Add(PacketId.MAGIC_ON_PLAYER, temp); //Magic on player temp = new NPCInteract(); handlers.Add(PacketId.NPC_FIRST_CLICK, temp); //Attack handlers.Add(PacketId.NPC_SECOND_CLICK, temp); //Second click handlers.Add(PacketId.NPC_THIRD_CLICK, temp); //Third click handlers.Add(PacketId.NPC_FOURTH_CLICK, temp); //Fourth click handlers.Add(PacketId.NPC_FIFTH_CLICK, temp); //Fifth click handlers.Add(PacketId.NPC_EXAMINE, temp); //Examine Npc handlers.Add(PacketId.MAGIC_ON_NPC, temp); //Magic on NPC handlers.Add(PacketId.ITEM_ON_NPC, temp); //Item on NPC temp = new ObjectInteract(); handlers.Add(PacketId.OBJECT_FIRST_CLICK, temp); //First click handlers.Add(PacketId.OBJECT_SECOND_CLICK, temp); //Second click handlers.Add(PacketId.OBJECT_THIRD_CLICK, temp); //Third click handlers.Add(PacketId.OBJECT_FOURTH_CLICK, temp); //Fourth click handlers.Add(PacketId.OBJECT_FIFTH_CLICK, temp); //Fifth click handlers.Add(PacketId.OBJECT_EXAMINE, temp); //object examine temp = new ItemInteract(); handlers.Add(PacketId.EQUIP, temp); //Equip item handlers.Add(PacketId.ITEM_ON_ITEM, temp); //Item used on item handlers.Add(PacketId.INV_CLICK, temp); //Inventory click item handlers.Add(PacketId.ITEM_ON_OBJECT, temp); //Item used on object handlers.Add(PacketId.ITEM_ON_GROUND_ITEM, temp); //Item used on ground item. handlers.Add(PacketId.INV_OPERATE, temp); //Operate option handlers.Add(PacketId.INV_DROP, temp); //Drop item handlers.Add(PacketId.PICKUP, temp); //Pick up item handlers.Add(PacketId.INV_SWAP_SLOT, temp); //Swap item slot 1 handlers.Add(PacketId.INV_SWAP_SLOT2, temp); //Swap item slot 2 handlers.Add(PacketId.INV_RIGHT_CLICK_OPTION1, temp); //Right click option 1 handlers.Add(PacketId.INV_RIGHT_CLICK_OPTION2, temp); //Right click option 2 handlers.Add(PacketId.INV_EXAMINE_ITEM, temp); //Inventory item examine handlers.Add(PacketId.INV_EXAMINE_ITEM_GE, temp); //Inventory item examine in GE_SELL_ITEM temp = new InterfaceOptions(); handlers.Add(PacketId.ENTER_AMOUNT, temp); //Enter amount handlers.Add(PacketId.ENTER_TEXT, temp); // Enter text handlers.Add(PacketId.INTERFACE_CLICK_1, temp); //Option 1 handlers.Add(PacketId.INTERFACE_CLICK_2, temp); //Option 2 handlers.Add(PacketId.INTERFACE_CLICK_3, temp); //Option 3 handlers.Add(PacketId.INTERFACE_CLICK_4, temp); //Option 4 handlers.Add(PacketId.INTERFACE_CLICK_5, temp); //Option 5 handlers.Add(PacketId.INTERFACE_CLICK_6, temp); //Option 6 handlers.Add(PacketId.INTERFACE_CLICK_7, temp); //Option 7 handlers.Add(PacketId.INTERFACE_CLICK_8, temp); //Option 8 handlers.Add(PacketId.INTERFACE_CLICK_9, temp); //Option 9 handlers.Add(PacketId.INTERFACE_CLICK_10, temp); //Option 9 handlers.Add(PacketId.GE_SEARCH, temp); //Grand exchange search temp = new Unused(); handlers.Add(PacketId.REIGON_LOADING, temp); //Region loading, varied size handlers.Add(PacketId.PACKET_COUNT, temp); //Sent after any click which increases 'count' in getPackets handlers.Add(PacketId.CLIENT_VARIABLE_30, temp); //Sent if a client variable is 30..unknown handlers.Add(PacketId.DODGY_PACKET, temp); //Caused by a dodgy packet Console.WriteLine("Binded packetHandlers"); }
// Update is called once per frame void Update() { if (!grabbed) { interactable = RaycastForInteractable(); if (!interactable) { return; } } Vector3 curHandPos = transform.position; Quaternion curHandRot = transform.rotation; if (clickAction.GetStateDown(targetSource)) { grabbed = true; interactable.SetKinematic(true); interactable.SetMoveScale(transform.position); lastHandPos = curHandPos; lastHandRot = curHandRot; DisplayLine(false, transform.position); } else if (clickAction.GetState(targetSource)) { if (isHover) { enableHighlight.EnableHighlight(true); } interactable.Move(curHandPos, lastHandPos, curHandRot, lastHandRot); if (touchPadAction.GetAxis(trackedObjRight.inputSource).y > 0) { interactable.ScaleUp(); } else if (touchPadAction.GetAxis(trackedObjRight.inputSource).y < 0) { interactable.ScaleDown(); } if (touchPadAction.GetAxis(trackedObjLeft.inputSource).x > 0) { interactable.Rotate(true); } else if (touchPadAction.GetAxis(trackedObjLeft.inputSource).x < 0) { interactable.Rotate(false); } } else if (clickAction.GetStateUp(targetSource)) { grabbed = false; interactable.SetKinematic(false); } lastHandPos = curHandPos; lastHandRot = curHandRot; }
void Update() { ItemSelector(); currentObject = GetComponent <PlayerInteraction>().GetCurrentInterObject(); selectedObject = inventory[itemNum].items[0]; }