コード例 #1
0
 private void DisplayInfoObjectPickedUp(PickUpable item)
 {
     _infoDrop.text = "Press E to drop the " + item.cleanName;
     _infoDrop.gameObject.SetActive(true);
     _infoThrow.text = "Press F to throw the " + item.cleanName;
     _infoThrow.gameObject.SetActive(true);
 }
コード例 #2
0
    public void PickUp(PickUpable item)
    {
        currentHeldItem = item;

        PhotonView view = item.GetComponent <PhotonView>();

        // transfer ownership to the player if they were not already the owner
        if (!view.IsMine)
        {
            view.TransferOwnership(PhotonNetwork.LocalPlayer);
        }
        else
        {
            // check if the item is a gun or a rock
            // we set ikActive to true to let the player look as if they are holding the item
            // we set the handObj to be an empty game object on the item which indicates where the player should appear to be holding the item
            if (item.tag == "Gun")
            {
                item.transform.GetChild(17).GetChild(0).gameObject.SetActive(true);
                GetComponent <IkBehaviour>().ikActive = true;
                GetComponent <IkBehaviour>().handObj  = item.transform.GetChild(18);
            }
            else if (item.tag == "Rock")
            {
                GetComponent <IkBehaviour>().ikActive = true;
                GetComponent <IkBehaviour>().handObj  = item.transform.GetChild(0).transform.GetChild(2);
                // sets a fake rock to active so the player can see a rock on their screen to let them know they are holding a rock
                actualCamera.transform.GetChild(0).gameObject.SetActive(true);
            }

            photonView.RPC("PickUpRPC", RpcTarget.Others, item.transform.GetComponent <PhotonView>().ViewID);
            photonView.RPC("PickUpRPCLocal", PhotonNetwork.LocalPlayer, item.transform.GetComponent <PhotonView>().ViewID);
        }
    }
コード例 #3
0
    void PickUpRPCLocal(int itemID)
    {
        // get component by using the item's photon view
        PickUpable item = PhotonView.Find(itemID).GetComponent <PickUpable>();

        // checks if the player has achievement
        if (!PlayerPrefs.HasKey("TheCompletePicture"))
        {
            // the Unachievable class was placed on the tutorial gun and rock outside the station so players could not get the achievement for picking up those objects
            if (item.GetComponent <Unachievable>() == null)
            {
                GetComponent <Achievements>()?.TheCompletePictureCompleted();
            }
        }

        // we make the item's position be the same as the pickup destination on the local player
        item.transform.position = pickUpDestinationLocal.position;
        // if the item is a shootable, we set the canvas to active as we want to see the ammo count
        if (item.GetComponent <Shootable>() != null)
        {
            item.transform.Find("Canvas").gameObject.SetActive(true);
        }
        // set item to be a child of the pickup destination
        item.transform.parent = pickUpDestinationLocal;
        item.transform.Rotate(0, 90, 0);

        item.ItemPickedUp();
    }
コード例 #4
0
ファイル: PickUp.cs プロジェクト: StaticDDQ/DDQ
    void setIsCarry()
    {
        if (Input.GetKeyDown(KeyCode.E))
        {
            int x = Screen.width / 2;
            int y = Screen.height / 2;

            Ray        ray = Camera.main.ScreenPointToRay(new Vector3(x, y));
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, rayLength))
            {
                PickUpable p = hit.collider.GetComponent <PickUpable>();
                if (p != null)
                {
                    IndicatorMethod._instance.EnableIndicator(false);

                    p.carrying = true;

                    if (hit.collider.tag == "pickUp")
                    {
                        bool canAdd = (!pressAgain && ItemDB._instance.AddItem(hit.collider.gameObject.GetComponent <Item>()));
                        Grab(hit.collider.gameObject, canAdd);
                    }
                    else
                    {
                        SetObjectCarry(hit.collider.gameObject);
                        hit.collider.gameObject.layer = 11;
                    }
                }
            }
        }
    }
コード例 #5
0
 private void PickUpable_OnDropped(PickUpable go)
 {
     //Deactivates all glows
     foreach (GameObject slot in slots)
     {
         slot.transform.GetChild(0).gameObject.SetActive(false);
         slot.GetComponent <XZABB>().ClearCheckAgainst();
     }
 }
コード例 #6
0
    private void XZABB_OnXZABBEnter(GameObject go1, GameObject other)
    {
        PickUpable pickUpable = other.GetComponent <PickUpable>();

        if (GetIsValid(pickUpable))
        {
            Animator glowAnimator = slotProvider.GetGlowAnimator();
            glowAnimator.SetBool(glowHoveringParameter, true);
        }
    }
