Exemplo n.º 1
0
        protected override void Init(CompoundTag nbt)
        {
            this.Inventory = new ChestInventory(this);
            this.Inventory.LoadNBT(nbt);

            base.Init(nbt);
        }
 // Start is called before the first frame update
 void Start()
 {
     Chestinventory = ChestInventory.instance;
     Chestinventory.onItemChangedCallBackChest += updateUI;
     slots = itemsParent.GetComponentsInChildren <InventorySlot>();
     updateUI();
 }
Exemplo n.º 3
0
    public void UpdateUI()
    {
        chestInventory = this.GetComponent <ChestInventory>();

        slots = itemsParent.GetComponentsInChildren <ChestInventorySlot>();

        //Debug.Log("Updating chest inventory UI");


        for (int i = 0; i < slots.Length; i++)
        {
            //Check if slot has item using its index.
            if (chestInventory.itemAtIndex.ContainsKey(i))
            {
                //Get the item.
                Item item;
                chestInventory.itemAtIndex.TryGetValue(i, out item);

                //Add the item in the slot.
                slots[i].AddItem(item, chestInventory.itemsCount[i]);
            }
            else
            {
                slots[i].ClearSlot();
            }
        }
    }
Exemplo n.º 4
0
 // Start is called before the first frame update
 void Awake()
 {
     instance = this;
     //items = new List<Item>();
     ui                    = GetComponent <ChestUI>();
     render                = GetComponent <CanvasGroup>();
     render.alpha          = 0f;
     render.blocksRaycasts = false;
 }
Exemplo n.º 5
0
 private void Awake()
 {
     if (instance != null)
     {
         Debug.Log("plus d'une instance de coffre trouvé");
         return;
     }
     instance = this;
     DontDestroyOnLoad(instance);
 }
Exemplo n.º 6
0
 private void Start()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Debug.LogError("Duplicate " + this.GetType().Name);
         Destroy(gameObject);
     }
     gameObject.SetActive(false);
 }
        public void PacketReceive_ChestInventory_EventCanceled()
        {
            var packet = new ChestInventory
            {
                ChestIndex = 5,
                Id         = ItemId.Sdmg,
                StackSize  = 1,
                Prefix     = ItemPrefix.Unreal
            };
            var sender = Mock.Of <IPlayer>();

            PacketReceive_EventCanceled <ChestInventory, ChestInventoryEvent>(packet, sender);
        }
Exemplo n.º 8
0
    // Start is called before the first frame update
    void Start()
    {
        canvas = CanvasInstance.instance.transform;

        /*if (inventory == null)
         * {
         *  inventory = Instantiate(invPrefab);
         *  inventory.transform.SetParent(canvas.transform);
         *  inventory.transform.position = new Vector3(230, 150, 0);
         *  inventory.transform.localScale = new Vector3(1, 1);
         *
         * }*/
        inventory = ChestInventory.instance;
    }
Exemplo n.º 9
0
        public BlockEntityChest(Position position, CompoundTag nbt = null) : base(position, nbt)
        {
            this.Inventory = new ChestInventory(this);

            if (!this.NamedTag.Exist("items"))
            {
                this.NamedTag.PutList(new ListTag("items", NBTTagType.COMPOUND));
            }

            ListTag items = this.NamedTag.GetList("items");

            for (int i = 0; i < items.Count; ++i)
            {
                this.Inventory.SetItem(i, NBTIO.ReadItem((CompoundTag)items[i]));
            }
        }
Exemplo n.º 10
0
        public void PacketReceive_ChestInventory_EventTriggered()
        {
            Terraria.Main.chest[5] = new Terraria.Chest();

            var packet = new ChestInventory
            {
                ChestIndex = 5,
                Id         = ItemId.Sdmg,
                StackSize  = 1,
                Prefix     = ItemPrefix.Unreal
            };
            var sender = Mock.Of <IPlayer>();

            PacketReceive_EventTriggered <ChestInventory, ChestInventoryEvent>(packet, sender,
                                                                               evt => evt.Player == sender && ((OrionChest)evt.Chest).Wrapped == Terraria.Main.chest[5] &&
                                                                               evt.Item == new ItemStack(ItemId.Sdmg, ItemPrefix.Unreal, 1));
        }
Exemplo n.º 11
0
        private void OpenChest()
        {
            if (isCreated == false)
            {
                insInventory = Help.HelpFunctions.TransformSeer.CreateObjectInParent(DinamicUI._instance.transform, chestPrefab.gameObject, chestPrefab.name).GetComponent <ChestInventory>();
                insInventory.currentItems = startItems;

                insInventory.buttonClose?.onClick.AddListener(() => CloseChest());
                insInventory.buttonTakeAll?.onClick.AddListener(delegate { EmptiedChest(); CloseChest(); });

                isCreated = true;

                onCreated.Invoke();
            }
            else
            {
                insInventory.ShowInventory();
            }
        }
Exemplo n.º 12
0
	/**
	 * The Start method is called automatically by Monobehaviours,
	 * essentially becoming the constructor of the class.
	 * <p>
	 * See <a href="http://docs.unity3d.com/ScriptReference/MonoBehaviour.Start.html">docs.unity3d.com</a> for more information.
	 */
    private void Start() {
        animator = GetComponent<Animator>();
        animator.speed = 4.0f;

        audioSource = GetComponent<AudioSource>();

        GameObject _Inventory = GameObject.Find("Inventory");

        inventory = Instantiate(ChestInventory).GetComponent<ChestInventory>();
        inventory.transform.SetParent(_Inventory.transform);
        inventory.Initialize();

        GameObject chestHeader = Instantiate(ChestHeader);
        chestHeader.transform.SetParent(_Inventory.transform);
        inventory.header = chestHeader;

        inventory.ResetPosition();

        for (int i = 0; i < ItemsToAdd.Count; i++) {
            inventory.AddItem(ItemsToAdd[i], ItemAmounts[i]);
        }

        Close();
    }
Exemplo n.º 13
0
 // Start is called before the first frame update
 void Awake()
 {
     inventory = this.gameObject.GetComponent <ChestInventory>();//Equipment.instance.playerInventory;
     slots     = itemsParent.GetComponentsInChildren <InventorySlot>();
 }
Exemplo n.º 14
0
 void Start() {
     linkedInventory = GameObject.Find("VendorBackground").GetComponent<VendorInventory>();
     allSlots = new List<Stack<ItemScript>>();
 }