Exemplo n.º 1
0
 void RenderBasicItemConsumedByPentagram(BasicItem item)
 {
     if (item.GetComponentInChildren <Light>())
     {
         item.GetComponentInChildren <Light>().color = activatedColor;
     }
     item.GetComponent <BoxCollider>().enabled          = false;
     item.GetComponent <IsometricObject>().TargetOffset = -290;
 }
Exemplo n.º 2
0
 protected override void OnPointerClick(BasicItem _item, PointerEventData _eventData)
 {
     if (Interpreter._instance.isReadAssignments)
     {
         return;
     }
     if (!_item.IsEmpty() && WhithClicks)
     {
         if (InventoryOverseer._instance.put == null)
         {
             InventoryOverseer._instance.put = InventoryOverseer._instance.programmingContainers[1];
         }
         if (InventoryOverseer._instance.put.gameObject.activeSelf)
         {
             int counter = 0;
             for (int i = 0; i < InventoryOverseer._instance.programmingContainers.Count; i++)
             {
                 Container temp = InventoryOverseer._instance.programmingContainers[i];
                 if (!temp.isFull() && temp.gameObject.activeSelf)
                 {
                     InventoryOverseer._instance.put = temp;
                     break;
                 }
                 else
                 {
                     counter++;
                 }
             }
             if (counter != InventoryOverseer._instance.programmingContainers.Count)
             {
                 InventoryOverseer._instance.put.AddItem(_item.Item);
             }
         }
         else
         {
             int counter = 0;
             for (int i = 0; i < InventoryOverseer._instance.programmingContainers.Count; i++)
             {
                 Container temp = InventoryOverseer._instance.programmingContainers[i];
                 if (!temp.isFull() && temp.gameObject.activeSelf)
                 {
                     InventoryOverseer._instance.put = temp;
                     break;
                 }
                 else
                 {
                     counter++;
                 }
             }
             if (counter != InventoryOverseer._instance.programmingContainers.Count)
             {
                 InventoryOverseer._instance.put.AddItem(_item.Item);
             }
             //OpenCloseFunction._instance.DeleteDisabledFunctions();
         }
     }
 }
Exemplo n.º 3
0
 void OnGUI()
 {
     if (GUI.Button(new Rect(10, 10, 150, 100), "Add item"))
     {
         BasicItem item = new BasicItem("Test Item", "BasicIcon");
         item.Amount     = (ushort)Random.Range(1, 10);
         item.Durability = Random.Range(0.1f, 1.0f);
         mainContainer.AddItemAsASingleStack(item);
     }
 }
Exemplo n.º 4
0
    // Returns the item of a given slot index, or null if such item doesn't exist
    public BasicItem GetItemOfSlotIndex(int slotIndex)
    {
        BasicItem item = null;

        if (items.TryGetValue(slotIndex, out item))
        {
            return(item);
        }
        return(item);
    }
Exemplo n.º 5
0
 public void PlaceItem(BasicItem item)
 {
     //item.transform.position = ItemPos.position;
     //item.transform.rotation = ItemPos.rotation;
     //item.transform.localScale = ItemPos.localScale;
     //item.gameObject.SetActive(true);
     item.PlacedAtPedestal();
     Destroy(item);
     Destroy(transform.parent.gameObject);
 }
Exemplo n.º 6
0
        private void BasicItem_Click(object sender, RoutedEventArgs e)  //基本設定檔維護按鈕
        {
            BasicItem basicitem_View = new BasicItem();
            object    content        = basicitem_View.Content;

            basicitem_View.Content = null;

            AddTabItem(BasicItem.Header.ToString(), content);
            CheckList.Add(BasicItem.Header.ToString());
            Selected(BasicItem.Header.ToString());
        }
Exemplo n.º 7
0
    protected override void EndDrag(BasicItem _item, PointerEventData _eventData)
    {
        if (!iCanDrag)
        {
            return;
        }

        bufferItem.Dispose();        //освобождаем буффер

        isDrag = false;
    }
