コード例 #1
0
    private void Stream_PickupObject(int viewID)
    {
        WieldableCleanableObject toStore = NetworkManager.GetViewByID(viewID).GetComponent <WieldableCleanableObject>();

        toStore.Set_RigidbodyState(true);
        toStore.CanBeInteractedWith = true;
        toStore.transform.SetParent(null);
        toStore.transform.localPosition           = transform.position + transform.forward + transform.up;
        toStore.GetComponent <Collider>().enabled = true;
        timer = 0;
        return;
    }
コード例 #2
0
    private void FixedUpdate()
    {
        collisions = Physics.OverlapSphere(transform.position + transform.TransformDirection(offset), RADIUS, TARGETMASK);
        bool collidedWithAnother = false;

        if (collisions.Length > 0)
        {
            for (int i = 0; i < collisions.Length; i++)
            {
                if (collisions[i].transform.parent.gameObject.GetPhotonView().Owner != PhotonNetwork.LocalPlayer)
                {
                    if (!AlreadyDetected(collisions[i].transform.parent.gameObject.GetPhotonView().ViewID))
                    {
                        const string TARGET_METHOD_NAME = "Stream_StunPlayer";
                        const int    FORCE = 500;

                        Player owner = collisions[i].transform.parent.gameObject.GetPhotonView().Owner;

                        hitPhotonIds.Add(collisions[i].transform.parent.gameObject.GetPhotonView().ViewID);

                        collisions[i].transform.parent.gameObject.GetPhotonView().RPC(TARGET_METHOD_NAME, owner,

                                                                                      //---Parameters---//
                                                                                      PUNISHMENT_DURATION,
                                                                                      transform.forward * FORCE,
                                                                                      NetworkManager.localPlayerInformation.team
                                                                                      );

                        collisions[i].transform.parent.GetComponent <Rigidbody>().AddForceAtPosition(transform.forward * FORCE, transform.position);
                        collidedWithAnother = true;
                    }
                }
            }
        }

        if (collidedWithAnother)
        {
            if (OwningObject.GetType() == typeof(WieldableCleanableObject))
            {
                WieldableCleanableObject currentCleanableWieldable = (WieldableCleanableObject)OwningObject;
                PlayerManager            manager = ServiceLocator.GetServiceOfType <PlayerManager>();

                manager.player_InteractionController.DropObject(manager.player_InteractionController.currentlyWielding);
                currentCleanableWieldable.BreakObject();
            }
        }
    }
コード例 #3
0
    public static void AddInteractableToObservedLists(WieldableCleanableObject wieldableCleanableObject = null, CleanableObject cleanableObject = null)
    {
        if (wieldableCleanableObject == null && cleanableObject == null)
        {
            throw new Exception($"You must pass 1 of the parameters...");
        }

        if (wieldableCleanableObject != null)
        {
            wieldableCleanableObjects.Add(wieldableCleanableObject);
        }

        if (cleanableObject != null)
        {
            cleanableObjects.Add(cleanableObject);
        }
    }
コード例 #4
0
    public override void Interact(PlayerInteractionController interactionController)
    {
        DeInteract(interactionController);

        if (IsLocked == true)
        {
            return;
        }

        LockTemporarily();

        if (interactionController.currentlyWielding)
        {
            if (DoesAllowForObjectID(interactionController.currentlyWielding.toolID))
            {
                if (interactionController.currentlyWielding.GetType() == typeof(WieldableCleanableObject))
                {
                    WieldableCleanableObject wieldable = (WieldableCleanableObject)interactionController.currentlyWielding;

                    if (wieldable.isCleaned)
                    {
                        interactionController.DropObject(wieldable);
                        wieldable.StoreObject();

                        ObjectPool.Set_ObjectBackToPool(wieldable.photonView.ViewID);
                        return;
                    }

                    Set_DisplayStateTooltip((int)TooltipType.NotCleanedItem);
                }

                //NOTE: No Warning here because we assume that the storage can only store cleanable objects...
            }

            Set_DisplayStateTooltip((int)TooltipType.WrongItem);
            return;
        }

        Set_DisplayStateTooltip((int)TooltipType.NoItem);
        return;
    }
