示例#1
0
    // adds the given item to this player's inventory
    // this method should only be used when restoring a previous game state
    // after a minigame
    public void restoreItem(ItemD.Type itemType)
    {
        ItemD item = itemDB.getItem(itemType);

        itemObjects.Add(Instantiate(item.inventoryPrefab, inventorySlots[items.Count]));
        items.Add(itemType);
    }
示例#2
0
 // removes the given item from this player's inventory
 // does nothing, when the inventory does not contain the item
 public void removeItem(ItemD.Type itemType)
 {
     if (hasItem(itemType))
     {
         int index = items.IndexOf(itemType);
         items.RemoveAt(index);
         Destroy(itemObjects[index]);
         itemObjects.RemoveAt(index);
     }
 }
示例#3
0
    // adds the given item to this player's inventory
    // does nothing, when the inventory is full
    public void addItem(ItemD.Type itemType)
    {
        ItemD item = itemDB.getItem(itemType);

        if (items.Count < 3)
        {
            controller.PlayPickupItemSound();
            itemObjects.Add(Instantiate(item.inventoryPrefab, inventorySlots[items.Count]));
            items.Add(itemType);
        }
    }
示例#4
0
    private void buyItem()
    {
        ItemD.Type item  = itemShop.getSelectedItem();
        int        price = itemDB.getItem(item).getPrice();

        if (playerBelongings[activePlayer].creditAmount() >= price && playerBelongings[activePlayer].hasSpaceForAnItem())
        {
            // buy the item
            playerBelongings[activePlayer].addCreditAmount(-price);
            playerBelongings[activePlayer].addItem(item);

            // dirty hack/shortcut: just switch to the EXECUTING_ACTON state, the credit animation is savely finished there
            currentActionFSM = null;
            currentState     = TurnState.EXECUTING_ACTION;

            itemShop.close();
        }
        // else: cannot buy item
        // TODO: add feedback?!
    }
示例#5
0
    private FSM getPurpleTileAction()
    {
        float selection = UnityEngine.Random.Range(0, 10);

        if (selection >= 6)
        {
            // receive some coins/credits
            return(new TileGainCoins(playerBelongings[activePlayer]));
        }
        else if (selection >= 2)
        {
            // give the player a few APs and extend their turn
            actionPoints += 3;
            currentState  = TurnState.EXECUTING_ACTION;
            return(new TileRandomGiveAP(audioSource, gainAPAudioClip));
        }
        else
        {
            // receive a random item
            ItemD.Type selectedItem = itemDB.getItem((int)UnityEngine.Random.Range(0, itemDB.getItemCount() - 0.1f)).type;
            return(new TileRandomGiveItem(playerBelongings[activePlayer], selectedItem));
        }
    }
示例#6
0
 public ItemD getItem(ItemD.Type type)
 {
     return(itemDataBase[type]);
 }
示例#7
0
 /// whether the player's inventory contains the given item
 public bool hasItem(ItemD.Type itemType)
 {
     return(items.Contains(itemType));
 }
示例#8
0
 public TileRandomGiveItem(PlayerDisplay playersStuff, ItemD.Type selectedItem)
 {
     playersStuff.addItem(selectedItem);
 }