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);
            }
        }
    }
Ejemplo n.º 2
0
    public void SpreadSeed(PlantScript parent)
    {
        PlantScript newSeed = plantSpecies.SpawnSeed(parent, seedDispertionRange);

        newSeed.SpawnSeed();
        AddSeed();
    }
Ejemplo n.º 3
0
    internal override void AddSpecificOrganism(BasicOrganismScript newOrganism)
    {
        PlantScript newPlant = (PlantScript)newOrganism;

        plants.Add(newPlant);
        newPlant.specificOrganismIndex = plants.Count - 1;
    }
Ejemplo n.º 4
0
 void SetUpOrgans(PlantScript plantScript)
 {
     for (int i = 0; i < speciesOrgansOrder.Count; i++)
     {
         speciesOrgansOrder[i].MakeOrganism(plantScript);
     }
 }
Ejemplo n.º 5
0
    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;
        }
    }
Ejemplo n.º 6
0
    public PlantScript SpawnRandomSeed()
    {
        PlantScript plantScript = GetInactivePlant();

        ActivatePlant(plantScript, ListType.inactivePlants, true);
        RandomiseOrganismPosition(plantScript);
        AddToFindZone(plantScript);
        return(plantScript);
    }
Ejemplo n.º 7
0
 public void AddPlant(PlantScript plant)
 {
     if (allPlantsCount == allPlants.Length)
     {
         IncreaceAllPlantLength(1);
     }
     plant.plantDataIndex = allPlantsCount;
     allPlantsCount++;
 }
Ejemplo n.º 8
0
 public bool Eat(PlantScript plant)
 {
     if (Full())
     {
         return(false);
     }
     AddFood(plant.EatPlant(this, math.min(GetMouth().biteSize *GetBiteAmmount(), animalSpecies.maxFood - food)));
     return(true);
 }
Ejemplo n.º 9
0
    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);
    }
Ejemplo n.º 10
0
    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);
    }
Ejemplo n.º 11
0
 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();
     }
 }
Ejemplo n.º 12
0
    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);
    }
Ejemplo n.º 13
0
 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;
 }
Ejemplo n.º 14
0
 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;
 }
Ejemplo n.º 15
0
 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;
 }
Ejemplo n.º 16
0
 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);
     }
 }
Ejemplo n.º 17
0
    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();
        }
    }
Ejemplo n.º 18
0
 public DataLocation(PlantScript plant)
 {
     this.dataType  = DataType.Plant;
     this.dataIndex = plant.plantDataIndex;
 }
Ejemplo n.º 19
0
 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));
 }
Ejemplo n.º 20
0
 public void MakePlant(PlantScript plant, float growth)
 {
 }
Ejemplo n.º 21
0
 // Use this for initialization
 void Start()
 {
     PlantScript = GetComponentInParent <PlantScript>();
 }
Ejemplo n.º 22
0
    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;
            }
        }
    }
Ejemplo n.º 23
0
 internal override void SetupOrgan(BasicSpeciesOrganScript basicSpeciesOrganScript)
 {
     basicPlantSpeciesOrganScript = (BasicPlantSpeciesOrganScript)basicSpeciesOrganScript;
     plantScript = basicOrganismScript.GetComponent <PlantScript>();
     plantScript.organs.Add(this);
 }
Ejemplo n.º 24
0
 void Start()
 {
     pScript         = pPlant.GetComponent <PlantScript>();
     stopPlantMoving = false;
 }