コード例 #1
0
    public string getDescription()
    {
        string txt = "";

        GameObject tree = layers[0].getFirstObject();

        if (tree != null)
        {
            txt += "<b>" + tree.name + "</b>\n";
            AssignedPlant ap = tree.GetComponent <AssignedPlant>();
            if (ap != null)
            {
                txt += "<i>" + ap.get().description + "</i>\n";
            }

            Datable dat = tree.GetComponent <Datable>();
            if (dat != null)
            {
                txt += "Âge : " + dat.getAge() + " ans\n";
            }

            Cuttable cut = tree.GetComponent <Cuttable>();
            if (cut != null)
            {
                txt += "Coupe : " + cut.getCutPrice() + "$\n";
            }

            Uprootable up = tree.GetComponent <Uprootable>();
            if (up != null)
            {
                txt += "Déracinement : " + up.getUprootCost() + "$\n";
            }

            txt += "\n";
        }

        txt += "Humidité : " + getHumidite() + "\n";
        txt += "Luminosité : " + getLuminosite() + "\n";
        txt += "Fertilité : " + getFertilite() + "\n\n";

        txt += "Contient :\n";
        for (int i = 1; i < (int)Layers.NbLayers; ++i)
        {
            txt += layers[i].getTxt();
        }
        return(txt);
    }
コード例 #2
0
 public void addToDico(Dictionary <string, float> dico)
 {
     for (int i = 0; i < 4; ++i)
     {
         if (objs[i] != null)
         {
             AssignedPlant p = objs[i].GetComponent <AssignedPlant>();
             Mort          m = objs[i].GetComponent <Mort>();
             if (p != null && m == null)
             {
                 string n = p.get().theName;
                 if (dico.ContainsKey(n))
                 {
                     dico[n] += p.get().diversImpact;
                 }
                 else
                 {
                     dico[n] = 1;
                 }
             }
         }
     }
 }