コード例 #5
0
    private void Stream_StoreObject(int viewID, bool isBeingPooledFrom)
    {
        WieldableCleanableObject toStore = NetworkManager.GetViewByID(viewID).GetComponent <WieldableCleanableObject>();

        toStore.Set_RigidbodyState(!isBeingPooledFrom);
        toStore.CanBeInteractedWith = isBeingPooledFrom;

        if (isBeingPooledFrom)
        {
            toStore.transform.SetParent(null);
            toStore.transform.localPosition           = transform.position + transform.forward + transform.up;
            toStore.GetComponent <Collider>().enabled = true;
            timer = 0;
            return;
        }

        allContainedObjects.Add(toStore.transform);

        toStore.transform.SetParent(storagePlaces[allContainedObjects.Count - 1]);
        toStore.transform.localPosition           = Vector3.zero;
        toStore.transform.localEulerAngles        = Vector3.zero;
        toStore.GetComponent <Collider>().enabled = false;
    }
コード例 #6
0
    public override void Interact(PlayerInteractionController interactionController)
    {
        if (currentState == StateOfObject.Washing || ownedByTeam != (OwnedByTeam)NetworkManager.localPlayerInformation.team)
        {
            Set_DisplayStateTooltip((int)TooltipType.BusyWashing);
            DeInteract(interactionController);
            return;
        }

        photonView.TransferOwnership(PhotonNetwork.LocalPlayer);

        if (currentState == StateOfObject.Inactive)
        {
            if (interactionController.currentlyWielding)
            {
                if (acceptedItemIds.Contains(interactionController.currentlyWielding.toolID))
                {
                    if (allContainedObjects.Count < maxSlotsAvailable)
                    {
                        if (!allContainedObjects.Contains(interactionController.currentlyWielding.transform))
                        {
                            int viewID = interactionController.currentlyWielding.photonView.ViewID;

                            interactionController.DropObject(interactionController.currentlyWielding);
                            Set_StoreObject(viewID, false);

                            Set_DishwasherOpenState(true);
                            return;
                        }
                    }

                    Set_DisplayStateTooltip((int)TooltipType.ObjectIsFull);
                    return;
                }

                Set_DisplayStateTooltip((int)TooltipType.WrongItemInHands);
                return;
            }

            if (allContainedObjects.Count > 0)
            {
                StartWashing();
                Set_DishwasherOpenState(false);
                return;
            }

            Set_DisplayStateTooltip((int)TooltipType.StorageEmpty);
        }

        if (currentState == StateOfObject.Done)
        {
            if (interactionController.currentlyWielding == null)
            {
                if (allContainedObjects.Count > 0)
                {
                    Set_DishwasherOpenState(true);

                    WieldableCleanableObject toStore = NetworkManager.GetViewByID(allContainedObjects[0].gameObject.GetPhotonView().ViewID).GetComponent <WieldableCleanableObject>();

                    Set_PickupObject(allContainedObjects[0].gameObject.GetPhotonView().ViewID);
                    Set_GrabItemFromObject(allContainedObjects[0].gameObject.GetPhotonView().ViewID);

                    toStore.transform.localPosition = Vector3.zero;

                    interactionController.currentSelected = this;

                    if (allContainedObjects.Count == 0)
                    {
                        if (postcleanLoop != null)
                        {
                            StopCoroutine(postcleanLoop);
                        }

                        Set_EnableStateWarningProgressbar(false);
                        Set_StateOfObject(StateOfObject.Inactive);
                    }

                    toStore.Interact(interactionController);
                    return;
                }
            }

            Set_DisplayStateTooltip((int)TooltipType.HandsFull);
        }
    }