public override void Process(OpenableStateChanged packet)
        {
            Optional <GameObject> opGameObject = GuidHelper.GetObjectFrom(packet.Guid);

            if (opGameObject.IsPresent())
            {
                Openable openable = opGameObject.Get().GetComponent <Openable>();

                if (openable != null)
                {
                    using (packetSender.Suppress <OpenableStateChanged>())
                    {
                        openable.PlayOpenAnimation(packet.IsOpen, packet.Duration);
                    }
                }
                else
                {
                    Console.WriteLine("Gameobject did not have a corresponding openable to change state!");
                }
            }
            else
            {
                Console.WriteLine("Could not find openable game object with guid: " + packet.Guid);
            }
        }
        public override void Process(OpenableStateChanged packet)
        {
            GameObject gameObject = GuidHelper.RequireObjectFrom(packet.Guid);
            Openable   openable   = gameObject.RequireComponent <Openable>();

            using (packetSender.Suppress <OpenableStateChanged>())
            {
                openable.PlayOpenAnimation(packet.IsOpen, packet.Duration);
            }
        }
Beispiel #3
0
        public static bool Prefix(Openable __instance, bool openState, float duration)
        {
            if (__instance.isOpen != openState)
            {
                NitroxId id = NitroxEntity.GetId(__instance.gameObject);
                NitroxServiceLocator.LocateService <Interior>().OpenableStateChanged(id, openState, duration);
            }

            return(true);
        }
        public static bool Prefix(Openable __instance, bool openState, float duration)
        {
            if (__instance.isOpen != openState)
            {
                String guid = GuidHelper.GetGuid(__instance.gameObject);
                Multiplayer.Logic.Interior.OpenableStateChanged(guid, openState, duration);
            }

            return(true);
        }
Beispiel #5
0
        public static bool Prefix(Openable __instance, bool openState, float duration)
        {
            if (__instance.isOpen != openState)
            {
                string guid = GuidHelper.GetGuid(__instance.gameObject);
                NitroxServiceLocator.LocateService <Interior>().OpenableStateChanged(guid, openState, duration);
            }

            return(true);
        }
Beispiel #6
0
        public static bool Prefix(Openable __instance, bool openState, float duration)
        {
            Console.WriteLine(__instance.gameObject.name);
            Console.WriteLine(__instance.gameObject.transform.parent.gameObject.name);

            if (__instance.isOpen != openState)
            {
                String guid = GuidHelper.GetGuid(__instance.gameObject);
                Multiplayer.Logic.Interior.OpenableStateChanged(guid, openState, duration);
            }

            return(true);
        }
Beispiel #7
0
 public void unpressLever()
 {
     transform.localScale = new Vector3(1f, 0.25f, 1f);
     foreach (GameObject openable in openables)
     {
         Openable script = openable.GetComponent <Openable>();
         if (script.identifier == identifier)
         {
             script.close();
             break;
         }
     }
 }
Beispiel #8
0
 // Use this for initialization
 void Start()
 {
     control = GameObject.FindGameObjectWithTag("Player").GetComponent <Control>();
     a       = openable.GetComponent <Openable>();
     s       = GetComponent <SpriteRenderer>();
     coli    = GetComponent <Collider2D>();
     if (PlayerPrefs.GetInt("Newgame") == 1)
     {
         PlayerPrefs.SetInt(gameObject.name, 0);
     }
     if (PlayerPrefs.GetInt(gameObject.name) == 1)
     {
         Disable();
     }
 }
Beispiel #9
0
    // Use this for initialization
    void Start()
    {
        if (isOpenable)
        {
            openable = new Openable(true, false);
        }
        else
        {
            openable = new Openable(false, false);
        }

        if (openable.isOpen && openSprite != null)
        {
            this.GetComponent <SpriteRenderer>().sprite = openSprite;
        }
        else if (closedSprite != null)
        {
            this.GetComponent <SpriteRenderer>().sprite = closedSprite;
        }
    }
Beispiel #10
0
 public void collisionWithCharacterOccurred()
 {
     transform.localScale = new Vector3(1f, 0.125f, 1f);
     Debug.Log("Lever Hit! Im Lever-Script");
     foreach (GameObject openable in openables)
     {
         Openable script = openable.GetComponent <Openable>();
         if (script.identifier == identifier)
         {
             script.switchStateOfOpenable();
             break;
         }
     }
     foreach (GameObject inv in invisibles)
     {
         MakeInvisibleAfterTime script = inv.GetComponent <MakeInvisibleAfterTime>();
         if (script.identifier == identifier)
         {
             script.disappear();
             break;
         }
     }
 }
