private void InitAdsPanel()
    {
        for(int i = 0;i<m_ADGroup.transform.childCount;i++)
        {
            Destroy(m_ADGroup.transform.GetChild(i).gameObject);
        }

        for(int i = 0;i<m_adNumber;i++)
        {
            GameObject go = Instantiate(m_ADButton);
            go.name = "Advertisement " + i;
            go.transform.SetParent(m_ADGroup.transform, false);
            ItemButton button = go.GetComponent<ItemButton>();
            button.SetSwitchable(true);
            button.SetText(go.name);

            button.AddOnClick(()=>{

                if(m_selectedButton != null)
                {
                    m_selectedButton.Deselect();
                }
                m_selectedButton = m_selectedButton == button ? null : button;
                m_confirmBtn.interactable = m_selectedButton != null;

            });
        }
        m_confirmBtn.interactable = m_selectedButton != null;
    }
Esempio n. 2
0
 private void init()
 {
     button=GetComponent<ItemButton>();
     hoverNoise=((GameObject)GameObject.Find("ButtonHoverSound")).GetComponent<AudioSource>();
     clickNoise=((GameObject)GameObject.Find("ButtonClickSound")).GetComponent<AudioSource>();
     wrongClickNoise=((GameObject)GameObject.Find("ButtonWrongClickSound")).GetComponent<AudioSource>();
     initialized=true;
 }
Esempio n. 3
0
 private void SendToShelf(Button interactedButton, ItemButton itemButton, ItemInstance itemInstance)
 {
     if (itemInstance.stock > 1)
     {
         AddItemToActiveShelf(itemButton, itemInstance);
     }
     else
     {
         //If it is the last item destroy it after moving it to the other container.
         AddItemToActiveShelf(itemButton, itemInstance);
         playerInventory.TakeItem(itemInstance);
         Destroy(interactedButton.gameObject);
     }
 }
Esempio n. 4
0
 public void InitializeInventoryView(CharacterEntity entity, Action <ItemButton> onItemButtonClicked = null)
 {
     m_entity = entity;
     entity.EntityInventory.onInventoryUpdated += UpdateInventory;
     m_onItemButtonClicked = onItemButtonClicked;
     for (int i = 0; i < GameDataManager.instance.GlobalConfig.m_maxItemSlots; i++)
     {
         ItemButton newButton = GameObject.Instantiate <ItemButton>(m_buttonPrefab);
         newButton.transform.SetParent(m_itemContainer);
         newButton.Slot = i;
         newButton.UpdateItemContainer(null);
         m_buttonsDict.Add(i, newButton);
     }
 }
Esempio n. 5
0
        public WndBlacksmith(Blacksmith troll, Hero hero)
        {
            ItemSelector = new BlacksmithItemSelector(this);

            var titlebar = new IconTitle();

            titlebar.Icon(troll.Sprite);
            titlebar.Label(Utils.Capitalize(troll.Name));
            titlebar.SetRect(0, 0, WIDTH, 0);
            Add(titlebar);

            var message = PixelScene.CreateMultiline(TxtPrompt, 6);

            message.MaxWidth = WIDTH;
            message.Measure();
            message.Y = titlebar.Bottom() + Gap;
            Add(message);

            BtnItem1             = new ItemButton();
            BtnItem1.ClickAction = () =>
            {
                BtnPressed = BtnItem1;
                GameScene.SelectItem(ItemSelector, WndBag.Mode.UPGRADEABLE, TxtSelect);
            };
            BtnItem1.SetRect((WIDTH - BtnGap) / 2 - BtnSize, message.Y + message.Height + BtnGap, BtnSize, BtnSize);
            Add(BtnItem1);

            BtnItem2             = new ItemButton();
            BtnItem2.ClickAction = () =>
            {
                BtnPressed = BtnItem2;
                GameScene.SelectItem(ItemSelector, WndBag.Mode.UPGRADEABLE, TxtSelect);
            };
            BtnItem2.SetRect(BtnItem1.Right() + BtnGap, BtnItem1.Top(), BtnSize, BtnSize);
            Add(BtnItem2);

            BtnReforge             = new RedButton(TxtReforge);
            BtnReforge.ClickAction = button =>
            {
                troll.Upgrade(BtnItem1.Item, BtnItem2.Item);
                Hide();
            };
            BtnReforge.Enable(false);
            BtnReforge.SetRect(0, BtnItem1.Bottom() + BtnGap, WIDTH, 20);
            Add(BtnReforge);


            Resize(WIDTH, (int)BtnReforge.Bottom());
        }
