Exemplo n.º 1
0
    private void Reproduce()
    {
        HouseScript home = agentResources.Home.GetComponent("HouseScript") as HouseScript;

        if (home.CanReproduce())
        {
            int dieRoll = UnityEngine.Random.Range(1, 100);

            if (dieRoll < PROCREATE_CHANCE)
            {
                AgentsCreator agentsCreator = transform.parent.gameObject.GetComponent("AgentsCreator") as AgentsCreator;
                agentsCreator.BornAgent(transform.position);
            }
        }
    }
    // Use this for initialization
    void Start()
    {
        agentsCreator    = gameObject.GetComponent("AgentsCreator") as AgentsCreator;
        agentsManager    = gameObject.GetComponent("AgentsManager") as AgentsManager;
        deathsHandler    = gameObject.GetComponent("AgentsDeathsHandler") as AgentsDeathsHandler;
        timeDistribution = gameObject.GetComponent("TimeDistribution") as TimeDistribution;


        populationCounterTxt = populationCounterTxtbox.GetComponent <Text>();
        populationCounterTxt = populationCounterTxtbox.GetComponent <Text>();

        infantsCounterTxt = infantsCounterTxtbox.GetComponent <Text>();

        eatenCounterTxt     = eatenCounterTxtbox.GetComponent <Text>();
        starvedCounterTxt   = starvedCounterTxtbox.GetComponent <Text>();
        deathsCounterTxt    = deathsCounterTxtbox.GetComponent <Text>();
        averageLifespaneTxt = averageLifespanTxtbox.GetComponent <Text>();

        daysPassedTxt = daysPassedTxtbox.GetComponent <Text>();

        scoreManager = HSManager.GetComponent("ScoreManager") as ScoreManager;
    }
    internal void Procreate()
    {
        ABOD3_Bridge.GetInstance().AletForElement(botNumber, "C-Procreate", "C");

        isGoingToProcreate = false;
        isHome             = true;
        if (home != null)
        {
            home.GetComponent <HouseScript>().UpdateAgentReproduction(canProcreate);
        }

        if ((home.GetComponent <HouseScript>()).CanReproduce())
        {
            ABOD3_Bridge.GetInstance().AletForElement(botNumber, "CE-HasEnoughEnergy", "CE");
            ABOD3_Bridge.GetInstance().AletForElement(botNumber, "AttemptProcreation", "A");

            int dieRoll = UnityEngine.Random.Range(0, 100);
            staminaLevel--;
            if (dieRoll < PROCREATE_CHANCE)
            {
                staminaLevel--;

                AgentsCreator agentsCreator = transform.parent.gameObject.GetComponent("AgentsCreator") as AgentsCreator;
                agentsCreator.BornAgent(transform.position);
            }
        }
        else
        {
            ABOD3_Bridge.GetInstance().AletForElement(botNumber, "CE-NotEnoughEnergy", "CE");
            ABOD3_Bridge.GetInstance().AletForElement(botNumber, "StayHome", "A");
        }


        if (home != null)
        {
            home.GetComponent <HouseScript>().UpdateAgentReproduction(false);
        }
    }