Beispiel #1
0
    public void DropObject(WieldableObject wieldableObject)
    {
        if (currentlyWielding != null)
        {
            const int HAND_LAYER = 1;

            if (currentlyWielding.GetComponent <StunComponent>())
            {
                Destroy(currentlyWielding.GetComponent <StunComponent>());
            }

            playerAnimator.SetLayerWeight(HAND_LAYER, 0);

            currentlyWielding.UnlockObjectManually();
            currentlyWielding = null;

            if (NetworkManager.IsConnectedAndInRoom)
            {
                photonView.RPC(nameof(Cast_ThrowObject), RpcTarget.AllBuffered, wieldableObject.gameObject.GetPhotonView().ViewID, forceDrop);

                if (currentlyInteracting)
                {
                    currentlyInteracting.DeInteract(this);
                }

                forceDrop = false;
                return;
            }
        }
    }
Beispiel #2
0
    public void PickupObject(WieldableObject wieldableObject, Vector3 localHandOffset, Vector3 localRotationOffset)
    {
        const string HANDED_BOOL_NAME = "is2h";

        int  targetViewID      = wieldableObject.handedType == WieldableObject.Handed_Type.H1Handed ? 0 : 1;
        bool targetHandedState = wieldableObject.handedType != WieldableObject.Handed_Type.H1Handed;

        playerAnimator.SetBool(HANDED_BOOL_NAME, targetHandedState);

        if (currentlyWielding == null)
        {
            currentlyWielding = wieldableObject;

            if (NetworkManager.IsConnectedAndInRoom)
            {
                photonView.RPC(nameof(Cast_PickupObject), RpcTarget.AllBuffered,
                               targetViewID,
                               wieldableObject.gameObject.GetPhotonView().ViewID,
                               localRotationOffset,
                               localHandOffset
                               );
                return;
            }

            Cast_PickupObject(
                targetViewID,
                wieldableObject.gameObject.GetPhotonView().ViewID,
                localRotationOffset,
                localHandOffset
                );
        }
    }
    private void Stream_ExplosionParticles()
    {
        const string EXPLOSION_VFX = "Explosion_VFX";
        const string POOP_OBJ_NAME = "Poo [Interactable]";

        Instantiate(Resources.Load(EXPLOSION_VFX) as GameObject, transform.position, Quaternion.identity);

        playerManager = ServiceLocator.GetServiceOfType <PlayerManager>();

        if (playerManager.player_InteractionController.currentlyWielding == this)
        {
            WieldableObject toDrop = playerManager.player_InteractionController.currentlyWielding;

            playerManager.player_Controller.StunPlayer(5);
            playerManager.player_InteractionController.DropObject(toDrop);
        }

        if (PhotonNetwork.LocalPlayer.IsMasterClient)
        {
            PhotonNetwork.InstantiateSceneObject(POOP_OBJ_NAME, transform.position, Quaternion.identity);
        }

        if (photonView.IsMine)
        {
            PhotonNetwork.Destroy(photonView);
        }
    }
    public override void Interact(PlayerInteractionController interactionController)
    {
        #region ### Base Checks ###
        if (IsLocked || IsRefreshed == false)
        {
            DeInteract(interactionController);
            return;
        }

        if (playerManager == null)
        {
            playerManager = ServiceLocator.GetServiceOfType <PlayerManager>();
            return;
        }

        LockLocallyOnTimer();
        #endregion

        if (playerManager.player_InteractionController.currentlyWielding != null)
        {
            if (playerManager.player_InteractionController.currentlyWielding.toolID == POOP_ITEM_ID)
            {
                WieldableObject wieldedItem = playerManager.player_InteractionController.currentlyWielding;

                playerManager.player_InteractionController.DropObject(wieldedItem);
                PhotonNetwork.Destroy(wieldedItem.gameObject.GetPhotonView());
                Set_VFX();
                return;
            }

            Set_DisplayIcon(ToDisplay.WrongItemIcon);
            return;
        }

        Set_DisplayIcon(ToDisplay.NoItemIcon);
    }