Example #1
0
        private int CalculateHappiness()
        {
            Camp currentCamp  = Simulation.GetEmptyCamp();
            int  tentCapacity = Simulation.TentCapacity;
            // Set tents
            List <Tent> tentsForLord = new List <Tent>();

            foreach (GameObject tent in tents)
            {
                Vector2 position = new Vector3(tent.transform.position.x, tent.transform.position.z);
                tentsForLord.Add(new Tent(position, tentCapacity));
            }
            currentCamp.SetTents(tentsForLord);
            // Set watertanks
            List <Water> watertanksForLord = new List <Water>();

            foreach (GameObject watertank in watertanks)
            {
                watertanksForLord.Add(new Water((int)watertank.transform.position.x, (int)watertank.transform.position.z));
            }
            currentCamp.SetWaters(watertanksForLord);
            // Set washrooms
            List <Toilet> washroomsForLord = new List <Toilet>();

            foreach (GameObject washroom in washrooms)
            {
                Vector2 position = new Vector3(washroom.transform.position.x, washroom.transform.position.z);
                washroomsForLord.Add(new Toilet(position));
            }
            currentCamp.SetToilets(washroomsForLord);

            // Set water per person
            currentCamp.SetWaterPerPersonForDrink((int)UI.WaterPerPerson);
            return(currentCamp.GetHappiness());
        }