Exemple #1
0
    internal void GotEaten()
    {
        AgentsDeathsHandler deathsHandler = transform.parent.gameObject.GetComponent("AgentsDeathsHandler") as AgentsDeathsHandler;

        deathsHandler.AgentWasEaten((agentsManager.GetComponent("TimeDistribution") as TimeDistribution).DaysPassed - dateBorn);

        KillItself();
    }
Exemple #2
0
    internal void GotDrowned()
    {
        AgentsDeathsHandler deathsHandler = transform.parent.gameObject.GetComponent("AgentsDeathsHandler") as AgentsDeathsHandler;

        deathsHandler.AgentWasDrowned(timeDistribution.DaysPassed - dateBorn);

        KillItself();
    }
Exemple #3
0
    internal void GotEaten()
    {
        if (canBeEaten && isNight)
        {
            AgentsDeathsHandler deathsHandler = transform.parent.gameObject.GetComponent("AgentsDeathsHandler") as AgentsDeathsHandler;
            deathsHandler.AgentWasEaten(timeDistribution.DaysPassed - dateBorn);

            KillItself();
        }
    }
Exemple #4
0
    private void CheckIfAlive()
    {
        if (Time.time >= maxLife)
        {
            AgentsDeathsHandler deathsHandler = transform.parent.gameObject.GetComponent("AgentsDeathsHandler") as AgentsDeathsHandler;
            deathsHandler.AgentDied(timeDistribution.DaysPassed - dateBorn);

            KillItself();
        }
    }
Exemple #5
0
    private void Tired()
    {
        agentResources.DecreaseStamina();
        if (agentResources.Stamina == 0)
        {
            AgentsDeathsHandler deathsHandler = transform.parent.gameObject.GetComponent("AgentsDeathsHandler") as AgentsDeathsHandler;
            deathsHandler.AgentStaved((agentsManager.GetComponent("TimeDistribution") as TimeDistribution).DaysPassed - dateBorn);

            KillItself();
        }
    }
    // 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;
    }
Exemple #7
0
    private void UpdateStamina()
    {
        if (Time.time >= nextStaminaUpdate)
        {
            nextStaminaUpdate = Mathf.FloorToInt(Time.time) + staminaUpdateTime;             // Change the next update (current second+1)
            agentBehaviours.GetHungrier();
        }

        if (agentBehaviours.IsFull())
        {
            agentBehaviours.BecomeFull();
        }
        else if (agentBehaviours.HasStaminaToProcreate())
        {
            agentBehaviours.BecomeAbleToProcreate();
        }
        else if (agentBehaviours.IsHungry())
        {
            agentBehaviours.BecomeHungry();
        }
        else if (agentBehaviours.IsStarving())
        {
            agentBehaviours.BecomeStarving();
        }
        else if (agentBehaviours.IsDead())
        {
            AgentsDeathsHandler deathsHandler = transform.parent.gameObject.GetComponent("AgentsDeathsHandler") as AgentsDeathsHandler;
            deathsHandler.AgentStaved(timeDistribution.DaysPassed - dateBorn);

            KillItself();
        }
        else
        {
            agentBehaviours.BecomeUnableToProcreate();
        }
    }