예제 #1
0
    public void GoOutside(World world) //decides if they go outside
    {
        Move.slotNum = Slot;
        mostHungry   = 0;
        int prob;
        int thingy;

        for (int i = 0; i < world.neighborhood[houseSlot].family.Length; i++)
        {
            if (world.neighborhood[houseSlot].family[i] != null)
            {
                if (world.neighborhood[houseSlot].family[i].hunger > mostHungry)
                {
                    mostHungry = world.neighborhood[houseSlot].family[i].hunger;    //sets mostHungry to the most hungry person in the house
                }
            }
        }

        if (mostHungry > shoppingThreshhold && world.neighborhood[houseSlot].someoneShopping == false)
        {
            wentShopping = true;
            world.neighborhood[houseSlot].someoneShopping = true;
            Move.GoToStore();
            Move.agent.radius = 0.15f;
        }

        if (wentShopping == false)
        {
            if (personalityType.Equals("Introverted"))
            {
                prob = (boredom - personalityModifier) / coop;   //makes them more likely to stay inside if introverted, vice versa
            }
            else
            {
                prob = (boredom + personalityModifier) / coop;
            }

            thingy = Random.Range(0, 101);

            if (thingy <= prob)
            {
                wentOutside = true;
                Move.GoToPark();
            }
        }
    }