Esempio n. 6
0
    private void CheckVariant(ItemButton itemButton)
    {
        bool guessWasSuccessfull = quizModeController.CheckIfWinner(itemButton.item);

        if (guessWasSuccessfull)
        {
            SwitchFromQuizToBrowse(itemButton.item);
            soundController.TellRight();
        }
        else
        {
            itemButton.MoveRedCrossForward();
            soundController.TellWrong();
        }
    }
Esempio n. 7
0
    public void CreateInventory(PlayerResources newPlayerResources)
    {
        items = new ItemButton[ItemModel.instance.itemData.Count];
        for (int i = 0; i < ItemModel.instance.itemData.Count; ++i)
        {
            GameObject newButton  = Instantiate(itemButtonPrefab, content);
            ItemButton itemButton = newButton.GetComponent <ItemButton>();

            itemButton.SetItem(i);
            itemButton.button.onClick.AddListener(() => SelectItem(itemButton.Id));
            items[i] = itemButton;
        }
        playerResources = newPlayerResources;
        IsActive        = true;
    }
Esempio n. 8
0
 public void ClientInventoryItemClicked(ItemButton itemButton)
 {
     if (itemButton.InventoryItem != null)
     {
         BaseItemContainer baseItem = itemButton.InventoryItem.ItemContainer;
         if (baseItem != null && baseItem.ItemUseType == BaseItemContainer.EItemUseType.Active)
         {
             if (baseItem.AbilityBase)
             {
                 CharacterLogic characterLogic = m_entity.EntityLogic as CharacterLogic;
                 EAttackType    attackType     = (EAttackType)Enum.Parse(typeof(EAttackType), "ItemSlot" + itemButton.Slot);
                 characterLogic.TryToCastAbilityOnClient(attackType, false);
             }
         }
     }
 }
    void GenerateItem(string _name, string _description)
    {
        Item newItem = (Item)Instantiate(GameManager.instance.itemPrefab);

        newItem.itemName    = _name;
        newItem.description = _description;
        newItem.transform.SetParent(this.transform, false);
        newItem.gameObject.SetActive(true);

        ItemButton button = (ItemButton)Instantiate(GameManager.instance.itemButtonPrefab);

        button.thisItem      = newItem;
        button.itemName.text = newItem.itemName;
        button.transform.SetParent(itemPanel, false);
        button.gameObject.SetActive(true);
    }
Esempio n. 10
0
    public void _UpdateItems()
    {
        foreach (GameObject oldButton in GameObject.FindGameObjectsWithTag("ItemButton"))
        {
            Destroy(oldButton);
        }

        madeChanges = true;

        foreach (Item item in openProject.items)
        {
            ItemButton itemButton = Instantiate(itemPrefab, itemList).GetComponent <ItemButton>();

            itemButton.item = item;
        }
    }
Esempio n. 11
0
    public void LoadItemButton(ItemButton itemButton)
    {
        string key = itemButton.itemName;

        itemButton.level       = PlayerPrefs.GetInt(key + "_level");
        itemButton.currentCost = PlayerPrefs.GetInt(key + "_cost", itemButton.startCurrentCost);
        itemButton.goldPerSec  = PlayerPrefs.GetInt(key + "_goldPerSec");
        if (PlayerPrefs.GetInt(key + "_isPurchased") == 1)
        {
            itemButton.isPurchased = true;
        }
        else
        {
            itemButton.isPurchased = false;
        }
    }
Esempio n. 12
0
    public void InitialiseTargetList()
    {
        foreach (Transform transform in listContainer)
        {
            Destroy(transform.gameObject);
        }

        for (int i = 0; i < InventoryManager.Instance.inventorySlots.Length; i++)
        {
            if (!InventoryManager.Instance.inventorySlots[i].empty)
            {
                ItemButton button = Instantiate(buttonPrefab, listContainer).GetComponent <ItemButton>();
                button.Initialise(i, commandMenu, InventoryManager.Instance.inventorySlots[i].item);
            }
        }
    }
Esempio n. 13
0
    public void SaveItemButton(ItemButton itemButton)
    {
        string key = itemButton.itemName;

        PlayerPrefs.SetInt(key + "_level", itemButton.level);
        PlayerPrefs.SetInt(key + "_cost", itemButton.currentCost);
        PlayerPrefs.SetInt(key + "_goldPerSec", itemButton.goldPerSec);
        if (itemButton.isPurchased == true)
        {
            PlayerPrefs.SetInt(key + "_isPurchased", 1);
        }
        else
        {
            PlayerPrefs.SetInt(key + "_isPurchased", 0);
        }
    }