コード例 #7
0
    public void Drag(Draggable item)
    {
        currentHeldItem = item;

        PhotonView view = item.GetComponent <PhotonView>();

        view.TransferOwnership(PhotonNetwork.LocalPlayer);
        gameObject.transform.GetComponent <PlayerMovementPhoton>().Speed = 3f;
        photonView.RPC("DragRPC", RpcTarget.All, item.transform.GetComponent <PhotonView>().ViewID);
    }
コード例 #8
0
 public void Throw(Throwable item)
 {
     // sets the Inverse Kinematics to false so the player's hand can be reset to normal
     GetComponent <IkBehaviour>().ikActive = false;
     // player no longer holding any item
     currentHeldItem = null;
     // resets the item's conditions as it is no longer picked up
     item.ItemDropped(this);
     // disables fake rock
     actualCamera.transform.GetChild(0).gameObject.SetActive(false);
     photonView.RPC("ThrowRPC", RpcTarget.All, item.transform.GetComponent <PhotonView>().ViewID);
 }
コード例 #9
0
    public void Drop(PickUpable Item)
    {
        currentHeldItem = null;
        Item.ResetItemConditions(this);

        if (Item.tag == "Gun")
        {
            Item.transform.GetChild(17).GetChild(0).gameObject.SetActive(false);
        }
        gameObject.transform.GetComponent <PlayerMovementPhoton>().Speed = 4f;
        //Item.transform.parent = GameObject.Find("/Environment/Interactables/Rocks").transform;
        photonView.RPC("DropRPC", RpcTarget.All, Item.transform.GetComponent <PhotonView>().ViewID);
    }
コード例 #10
0
    //Places the pickUpable into the placement location
    public void PlacePickUpable(PickUpable pickUpable)
    {
        if (!GetIsValid(pickUpable))
        {
            return;
        }


        pickUpable.transform.SetParent(slotProvider.GetActiveSlot().transform);
        pickUpable.transform.localPosition = Vector3.zero;

        contents[contentsCount] = pickUpable.gameObject;
        contentsCount++;
    }
コード例 #11
0
    void DropRPC(int ItemID)
    {
        PickUpable Item = PhotonView.Find(ItemID).GetComponent <PickUpable>();

        Item.transform.Rotate(50, 50, 0);
        if (Item.GetComponent <Shootable>() != null)
        {
            Item.transform.parent = GameObject.Find("/Environment/Interactables/Guns").transform;
        }
        else
        {
            Item.transform.parent = GameObject.Find("/Environment/Interactables/DeadGuards").transform;
        }
    }
コード例 #12
0
    public void PickUp(PickUpable Item)
    {
        currentHeldItem = Item;

        PhotonView view = Item.GetComponent <PhotonView>();

        view.TransferOwnership(PhotonNetwork.LocalPlayer);
        //Item.SetItemPickupConditions();

        if (Item.tag == "Gun")
        {
            Item.transform.GetChild(17).GetChild(0).gameObject.SetActive(true);
        }

        photonView.RPC("PickUpRPC", RpcTarget.Others, Item.transform.GetComponent <PhotonView>().ViewID);
        photonView.RPC("PickUpRPCLocal", PhotonNetwork.LocalPlayer, Item.transform.GetComponent <PhotonView>().ViewID);
    }
コード例 #13
0
    void PickUpRPC(int ItemID)
    {
        PickUpable Item = PhotonView.Find(ItemID).GetComponent <PickUpable>();

        Debug.Log("drill");
        //PhotonView view = Item.GetComponent<PhotonView>();
        //view.TransferOwnership(PhotonNetwork.LocalPlayer);
        // Move to players pickup destination.
        Item.transform.position = pickUpDestination.position;

        // Set the parent of the object to the pickupDestination so that it moves
        // with the player.
        Item.transform.parent = pickUpDestination;
        Item.transform.Rotate(0, 90, 0);

        Item.SetItemPickupConditions();
    }
コード例 #14
0
    void DropRPC(int itemID)
    {
        PickUpable item = PhotonView.Find(itemID).GetComponent <PickUpable>();

        item.transform.Rotate(50, 50, 0);
        // sets the Inverse Kinematics to false so the player's hand can be reset to normal
        GetComponent <IkBehaviour>().ikActive = false;
        if (item.GetComponent <Shootable>() != null)
        {
            item.transform.GetChild(17).GetChild(0).gameObject.SetActive(false);
            item.transform.parent = GameObject.Find("/Environment/Interactables/Guns").transform;
            item.transform.Find("Canvas").gameObject.SetActive(false);
        }
        else
        {
            item.transform.parent = GameObject.Find("/Environment/Interactables/DeadGuards").transform;
        }
    }