Exemplo n.º 8
0
    // Clears the slot and its entry in the dictionary
    public void ClearItemOfSlot(int slotIndex)
    {
        BasicItem item = null;

        if (items.TryGetValue(slotIndex, out item))
        {
            items.Remove(slotIndex);
            item = null;
            OnInventoryChange.Invoke();
        }
    }
 public void Drop(int slot)
 {
     GameObject.Find("slotText" + (slot)).GetComponent <Text>().text         = "Empty";
     GameObject.Find("slotBackground" + (slot)).GetComponent <Image>().color = currentSlotColor;
     mySlot = InventoryList[slot - 1];
     mySlot.GetComponent <Transform>().position         = new Vector3(playerObject.position.x, playerObject.position.y, 0f);
     mySlot.GetComponentInChildren <Renderer>().enabled = true;
     mySlot.GetComponent <BasicItem>().velocity         = playerObject.GetComponent <Player>().velocity;
     //InventoryList.Remove(mySlot);
     InventoryList[slot - 1] = null;
 }
Exemplo n.º 10
0
    public void OnClick()
    {
        if (OnItemClick != null)
        {
            OnItemClick();
        }

        if (!usingItem && itemPrefab != null && itemCount > 0)
        {
            item = (GameObject.Instantiate(itemPrefab) as GameObject).GetComponent <BasicItem>();
            if (itemPosition)
            {
                item.effectPosition = itemPosition;
            }
            twinItem.item = item;

            usingItem = true;
            itemCancelIcon.enabled          = true;
            twinItem.itemCancelIcon.enabled = true;

            transform.parent.animation.Play("Gui_Powerup_Use");
            itemBg.spriteName = spriteSelected;
            twinItem.transform.parent.animation.Play("Gui_Powerup_Use");
            twinItem.itemBg.spriteName = spriteSelected;

            item.OnFinishUsingItem   += FinishUsingItem;
            item.OnActuallyUsingItem += ActuallyUsingItem;
            item.StartUsingItem(boardLogic);

            SoundManager.Instance.Play("item_select_sfx");
        }
        else if (!usingItem && itemCount <= 0)
        {
            if (!temporaryItem)
            {
                BuyItemHolder.SetSelectedItem(this);
                buyFSM.SendEvent("Buy");
            }

            SoundManager.Instance.Play("item_select_sfx");
        }
        else if (usingItem && item != null)
        {
            item.OnFinishUsingItem   -= FinishUsingItem;
            item.OnActuallyUsingItem -= ActuallyUsingItem;
            item.CancelUsingItem();

            canceling = true;
            FinishUsingItem(item);

            SoundManager.Instance.Play("item_unselect_sfx");
        }
    }
Exemplo n.º 11
0
 public void useItemOnDoor(BasicItem basicItem)
 {
     for (int i = 0; i < possibleItems.Count; i++)
     {
         if (basicItem.myName == possibleItems[i] && basicItem != null)
         {
             locked = false;
             inventory.DropKey();
             break;
         }
     }
 }
Exemplo n.º 12
0
 protected override void OnPointerClick(BasicItem _item, PointerEventData _eventData)
 {
     if (!isDrag)
     {
         if (!_item.IsEmpty())              //если слот не пуст то удаляем объект и нормализуем контэйнер
         {
             RemoveItem(_item.Item);
             _item.Dispose();
             NormalizedContainerBySlots();
         }
     }
 }
Exemplo n.º 13
0
    public IItem GrabItem()
    {
        int       ingrCount = Random.Range(Config.MinIngredientsPerItem, Config.MaxIngredientsPerItem);
        BasicItem item      = new BasicItem(Config.RandomItem());

        // FIXME: Ben�tigt Abfrage was zugeordnet wurde
        for (int i = 0; i < ingrCount; ++i)
        {
            item.AddIngredient(Config.PossibleIngredients.RetrieveRandom(Config.MinIngredientsPerItem));
        }
        return(item);
    }
Exemplo n.º 14
0
        internal void CreateItem(BasicItem item, int _shelfIndex = 0)
        {
            GameObject go  = Instantiate(_shelfItemPrefab);
            var        tmp = go.GetComponent <ShelfItem>();

            tmp.lojaItem = (LojaItem)item;
            tmp.name     = item.imagem;
            //To ensure that _shelfIndex is valid
            if (_shelves.Length > _shelfIndex)
            {
                _shelves[_shelfIndex].InsertItem(go);
            }
        }