Esempio n. 14
0
 private void _init()
 {
     _lastUpdated = DateTime.Now;
     // events
     clickerButton.onClick.AddListener(() => Click());
     // init player
     player = Player.GetInstance();
     player.Init();
     // init UI
     dropController.Init();
     UnityEngine.Object buttonPrefab = Resources.Load("ItemButton");
     buttons  = new ItemButton[player.items.Count];
     _itemIds = new int[player.items.Count];
     for (int i = 0; i < player.items.Count; ++i)
     {
         hardwares[i].SetActive(false);
         GameObject    obj  = Instantiate(buttonPrefab) as GameObject;
         RectTransform rect = obj.GetComponent <RectTransform>();
         rect.SetParent(buttonContainer);
         rect.anchoredPosition = new Vector2(0, i * -58);
         int index = i;
         _itemIds[i] = player.items[i].id;
         ItemButton button = obj.GetComponent <ItemButton>();
         button.SetOnMouseCallback(() => ShowTip(index));
         button.SetItem(player.items[i]);
         button.SetSprite(player.items[i].id);
         buttons[i] = button;
         obj.GetComponent <Button>().onClick.AddListener(() => BuyItem(index));
     }
     // load data & refresh
     player.Load();
     for (int i = 0; i < player.items.Count; ++i)
     {
         buttons[i].SetItem(player.items[i]);
         if (player.items[i].unlocked)
         {
             buttons[i].Unlock();
         }
         if (player.items[i].level > 0)
         {
             hardwares[i].SetActive(true);
         }
         dropController.SetMaxUnlockedNum(player.unlockedItem);
         dropController.SetSpeed(player.autoValue);
     }
     RefreshScore();
 }
Esempio n. 15
0
 public void TryTransferItemToOtherList(ItemButton itmBtn)
 {
     if (itmBtn.transform.parent.Equals(shopViewPortContent))
     {
         //Debug.Log("Move to shopping list.");
         MoveToShoppingList(itmBtn);
     }
     else if (itmBtn.transform.parent.Equals(listViewPortContent))
     {
         //Debug.Log("Move out of shopping list.");
         MoveOutOfShoppingList(itmBtn);
     }
     else
     {
         throw new InvalidOperationException();
     }
 }
Esempio n. 16
0
 // Use this for initialization
 public void Initialize(CharacterEntity entity)
 {
     if (!m_initialized)
     {
         foreach (BaseItemContainer item in InventoryManager.Instance.m_items)
         {
             ItemButton newButton = Instantiate <ItemButton>(m_itemButtonPrefab);
             newButton.transform.SetParent(m_itemContainer);
             newButton.UpdateItemContainer(item, ShowStoreItem);
         }
         if (m_inventoryView != null)
         {
             m_inventoryView.InitializeInventoryView(entity, ShowInventoryItem);
         }
         m_initialized = true;
     }
 }
Esempio n. 17
0
    void BuildElement(string id, string text, string count)     // создание нового элемента и настройка параметров
    {
        RectTransform clone = Instantiate(element) as RectTransform;

        clone.name = id;
        clone.SetParent(scroll.content);
        clone.localScale       = Vector3.one;
        clone.anchoredPosition = new Vector2(e_Pos.x, e_Pos.y - curY);
        ItemButton item = clone.GetComponent <ItemButton>();

        SetMainButton(item.mainButton, id);
        SetRemoveButton(item.removeButton, id);
        item.mainButtonText.text = text;
        item.id         = id;
        item.count.text = count;
        buttons.Add(clone);
    }
Esempio n. 18
0
    /// <summary>
    /// Creates a new ItemButton, and adds it to the provided game object as a child.
    /// </summary>
    /// <param name="item"></param>
    /// <param name="newPanelParent"></param>
    private ItemButton AddNewItemButton(ItemInstance item, GameObject newPanelParent)
    {
        Button newButton = Instantiate(itemButtonPrefab);

        newButton.transform.SetParent(newPanelParent.transform, false);
        Image image = newButton.GetComponent <Image>();

        image.sprite = item.item.itemIcon;

        ItemButton itemButton = newButton.GetComponent <ItemButton>();

        itemButton.heldItem = item;

        newButton.onClick.AddListener(delegate { MoveItem(newButton); });

        return(itemButton);
    }
