示例#1
0
 // Update is called once per frame
 public void UpdateState()
 {
     if (!isSleeping)
     {
         isSleeping  = true;
         currentTime = Time.fixedTime;
     }
     else
     {
         if (survivor.getSurvivorTiredness() < 90)
         {
             if (Time.fixedTime - currentTime >= 0.5f)
             {
                 survivor.setSurvivorTiredness(survivor.getSurvivorTiredness() + 10);
                 if (survivor.getSurvivorHealth() + 1 < 100)
                 {
                     survivor.setSurvivorHealth(survivor.getSurvivorHealth() + 1);
                 }
                 currentTime = Time.fixedTime;
             }
         }
         else
         {
             isSleeping = false;
             survivor.home.GetComponent <House>().setSign(0);
             ToHomeState();
         }
     }
 }
示例#2
0
    // Update is called once per frame
    public void UpdateState()
    {
        survivor.GetComponent <Statistics>().AgentVisible(false);

        if (survivor.getSurvivorHunger() < 15 || survivor.getSurvivorThirst() < 15)
        {
            Debug.Log("MANGER");
            ToNourrishState();
        }

        else if (survivor.getSurvivorHealth() <= 50)
        {
            Debug.Log("SOIN");
            ToHealState();
        }

        else if (survivor.getSurvivorTiredness() < 15)
        {
            Debug.Log("DODO");
            survivor.home.GetComponent <House>().setSign(1);
            ToSleepState();
        }

        else if (survivor.collectState.getNoResources() && (!survivor.home.GetComponent <House>().haveFarm ||
                                                            !survivor.home.GetComponent <House>().haveWell) && survivor.home.GetComponent <House>().LowResources())
        {
            survivor.home.GetComponent <House>().setSign(0);
            survivor.GetComponent <Statistics>().AgentVisible(true);
            survivor.sword.enabled = true;
            Debug.Log("A LA BATAILLE!");
            ToFightState();
        }

        else if ((!survivor.home.GetComponent <House>().haveWell || !survivor.home.GetComponent <House>().haveFarm) && survivor.home.GetComponent <House>().getScrap() >= 2)
        {
            survivor.home.GetComponent <House>().setSign(3);
            Debug.Log("BUILDING");
            ToBuildState();
        }

        else if (survivor.home.GetComponent <House>().getSafety() < 10 && survivor.home.GetComponent <House>().getScrap() >= 1)
        {
            survivor.home.GetComponent <House>().setSign(2);
            Debug.Log("REPARO!");
            ToRepairState();
        }

        else
        {
            survivor.home.GetComponent <House>().setSign(0);
            survivor.GetComponent <Statistics>().AgentVisible(true);
            ToCollectState();
        }
    }