Exemplo n.º 15
0
    protected void SubscribeItemEvents(BasicItem _item)
    {
        _item.OnPointerEnterEvent += PointerEnter;
        _item.OnPointerExitEvent  += PointerExit;

        _item.OnPointerDownEvent  += OnPointerDown;
        _item.OnPointerUpEvent    += OnPointerUp;
        _item.OnPointerClickEvent += OnPointerClick;

        _item.OnBeginDragEvent += onBeginDrag;
        _item.OnDragEvent      += Drag;
        _item.OnEndDragEvent   += EndDrag;
    }
Exemplo n.º 16
0
 public bool CheckCorrectItem(BasicItem item)
 {
     if (item?.Kind != RequiredItem)
     {
         OnWrongItem.Invoke();
         return(false);
     }
     else
     {
         OnToggle.Invoke();
         return(true);
     }
 }
Exemplo n.º 17
0
    //Finds the first item of a given name, or returns null if there is no such item
    public BasicItem FindFirstItemOfName(string itemName)
    {
        BasicItem item = null;

        foreach (KeyValuePair <int, BasicItem> entry in items)
        {
            if (entry.Value.Name == itemName)
            {
                item = entry.Value;
                return(item);
            }
        }
        return(item);
    }
Exemplo n.º 18
0
    void Setup(List <BasicSlot> _slots)
    {
        foreach (BasicSlot slot in _slots)
        {
            //BasicSlot
            SubscribeSlotEvents(slot);
            //BasicItem
            BasicItem item = slot.currentItem;

            SubscribeItemEvents(item);

            slot.currentItem.Item = null;
        }
    }
Exemplo n.º 19
0
 // Through this method, whenever an item properties change the container invokes the OnInvenotryChange event for its clients
 private void HookUpItemEventsToContainer(BasicItem item)
 {
     // Remove previous listeners if they exists
     item.OnNameChange.RemoveAllListeners();
     item.OnMaxAmountChange.RemoveAllListeners();
     item.OnGraphicChange.RemoveAllListeners();
     item.OnDurabilityChange.RemoveAllListeners();
     item.OnAmountChange.RemoveAllListeners();
     item.OnNameChange.AddListener(delegate { OnInventoryChange.Invoke(); });
     item.OnMaxAmountChange.AddListener(delegate { OnInventoryChange.Invoke(); });
     item.OnGraphicChange.AddListener(delegate { OnInventoryChange.Invoke(); });
     item.OnDurabilityChange.AddListener(delegate { OnInventoryChange.Invoke(); });
     item.OnAmountChange.AddListener(delegate { OnInventoryChange.Invoke(); });
 }
Exemplo n.º 20
0
    void ForcePlayerDropItem(BasicItem item)
    {
        PlayerController player1 = GameObject.FindGameObjectWithTag("player1").GetComponent <PlayerController>();

        if (player1.CurrentlyHeldItem() == item)
        {
            player1.DropCurrentItem();
        }
        PlayerController player2 = GameObject.FindGameObjectWithTag("player2").GetComponent <PlayerController>();

        if (player2.CurrentlyHeldItem() == item)
        {
            player2.DropCurrentItem();
        }
    }
Exemplo n.º 21
0
    void OnTriggerEnter(Collider other)
    {
        if (isFilled)
        {
            return;
        }
        BasicItem item = other.gameObject.GetComponent <BasicItem>();

        if (item && item.specialItem)
        {
            isFilled = true;
            spriteComponent.color = activatedColor;
            ForcePlayerDropItem(item);
            RenderBasicItemConsumedByPentagram(item);
        }
    }
Exemplo n.º 22
0
        public void TestPickUpFullInventory()
        {
            // prepare map block with one item, player and pick up action
            MapBlock mapBlock          = new MapBlock(0, 0);
            AbstractInventoryItem item = new BasicItem("Test item", mapBlock, 10);

            mapBlock.Item = item;
            AbstractPlayer testPlayer   = new FullInventoryPlayer("Test player", mapBlock);
            PickUp         pickUpAction = new PickUp()
            {
                Actor = testPlayer
            };

            // perform pickup action
            pickUpAction.Execute();
        }