Esempio n. 19
0
    public void loadItemButton(ItemButton itemButton)
    {
        string key = itemButton.itemName;

        itemButton.level       = PlayerPrefs.GetInt(key + "_level", 0);
        itemButton.goldPerSec  = PlayerPrefs.GetInt(key + "_GoldBySec", itemButton.startGoldPerSec);
        itemButton.currentCost = PlayerPrefs.GetInt(key + "_cost", itemButton.startCurrentCost);

        if (PlayerPrefs.GetInt(key + "_purchase") == 1)
        {
            itemButton.isPurchase = true;
        }
        else
        {
            itemButton.isPurchase = false;
        }
    }
Esempio n. 20
0
    void LoadItems()                                //create all buttons and link the to their coresponding item
    {
        currentHand = Instantiate(HandSlot);        //create hand item
        currentHand.transform.SetParent(transform); //set parent for acces
        currentHand.transform.localPosition = Vector3.zero;

        currentTemp = Instantiate(TempSlot); //same as above for swap loot
        currentTemp.transform.SetParent(transform);

        for (int i = 1; i < playerInv.loots.Count; i++)         //loop for each item in inventory, besides the first one which is the hand slot
        {
            GameObject newButt = Instantiate(itemButton);       //create the gameobject
            newButt.transform.SetParent(transform.GetChild(0)); //give it the correct parent for sorting
            ItemButton itemButtonScript = newButt.GetComponent <ItemButton>();
            itemButtonScript.index = i;                         // link it to item by giving it it's index in inventory
        }
    }
Esempio n. 21
0
 public ItemButton SetUpButton(int index, ItemButton itemButton)
 {
     if (GameManager.instance.itemsHeld[index] != "")
     {
         itemButton.buttonImage.gameObject.SetActive(true);
         Item foundItem = GameManager.instance.GetItemDetails(GameManager.instance.itemsHeld[index]);
         itemButton.buttonImage.sprite = foundItem.itemSprite;
         itemButton.amountText.text    = GameManager.instance.itemsInventory[index].ToString();
         itemButton.buttonValue        = index;
     }
     else
     {
         itemButton.buttonImage.gameObject.SetActive(false);
         itemButton.amountText.text = "";
     }
     return(itemButton);
 }
Esempio n. 22
0
    public void Setup(Battler _focus)
    {
        focus        = _focus;
        nameTag.text = focus.name;
        //Attacks
        foreach (BattleSkill i in focus.attacks)
        {
            SkillButton newButton = Instantiate(skillButtonPrefab);
            newButton.transform.SetParent(attacks.transform);
            newButton.attack = i;
            //attackButtons.Add(newButton);
        }
        //Specials
        foreach (BattleSkill i in focus.specials)
        {
            SkillButton newButton = Instantiate(skillButtonPrefab);
            newButton.transform.SetParent(specials.transform);
            newButton.attack = i;
            //attackButtons.Add(newButton);
        }
        //Items
        foreach (BattleItem i in focus.items)
        {
            ItemButton newButton = Instantiate(itemButtonPrefab);
            newButton.transform.SetParent(items.transform);

            newButton.item = i;
            //attackButtons.Add(newButton);
        }
        // Test

        /*foreach (BattleAction i in focus.allActions.Where(x => x is BattleSkill))
         * {
         *  SkillButton newButton = Instantiate(skillButtonPrefab);
         *  newButton.transform.SetParent(items.transform);
         *
         *  newButton.attack = (i as BattleSkill);
         *  //attackButtons.Add(newButton);
         * }*/

        /*if (focus.rank == 0 && manager.GetPlayersInRank(0).Count <= 1)
         * {
         *  strategyButtons[0].GetComponent<Image>().color = Color.grey;
         * }*/
    }
Esempio n. 23
0
    private void PopulateListItem(Node node, int nodeIndex)
    {
        listItens = node.GetListItens();

        for (int i = 0; i < listItens.Count; i++)
        {
            GameObject newObject = Instantiate(buttonsPrefabs[1], panelInteraction.transform);
            ItemButton pointer   = newObject.GetComponent <ItemButton>();

            pointer.SetController(this);
            pointer.SetParentNode(listNodes[i]);
            pointer.SetParentIndex(nodeIndex);
            pointer.SetItem(listItens[i]);
            pointer.SetIndex(i);

            itenButtonList.Add(newObject);
        }
    }
Esempio n. 24
0
    private void AssignItemToButton(InventoryItem item, GameObject button)
    {
        if (button != null)
        {
            ItemButton btn = button.GetComponent <ItemButton>();
            btn.item = item;

            if (item.count == 0)
            {
                button.SetActive(false);
            }
            else
            {
                button.SetActive(true);
                numItemTypesWithItemsRemaining++;
            }
        }
    }
