Container.OpenContainer C# (CSharp) Method

OpenContainer() public method

public OpenContainer ( ) : void
return void
    public void OpenContainer()
    {
        GameWorldController.instance.playerUW.playerInventory.ContainerOffset=0;
        ScrollButtonStatsDisplay.ScrollValue=0;
        ObjectInteraction currObjInt = this.gameObject.GetComponent<ObjectInteraction>();
        if (currObjInt.PickedUp==false)
            {//The requested container is open in the game world. This can cause problems!
            //Debug.Log ("Opening a container in the real world");
            SpillContents();
            return;
            }
        //Sort the container
        Container.SortContainer(this);
        //GameObject.Find("ContainerOpened").GetComponent<UITexture>().mainTexture=currObjInt.GetEquipDisplay().texture;
        UWHUD.instance.ContainerOpened.GetComponent<RawImage>().texture=currObjInt.GetEquipDisplay().texture;
        if (this.isOpenOnPanel==false)
        {
            this.isOpenOnPanel=true;
            ContainerParent=GameWorldController.instance.playerUW.playerInventory.currentContainer;
        }
        GameWorldController.instance.playerUW.playerInventory.currentContainer=this.name;
        if (GameWorldController.instance.playerUW.playerInventory.currentContainer=="")
        {
            GameWorldController.instance.playerUW.playerInventory.currentContainer=GameWorldController.instance.playerUW.name;
            this.ContainerParent=GameWorldController.instance.playerUW.name;
        }
        for (int i = 0; i<8; i++)
        {
            string sItem = this.GetItemAt(i);
            GameWorldController.instance.playerUW.playerInventory.SetObjectAtSlot(i+11,sItem);
        }
        UWHUD.instance.ContainerOpened.GetComponent<ContainerOpened>().BackpackBg.SetActive(true);
        if (CountItems()>=8)
        {
            UWHUD.instance.ContainerOpened.GetComponent<ContainerOpened>().InvUp.SetActive(true);
            UWHUD.instance.ContainerOpened.GetComponent<ContainerOpened>().InvDown.SetActive(true);
        }
        else
        {
            UWHUD.instance.ContainerOpened.GetComponent<ContainerOpened>().InvUp.SetActive(false);
            UWHUD.instance.ContainerOpened.GetComponent<ContainerOpened>().InvDown.SetActive(false);
        }
    }

Usage Example

Esempio n. 1
0
    public override bool Use(GameObject caller)
    {
        //Check if we are within a container
        var       chests    = GameObject.FindGameObjectsWithTag("Chest");
        Container container = null;

        foreach (var chest in chests)
        {
            var cont = chest.GetComponent <Container>();
            if (cont != null && cont.playerNearby)
            {
                container = cont;
            }
        }
        if (container != null)
        {
            if (container.KeyType == KeyType)
            {
                container.OpenContainer();
                return(true);
            }
        }
        // We were unable to use the key
        return(false);
    }
All Usage Examples Of Container::OpenContainer