Beispiel #1
0
 public void hoeingPlot()
 {
     if (isPlotted == false)
     {
         for (int i = 0; i < Gen.plots.Count; i++)
         {
             if (Gen.gridpos(Gen.plots[i].transform.position.x, Gen.plots[i].transform.position.y) == Gen.gridpos(plotPos.transform.position.x, plotPos.transform.position.y))
             {
                 if (Gen.plots[i].GetComponent <CheckIsScraped>().isFinishedGrowing != true)
                 {
                     if (Gen.plots[i].GetComponent <SpriteRenderer>().sprite == Gen.plotTiles[0])
                     {
                         Gen.plots[i].GetComponent <SpriteRenderer>().sprite    = Gen.plotTiles[1];
                         Gen.plots[i].GetComponent <CheckIsScraped>().isScraped = true;
                         isPlotted = true;
                     }
                     else if (Gen.plots[i].GetComponent <CheckIsScraped>().isScraped == true)
                     {
                         Gen.plots[i].GetComponent <SpriteRenderer>().sprite       = Gen.plotTiles[0];
                         Gen.plots[i].GetComponent <CheckIsScraped>().isScraped    = false;
                         Gen.plots[i].GetComponent <CheckIsScraped>().isPlanted    = false;
                         Gen.plots[i].GetComponent <CheckIsScraped>().isWatered    = false;
                         Gen.plots[i].GetComponent <CheckIsScraped>().wateredCount = 0;
                         isPlotted = true;
                     }
                 }
             }
         }
     }
 }
    public void plantingSeed()
    {
        for (int i = 0; i < Gen.plots.Count; i++)
        {
            if (inventory.getSelected().name != "" && inventory.getSelected().type == itemDefault.itemType.crops)
            {
                if (Gen.gridpos(Gen.plots[i].transform.position.x, Gen.plots[i].transform.position.y) == Gen.gridpos(plotPos.transform.position.x, plotPos.transform.position.y))
                {
                    if (Gen.plots[i].GetComponent <CheckIsScraped>().isScraped == true)
                    {
                        if (Gen.plots[i].GetComponent <CheckIsScraped>().isPlanted == false)
                        {
                            inventory.displayCurrentAmount();
                            Gen.plots[i].GetComponent <CheckIsScraped>().nameOfVeg = inventory.itemNameToBeGround();
                            Gen.plots[i].GetComponent <SpriteRenderer>().sprite    = Gen.plotTiles[itemSpriteChange(i)];

                            Gen.plots[i].GetComponent <CheckIsScraped>().needsWater = true;
                            Gen.plots[i].GetComponent <CheckIsScraped>().isPlanted  = true;
                        }
                        inventory.subtractFromInventory(Gen.plots[i].GetComponent <CheckIsScraped>().isPlanted = true);
                    }
                }
            }
        }
    }
Beispiel #3
0
    public void wateringPlant()
    {
        for (int i = 0; i < Gen.plots.Count; i++)
        {
            if (Gen.gridpos(Gen.plots[i].transform.position.x, Gen.plots[i].transform.position.y) == Gen.gridpos(plotPos.transform.position.x, plotPos.transform.position.y))
            {
                if (Gen.plots[i].GetComponent <CheckIsScraped>().isPlanted == true)
                {
                    if (isBeingPressed == false && Gen.plots[i].GetComponent <CheckIsScraped>().isWatered == true)
                    {
                        Gen.plots[i].GetComponent <CheckIsScraped>().wateredCount++;

                        if (Gen.plots[i].GetComponent <CheckIsScraped>().wateredCount > 3)
                        {
                            Gen.plots[i].GetComponent <CheckIsScraped>().isWatered = false;
                        }
                        else if (Gen.plots[i].GetComponent <CheckIsScraped>().wateredCount < 4 && Gen.plots[i].transform.GetChild(0).gameObject.GetComponent <SpriteRenderer>().color == new Color32(255, 255, 255, 112))
                        {
                            Gen.plots[i].GetComponent <SpriteRenderer>().sprite = Gen.plotTiles[itemSpriteChange(i) + Gen.plots[i].GetComponent <CheckIsScraped>().wateredCount];
                        }

                        Gen.plots[i].transform.GetChild(0).gameObject.GetComponent <SpriteRenderer>().color = new Color32(0, 0, 0, 0);


                        isBeingPressed = true;
                    }

                    else if (Gen.plots[i].GetComponent <CheckIsScraped>().isWatered == false && Gen.plots[i].GetComponent <CheckIsScraped>().isFinishedGrowing != true)
                    {
                        Gen.plots[i].GetComponent <SpriteRenderer>().sprite            = Gen.plotTiles[1];
                        Gen.plots[i].GetComponent <CheckIsScraped>().wateredCount      = 0;
                        Gen.plots[i].GetComponent <CheckIsScraped>().needsWater        = false;
                        Gen.plots[i].GetComponent <CheckIsScraped>().isFinishedGrowing = false;
                        Gen.plots[i].GetComponent <CheckIsScraped>().isPlanted         = false;
                        waterWarningCount = 0;
                    }
                }
            }
        }
    }