//GameObject[] puzzleObjs = GameObject.FindGameObjectsWithTag("Puzzle Objs"); public Puzzle(GameObject name, Sprite sprite, Sprite solved_s, GameObject puzzleBoard, InteractableObj unlocked) : base(name, sprite) { solvedSprite = solved_s; unlockedItem = unlocked; unlockedItem.obj.SetActive(false); puzzleObj = puzzleBoard; }
public void PickUp(InteractableObj obj) { if (!rightHandFull) { obj.GetPickedUpBy(this, isPlayer); } }
public void SetDisplay(InteractableObj _asdObj) { itemImg.sprite = _data.artWork; _button = GetComponent <MultiImageButton>(); _button.onClick.AddListener(HoldItem); _script = _asdObj; }
public void SetPlayerhandEmpty() { Inventory.instance.RemoveItem(handObj.GetGameObj()); handObj = null; permissionToLift = true; playerAnimator.SetBool("HoldingItem", false); }
public void ChangeHandItemFromIconEmptyHand(InteractableObj _obj) { if (!handItemChanging) { StartCoroutine(BringUpInventoryItem(_obj)); } }
public static InteractableObj selectedObj; // Must be static b/c only one selectedObj across all instances of InvButton void Start() { inventoryObj = GameObject.FindObjectOfType <inventoryObj>(); button = gameObject.GetComponent <Button>(); selectedObj = null; }
public void ChangeItemFromIcon(InteractableObj _obj) { if (!handItemChanging) { StartCoroutine(WaitForItemChange(_obj)); } }
[PunRPC] private void OnlineSpawn(int id) { GameObject newObj = Instantiate(prefabs[id], gameObject.transform.position, Quaternion.identity, gameObject.transform); InteractableObj interactableObj = newObj.GetComponent <InteractableObj>(); interactableObj.SetNumber(objs.Count); objs.Add(interactableObj); }
public void AddtoInv(InteractableObj obj) { if (inventory.Count < invSpaces && !inventory.ContainsValue(obj)) { FillNextSlot(obj); int key = obj.slotNum; inventory.Add(key, obj); } }
private void OnlineSpawn(int modelID, int materialID) { GameObject newObj = Instantiate(prefabs[modelID], gameObject.transform.position, transform.rotation, gameObject.transform); InteractableObj interactableObj = newObj.GetComponent <InteractableObj>(); interactableObj.OnSpawn(objs.Count, materialID, this, _displayType, !grabbed); interactableObj.OnDestroy.AddListener((num) => photonView.RPC("destroy", RpcTarget.AllBuffered, num)); interactableObj.OnCatchStatusChange.AddListener((status) => SetGrabable(status)); objs.Add(interactableObj); }
public void UseItem(InteractableObj i) // { //InvSlot slot; Button slot; int num = i.slotNum; inventory.Remove(num); slot = slotList[num]; slot.gameObject.SetActive(false); }
void OnTriggerEnter(Collider collider) { //Debug.Log ("I hit something"); InteractableObj intObj = collider.GetComponentInParent <InteractableObj>(); if (intObj != null && intObj.isGrabbable) { //Debug.Log ("I'm interacting"); interactableItems.Add(intObj.gameObject); } }
public IEnumerator BringUpInventoryItem(InteractableObj _obj) { handItemChanging = true; playerAnimator.SetBool("HoldingItem", false); yield return(new WaitForSeconds(1f)); playerAnimator.SetBool("HoldingItem", true); _obj.GetGameObj().SetActive(true); handObj = _obj; handItemChanging = false; }
public IEnumerator WaitForItemChange(InteractableObj _obj) { playerAnimator.SetBool("HoldingItem", false); yield return(new WaitForSeconds(1f)); playerAnimator.SetBool("HoldingItem", true); GetHandObject().SetActive(false); _obj.GetGameObj().SetActive(true); handObj = _obj; }
//Mostly called from Raycaster after interact button clicked public void AddItem(ShopItem _item, InteractableObj _script) { GameObject newObj = GameObject.Instantiate(itemPrefab, _inventoryGrid.transform); StartCoroutine(WaitForHold(newObj)); _currentInv.Add(new InventoryItem(newObj, _item, _script.GetGameObj())); InventoryItemDisplay objDisplay = newObj.GetComponent <InventoryItemDisplay>(); objDisplay._master = this; objDisplay._data = _item; objDisplay.SetDisplay(_script); }
private void Update() { if (Input.GetKeyDown(KeyCode.E)) { UIManager.Instance.Push <UIScreenDialogue>(UIDepthConst.MiddleDepth, false, 10001); interactableObj = SearchInteractableObj(); if (interactableObj) { print("交互"); } } }
public void ThrowButton() { if (handObj != null && !handItemChanging && !handItemPickingUp) { ThrowGameObject(); handObj = null; } else { handObj = null; } }
public void FillNextSlot(InteractableObj obj) { foreach (Button b in slotList) { if (b.gameObject.activeSelf == false) { b.gameObject.SetActive(true); b.image.sprite = obj.sprite; obj.slotNum = slotList.IndexOf(b); break; } } }
private void destroy(int id) { InteractableObj buff = objs[id]; objs.RemoveAt(id); for (int i = 0; i < objs.Count; ++i) { objs[i].UpdId(i); } buff.DestroyObject(); }
void OnTriggerExit(Collider collider) { //Debug.Log ("I hit something"); if (collider.GetComponentInParent <InteractableObj> () != null) { InteractableObj intObj = collider.GetComponentInParent <InteractableObj> (); if (interactableItems.Contains(intObj.gameObject)) { //Debug.Log ("I'm no longer interacting"); interactableItems.Remove(intObj.gameObject); } } }
private void Awake() { //Set all interactables inactive inventoryObj = GameObject.FindObjectOfType <inventoryObj>(); knight_i = new InteractableObj(knight, knight_s); king_i = new InteractableObj(king, king_s); codeNote_i = new InteractableObj(codeNote, codeNote_s); interactablesList = new Dictionary <string, InteractableObj>(); interactablesList.Add(knight.name, knight_i); interactablesList.Add(king.name, king_i); interactablesList.Add(codeNote.name, codeNote_i); }
public InteractableObj SearchInteractableObj() { Ray ray = m_camera.ScreenPointToRay(new Vector2(Screen.width, Screen.height) / 2); RaycastHit hit; if (Physics.Raycast(ray, out hit, maxSearchDis)) { InteractableObj obj = hit.collider.GetComponentInChildren <InteractableObj>(); if (obj != null) { return(obj); } } return(null); }
public void PickUp() { Collider2D[] colliders_ = Physics2D.OverlapCircleAll(transform.position, armsReach); foreach (Collider2D c in colliders_) { if (c.gameObject.layer == 12) { print("found something"); InteractableObj obj = c.GetComponent <InteractableObj>(); if (obj == null) { obj = c.transform.parent.GetComponent <InteractableObj>(); } PickUp(obj); return; } } }
public void SetPuzzleActive(int _puzzleID, bool _activate = true, InteractableObj _whoYouGonnaCall = null) { whoYouGonnaCall = _whoYouGonnaCall; Puzzle p = FindPuzzle(_puzzleID); if (p != null) { p.gameObject.SetActive(_activate); if (_activate == true) { activePuzzle = p; playerController.enabled = false; } else if (activePuzzle == p) { activePuzzle = null; } } else { print("Puzzle " + _puzzleID + " not found"); } }
private void Awake() { interactableObj = GetComponentInParent <InteractableObj>(); }
public void OnDeselect(BaseEventData eventData) { selectedObj = null; Debug.Log("Deselected"); }
public void OnSelect(BaseEventData eventData) { selectedObj = inventoryObj.GetObjFromButton(button); Debug.Log(selectedObj.obj.name + " was selected"); Debug.Log("Select name: " + GetSelectedName()); }
// Use this for initialization void Start() { GameManager.onKnightsWinEvent += DragonLose; rigidBody = GetComponent <Rigidbody>(); interactionScript = GetComponent <InteractableObj>(); }
void FixedUpdate() { var device = SteamVR_Controller.Input((int)trackedObj.index); if (!currentlyHolding && interactableItems.Count != 0 && device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger)) { interObj = interactableItems [0]; InteractableObj intObjScript = interObj.GetComponentInParent <InteractableObj> (); if (intObjScript.returnOnDrop) { //set orig position oldPosition = interObj.transform.position; oldRotation = interObj.transform.rotation; } //snaps pos to controller attachPoint if (intObjScript.snapPosToAttach) { interObj.transform.position = attachPoint.transform.position; } //snaps rot to controller attachPoint if (intObjScript.snapRotToAttach) { interObj.transform.rotation = attachPoint.transform.rotation; } if (intObjScript.grabType == GrabTypeDropList.Parent) { //parent attach mode interObj.transform.parent = attachPoint.transform; currentlyHolding = true; } if (intObjScript.grabType == GrabTypeDropList.FixedJoint) { //fixedJoint attach mode joint = interObj.AddComponent <FixedJoint> (); joint.connectedBody = attachPoint; currentlyHolding = true; } } else if (currentlyHolding && device.GetPressDown(SteamVR_Controller.ButtonMask.Grip)) { InteractableObj intObjScript = interObj.GetComponentInParent <InteractableObj> (); var rgbd = interObj.GetComponent <Rigidbody>(); if (intObjScript.grabType == GrabTypeDropList.Parent) { //parent detach mode interObj.transform.parent = null; currentlyHolding = false; } if (intObjScript.grabType == GrabTypeDropList.FixedJoint) { //fixedJoint detach mode Object.DestroyImmediate(joint); joint = null; currentlyHolding = false; } if (intObjScript.isThrowable) { //stuff for throwing and momentum var origin = trackedObj.origin ? trackedObj.origin : trackedObj.transform.parent; if (origin != null) { rgbd.velocity = origin.TransformVector(device.velocity); rgbd.angularVelocity = origin.TransformVector(device.angularVelocity); } else { rgbd.velocity = device.velocity; rgbd.angularVelocity = device.angularVelocity; } rgbd.maxAngularVelocity = rgbd.angularVelocity.magnitude; } if (intObjScript.returnOnDrop && !intObjScript.isThrowable) { //snap back to orig position //Debug.Log ("returning "+interObj.name+" to original pos"); interObj.transform.position = oldPosition; interObj.transform.rotation = oldRotation; } } else if (currentlyHolding && (device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger) || device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))) { onButtonPress(); } }
public bool CheckForValue(InteractableObj o) { Debug.Log("Looking for " + o.obj.name); return(inventory.ContainsValue(o)); }