Exemplo n.º 1
0
    public void UseStart(GameObject user)
    {
        if (user == null || string.IsNullOrEmpty(triggerObjectName))
        {
            return;
        }

        Inventory userInventory = (Inventory)user.GetComponent <PlayerInventory>().playerInventory;

        if (userInventory != null)
        {
            ObjectPickup inventoryItem = userInventory.Remove(triggerObjectName);
            if (inventoryItem == null)
            {
                Debug.Log("Did not find " + triggerObjectName + " in your inventory");
                return;
            }

            if (!user.GetComponent <GhostController>().isGhost)
            {
                InventoryUIController uiInventory = (InventoryUIController)Transform.FindObjectOfType <InventoryUIController>();
                if (uiInventory != null)
                {
                    Debug.Log("Found InventoryUIController");
                    uiInventory.RemoveFromInventoryPanel(inventoryItem);
                }
            }

            // inventoryItem.gameObject.SetActive(true);
            // inventoryItem.transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z - 1f);
            Debug.Log("--- objectInventory ---");
            objectInventory.Add(inventoryItem);
            objectInventory.LogInventory();
        }
    }
Exemplo n.º 2
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
Exemplo n.º 3
0
        protected void OpenInventory(int cnt, List <StuffItem> itemList)
        {
            MapUIContainer.ReserveSystemMenuMode(SystemMenuUI.MenuMode.InventoryEnter);
            SystemMenuUI          systemUI    = MapUIContainer.SystemMenuUI;
            InventoryUIController inventoryUI = systemUI.InventoryEnterUI;

            inventoryUI.isConfirm = true;
            inventoryUI.CountViewerVisible(true);
            inventoryUI.itemList = (Func <List <StuffItem> >)(() => itemList);
            inventoryUI.SetItemFilter(InventoryBase.ToFilter(this.GetArgToSplitLastTable(cnt)));
            inventoryUI.OnSubmit = (Action <StuffItem>)(item =>
            {
                this.Item = item;
                InventoryUIController inventoryUiController = inventoryUI;
                if (inventoryUiController == null)
                {
                    return;
                }
                inventoryUiController.OnClose();
            });
            inventoryUI.OnClose = (Action)(() =>
            {
                inventoryUI.OnSubmit = (Action <StuffItem>)null;
                inventoryUI.IsActiveControl = false;
                systemUI.IsActiveControl = false;
                Singleton <Input> .Instance.FocusLevel = 0;
                Singleton <Input> .Instance.ReserveState(Input.ValidType.UI);
                this.isClose = true;
                inventoryUI.OnClose = (Action)null;
            });
            MapUIContainer.SetActiveSystemMenuUI(true);
        }
Exemplo n.º 4
0
    // Add this controller to any game object that the player can pick up and hold in their inventory.  The object
    // must have UsableObjectTpl template with the object as the target of UsableObjectCS.  To enable the player to pick up the item, add the
    // PlayerInventory controller (Assets/CommonScripts/Inventory/PlayerInventory.cs) to the player's controllers.

    public void Pickup(GameObject user)
    {
        Inventory inventory = (Inventory)user.GetComponent <PlayerInventory>().playerInventory;

        if (inventory == null)
        {
            return;
        }

        inventory.Add(this);
        inventory.LogInventory();
        this.gameObject.SetActive(false);

        if (!user.GetComponent <GhostController>().isGhost)
        {
            InventoryUIController uiInventory = (InventoryUIController)Transform.FindObjectOfType <InventoryUIController>();
            if (uiInventory == null)
            {
                Debug.Log("Couldn't find InventoryUIController");
                return;
            }

            uiInventory.AddToInventoryPanel(this);
        }
    }
Exemplo n.º 5
0
 void Start()
 {
     //uIInventory = FindObjectOfType<UIInventory>();
     levelController     = FindObjectOfType <LevelController>();
     isActive            = false;
     inventoryController = FindObjectOfType <InventoryUIController>();
 }
Exemplo n.º 6
0
 private void Awake()
 {
     PV = transform.root.GetComponent <PhotonView>();
     if (Instance == null)
     {
         Instance = this;
     }
 }
Exemplo n.º 7
0
 private void Start()
 {
     uIInventory = GetComponentInParent <UIInventory>();
     //quantityText = transform.parent.GetComponentInChildren<Text>();
     //spriteImage = GetComponent<Image>();
     itemQuantityFull    = false;
     inventory           = FindObjectOfType <Inventory>();
     inventoryController = FindObjectOfType <InventoryUIController>();
     UpdateItem(null, 0);
 }
        public IEnumerator InventoryUIControllerOnInventoryOpenTest()
        {
            game      = MonoBehaviour.Instantiate(Resources.Load <GameObject>("Game"));
            inventory = GameObject.FindObjectOfType <InventoryUIController>();
            yield return(new WaitForSecondsRealtime(1f));

            inventory.OnInventoryOpen();
            yield return(new WaitForSecondsRealtime(1f));

            Assert.IsTrue(inventory.isActiveAndEnabled);
        }
