private bool addItem(ItemController.Item itemType, TileController[,] map)
    {
        List <TileController> possibleLocations = new List <TileController>();

        foreach (TileController tile in map)
        {
            if (!tile.IsWall() && !tile.IsProtected() && !tile.isDoor)
            {
                possibleLocations.Add(tile);
            }
        }
        if (possibleLocations.Count == 0)
        {
            return(false);
        }
        TileController cTile = possibleLocations[Random.Range(0, possibleLocations.Count - 1 + 1)];

        ItemController item = gameObject.AddComponent <ItemController>();

        item.GenerateMe(itemType);
        item.PutMeDown(cTile);

        return(true);
    }
示例#2
0
    public void UpdateTooltip(string itemType, string food, int bonusID)
    {
        string iconToGet   = "";
        string nameText    = "";
        string descText    = "";
        string effectText  = "";
        string specialText = "";

        ItemController.Item   foodItem  = new ItemController.Item();
        BonusController.Bonus bonusItem = new BonusController.Bonus();

        if (itemType != "bonus")
        {
            foodItem = gameController.GetComponent <ItemController>().GetItem(food);
        }
        else
        {
            bonusItem = gameController.GetComponent <BonusController>().allBonuses [bonusID];
        }

        switch (itemType)
        {
        case "storeBuild":
            iconToGet  = food + "1";
            nameText   = foodItem.store1Name;
            descText   = "\"" + foodItem.store1Desc + "\"";
            effectText = "Earns $" + gameController.GetComponent <MoneyController>().getNewStoreEarning(food) + " /s";
            List <string> groupBonuses = gameController.GetComponent <MoneyController>().getGroupBonuses(food);
            if (groupBonuses.Count == 0)
            {
                specialText = "No Group Bonuses";
            }
            else
            {
                specialText = "Group Bonuses:";
                foreach (string f in groupBonuses)
                {
                    specialText += " " + f + ",";
                }
                specialText = specialText.Substring(0, specialText.Length - 1);
            }
            break;

        case "storeUpgrade":
            iconToGet   = food + "2";
            nameText    = foodItem.store2Name;
            descText    = foodItem.store2Desc;
            effectText  = "$Some /s";
            specialText = "No group bonuses";
            break;

        case "farmBuild":
            iconToGet   = food + "-1";
            nameText    = foodItem.farmName;
            descText    = foodItem.farmDesc;
            effectText  = "+1 " + formatFoodName(food);
            specialText = "";
            break;

        case "farmUpgrade":
            iconToGet   = food + "-1";
            nameText    = foodItem.farmName;
            descText    = foodItem.farmDesc;
            effectText  = "+1 " + formatFoodName(food);
            specialText = "";
            break;

        case "bonus":
            iconToGet   = food;
            nameText    = bonusItem.bonusName;
            descText    = bonusItem.bonusDesc;
            effectText  = "x" + bonusItem.bonusMult;
            specialText = "";
            break;

        default:
            return;
        }

        icon.sprite  = getIcon(iconToGet);
        name.text    = nameText;
        desc.text    = descText;
        effects.text = effectText;
        special.text = specialText;
    }