private void readFile()
        {
            TextAsset xml_Text = (TextAsset)Resources.Load("EasyPopulation/population", typeof(TextAsset));

            MemoryStream stream   = new MemoryStream(xml_Text.bytes);
            Encoding     encoding = Encoding.GetEncoding("UTF-8");
            StreamReader stream2  = new StreamReader(stream, encoding);

            popDBFile = new populationDB();
            XmlSerializer serializer = new XmlSerializer(typeof(populationDB));

            popDBFile = serializer.Deserialize(stream2) as populationDB;
            stream.Close();
            stream2.Close();
        }
示例#2
0
      private void loadDataFromCitizenFactoryData()
      {
          popDBFile = new populationDB();

          if (popDBFile != null)
          {
              popDBFile.list.Clear();
              ActorData ad = new ActorData();
              ad.quantidade = CitizenFactory.quantity_Production;
              foreach (GameObject adult in CitizenFactory.listaTemplates_Adults_Production)
              {
                  if (adult == null)
                  {
                      Debug.LogError("There is no associated 3d model (citizen)!");
                  }
                  else
                  {
                      ad.adults.Add(adult.name);
                  }
              }
              foreach (GameObject child in CitizenFactory.listaTemplates_Children_Production)
              {
                  if (child == null)
                  {
                      Debug.LogError("There is no associated 3d model (children)!");
                  }
                  else
                  {
                      ad.children.Add(child.name);
                  }
              }
              foreach (GameObject anchor in CitizenFactory.anchors_Production)
              {
                  if (anchor == null)
                  {
                      Debug.LogError("There is no anchors (anchor)!");
                  }
                  else
                  {
                      ad.anchors.Add(new Vector3(anchor.transform.position.x, anchor.transform.position.y, anchor.transform.position.z));
                  }
              }
              ad.anchorRadius = (int)CitizenFactory.anchorRadius_Production;
              ad.anchorHeight = (int)CitizenFactory.anchorHeight_Production;
              foreach (ClassWorkerProducao worker in CitizenFactory.listaDefinicaoWorkers)
              {
                  TrabalhadorData tr = new TrabalhadorData();
                  tr.tipo  = (int)worker.tipo;
                  tr.count = worker.count;
                  if (worker.boneco != null)
                  {
                      tr.nome = worker.boneco.name;
                  }
                  if (worker.posicaoInicial != null)
                  {
                      tr.posicao = worker.posicaoInicial.transform.position;
                  }
                  tr.raioAtracao = worker.raioAtracao;
                  if (worker.animacaoInicial != null)
                  {
                      tr.animacao = worker.animacaoInicial.name;
                  }
                  if (worker.posicaoDelivery != null)
                  {
                      tr.delivery = worker.posicaoDelivery.transform.position;
                  }
                  tr.freedom = worker.freedom;
                  if (worker.animacao2 != null)
                  {
                      tr.animacao2 = worker.animacao2.name;
                  }
                  ad.worker.Add(tr);
              }
              popDBFile.list.Add(ad);
          }
          else
          {
              Debug.LogError("XMLManager Before Serialize popPrep e null");
          }
      }