Exemplo n.º 9
0
    // Use this for initialization
    void Start()
    {
        inventory = new Dictionary <InteractableController.ActivateType, bool>();
        for (int i = InteractableController.ITEM_START - 1; i < InteractableController.ACTIVATE_LENGTH; i++)
        {
            inventory.Add((InteractableController.ActivateType)i, false);
        }
        ui = inventoryUIController.GetComponent <InventoryUIController>();

        timer = 0.00f;
    }
Exemplo n.º 10
0
 public void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else if (Instance != this)
     {
         Destroy(gameObject);
     }
 }
Exemplo n.º 11
0
        public IEnumerator InventoryUIControllerOnPotionSelectTest()
        {
            game      = MonoBehaviour.Instantiate(Resources.Load <GameObject>("Game"));
            inventory = GameObject.FindObjectOfType <InventoryUIController>();
            yield return(new WaitForSecondsRealtime(1f));

            inventory.OnInventoryOpen();
            yield return(new WaitForSecondsRealtime(1f));

            inventory.OnPotionSelect(GameObject.Find("Canvas").transform.Find("Inventory").transform.Find("Potions").Find("SmallHPCell").gameObject);
            yield return(new WaitForSecondsRealtime(1f));

            Assert.IsTrue(inventory.UseButton.isActiveAndEnabled);
            Assert.IsFalse(inventory.DropButton.interactable);
            Assert.IsFalse(inventory.EquipButton.interactable);
            Assert.IsFalse(inventory.TakeOffButton.interactable);
        }
Exemplo n.º 12
0
        public IEnumerator InventoryUIControllerOnEquipedSelectTest()
        {
            game      = MonoBehaviour.Instantiate(Resources.Load <GameObject>("Game"));
            inventory = GameObject.FindObjectOfType <InventoryUIController>();
            yield return(new WaitForSecondsRealtime(1f));

            var db = Camera.main.GetComponent <DataBase>();

            inventory.Inventory.Items[12] = db.Swords[0];
            inventory.OnInventoryOpen();
            yield return(new WaitForSecondsRealtime(1f));

            inventory.OnEquipedSelect(GameObject.Find("Canvas").transform.Find("Inventory").transform.Find("Equiped").Find("WeaponCell").gameObject);
            yield return(new WaitForSecondsRealtime(1f));

            Assert.IsFalse(inventory.UseButton.interactable);
            Assert.IsTrue(inventory.DropButton.isActiveAndEnabled);
            Assert.IsFalse(inventory.EquipButton.interactable);
            Assert.IsTrue(inventory.TakeOffButton.isActiveAndEnabled);
        }
Exemplo n.º 13
0
 void Awake()
 {
     /****** Finds the InventoryUIController or adds one *******/
     if (this.gameObject.GetComponent <InventoryUIController> () != null)
     {
         iuic = this.gameObject.GetComponent <InventoryUIController> ();
     }
     else
     {
         iuic = this.gameObject.AddComponent(typeof(InventoryUIController)) as InventoryUIController;
     }
     if (this.gameObject.GetComponent <ScoreSystem> () != null)
     {
         ss = this.gameObject.GetComponent <ScoreSystem> ();
     }
     else
     {
         ss = this.gameObject.AddComponent(typeof(ScoreSystem)) as ScoreSystem;
     }
 }
Exemplo n.º 14
0
        public IEnumerator InventoryUIControllerOnItemRemoveTest()
        {
            game      = MonoBehaviour.Instantiate(Resources.Load <GameObject>("Game"));
            inventory = GameObject.FindObjectOfType <InventoryUIController>();
            yield return(new WaitForSecondsRealtime(1f));

            var db = Camera.main.GetComponent <DataBase>();

            inventory.Inventory.Items[12] = db.Swords[0];
            inventory.OnInventoryOpen();
            yield return(new WaitForSecondsRealtime(1f));

            var cell = GameObject.Find("Canvas").transform.Find("Inventory").transform.Find("Equiped").Find("WeaponCell").gameObject;

            inventory.OnEquipedSelect(cell);
            yield return(new WaitForSecondsRealtime(0.5f));

            inventory.OnItemRemove();
            yield return(new WaitForSecondsRealtime(0.5f));

            var item = cell.transform.Find("Button").GetComponent <Button>();

            Assert.IsFalse(item.isActiveAndEnabled);
        }
Exemplo n.º 15
0
 void Awake()
 {
     Instance = this;
 }
Exemplo n.º 16
0
 // Use this for initialization
 void Start()
 {
     data       = GameObject.FindGameObjectWithTag("GameData");
     InvControl = data.GetComponent <InventoryUIController>();
 }
Exemplo n.º 17
0
 public void SetuUpVars()
 {
     inventoryController = FindObjectOfType <InventoryUIController>();
     levelController     = FindObjectOfType <LevelController>();
 }