コード例 #1
0
    public void ApplyTGS(string item)
    {
        GameObject tgt = planetPointer.GetObjectPointedAt();

        if (tgt.GetComponent(typeof(Planter)))
        {
            UsableItem useItem = spaceBarn.TGSItemFromString(item);

            if (useItem.GetItemType() == "Plant")
            {
                //Debug.Log ("In plant branch");
                (tgt.GetComponent(typeof(Planter)) as Planter).PlantSeed(useItem as Plant);
                int seedCount = spaceBarn.RemovePlant(useItem as Plant);
                if (seedCount == 0)
                {
                    DisplayTGSMenu();
                }
            }
            else if (useItem.GetItemType() == "Goodie")
            {
                //Debug.Log ("In goodie branch");
                (tgt.GetComponent(typeof(Planter)) as Planter).ApplyGoodie(useItem as Goodie);
                int goodieCount = spaceBarn.RemoveGoodie(useItem as Goodie);
                if (goodieCount == 0)
                {
                    DisplayTGSMenu();
                }
            }
            else if (useItem.GetItemType() == "Tool")
            {
            }
        }
        else if (tgt.GetComponent(typeof(Planet)))
        {
            //TODO: Terraforming stuff here
        }
        else
        {
            //TODO: Put some default stuff here
        }
    }