public override void OnTick(BaseTilemap <CropTileData> tilemap, int x, int y)
        {
            // Increment the age of the crop.
            CropTileData crop = tilemap[x, y];

            crop.Age++;
            tilemap[x, y] = crop;

            // If the age is greater than or equal to the death age, unset the tile.
            if (crop.Age >= deathAge)
            {
                tilemap.SetTile(x, y, tilemap.Tileset.EmptyTileName);
            }
            // Otherwise; handle ageing the crop and spawning creatures.
            else
            {
                // Scale the plant.
                scalePlant(tilemap, x, y, crop);

                // If the age is greater than or equal to the mature age, spawn creatures.
                if (crop.Age >= matureAge)
                {
                    CropTilemap cropTilemap = tilemap as CropTilemap;

                    // Spawn the amount of creatures for this plant.
                    for (int i = 0; i < creaturesPerTick; i++)
                    {
                        cropTilemap.CreatureManager.SpawnCreature(cropTilemap.GetCropSeed(x, y), creaturePrefab, x, y);
                    }
                }
            }
        }
Beispiel #2
0
 private void Start()
 {
     cropTilemap = WorldMap.GetTilemap <CropTileData>() as CropTilemap;
 }