Exemple #1
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        GestationHandler gestationHandler = (GestationHandler)target;

        if (GUILayout.Button("Force Birth"))
        {
            if (Application.isPlaying)
            {
                gestationHandler.father = gestationHandler.mother;

                gestationHandler.childCount      = (uint)Mathf.FloorToInt(Mathf.Lerp(2, 9, Random.Range(0, 2) == 1 ? gestationHandler.father.genes[Genotype.GestationSize] : gestationHandler.mother.genes[Genotype.GestationSize]));
                gestationHandler.gestationPeriod = 0f;
                gestationHandler.gestationStart  = Time.time;

                gestationHandler.pregnant = true;
                gestationHandler.StartCoroutine("Gestate");
            }
        }
    }
Exemple #2
0
    private void Awake()
    {
        transform.parent = GameObject.Find("Creatures").transform;
        originalScale    = transform.localScale;
        navAgent         = GetComponent <NavMeshAgent>();
        gestation        = GetComponent <GestationHandler>();
        birthTime        = Time.time;

        if (Generation == 1)
        {
            genes     = GeneSet.GetFirstGenerationGenes();
            birthTime = Time.time - 60f;

            maxNutrition = Mathf.Clamp(Mathf.Lerp(originalMaxNutrition - 2, originalMaxNutrition + 2, ability[Genotype.Nutrition]), 1, Mathf.Infinity);
            maxHydration = Mathf.Clamp(Mathf.Lerp(originalMaxHydration - 2, originalMaxHydration + 2, ability[Genotype.Nutrition]), 1, Mathf.Infinity);

            Nutrition        = Random.Range(1f, maxNutrition);
            Hydration        = Random.Range(1f, maxHydration);
            ReproductiveUrge = Random.Range(0.1f, 0.35f);
        }
        else
        {
            gender = (Random.Range(0, 2) == 1 ? GenderType.Male : GenderType.Female);
        }

        if (gestation != null && gender == GenderType.Male)
        {
            gestation.enabled = false;
        }
        ReproductiveUrge = 0f;

        CreatureDatabase.RegisterCreature(this);
        specieNo = (uint)CreatureDatabase.GetCreatureCount(this);

        name = ID;

        StartCoroutine(UpdateSight());
    }