Exemplo n.º 23
0
    // Adds an item as a single stack, and returns true if it was successful
    public bool AddItemAsASingleStack(BasicItem item)
    {
        int iEmptySlot = FindEmptySlot();

        if (iEmptySlot == -1)
        {
            return(false);                  // if there are no free slots, do nothing
        }
        else
        {
            HookUpItemEventsToContainer(item);
            items.Add(iEmptySlot, item);
            OnInventoryChange.Invoke();
            return(true);
        }
    }
Exemplo n.º 24
0
    protected override void PointerEnter(BasicItem _item, PointerEventData _eventData)
    {
        if (isDrag && !bufferItem.IsEmpty())                       //если буфер не пуст
        {
            if (!isFull() || InventoryOverseer._instance.Verify()) //если контэйнер не полон или это тот контейнер откуда взяли
            {
                hoverSlot  = _item.GetComponentInParent <BasicSlot>();
                indexThrow = slots.FindIndex(x => x == hoverSlot);

                if (hoverSlot.IsEmpty() == false)                  //если слот на который навели не пуст
                //когда драгаешь сам на себя переходит в конец контэйнера
                {
                    if ((indexThrow + 1) % width == 0)                        //если навёл на последний элемент в строке
                    {
                        slots[indexThrow + 1].SetActiveLeftHover(true);       //то подсвечиваем на новой строке
                    }
                    else
                    {
                        hoverSlot.SetActiveRightHover(true);                        //то подсвечиваем право для вставки
                    }
                }
                else                    //если навёл на пустую ячейку, то подсветка самого последнего или первого
                {
                    if (isEmpty())      //если контэйнер пуст то подсвечивается первый слот
                    {
                        slots[0].SetActiveLeftHover(true);
                    }
                    else                      //или же последний
                    {
                        if (items.Count % width == 0)
                        {
                            slots[items.Count].SetActiveLeftHover(true);                            //не уверен
                        }
                        else
                        {
                            slots[items.Count - 1].SetActiveRightHover(true);
                        }
                    }
                }
            }
            else
            {
                //IsFull
            }
        }
    }
Exemplo n.º 25
0
        private List <BasicItem> GetItemsOnPage(string url, AbstractSource source)
        {
            List <BasicItem> items = new List <BasicItem>();

            WebClient wc = new WebClient();

            wc.UseDefaultCredentials = true;

            string page = wc.DownloadString(url);

            HtmlDocument doc = new HtmlDocument();

            doc.LoadHtml(page);

            var resultsNode = doc.DocumentNode.SelectSingleNode("//div[@id='serp']");
            var itemNodes   = resultsNode.SelectNodes("div");

            foreach (var i in itemNodes)
            {
                string location, posted, title, link;

                var linkNode = i.SelectSingleNode(".//a[@class='dice-btn-link']");
                title = linkNode.InnerText.Trim();
                link  = linkNode.Attributes["href"].Value;

                if (link.Contains('?'))
                {
                    link = link.Substring(0, link.IndexOf('?'));
                }

                string id = GetId(link);

                location = i.SelectSingleNode(".//li[@class='location']").InnerText.Trim();
                posted   = i.SelectSingleNode(".//li[@class='posted']").InnerText.Trim();

                string name = String.Format("{0} ({1}, {2})", title, location, id);

                var item = new BasicItem(source, name, link);

                items.Add(item);
            }

            return(items);
        }
Exemplo n.º 26
0
    public void OnUse()
    {
        if (InGameHUD.instance.paused)
        {
            InGameHUD.instance?.Resume();
        }
        animator.SetTrigger("Use");

        if (lastItemTargeted != null)
        {
            if (lastItemTargeted.Kind == Items.GOAL)
            {
                // We win
                GameManager.instance.LoadScene("WinScene");
            }
            else
            {
                Inventory.Add(lastItemTargeted);
                lastItemTargeted.AddedToInventory();
                itemImageUI.sprite = lastItemTargeted.Icon;
                itemImageUI.color  = Color.white;

                var obj = Instantiate(ItemIconHUDPrefab, iconGroup.transform);
                obj.GetComponent <UnityEngine.UI.Image>().sprite = lastItemTargeted.Icon;

                lastItemTargeted = null;
            }
        }

        else if (Inventory.Count > 0 && CurSwitch != null)
        {
            if (CurSwitch.CheckCorrectItem(Inventory[0]))
            {
                CurSwitch.PlaceItem(Inventory[0]);
                Inventory.RemoveAt(0);
            }
            else
            {
                Debug.Log("Placing wrong item");
            }
        }
    }