Esempio n. 25
0
 private void AddItemToActiveShelf(ItemButton itemButton, ItemInstance itemInstance)
 {
     playerInventory.TakeItem(itemInstance);
     //If the active shelf does not have this item then we have to create a new button.
     if (!activeShelf.heldItems.Contains(itemButton.heldItem))
     {
         ItemInstance newItemInstance = new ItemInstance();
         newItemInstance.item = itemButton.heldItem.item;
         ItemButton newItemButton = AddNewItemButton(newItemInstance, shelfInventoryPanel);
         activeShelf.heldItems.Add(newItemButton.heldItem);
         ShelfItem(newItemButton.heldItem, 1);
     }
     else
     {
         activeShelf.changeStock(itemButton.heldItem, 1);
         ShelfItem(itemButton.heldItem, 1);
     }
 }
Esempio n. 26
0
    /// <summary>
    /// Moves item between inventories.
    /// </summary>
    /// <param name="interactedButton"></param>
    private void MoveItem(Button interactedButton)
    {
        ItemButton   itemButton   = interactedButton.GetComponent <ItemButton>();
        ItemInstance itemInstance = itemButton.heldItem;
        int          itemStock    = playerInventory.GetStock(itemInstance);

        //If the button is on the player inventory panel we are sending it to the shelf
        if (interactedButton.transform.IsChildOf(playerInventoryPanel.transform))
        {
            SendToShelf(interactedButton, itemButton, itemInstance);
        }
        //Else we are sending it to the player inventory
        else
        {
            SendToPlayerInventory(interactedButton, itemButton, itemInstance);
        }
        isModified = true;
    }
Esempio n. 27
0
        protected internal virtual void PlaceItem(Item item)
        {
            var x          = col * (SLOT_SIZE + SLOT_MARGIN);
            var y          = TITLE_HEIGHT + row * (SLOT_SIZE + SLOT_MARGIN);
            var itemButton = new ItemButton(this, item);

            itemButton.SetPos(x, y);
            Add(itemButton);
            itemButton.Item(item);

            if (++col >= COLS)
            {
                col = 0;
                row++;
            }

            count++;
        }
Esempio n. 28
0
    //взять кнопку из пула и просетапить ее полученным аргументом itemToSetupWith
    public void TakeOneButtonFromPoolAndSetupWith(Item itemToSetupWith)
    {
        GameObject returningGameObject     = buttonObjectPool.GetObject(this.transform);
        ItemButton buttonUnderConstruction = returningGameObject.GetComponent <ItemButton> ();

        buttonUnderConstruction.Setup(itemToSetupWith);

        // фиксим якоря и оффсеты при возвращении из пула
        RectTransform buttonRectTransform = buttonUnderConstruction.GetComponent <RectTransform>();

        buttonRectTransform.anchorMax = new Vector2(1, 1);
        buttonRectTransform.anchorMin = new Vector2(0, 0);

        buttonRectTransform.offsetMin = new Vector2(buttonRectTransform.offsetMin.x, 0);
        buttonRectTransform.offsetMax = new Vector2(buttonRectTransform.offsetMax.x, 0);
        buttonRectTransform.offsetMin = new Vector2(buttonRectTransform.offsetMin.y, 0);
        buttonRectTransform.offsetMax = new Vector2(buttonRectTransform.offsetMax.y, 0);
    }
Esempio n. 29
0
    public void OnBeginDrag(PointerEventData eventData)
    {
        itemSlotDraggedFrom = eventData.pointerDrag.GetComponent <ItemButton>();

        if (itemSlotDraggedFrom.amountText.text != "")
        {
            replicatedItem  = Instantiate(GameManager.instance.GetItemDetails(GameManager.instance.itemsHeld[itemSlotDraggedFrom.itemAmount]));
            sRenderer       = replicatedItem.GetComponent <SpriteRenderer>();
            sRenderer.color = new Color(1f, 1f, 1f, .6f); // set opacity lower
            // we co
            Vector3 mousePos = Input.mousePosition;
            Vector3 itemPos  = Camera.main.ScreenToWorldPoint(mousePos);
            itemPos.z = 0;
            replicatedItem.GetComponent <SpriteRenderer>().sortingLayerName = "Player";
            replicatedItem.transform.position = itemPos;
            replicatedItem.gameObject.SetActive(true);
        }
    }
