Esempio n. 1
0
        public void SpawnFigure(FigurePool fp)
        {
            Figure figure = fp.Get();

            figure.gameObject.SetActive(true);
            figure.gameObject.transform.position = _spawnPosition;
            figure.Dead += fp.ReturnObject;
            Debug.Log("Spawn:" + fp.gameObject.name);
        }
Esempio n. 2
0
 private void GenerateObject(XElement root)
 {
     foreach (XElement element in root.Elements(ChildElementXML))
     {
         GameObject go = (GameObject)Instantiate(Resources.Load(PrefabPoolName));
         FigurePool fp = go.GetComponent <FigurePool>();
         fp.m_prefab        = (Resources.Load <Figure>("Figure/" + element.Value));
         fp.m_prefab.Score  = Int32.Parse(element.Attribute("reward").Value);
         fp.m_size          = DataManager.DM.MaxSizePool;
         fp.gameObject.name = fp.gameObject.name + element.Value;
         fp.AwakePool();
         GenerateUI(element, fp);
         DataManager.DM.Pools.Add(fp);
     }
 }
Esempio n. 3
0
        private void GenerateUI(XElement element, FigurePool fp)
        {
            GameObject item = Instantiate(Resources.Load <GameObject>(PrefabItemUI), _scrollViewContent.transform);

            foreach (Transform child in item.transform)
            {
                if (child.gameObject.GetComponent <TextMeshProUGUI>() != null)
                {
                    child.gameObject.GetComponent <TextMeshProUGUI>().text = element.Attribute("reward").Value;
                }
                if (child.gameObject.GetComponent <Button>() != null)
                {
                    child.gameObject.AddComponent <ButtonSpawn>();
                    child.gameObject.GetComponent <ButtonSpawn>().Fp     = fp;
                    child.gameObject.GetComponent <ButtonSpawn>().Spawn += GameManager.Gm.SpawnFigure;
                }
            }
            Instantiate(Resources.Load <GameObject>("FigureUI/" + element.Value), item.transform);
        }