Exemplo n.º 27
0
    void OnPurchaseSuccess(string id)
    {
        purchasing = false;

        InAppPurchasesSystem.OnPurchaseSuccess -= OnPurchaseSuccess;
        InAppPurchasesSystem.OnPurchaseFail    -= OnPurchaseFail;
        InAppPurchasesSystem.OnPurchaseCancel  -= OnPurchaseFail;

        InAppProduct product = InAppPurchasesSystem.Instance.GetProduct(id);

        if (product != null)
        {
            BasicItem itemComponent = item.itemPrefab.GetComponent <BasicItem>();

            string subtype = "small";
            if (packIndex == 1)
            {
                subtype = "medium";
            }
            else if (packIndex == 2)
            {
                subtype = "large";
            }

                        #if UNITY_ANDROID
            AnalyticsBinding.LogEventPaymentAction(product.currencyCode, InAppPurchasesSystem.locale, "-" + product.price, id, 1, itemComponent.ItemName,
                                                   "consumable", endGame ? "postgame" : "ingame", Match3BoardRenderer.levelIdx);
                        #else
            float price;
            if (!float.TryParse(product.price, out price))
            {
                price = 0.99f + packIndex * 1f;
            }

            AnalyticsBinding.LogEventPaymentAction(product.currencyCode, InAppPurchasesSystem.locale, -price, id, 1, itemComponent.ItemName,
                                                   "consumable", endGame ? "postgame" : "ingame", Match3BoardRenderer.levelIdx);
                        #endif
        }

        item.AddItems(itemCount + freeItemCount);
        buyFSM.SendEvent("BuyFinished");
    }
Exemplo n.º 28
0
    protected void SelectRandomItem()
    {
        SoundManager.Instance.PlayOneShot("troll_magic_sfx");

        ActuallyUsingItem();

        Debug.Log("Choosing the one");
        theChosenOne = finalEligibleItems[Random.Range(0, finalEligibleItems.Count)];

        Debug.Log("The one: " + theChosenOne.name);

        SpawnEffect(effectPosition.position, effectPrefab);

        Debug.Log("spawned effect");

        Invoke("DoItem", destroyEffect.destroyTileTime);
        Invoke("DoDestroy", destroyEffect.lifeTime);

        Debug.Log("invoked the spirits");
    }
Exemplo n.º 29
0
 // This method refreshes the inventory window slots and sets them up with necessary references
 private void RefreshInventoryWindow()
 {
     if (slots.Count <= 0)
     {
         return;
     }
     for (int i = 0; i < entityInventory.mainContainer.slotAmount; i++)                 // itirate through all the slots
     {
         ItemSlot  itemSlot      = slots[i];                                            // get the slot
         BasicItem inventoryItem = entityInventory.mainContainer.GetItemOfSlotIndex(i); // get the item
         if (inventoryItem != null)                                                     // if the item exists fill the inventory slot
         {
             ApplyInventoryItemToSlot(itemSlot, inventoryItem);
         }
         else // if it doesnt empty the slot
         {
             EmptySlot(itemSlot);
         }
     }
 }
Exemplo n.º 30
0
	protected void SelectRandomItem()
	{
		SoundManager.Instance.PlayOneShot("troll_magic_sfx");
		
		ActuallyUsingItem();
		
		Debug.Log("Choosing the one");
		theChosenOne = finalEligibleItems[Random.Range(0, finalEligibleItems.Count)];
		
		Debug.Log("The one: " + theChosenOne.name);
		
		SpawnEffect(effectPosition.position, effectPrefab);
		
		Debug.Log("spawned effect");
		
		Invoke("DoItem", destroyEffect.destroyTileTime);
		Invoke("DoDestroy", destroyEffect.lifeTime);
		
		Debug.Log("invoked the spirits");
	}	