コード例 #15
0
    private void PickUpable_OnPickedUp(PickUpable pickedUp)
    {
        if (!GetIsValid(pickedUp))
        {
            return;
        }

        slotProvider.GetActiveGlow().SetActive(true);

        XZABB pickedUpXZABB = pickedUp.GetComponent <XZABB>();

        if (pickedUpXZABB == null)
        {
            Debug.Log("An object that was picked up doesn't have a valid XZABB: " + pickedUp.gameObject.name);
        }
        XZABB slotXZABB = slotProvider.GetActiveSlot().GetComponent <XZABB>();

        slotXZABB.AddToCheckAgainst(pickedUpXZABB);
        pickedUpXZABB.AddToCheckAgainst(slotXZABB);
    }
コード例 #16
0
 void pickup()
 {
     if (Input.GetMouseButtonDown(0))
     {
         int        x   = Screen.width / 2;
         int        y   = Screen.height / 2;
         Ray        ray = Camera.main.ScreenPointToRay(new Vector3(x, y));
         RaycastHit hit;
         if (Physics.Raycast(ray, out hit))
         {
             PickUpable p = hit.collider.GetComponent <PickUpable>();
             if (p != null)
             {
                 carrying      = true;
                 carriedObject = p.gameObject;
                 p.gameObject.GetComponentInParent <Rigidbody>().useGravity = false;
             }
         }
     }
 }
コード例 #17
0
    public void Drop(PickUpable item)
    {
        currentHeldItem = null;
        // resets the item's conditions as it is no longer picked up
        item.ItemDropped(this);
        // sets the Inverse Kinematics to false so the player's hand can be reset to normal
        GetComponent <IkBehaviour>().ikActive = false;
        // if item is a gun, disable the canvas
        if (item.tag == "Gun")
        {
            item.transform.GetChild(17).GetChild(0).gameObject.SetActive(false);
        }
        // otherwise disable fake rock
        else
        {
            actualCamera.transform.GetChild(0).gameObject.SetActive(false);
        }

        gameObject.transform.GetComponent <PlayerMovementPhoton>().Speed = 4f;

        photonView.RPC("DropRPC", RpcTarget.All, item.transform.GetComponent <PhotonView>().ViewID);
    }
コード例 #18
0
ファイル: PickUpObject.cs プロジェクト: hyanuary/Remember
    void PickUp()
    {
        if (Input.GetButtonDown("Pick Up"))
        {
            int x = Screen.width / 2;
            int y = Screen.height / 2;

            Ray        ray = mainCamera.ScreenPointToRay(new Vector3(x, y));
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                Debug.DrawLine(ray.origin, hit.point);
                PickUpable p = hit.collider.GetComponent <PickUpable>();
                if (p != null)
                {
                    isCarrying       = true;
                    carriedObject    = p.gameObject;
                    p.rb.isKinematic = true;
                }
            }
        }
    }
コード例 #19
0
    void PickUpRPC(int itemID)
    {
        PickUpable item = PhotonView.Find(itemID).GetComponent <PickUpable>();

        // check if the item is a gun or a rock
        // we set ikActive to true to let the player look as if they are holding the item
        // we set the handObj to be an empty game object on the item which indicates where the player should appear to be holding the item
        if (item.tag == "Gun")
        {
            GetComponent <IkBehaviour>().ikActive = true;
            GetComponent <IkBehaviour>().handObj  = item.transform.GetChild(18);
        }
        else if (item.tag == "Rock")
        {
            GetComponent <IkBehaviour>().ikActive = true;
            GetComponent <IkBehaviour>().handObj  = item.transform.GetChild(0).transform.GetChild(2);
        }
        // set item to be a child of the pickup destination
        item.transform.parent = pickUpDestination;
        item.transform.Rotate(0, 90, 0);

        item.ItemPickedUp();
    }
コード例 #20
0
    public void RemovePickUpable(PickUpable pickUpable)
    {
        int index = Array.IndexOf(contents, pickUpable.gameObject);

        if (index < 0)
        {
            return;
        }

        contents[index] = null;
        contentsCount--;

        //Goes through the lower contents and shifts them all up one
        for (int i = index + 1; i < contentsCount + 1; i++)
        {
            //Gets the first child of the slot object that has a PickUpable attached
            GameObject go = slots[i].GetComponentInChildren <PickUpable>().gameObject;

            //Moves it up one
            go.transform.SetParent(slots[i - 1].transform);
            go.transform.localPosition = Vector3.zero;
            contents[i - 1]            = go;
        }
    }
コード例 #21
0
 private void DisplayInfoObjectPickable(PickUpable item)
 {
     _infoPickUp.text = "Press E to pick up the " + item.cleanName;
     _infoPickUp.gameObject.SetActive(true);
 }
コード例 #22
0
 public void Throw(Throwable Item)
 {
     currentHeldItem = null;
     Item.ResetItemConditions(this);
     photonView.RPC("ThrowRPC", RpcTarget.All, Item.transform.GetComponent <PhotonView>().ViewID);
 }
コード例 #23
0
 //Whether a particular PickUpable can be placed in this location
 public bool GetIsValid(PickUpable pickUpable)
 {
     return(contentsCount < slotsCount);
 }