Esempio n. 30
0
    public void OnDrop(PointerEventData eventData)
    {
        Destroy(replicatedItem.gameObject);

        if (eventData.pointerDrag != null)
        {
            if (eventData.pointerEnter.transform.parent.name != "ItemButtons")
            {
                itemMovingTo = eventData.pointerEnter.transform.parent.GetComponent <ItemButton>();
                MoveItemInInventory(itemMovingTo);
            }
            else
            {
                itemMovingTo = eventData.pointerEnter.GetComponent <ItemButton>();
                MoveItemInInventory(eventData.pointerEnter.GetComponent <ItemButton>());
            }
        }
    }
Esempio n. 31
0
    /**
     * Go through the items list and see how many items are there
     * Add item buttons as needed for each item
     * Call the setup funtion in ItemButton
     */
    private void AddItemButtons()
    {
        for (int i = 0; i < Storage.Instance.unlockedItems.Count; i++)
        {
            // new item = the item at the current index in unlockedItems
            Item item = Storage.Instance.unlockedItems[i];
            // get an object from the pool and store the reference in the new button
            GameObject newItemButton = itemButtonObjectPool.GetObject();
            // set the parent of the new button to the content panel
            newItemButton.transform.SetParent(contentPanel, false);
            newItemButton.transform.localScale = new Vector3(1, 1, 1);

            // Get a reference to the item button script
            ItemButton itemButton = newItemButton.GetComponent <ItemButton>();
            // pass item and a reference to this crafting list
            itemButton.Setup(item, this);
        }
    }
Esempio n. 32
0
    void SpawnButton(Item i, Fighter f)
    {
        GameObject go  = Instantiate(itemButtonPrefab, itemList.transform);
        ItemButton btn = go.GetComponent <ItemButton>();

        go.GetComponent <UIHighlight>().OnSelectAction += () => { hovered = btn.GetItem(); };
        go.GetComponent <Button>().onClick.AddListener(() => { OpenActionMenu(); });

        if (i.IsUseable(f))
        {
            btn.label.color = Color.white;
        }
        else
        {
            btn.label.color = Color.gray;
        }

        btn.SetItem(i);
    }
Esempio n. 33
0
            public PredefinedColorList(Screen screen, PredefinedColorDialog owner)
                : base(screen)
            {
                this.owner = owner;

                paging.ItemCountPerPage = 5;

                var stackPanel = new StackPanel(screen)
                {
                    Orientation = Orientation.Vertical,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment = VerticalAlignment.Stretch
                };
                Content = stackPanel;

                var pageButtonPanel = new StackPanel(screen)
                {
                    HorizontalAlignment = HorizontalAlignment.Right
                };
                stackPanel.Children.Add(pageButtonPanel);

                var backPageButton = new Button(screen)
                {
                    Focusable = false,
                    Width = BlockViewerGame.SpriteSize,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    Content = new Image(screen)
                    {
                        Texture = screen.Content.Load<Texture2D>("UI/ArrowLeft")
                    }
                };
                backPageButton.Click += (Control s, ref RoutedEventContext c) => BackPage();
                pageButtonPanel.Children.Add(backPageButton);

                pageTextBlock = new TextBlock(screen)
                {
                    Width = BlockViewerGame.SpriteSize * 2,
                    ForegroundColor = Color.White,
                    BackgroundColor = Color.Black,
                    ShadowOffset = new Vector2(2)
                };
                pageButtonPanel.Children.Add(pageTextBlock);

                var forwardPageButton = new Button(screen)
                {
                    Focusable = false,
                    Width = BlockViewerGame.SpriteSize,
                    HorizontalAlignment = HorizontalAlignment.Right,
                    Content = new Image(screen)
                    {
                        Texture = screen.Content.Load<Texture2D>("UI/ArrowRight")
                    }
                };
                forwardPageButton.Click += (Control s, ref RoutedEventContext c) => ForwardPage();
                pageButtonPanel.Children.Add(forwardPageButton);

                for (int i = 0; i < itemButtons.Length; i++)
                {
                    itemButtons[i] = new ItemButton(screen);
                    itemButtons[i].KeyDown += OnListItemButtonKeyDown;
                    itemButtons[i].Click += OnListItemButtonClick;
                    stackPanel.Children.Add(itemButtons[i]);
                }
            }
