コード例 #1
0
    /// <summary>
    /// Attempts to purchase a weapon and displays dialog based on the result
    /// of the attempt.
    /// </summary>
    /// <param name="slot"></param>
    public void purchaseWeapon(int slot)
    {
        ShopInventorySlot shopSlot  = inventorySlots[slot];
        GameObject        selection = inventory[slot];
        WeaponStats       stats     = selection.GetComponentInChildren <WeaponStats>(true);

        if (stats.price > StateManager.cashOnHand)
        {
            audioS.PlayOneShot(failureSound, Settings.volume);
            dialogText.text = getRandomDialog(brokeDialogs);
            return;
        }

        if (playerShoot.guns.Count >= MAX_GUNS)
        {
            audioS.PlayOneShot(failureSound, Settings.volume);
            dialogText.text = getRandomDialog(fullInventoryDialogs);
            return;
        }

        // can purchase
        playerInventory.addWeapon(selection);
        shopSlot.purchased = true;

        // only remove cash if everything above that succeeded and the player received the gun
        StateManager.cashOnHand -= stats.price;
        shopSlot.buttonObject.GetComponent <Button>().interactable = false;
        shopSlot.infoBlock.SetActive(false);
        shopSlot.soldout.SetActive(true);
        shopSlot.pricetag.text = "-";
        audioS.PlayOneShot(paymentSound, Settings.volume);
        dialogText.text = getRandomDialog(purchaseDialogs);
    }
コード例 #2
0
    public override void OnBeginDrag(PointerEventData eventData)
    {
        base.OnBeginDrag(eventData);

        ShopInventorySlot parentSlot = ParentInventorySlot as ShopInventorySlot;

        if (parentSlot != null)
        {
            parentSlot.ShowFadedSprite(_image.sprite);
        }
        else
        {
            Debug.LogError("error!");
        }
    }
コード例 #3
0
    public override void OnEndDrag(PointerEventData eventData)
    {
        base.OnEndDrag(eventData);

        ShopInventorySlot parentSlot = ParentInventorySlot as ShopInventorySlot;

        if (parentSlot != null)
        {
            parentSlot.HideFadedSprite();
        }
        else
        {
            Debug.LogError("error!");
        }
    }