예제 #1
0
    // Update is called once per frame
    void Update()
    {
        if (!isLocalPlayer)   // networking related: this makes only local player controlled by this script
        {
            return;
        }
        if (Input.GetKeyDown(KeyCode.E))
        {
            active = !active;

            if (!active)
            {
                // This is not good because this reads from the UI to the character
                // inventory component. This should happen before this point
                // and all that should be needed is the foreach loop below.
                GetComponent <UICharacterInventoryFactory> ().DestroyFactoryItem();

                InteractUtility.InteractEnd(gameObject);
            }

            // TEMPORARY At some point soon this code will not work because the health bar
            // should always display.
            foreach (Transform t in Canvas.transform)
            {
                Destroy(t.gameObject);
            }
            if (active)
            {
                InteractUtility.InteractStart(gameObject);

                GetComponent <UITabsFactory> ().CreateFactoryItem();
                if (GetComponent <PlayerSettings>().rememberUIState)
                {
                    if (UIState.uiState == UIState.UIStateEnum.Inventory)
                    {
                        GetComponent <UICharacterInventoryFactory> ().CreateFactoryItem(slotItemPrefab);
                    }
                    else if (UIState.uiState == UIState.UIStateEnum.QuestLog)
                    {
                        GetComponent <UIQuestLogFactory> ().CreateFactoryItem();
                    }
                    else if (UIState.uiState == UIState.UIStateEnum.Options)
                    {
                        GetComponent <UIOptionsFactory> ().CreateFactoryItem();
                    }
                }
                else
                {
                    GetComponent <UICharacterInventoryFactory> ().CreateFactoryItem(slotItemPrefab);
                    UIState.uiState = UIState.UIStateEnum.Inventory;
                }
            }
        }
    }
예제 #2
0
    private void DestoryFactoryItem()
    {
        GetComponent <Container> ().PopulateContainerWithUIData(references[0]);

        InteractUtility.InteractEnd(PlayerReference);
        PlayerReference.GetComponent <PlayerMovementController> ().enabled = true;
        PlayerReference.GetComponent <UICharacterInventoryFactory> ().DestroyFactoryItem();
        PlayerReference.GetComponent <UIInputHandler> ().enabled = true;
        PlayerReference.GetComponent <UITabsFactory> ().enabled  = true;
        Destroy(references[0]);
        references.Clear();
        enabled = false;
    }
예제 #3
0
    public bool Interact(GameObject gameobject)
    {
        InteractUtility.InteractStart(gameobject);

        // Tell the gameobject that interacted with this to draw its inventory
        gameobject.GetComponent <UICharacterInventoryFactory> ().CreateFactoryItem(slotItemPrefab);

        gameobject.GetComponent <PlayerMovementController> ().enabled = false;

        // Disable factory input.
        gameobject.GetComponent <UIInputHandler> ().enabled = false;

        // Create the inventory.
        uiContainerFactory.CreateFactoryItem(inventory, gameobject);
        uiContainerFactory.enabled = true;
        return(true);
    }