Esempio n. 1
0
        public void OnClickDump()
        {
            string       path     = Application.dataPath + "/../SavedMap_" + System.DateTime.Now.ToBinary().ToString() + ".rc";
            BinaryWriter writer   = new BinaryWriter(new FileStream(path, FileMode.Create));
            Camp         bestCamp = GetComponent <SimulationController>().BestCamp;

            writer.Write(CalculateHappiness());
            // Player's camp
            writer.Write(tents.Count);
            foreach (GameObject tent in tents)
            {
                writer.Write((int)tent.transform.position.x);
                writer.Write((int)tent.transform.position.z);
            }

            writer.Write(watertanks.Count);
            foreach (GameObject watertank in watertanks)
            {
                writer.Write((int)watertank.transform.position.x);
                writer.Write((int)watertank.transform.position.z);
            }

            writer.Write(washrooms.Count);
            foreach (GameObject washroom in washrooms)
            {
                writer.Write((int)washroom.transform.position.x);
                writer.Write((int)washroom.transform.position.z);
            }
            // AI's camp
            writer.Write(bestCamp.GetHappiness());
            foreach (Tent tent in bestCamp.GetTents())
            {
                writer.Write(tent.X());
                writer.Write(tent.Y());
            }

            foreach (Water water in bestCamp.GetWaters())
            {
                writer.Write(water.X());
                writer.Write(water.Y());
            }

            foreach (Toilet toilet in bestCamp.GetToilets())
            {
                writer.Write(toilet.X());
                writer.Write(toilet.Y());
            }
            writer.Write(Settings.WaterHeight);
            writer.Close();
            Application.Quit();
        }
Esempio n. 2
0
 public void BuildCampOfDarkLord(Camp camp)
 {
     foreach (Tent tent in camp.GetTents())
     {
         Instantiate(tentPrefab, new Vector3(tent.X(), 0, tent.Y()), Quaternion.identity);
     }
     foreach (Water water in camp.GetWaters())
     {
         Instantiate(watertankPrefab, new Vector3(water.X(), 0, water.Y()), Quaternion.identity);
     }
     foreach (Toilet toilet in camp.GetToilets())
     {
         Instantiate(washroomPrefab, new Vector3(toilet.X(), 0, toilet.Y()), Quaternion.identity);
     }
 }