Beispiel #11
0
    // Update is called once per frame
    void Update()
    {
        if (cinemachineBrain.ActiveVirtualCamera as CinemachineVirtualCamera != Camera.GetComponent <CinemachineVirtualCamera>())
        {
            return;
        }

        bool canInteract = interactableInRange && !character.HasItem();

        if (canInteract)
        {
            Interactable newInteractable = null;

            try
            {
                newInteractable = interactableObject.GetComponent <Interactable>();
            }
            catch
            {
                //Debug.Log("Interactable is null");
            }


            //currentInteractable = newInteractable;

            if (newInteractable != null)
            {
                //Debug.Log("current interactable has a pick up script");
                if (((Input.GetKeyDown(KeyCode.E) || PoseParser.GETGestureAsString().CompareTo("P") == 0)))
                {
                    if (newInteractable.GetComponent <Breakable>() != null)
                    {
                        //photonView.RPC("SetBreakHandsInactive", GetComponent<PhotonView>().Owner);
                        SetBreakHandsInactive();
                        newInteractable.PrimaryInteraction(character);
                        return;
                    }
                }
                //d is for opening
                //u is closing

                if (Input.GetKeyDown(KeyCode.E))
                {
                    if (newInteractable.GetComponent <Openable>() != null)
                    {
                        newInteractable.PrimaryInteraction(character);
                        return;
                    }
                }

                if (PoseParser.GETGestureAsString().CompareTo("D") == 0)
                {
                    if (newInteractable.GetComponent <Openable>() != null && newInteractable.GetComponent <Openable>().isOpened == false)
                    {
                        newInteractable.PrimaryInteraction(character);
                        return;
                    }
                }

                if (PoseParser.GETGestureAsString().CompareTo("U") == 0)
                {
                    if (newInteractable.GetComponent <Openable>() != null && newInteractable.GetComponent <Openable>().isOpened == true)
                    {
                        newInteractable.PrimaryInteraction(character);
                        return;
                    }
                }

                if ((Input.GetKeyDown(KeyCode.E) || PoseParser.GETGestureAsString().CompareTo("B") == 0) && newInteractable.GetComponent <Breakable>() == null && newInteractable.GetComponent <Openable>() == null)
                {
                    if (newInteractable.GetComponent <Switchable>() != null)
                    {
                        newInteractable.PrimaryInteraction(character);
                    }
                    else if (newInteractable.GetComponent <Droppable>() != null)
                    {
                        newInteractable.PrimaryInteraction(character);
                        //photonView.RPC("SetPressDropToNotActive", GetComponent<PhotonView>().Owner);
                        SetPressDropToNotActive();
                    }
                    else
                    {
                        currentInteractable = newInteractable;
                        currentInteractable.GetComponent <Outline>().enabled = false;
                        // Debug.Log("F was pressed");

                        currentInteractable.PrimaryInteraction(character);
                    }
                }
            }
        }
        // if we are holding something, we are limited to the possible interactions
        else if (currentInteractable != null)
        {
            // check if there is a bag nearby as we can still pickup bags if we are holding an item
            Grabbable  newBag          = null;
            Switchable newSwitch       = null;
            Droppable  dropBag         = null;
            Breakable  breakableObject = null;
            Openable   openableObject  = null;
            try
            {
                newBag = interactableObject.GetComponent <Grabbable>();
            }
            catch
            {
                //Debug.Log("rock is null");
            }

            try
            {
                newSwitch = interactableObject.GetComponent <Switchable>();
            }
            catch
            {
                //Debug.Log("switch is null");
            }

            try
            {
                dropBag = interactableObject.GetComponent <Droppable>();
            }
            catch
            {
                //Debug.Log("switch is null");
            }

            try
            {
                breakableObject = interactableObject.GetComponent <Breakable>();
            }
            catch
            {
                //Debug.Log("breakable is null");
            }

            try
            {
                openableObject = interactableObject.GetComponent <Openable>();
            }
            catch
            {
                //Debug.Log("Opanable is null");
            }
            if ((Input.GetKeyDown(KeyCode.E) || PoseParser.GETGestureAsString().CompareTo("P") == 0) && openableObject != null)
            {
                openableObject.PrimaryInteraction(character);
            }

            if ((Input.GetKeyDown(KeyCode.E) || PoseParser.GETGestureAsString().CompareTo("B") == 0) && newBag != null)
            {
                newBag.PrimaryInteraction(character);
            }

            if ((Input.GetKeyDown(KeyCode.E) || PoseParser.GETGestureAsString().CompareTo("B") == 0) && newSwitch != null)
            {
                newSwitch.PrimaryInteraction(character);
            }

            if (Input.GetKeyDown(KeyCode.E) && dropBag != null)
            {
                dropBag.PrimaryInteraction(character);
                //photonView.RPC("SetPressDropToNotActive", GetComponent<PhotonView>().Owner);
                SetPressDropToNotActive();
            }

            if (Input.GetKeyDown(KeyCode.E) && breakableObject != null)
            {
                breakableObject.PrimaryInteraction(character);
            }
            // press G to drop/throw item
            if (Input.GetKeyDown(KeyCode.G))
            {
                // we drop/throw item and turn off its outline
                currentInteractable.SecondaryInteraction(character);
                currentInteractable.GetComponent <Outline>().enabled = true;
                currentInteractable = null;
            }
            else

            if ((Input.GetMouseButtonDown(0) || PoseParser.GETGestureAsString().CompareTo("R") == 0) && currentInteractable.GetComponent <Throwable>() != null)
            {
                currentInteractable.GetComponent <Throwable>().ThrowRock(character);
                currentInteractable.GetComponent <Outline>().enabled = true;
                currentInteractable = null;
            }
            else
            // if item is shootable
            if (Input.GetMouseButtonDown(0) && currentInteractable.GetComponent <Shootable>() != null)
            {
                //Debug.Log(currentInteractable);
                currentInteractable.GetComponent <Shootable>().ShootGun(character);
            }
        }
    }
Beispiel #12
0
 // sends RPC to all clients to close door and do the animation
 public void Close(Openable item)
 {
     photonView.RPC(nameof(CloseRPC), RpcTarget.All, item.transform.GetComponent <PhotonView>().ViewID);
 }
Beispiel #13
0
 private void openOrClose(Openable openable)
 {
     openable.openOrClose();
 }