Ejemplo n.º 1
0
    public void UpdateText() => lvl.text = PlayerPrefs.GetInt("level", 0).ToString();//"100";//

    public bool HasSpace(BuyableItem asquer)
    {
        int  space     = 0;
        bool isAlready = false;

        foreach (BuyableItem item in equippedItems)
        {
            if (item.id == "Slot1" || item.id == "Slot2" || item.id == "Slot3")
            {
                space++;
            }
            if (item.id == asquer.id)
            {
                isAlready = true;
            }
        }
        if (space > 0 && !isAlready)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Ejemplo n.º 2
0
    public void MakePurchase(GameObject pButtonGameObject)
    {
        BuyableItem   item          = ButtonToItemModel [pButtonGameObject];
        ItemUIControl itemUIControl = ItemModelToUIControl [item];

        item.OnPurchased();
        itemUIControl.OnPurchased();
    }
Ejemplo n.º 3
0
 public void FillEquipped(BuyableItem item)
 {
     if (HasSpace(item))
     {
         item.Equip();
         GetFirstFreeSpace().Set(item);
     }
 }
Ejemplo n.º 4
0
    private void InitializeItemDictionary()
    {
        ItemDictionary = new Dictionary <string, BuyableItem> ();
        BuyableItem item;


        item          = new BuyableItem();
        item.ItemId   = "heart_facepaint";
        item.ItemName = "Heart Facepaint";
//		item.Price = 5.00;
//		item.Description = "Paint your face with this cute heart and enhace your swag!";
        ItemDictionary.Add("heart_facepaint", item);

        item          = new BuyableItem();
        item.ItemId   = "green_sunglasses";
        item.ItemName = "Sunglasses";
//		item.Price = 1.00;
//		item.Description = "These are actually a pair of very rare swag glasses.";
        ItemDictionary.Add("green_sunglasses", item);


//		item = new BuyableItem ();
//		item.ItemId = "jetpack";
//		item.Price = 5.00;
//		item.Description = "fly and shit";
//		ItemDictionary.Add ("jetpack", item);

        item          = new BuyableItem();
        item.ItemId   = "mustache";
        item.ItemName = "Mustache";
//		item.Price = 5.00;
//		item.Description = "With this pedo stache, you can disguise yourself as a pedophile.";
        ItemDictionary.Add("mustache", item);

        item          = new BuyableItem();
        item.ItemId   = "orange_wings";
        item.ItemName = "Fairy Wings";
//		item.Price = 5.00;
//		item.Description = "I believe I can fly with these swag wings! Also makes you look like a f*g.";
        ItemDictionary.Add("orange_wings", item);

        item          = new BuyableItem();
        item.ItemId   = "scroll60";
        item.ItemName = "Magic Scroll";
//		item.Price = 5.00;
//		item.Description = "This scroll increases weapon attack of your brush. Success rate: 60%";
        ItemDictionary.Add("scroll60", item);

        item          = new BuyableItem();
        item.ItemId   = "witch_hat";
        item.ItemName = "Witch Hat";
//		item.Price = 5.30;
//		item.Description = "This witch hat is from the ghetto yo whatcha know about swag.";
        ItemDictionary.Add("witch_hat", item);
    }
Ejemplo n.º 5
0
 public bool AddPurchasedItem(BuyableItem item)
 {
     foreach (BuyableItem currentItem in PurchasedItems) {
         if (currentItem.ItemId == item.ItemId) {
             Debug.Log("Can't purchase again! Item already purchased");
             return false;
         }
     }
     PurchasedItems.Add(item);
     return true;
 }
Ejemplo n.º 6
0
    private void InitializeItemDictionary()
    {
        ItemDictionary = new Dictionary<string, BuyableItem> ();
        BuyableItem item;

        item = new BuyableItem ();
        item.ItemId = "heart_facepaint";
        item.ItemName = "Heart Facepaint";
        //		item.Price = 5.00;
        //		item.Description = "Paint your face with this cute heart and enhace your swag!";
        ItemDictionary.Add ("heart_facepaint", item);

        item = new BuyableItem ();
        item.ItemId = "green_sunglasses";
        item.ItemName = "Sunglasses";
        //		item.Price = 1.00;
        //		item.Description = "These are actually a pair of very rare swag glasses.";
        ItemDictionary.Add ("green_sunglasses", item);

        //		item = new BuyableItem ();
        //		item.ItemId = "jetpack";
        //		item.Price = 5.00;
        //		item.Description = "fly and shit";
        //		ItemDictionary.Add ("jetpack", item);

        item = new BuyableItem ();
        item.ItemId = "mustache";
        item.ItemName = "Mustache";
        //		item.Price = 5.00;
        //		item.Description = "With this pedo stache, you can disguise yourself as a pedophile.";
        ItemDictionary.Add ("mustache", item);

        item = new BuyableItem ();
        item.ItemId = "orange_wings";
        item.ItemName = "Fairy Wings";
        //		item.Price = 5.00;
        //		item.Description = "I believe I can fly with these swag wings! Also makes you look like a f*g.";
        ItemDictionary.Add ("orange_wings", item);

        item = new BuyableItem ();
        item.ItemId = "scroll60";
        item.ItemName = "Magic Scroll";
        //		item.Price = 5.00;
        //		item.Description = "This scroll increases weapon attack of your brush. Success rate: 60%";
        ItemDictionary.Add ("scroll60", item);

        item = new BuyableItem ();
        item.ItemId = "witch_hat";
        item.ItemName = "Witch Hat";
        //		item.Price = 5.30;
        //		item.Description = "This witch hat is from the ghetto yo whatcha know about swag.";
        ItemDictionary.Add ("witch_hat", item);
    }
Ejemplo n.º 7
0
 public bool AddPurchasedItem(BuyableItem item)
 {
     foreach (BuyableItem currentItem in PurchasedItems)
     {
         if (currentItem.ItemId == item.ItemId)
         {
             Debug.Log("Can't purchase again! Item already purchased");
             return(false);
         }
     }
     PurchasedItems.Add(item);
     return(true);
 }
Ejemplo n.º 8
0
 public void Set(BuyableItem item)
 {
     this.id               = item.id;
     this.price            = item.price;
     this.image            = item.image;
     this.state            = item.state;
     this.equipped         = item.equipped;
     this.chosedToEquipped = item.chosedToEquipped;
     this.controller       = item.controller;
     this.transform.GetChild(1).GetComponent <Image>().sprite = this.image;
     this.transform.GetChild(1).GetComponent <Image>().color  = new Color32(255, 255, 255, 255);
     this.Init();
 }
Ejemplo n.º 9
0
    public BuyableItem GetFirstFreeSpace()
    {
        BuyableItem returner = null;

        for (int i = 0; i < equippedItems.Count; i++)
        {
            if (equippedItems[i].id == "Slot1" || equippedItems[i].id == "Slot2" || equippedItems[i].id == "Slot3")
            {
                returner = equippedItems[i];
                break;
            }
        }
        return(returner);
    }
Ejemplo n.º 10
0
    void FixStore()
    {
        if (ItemWindow.activeSelf)
        {
            ItemWindow.SetActive(false);
        }
        BuyableItem Cur = Store.GetComponent <StoreManager>().Current;

        Store.GetComponent <StoreManager>().IsFocusing = false;
        if (Cur != null)
        {
            Cur.Focus = false;
            Cur.transform.localEulerAngles = Cur.StartRot;
            Cur.transform.localPosition    = Cur.StartPos;
            Cur = null;
        }
    }
Ejemplo n.º 11
0
 public void BuyItem()
 {
     if (state.Equals(BuyableState.NOT_BOUGHT))
     {
         if (PlayerPrefs.GetInt("level", 0) >= price)//if (100 >= price)//
         {
             GetComponent <Button>().colors = colors;
             GameManager.Instance.player.playerStats.LevelSpend(price);
             Debug.LogError("LEVEL BE LIKE WOW>" + PlayerPrefs.GetInt("level", 0));
             price = 0;
             state = BuyableState.BOUGHT;
             Debug.Log("BOUGHT ID: " + id);
             PlayerPrefs.SetInt(id, 1);
             PlayerPrefs.Save();
             controller.UpdateText();
             GetComponentInChildren <TMP_Text>().text = "BOUGHT";
         }
         else
         {
             GetComponent <Button>().colors = colorsInvalid;
         }
     }
     else
     {
         if (controller.currentSelected == null || controller.currentSelected != this)
         {
             BuyableItem aux = null;
             if (controller.currentSelected != null)
             {
                 aux = controller.currentSelected;
             }
             chosedToEquipped           = true;
             controller.currentSelected = this;
             if (controller.currentSelected != null && controller.currentSelected != this)
             {
                 aux.chosedToEquipped = false;
             }
         }
         if (controller.HasSpace(this))
         {
             Equip();
             controller.GetFirstFreeSpace().Set(this);
         }
     }
 }
Ejemplo n.º 12
0
    public void Setup(Shop shop, int itemIndex)
    {
        this.shop             = shop;
        this.item             = shop.itemsToBuy [itemIndex];
        this.index            = itemIndex;
        this.itemText.text    = this.item.itemName;
        this.itemImage.sprite = this.item.icon;
        this.priceText.text   = this.item.price.ToString();
        bool owned    = this.item.owned;
        bool equipped = this.item.equipped;

        //Set correct objects active.
        priceText.gameObject.SetActive(!owned);
        coinImage.gameObject.SetActive(!owned);
        ownedText.gameObject.SetActive(owned && !equipped);
        equippedText.gameObject.SetActive(owned && equipped);
        //equippedText.gameObject.SetActive (owned);
    }
Ejemplo n.º 13
0
    public void BuyItem()
    {
        if (_selectedItem != null)
        {
            //Get the item
            BuyableItem item     = _selectedList[_selectedItem.Index];
            int         quantity = (int)_quantitySlider.value;

            //Check the player has enough money
            if (_player.HasEnoughMoney(item._price * quantity))
            {
                //Spend the money
                _player.SpendMoney(item._price * quantity);

                //Add the item to the first empty slot
                _playerInventory.AddToFirstEmptySlot(item._item, item._quantity * quantity);

                _audioSource.PlayOneShot(_buySound);
            }

            _playerCash.text = "Your cash: " + _player.Cash.ToString("#0.00");
        }
    }
Ejemplo n.º 14
0
    public void SelectItem(BuyableItemUI ui)
    {
        //Set the selected list and item
        _selectedList = ui.transform.parent.GetComponent <BuyItems>().Items;
        _selectedItem = ui;

        //if we have a selected item
        if (_selectedItem != null)
        {
            //Get the item based on the index
            BuyableItem item = _items[_selectedItem.Index];

            //Set the name and description text
            _itemNameText.text        = item._item.Name;
            _itemDescriptionText.text = item._item.Description;
        }
        else
        {
            //Set the texts to blank
            _itemNameText.text        = "";
            _itemDescriptionText.text = "";
        }
    }
Ejemplo n.º 15
0
 public void Add(BuyableItem buyableItem, ItemUIControl itemUIControl)
 {
     ButtonToItemModel.Add(itemUIControl.purchaseButton.GameObjectInstance, buyableItem);
     ItemModelToUIControl.Add(buyableItem, itemUIControl);
 }
Ejemplo n.º 16
0
 public void Add(BuyableItem buyableItem, ItemUIControl itemUIControl)
 {
     ButtonToItemModel.Add (itemUIControl.purchaseButton.GameObjectInstance, buyableItem);
     ItemModelToUIControl.Add (buyableItem, itemUIControl);
 }
Ejemplo n.º 17
0
 public override void SetActualItem(BuyableItem item)
 {
     SaveLoad.data.actualSkin = (Skin)item;
 }
Ejemplo n.º 18
0
 public abstract void SetActualItem(BuyableItem item);
Ejemplo n.º 19
0
    void Update()
    {
        if (Input.GetMouseButton(1) && IsFocusing == true)
        {
            ItemWindow.SetActive(false);
            Current.Focus = false;
            IsFocusing    = false;
        }


        if (Input.GetMouseButton(0))
        {
            if (LastItem != null)
            {
                if (!Current.Focus)
                {
                    ItemWindow.SetActive(true);
                    Animator.SetBool("OpenWindow", true);
                    for (int i = 0; i < Items.Length; i++)
                    {
                        if (Items[i] == LastItem)
                        {
                            TextField.text  = Descripcion[i];
                            PriceField.text = Price[i].ToString();
                            indice          = i;
                        }
                    }

                    Current.Focus    = true;
                    IsFocusing       = true;
                    Current.hover    = false;
                    audioSource.clip = OnClickSFX;
                    audioSource.Play();
                }
                float RotationY = Input.GetAxis("Mouse Y") * RotSpeed * Mathf.Deg2Rad;
                LastItem.GetComponentInChildren <MeshRenderer>().transform.Rotate(Vector3.up, RotationY);
            }
        }
        else if (IsFocusing == false)
        {
            Ray        ray = UICamera.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                if (LastItem != hit.transform && LastItem != null)
                {
                    Current  = LastItem.GetComponent <BuyableItem>();
                    LastItem = null;
                    if (Current != null)
                    {
                        Current.hover = false;
                    }
                }
                if (hit.transform.CompareTag(InteractableTag))
                {
                    Current = hit.transform.GetComponent <BuyableItem>();
                    if (!Current.Focus)
                    {
                        Current.hover = true;
                    }
                    LastItem = hit.transform;
                    if (audioSource.clip != HoverSFX)
                    {
                        audioSource.clip = HoverSFX;
                        audioSource.Play();
                    }
                }
            }
            else
            {
                LastItem = null;
                if (Current != null)
                {
                    Current.hover = false;
                }
                audioSource.clip = null;
            }
        }
    }
Ejemplo n.º 20
0
 public override void SetActualItem(BuyableItem item)
 {
     SaveLoad.data.actualWeapon = (Weapon)item;
 }
Ejemplo n.º 21
0
 private void RegisterInBroker(BuyableItem b, ItemUIControl p)
 {
     PurchaseBroker.Instance.Add(b, p);
 }
Ejemplo n.º 22
0
 private void RegisterInBroker(BuyableItem b, ItemUIControl p)
 {
     PurchaseBroker.Instance.Add(b, p);
 }