void Awake() { if (flower == FlowerType.BigFlower) { ps = GetComponent <PlantScript>(); ps.enabled = false; foreach (Transform child in gameObject.transform) { childObjs.Add(child.gameObject); } for (int i = 0; i < childObjs.Count; i++) { childObjs[i].SetActive(false); } } else if (flower == FlowerType.SmallFlower) { inf = GetComponent <Info>(); inf.triggered = false; } else if (flower == FlowerType.GardenTree) { foreach (Transform child in gameObject.transform) { childObjs.Add(child.gameObject); } for (int i = 0; i < childObjs.Count; i++) { childObjs[i].SetActive(false); } } }
public void SpreadSeed(PlantScript parent) { PlantScript newSeed = plantSpecies.SpawnSeed(parent, seedDispertionRange); newSeed.SpawnSeed(); AddSeed(); }
internal override void AddSpecificOrganism(BasicOrganismScript newOrganism) { PlantScript newPlant = (PlantScript)newOrganism; plants.Add(newPlant); newPlant.specificOrganismIndex = plants.Count - 1; }
void SetUpOrgans(PlantScript plantScript) { for (int i = 0; i < speciesOrgansOrder.Count; i++) { speciesOrgansOrder[i].MakeOrganism(plantScript); } }
void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "Plant") { plant = col.gameObject.GetComponent <PlantScript>(); //Debug.Log(plant.getHealth()); //enemyHealth = plant.getHealth(); enemyHealth -= damage; plant.setHealth(enemyHealth); //Debug.Log(plant.getHealth()); } if (col.gameObject.tag == "Turret") { Debug.Log("Turret"); tower = col.gameObject.GetComponent <Tower>(); enemyHealth = tower.getHealth(); enemyHealth -= damage; tower.setHealth(enemyHealth); } if (col.gameObject.tag == "Bullet") { health -= 5; } }
public PlantScript SpawnRandomSeed() { PlantScript plantScript = GetInactivePlant(); ActivatePlant(plantScript, ListType.inactivePlants, true); RandomiseOrganismPosition(plantScript); AddToFindZone(plantScript); return(plantScript); }
public void AddPlant(PlantScript plant) { if (allPlantsCount == allPlants.Length) { IncreaceAllPlantLength(1); } plant.plantDataIndex = allPlantsCount; allPlantsCount++; }
public bool Eat(PlantScript plant) { if (Full()) { return(false); } AddFood(plant.EatPlant(this, math.min(GetMouth().biteSize *GetBiteAmmount(), animalSpecies.maxFood - food))); return(true); }
public PlantScript SpawnSeed(PlantScript parent, float range) { PlantScript plantScript = GetInactivePlant(); RemovePlantFromList(ListType.inactivePlants, plantScript.specificOrganismIndex); ActivatePlant(plantScript, ListType.unlisted); RandomiseOrganismChildPosition(plantScript, parent, range); AddToFindZone(plantScript, parent.zone, range); return(plantScript); }
public override void SpawnRandomOrganism() { PlantScript plantScript = GetInactivePlant(); ActivatePlant(plantScript, ListType.inactivePlants, true); populationCount++; RandomiseOrganismPosition(plantScript); AddToFindZone(plantScript); plantScript.SpawnPlantRandom(growthStages[Random.Range(0, growthStagesInput.Count)].stage); }
public void Populate() { plantSpecies.PreSpawn(startingSeedCount); for (int i = 0; i < startingSeedCount; i++) { PlantScript newseed = plantSpecies.SpawnRandomSeed(); newseed.SpawnSeedRandom(Random.Range(0, seedGerminationRequirement.timeRequirement)); AddSeed(); } }
public PlantScript SpawnPlant() { PlantScript plantScript = GetInactivePlant(); RemovePlantFromList(ListType.inactivePlants, plantScript.specificOrganismIndex); ActivatePlant(plantScript, ListType.unlisted); RandomiseOrganismPosition(plantScript); SetUpOrgans(plantScript); plantScript.stage = PlantScript.GrowthStage.Germinating; populationCount++; return(plantScript); }
public void ActivatePlant(PlantScript plant, ListType fromList, bool imediatly = false) { if (imediatly) { AddAndRemovePlantToList(new ChangePlantList(ListType.activePlants, fromList, plant.specificOrganismIndex)); } else { changePlantList.Add(new ChangePlantList(ListType.activePlants, fromList, plant.specificOrganismIndex)); } plant.spawned = true; }
public PlantData(PlantScript plantScript) { age = plantScript.age; speciesIndex = plantScript.species.speciesIndex; specificSpeciesIndex = plantScript.species.specificSpeciesIndex; plantIndex = plantScript.specificOrganismIndex; zone = plantScript.zone; position = plantScript.position; bladeArea = plantScript.bladeArea; stemHeight = plantScript.stemHeight; rootGrowth = plantScript.rootGrowth; rootDensity = .1f; stage = plantScript.stage; }
public void DeactivatePlant(PlantScript plant, ListType fromList, bool imediatly = false) { plant.ResetPlant(); if (imediatly) { AddAndRemovePlantToList(new ChangePlantList(ListType.inactivePlants, fromList, plant.specificOrganismIndex)); } else { changePlantList.Add(new ChangePlantList(ListType.inactivePlants, fromList, plant.specificOrganismIndex)); } plant.spawned = false; plant.GetMeshRenderer().enabled = false; }
public override void PreSpawn(int spawnNumber) { for (int i = 0; i < spawnNumber; i++) { PlantScript plant = SpawnOrganism(plantPrefab).GetComponent <PlantScript>(); plant.organs = new List <BasicPlantOrganScript>(speciesOrgansOrder.Count); plant.eddibleOrgans = new List <EddiblePlantOrganScript>(speciesOrgansOrder.Count); AddOrganism(plant); earth.GetZoneController().AddPlant(plant); for (int f = 0; f < speciesOrgansOrder.Count; f++) { speciesOrgansOrder[f].MakeOrganism(plant); } plant.SetUpPlantOrganism(this); DeactivatePlant(plant, ListType.unlisted, true); } }
private void OnTriggerStay(Collider other) { GameObject go = other.gameObject; PlantScript ps = go.GetComponent <PlantScript>(); if (ps != null) { if (transform.parent.GetComponent <PlantScript>().IsPlanted) { Debug.Log("une plante est trop proche !"); transform.parent.GetComponent <PlantScript>().AddPenalties(); } } WeedScript ws = go.GetComponent <WeedScript>(); if (ws != null) { Debug.Log("une mauvaise herbe est trop proche !"); transform.parent.GetComponent <PlantScript>().AddPenalties(); } }
public DataLocation(PlantScript plant) { this.dataType = DataType.Plant; this.dataIndex = plant.plantDataIndex; }
public void AddToFindZone(PlantScript plant, int zone = -1, float range = 0) { earth.GetZoneController().FindZoneController.AddFindZoneData(new FindZoneController.FindZoneData(new ZoneController.DataLocation(plant), zone, plant.position, range)); }
public void MakePlant(PlantScript plant, float growth) { }
// Use this for initialization void Start() { PlantScript = GetComponentInParent <PlantScript>(); }
public override void UpdateOrganismsBehavior() { for (int i = 0; i < activeAnimals.Count; i++) { AnimalScript.AnimalActions animalAction = GetAnimalJobController().animalActions[i]; AnimalScript animal = animals[activeAnimals[i]]; switch (animalAction.actionType) { case AnimalScript.AnimalActions.ActionType.Idle: animal.Idle(); User.Instance.PrintState("SittingStill", speciesDisplayName, 1); break; case AnimalScript.AnimalActions.ActionType.RunFromPredator: BasicOrganismScript targetPredatorOrganism = earth.GetZoneController().GetOrganismFromDataLocation(animalAction.dataLocation); if (targetPredatorOrganism.spawned) { animal.RunFromOrganism(targetPredatorOrganism); User.Instance.PrintState("PredatorFound", speciesDisplayName, 2); break; } animal.Explore(); User.Instance.PrintState("Exploring", speciesDisplayName, 1); break; case AnimalScript.AnimalActions.ActionType.EatFood: if (animalAction.dataLocation.dataType == ZoneController.DataLocation.DataType.Animal) { AnimalScript targetAnimal = earth.GetZoneController().GetAnimalFromDataLocation(animalAction.dataLocation); if (targetAnimal.spawned && animal.Eat(targetAnimal)) { animal.LookAtPoint(earth.GetZoneController().GetOrganismFromDataLocation(animalAction.dataLocation).position); User.Instance.PrintState("Eating", speciesDisplayName, 2); break; } } if (animalAction.dataLocation.dataType == ZoneController.DataLocation.DataType.Plant) { PlantScript targetPlant = earth.GetZoneController().GetPlantFromDataLocation(animalAction.dataLocation); if (targetPlant.spawned && animal.Eat(targetPlant)) { animal.LookAtPoint(earth.GetZoneController().GetOrganismFromDataLocation(animalAction.dataLocation).position); User.Instance.PrintState("Eating", speciesDisplayName, 2); break; } } animal.Explore(); User.Instance.PrintState("Exploring", speciesDisplayName, 1); break; case AnimalScript.AnimalActions.ActionType.GoToFood: BasicOrganismScript targetGoToOrganism = earth.GetZoneController().GetOrganismFromDataLocation(animalAction.dataLocation); if (targetGoToOrganism.spawned) { animal.GoToPoint(targetGoToOrganism.position); User.Instance.PrintState("GoingToFood", speciesDisplayName, 1); } else { animal.Explore(); User.Instance.PrintState("Exploring", speciesDisplayName, 1); } break; case AnimalScript.AnimalActions.ActionType.AttemptReproduction: if (animal.mate.spawned && animal.GetReproductive().AttemptReproduction()) { animal.LookAtPoint(animal.mate.position); User.Instance.PrintState("AttemptReproduction", speciesDisplayName, 2); } else { animal.Idle(); User.Instance.PrintState("SittingStill", speciesDisplayName, 1); } break; case AnimalScript.AnimalActions.ActionType.AttemptToMate: AnimalScript targetMate = earth.GetZoneController().GetAnimalFromDataLocation(animalAction.dataLocation); if (targetMate.spawned && animal.AttemptToMate(targetMate)) { animal.LookAtPoint(targetMate.position); User.Instance.PrintState("FoundMate", speciesDisplayName, 2); } else { animal.Explore(); User.Instance.PrintState("Exploring", speciesDisplayName, 1); } break; case AnimalScript.AnimalActions.ActionType.Explore: animal.Explore(); User.Instance.PrintState("Exploring", speciesDisplayName, 1); break; } } }
internal override void SetupOrgan(BasicSpeciesOrganScript basicSpeciesOrganScript) { basicPlantSpeciesOrganScript = (BasicPlantSpeciesOrganScript)basicSpeciesOrganScript; plantScript = basicOrganismScript.GetComponent <PlantScript>(); plantScript.organs.Add(this); }
void Start() { pScript = pPlant.GetComponent <PlantScript>(); stopPlantMoving = false; }