Esempio n. 34
0
            public PredefinedColorGrid(Screen screen, PredefinedColorDialog owner)
                : base(screen)
            {
                this.owner = owner;

                paging.ItemCountPerPage = columnCount * rowCount;

                var stackPanel = new StackPanel(screen)
                {
                    Orientation = Orientation.Vertical,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment = VerticalAlignment.Stretch
                };
                Content = stackPanel;

                var pageButtonPanel = new StackPanel(screen)
                {
                    HorizontalAlignment = HorizontalAlignment.Right
                };
                stackPanel.Children.Add(pageButtonPanel);

                var backPageButton = new Button(screen)
                {
                    Focusable = false,
                    Width = BlockViewerGame.SpriteSize,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    Content = new Image(screen)
                    {
                        Texture = screen.Content.Load<Texture2D>("UI/ArrowLeft")
                    }
                };
                backPageButton.Click += (Control s, ref RoutedEventContext c) => BackPage();
                pageButtonPanel.Children.Add(backPageButton);

                pageTextBlock = new TextBlock(screen)
                {
                    Width = BlockViewerGame.SpriteSize * 2,
                    ForegroundColor = Color.White,
                    BackgroundColor = Color.Black,
                    ShadowOffset = new Vector2(2)
                };
                pageButtonPanel.Children.Add(pageTextBlock);

                var forwardPageButton = new Button(screen)
                {
                    Focusable = false,
                    Width = BlockViewerGame.SpriteSize,
                    HorizontalAlignment = HorizontalAlignment.Right,
                    Content = new Image(screen)
                    {
                        Texture = screen.Content.Load<Texture2D>("UI/ArrowRight")
                    }
                };
                forwardPageButton.Click += (Control s, ref RoutedEventContext c) => ForwardPage();
                pageButtonPanel.Children.Add(forwardPageButton);

                var vColorPanel = new StackPanel(screen)
                {
                    Orientation = Orientation.Vertical,
                    HorizontalAlignment = HorizontalAlignment.Center
                };
                stackPanel.Children.Add(vColorPanel);

                for (int i = 0; i < rowCount; i++)
                {
                    var hColorPanel = new StackPanel(screen);
                    vColorPanel.Children.Add(hColorPanel);

                    for (int j = i * columnCount; j < (i + 1) * columnCount; j++)
                    {
                        itemButtons[j] = new ItemButton(screen);
                        hColorPanel.Children.Add(itemButtons[j]);

                        int mod = j % columnCount;
                        if (mod == 0)
                        {
                            itemButtons[j].KeyDown += OnLeftColorButtonKeyDown;
                        }
                        else if (mod == columnCount - 1)
                        {
                            itemButtons[j].KeyDown += OnRightColorButtonKeyDown;
                        }

                        itemButtons[j].GotFocus += OnItemButtonGotFocus;
                        itemButtons[j].LostFocus += OnItemButtonLostFocus;
                        itemButtons[j].Click += OnItemButtonClick;
                    }
                }
            }
