Exemple #1
0
 public void receiveFishTokens(FishTokenType resource, int amount)
 {
     if (amount < 0)
     {
         //Error
     }
     else
     {
         assets.fishTokens.fishTuple[resource] += amount;
     }
 }
 public void addFishTokenWithType(FishTokenType key, int value)
 {
     Debug.Log("Adding " + value + " of " + key.ToString() + " to this fish tuple");
     if (fishTuple.ContainsKey(key))
     {
         fishTuple[key] = value;
     }
     else
     {
         fishTuple.Add(key, value);
     }
 }
Exemple #3
0
    public FishTuple getFishTokenForTile(GameTile tile, int numCollected)
    {
        FishTuple fishTokensCollected = new FishTuple();

        if (tile.tileType != TileType.Desert && tile.tileType != TileType.Ocean)
        {
            Debug.Log("Tile is not fish, returning!");
            return(fishTokensCollected);
        }

        if (numFishTokensLeft() < numCollected)
        {
            Debug.Log("numFishTokensLeft () < numCollected");
            foreach (var pair in fishTokensAvailable.fishTuple)
            {
                Debug.Log("Key = " + pair.Key + ", Value = " + pair.Value);
            }
            return(fishTokensCollected);
        }

        int collectionLeft = numCollected;
        List <FishTokenType> tokensAvailable = fishTokensAvailable.listForm();

        while (collectionLeft > 0)
        {
            int           randomNum  = Random.Range(0, tokensAvailable.Count);
            FishTokenType drawnToken = tokensAvailable [randomNum];

            fishTokensCollected.addFishTokenWithType(drawnToken, 1);
            collectionLeft--;

            if (drawnToken == FishTokenType.OldBoot)
            {
                Debug.Log(CatanManager.instance.players [CatanManager.instance.currentPlayerTurn].playerName + " draws the Old Boot!");
            }
        }

        return(fishTokensCollected);
    }