Exemplo n.º 31
0
        protected override List <AbstractItem> GetNewItems(AbstractSource source)
        {
            List <AbstractItem> items = new List <AbstractItem>();

            WebClient wc = new WebClient();

            wc.UseDefaultCredentials = true;

            int maxPages = int.Parse(source.GetMetaDataValue(META_MAX_PAGES));

            for (int p = 1; p <= maxPages; p++)
            {
                string page;
                string url = BASE_URL + "?page=" + p;

                page = wc.DownloadString(url);

                HtmlDocument doc = new HtmlDocument();
                doc.LoadHtml(page);

                var resultsContainer = doc.DocumentNode.SelectSingleNode("//div[@id='browse-results']");
                var talks            = resultsContainer.SelectNodes(".//div[@class='talk-link']");

                foreach (var talk in talks)
                {
                    var innerContainer = talk.SelectSingleNode(".//div[@class='media__message']");

                    var link = innerContainer.SelectSingleNode(".//a");
                    if (link != null)
                    {
                        string name     = link.InnerText.Trim();
                        string link_url = link.Attributes["href"].Value;
                        link_url = "https://www.ted.com/" + link_url;

                        BasicItem item = new BasicItem(source, name, link_url);
                        items.Add(item);
                    }
                }
            }
            return(items);
        }
Exemplo n.º 32
0
	void OnActuallyUsingAnyItem (BasicItem item)
	{
		ThouShallObliterateLife();
	}
Exemplo n.º 33
0
	void OnStartUsingAnyItem (BasicItem item)
	{
		StartTimer();
	}
Exemplo n.º 34
0
	public void OnClick()
	{
		if (OnItemClick != null) {
			OnItemClick();
		}
		
		if (!usingItem && itemPrefab != null && itemCount > 0) 
		{
			item = (GameObject.Instantiate(itemPrefab) as GameObject).GetComponent<BasicItem>();
			if (itemPosition) {
				item.effectPosition = itemPosition;
			}
			twinItem.item = item;
			
			usingItem = true;
			itemCancelIcon.enabled = true;
			twinItem.itemCancelIcon.enabled = true;
			
			transform.parent.animation.Play("Gui_Powerup_Use");
			itemBg.spriteName = spriteSelected;
			twinItem.transform.parent.animation.Play("Gui_Powerup_Use");
			twinItem.itemBg.spriteName = spriteSelected;
			
			item.OnFinishUsingItem += FinishUsingItem;
			item.OnActuallyUsingItem += ActuallyUsingItem;
			item.StartUsingItem(boardLogic);
			
			SoundManager.Instance.Play("item_select_sfx");
		}
		else if (!usingItem && itemCount <= 0) 
		{
			if (!temporaryItem) {
				BuyItemHolder.SetSelectedItem(this);
				buyFSM.SendEvent("Buy");
			}
			
			SoundManager.Instance.Play("item_select_sfx");
		}
		else if (usingItem && item != null)
		{
			item.OnFinishUsingItem -= FinishUsingItem;
			item.OnActuallyUsingItem -= ActuallyUsingItem;
			item.CancelUsingItem();
			
			canceling = true;
			FinishUsingItem(item);

			SoundManager.Instance.Play("item_unselect_sfx");
		}
	}
Exemplo n.º 35
0
	void ActuallyUsingItem(BasicItem _item)
	{
		itemCancelIcon.enabled = false;
		twinItem.itemCancelIcon.enabled = false;
		AddItems(-1);
		
		item = null; //so we can't cancel it anymore
	}
Exemplo n.º 36
0
	void FinishUsingItem(BasicItem _item) 
	{
		usingItem = false;
		itemCancelIcon.enabled = false;
		twinItem.itemCancelIcon.enabled = false;
	
		if (temporaryItem && !canceling) {
			RestoreOriginalItem();
			twinItem.RestoreOriginalItem();
		}
		
		if ((_item as TrollMagic) != null) {
			SetTemporaryItem((_item as TrollMagic).theChosenOne.gameObject);
			twinItem.SetTemporaryItem(itemPrefab);
		}
		
		transform.parent.localScale = initScale;
		if (idleAnimName != null) {
			transform.parent.animation.Play(idleAnimName);
			twinItem.transform.parent.animation.Play(idleAnimName);
		}
		else {
			transform.parent.animation.Stop();
			twinItem.transform.parent.animation.Stop();
		}
		
		UpdateCountLabels();
		twinItem.UpdateCountLabels();
		
		item = null;
		twinItem.item = null;
		
		canceling = false;
	}