Esempio n. 35
0
        public ADAMenu()
        {
            PostProcessing.Add((IRequireResource)this);

            item = new Button();
            item.Area = new Microsoft.Xna.Framework.Rectangle(14, 362, 158, 42);
            item.OnMouseUp = delegate {
                if(currState == AMenuState.INV) {
                    currState = AMenuState.NONE;
                } else {
                    currState = AMenuState.INV;
                }
            };

            stat = new Button();
            stat.Area = new Microsoft.Xna.Framework.Rectangle(14, 409, 158, 42);
            stat.OnMouseUp = delegate {
                if(currState == AMenuState.STAT) {
                    currState = AMenuState.NONE;
                } else {
                    currState = AMenuState.STAT;
                }
            };

            journal = new Button();
            journal.Area = new Microsoft.Xna.Framework.Rectangle(14, 456, 158, 42);
            journal.OnMouseUp = delegate {

            };

            skill = new Button();
            skill.Area = new Microsoft.Xna.Framework.Rectangle(14, 503, 158, 42);
            skill.OnMouseUp = delegate {
                if(currState == AMenuState.SKILL) {
                    currState = AMenuState.NONE;
                } else {
                    currState = AMenuState.SKILL;
                }
            };

            quit = new Button();
            quit.Area = new Rectangle(14, 552, 158, 42);
            quit.OnMouseUp = delegate {
                StaticVars.inst.Exit();
            };

            menu = new Menu();
            menu.Add(item);
            menu.Add(journal);
            menu.Add(skill);
            menu.Add(stat);
            menu.Add(quit);

            pktButtons = new Button[6];

            // Scroll Left button
            pktButtons[0] = new Button();
            pktButtons[0].Active = false;
            pktButtons[0].Visible = false;
            pktButtons[0].Area = new Rectangle(231, 55, 13, 19);
            pktButtons[0].OnMouseUp = delegate {
                if(pktCenter > 1) pktCenter--;
                if(pktCenter == 1) {
                    pktButtons[0].Active = false;
                    pktButtons[0].Visible = false;
                }
                pktButtons[5].Active = true;
                pktButtons[5].Visible = true;
            };

            // Actual Tabs
            for(int i = 0; i < 4; i++) {
                pktButtons[i + 1] = new Button();
                pktButtons[i + 1].Active = false;
                pktButtons[i + 1].Visible = false;
                pktButtons[i + 1].Area = new Rectangle(244 + (i * 121), 55, 121, 19);
            }
            pktButtons[1].OnMouseUp = delegate {
                if(currDragButton == -1) {
                    currPkt = pktCenter - 1;
                    StaticVars.player.Stats.Inv.Pockets[currPkt].Condense();
                } else {
                    if(StaticVars.player.Stats.Inv.Pockets[pktCenter - 1].Content.Contains<Item.Item>(null)) { // Contains empty space...
                        Item.Item alpha = StaticVars.player.Stats.Inv.Pockets[currPkt][currDragButton];
                        StaticVars.player.Stats.Inv.Pockets[pktCenter - 1].Add(alpha);
                        StaticVars.player.Stats.Inv.Pockets[currPkt][currDragButton] = null;
                    }
                }
                currDragButton = -1;
            };
            pktButtons[2].OnMouseUp = delegate {
                if(currDragButton == -1) {
                    currPkt = pktCenter;
                    StaticVars.player.Stats.Inv.Pockets[currPkt].Condense();
                } else {
                    if(StaticVars.player.Stats.Inv.Pockets[pktCenter].Content.Contains<Item.Item>(null)) { // Contains empty space...
                        Item.Item alpha = StaticVars.player.Stats.Inv.Pockets[currPkt][currDragButton];
                        StaticVars.player.Stats.Inv.Pockets[pktCenter].Add(alpha);
                        StaticVars.player.Stats.Inv.Pockets[currPkt][currDragButton] = null;
                    }
                }
                currDragButton = -1;
            };
            pktButtons[3].OnMouseUp = delegate {
                if(currDragButton == -1) {
                    currPkt = pktCenter + 1;
                    StaticVars.player.Stats.Inv.Pockets[currPkt].Condense();
                } else {
                    if(StaticVars.player.Stats.Inv.Pockets[pktCenter + 1].Content.Contains<Item.Item>(null)) { // Contains empty space...
                        Item.Item alpha = StaticVars.player.Stats.Inv.Pockets[currPkt][currDragButton];
                        StaticVars.player.Stats.Inv.Pockets[pktCenter + 1].Add(alpha);
                        StaticVars.player.Stats.Inv.Pockets[currPkt][currDragButton] = null;
                    }
                }
                currDragButton = -1;
            };
            pktButtons[4].OnMouseUp = delegate {
                if(currDragButton == -1) {
                    currPkt = pktCenter + 2;
                    StaticVars.player.Stats.Inv.Pockets[currPkt].Condense();
                } else {
                    if(StaticVars.player.Stats.Inv.Pockets[pktCenter + 2].Content.Contains<Item.Item>(null)) { // Contains empty space...
                        Item.Item alpha = StaticVars.player.Stats.Inv.Pockets[currPkt][currDragButton];
                        StaticVars.player.Stats.Inv.Pockets[pktCenter + 2].Add(alpha);
                        StaticVars.player.Stats.Inv.Pockets[currPkt][currDragButton] = null;
                    }
                }
                currDragButton = -1;
            };

            // Scroll Right button
            pktButtons[5] = new Button();
            pktButtons[5].Active = false;
            pktButtons[5].Visible = false;
            pktButtons[5].Area = new Rectangle(728, 55, 13, 19);
            pktButtons[5].OnMouseUp = delegate {
                if(pktCenter < StaticVars.player.Stats.Inv.Pockets.Count - 3) pktCenter++;
                if(pktCenter == StaticVars.player.Stats.Inv.Pockets.Count - 3) {
                    pktButtons[5].Active = false;
                    pktButtons[5].Visible = false;
                }
                pktButtons[0].Active = true;
                pktButtons[0].Visible = true;
            };

            itemButtons = new ItemButton[20];

            for(int i = 0; i < 20; i++) {
                itemButtons[i] = new ItemButton(i, this);
            }
        }