Exemplo n.º 1
0
        public void OnClick(GameObject tagButton)
        {
            for (int i = 0; i < tagButtons.Length; i++)
            {
                if (tagButton == tagButtons[i])
                {
                    groups[i].SetActive(true);
                    GetGrids(i);
                    OnValueChange();
                    tagButtons[i].GetComponent <UIButton>().isEnabled = false;
                    group           = (Global.Group)System.Enum.Parse(typeof(Global.Group), tagButtons[i].transform.name);
                    groupLabel.text = groupLabelText[i];
                }
                else
                {
                    groups[i].SetActive(false);
                    tagButtons[i].GetComponent <UIButton>().isEnabled = true;
                }
            }

            if (File.Exists(Global.path))
            {
                SaveController.GetInstance().LoadXML();
                NumberController.GetInstance().Number();
            }
        }
Exemplo n.º 2
0
        public void Initialize()
        {
            obj.SetActive(true);
            int     random     = Random.Range(0, 4);
            UIAtlas totalAtlas = new UIAtlas();

            switch (random)
            {
            case 0:
                group = Global.Group.northern;
                avatar_group.spriteName = "player_faction_northern_realms";
                group_label.text        = "北方领域";
                deck_realms.spriteName  = "board_deck_northern_realms";
                totalAtlas = GameController.GetInstance().atlas[0];
                break;

            case 1:
                group = Global.Group.nilfgaardian;
                avatar_group.spriteName = "player_faction_northern_nilfgaard";
                group_label.text        = "尼弗迦德";
                deck_realms.spriteName  = "board_deck_nilfgaard";
                totalAtlas = GameController.GetInstance().atlas[1];
                break;

            case 2:
                group = Global.Group.monster;
                avatar_group.spriteName = "player_faction_northern_no_mans_land";
                group_label.text        = "怪兽";
                deck_realms.spriteName  = "board_deck_no_mans_land";
                totalAtlas = GameController.GetInstance().atlas[2];
                break;

            case 3:
                group = Global.Group.scoiatael;
                avatar_group.spriteName = "player_faction_scoiatael";
                group_label.text        = "松鼠党";
                deck_realms.spriteName  = "board_deck_scoiatael";
                totalAtlas = GameController.GetInstance().atlas[3];
                break;
            }

            XmlDocument xml = new XmlDocument();

            xml.Load(Global.enemyPath);
            XmlElement root    = xml.DocumentElement;
            XmlNode    xmlNode = root.SelectSingleNode(string.Format("/root/{0}", group));

            int name = 0;

            XmlNodeList leaderList   = xmlNode.SelectSingleNode("leader").ChildNodes;
            XmlNode     leaderNode   = leaderList[Random.Range(0, leaderList.Count)];
            GameObject  leaderObject = LeaderController.GetInstance().obj[1];
            UISprite    leaderSprite = leaderObject.GetComponent <UISprite>();

            leaderSprite.atlas      = totalAtlas;
            leaderSprite.spriteName = leaderNode.Attributes["sprite"].Value;
            leaderObject.AddComponent(System.Type.GetType(leaderNode.Attributes["behavior"].Value));

            XmlNodeList special = xmlNode.SelectSingleNode("special").ChildNodes;

            foreach (XmlNode cardNode in special)
            {
                for (int i = 0; i < int.Parse(cardNode.Attributes["max"].Value); i++)
                {
                    GameObject cardObject = Instantiate(GameController.GetInstance().cardPerfab, grids[0]);
                    cardObject.name = name.ToString();
                    name++;
                    UISprite cardSprite = cardObject.GetComponent <UISprite>();
                    cardSprite.atlas      = GameController.GetInstance().atlas[4];
                    cardSprite.spriteName = cardNode.Attributes["sprite"].Value;
                    CardProperty cardProperty = cardObject.GetComponent <CardProperty>();
                    cardProperty.line   = (Global.Line)System.Enum.Parse(typeof(Global.Line), cardNode.Attributes["line"].Value);
                    cardProperty.effect = (Global.Effect)System.Enum.Parse(typeof(Global.Effect), cardNode.Attributes["effect"].Value);
                    cardProperty.gold   = bool.Parse(cardNode.Attributes["gold"].Value);
                    cardProperty.power  = int.Parse(cardNode.Attributes["power"].Value);
                }
            }

            XmlNodeList monster = xmlNode.SelectSingleNode("monster").ChildNodes;

            foreach (XmlNode cardNode in monster)
            {
                for (int i = 0; i < int.Parse(cardNode.Attributes["max"].Value); i++)
                {
                    GameObject cardObject = Instantiate(GameController.GetInstance().cardPerfab, grids[0]);
                    cardObject.name = name.ToString();
                    name++;
                    UISprite cardSprite = cardObject.GetComponent <UISprite>();
                    cardSprite.atlas      = totalAtlas;
                    cardSprite.spriteName = cardNode.Attributes["sprite"].Value;
                    CardProperty cardProperty = cardObject.GetComponent <CardProperty>();
                    cardProperty.line   = (Global.Line)System.Enum.Parse(typeof(Global.Line), cardNode.Attributes["line"].Value);
                    cardProperty.effect = (Global.Effect)System.Enum.Parse(typeof(Global.Effect), cardNode.Attributes["effect"].Value);
                    cardProperty.gold   = bool.Parse(cardNode.Attributes["gold"].Value);
                    cardProperty.power  = int.Parse(cardNode.Attributes["power"].Value);
                }
            }

            XmlNodeList neutral = xmlNode.SelectSingleNode("neutral").ChildNodes;

            foreach (XmlNode cardNode in neutral)
            {
                for (int i = 0; i < int.Parse(cardNode.Attributes["max"].Value); i++)
                {
                    GameObject cardObject = Instantiate(GameController.GetInstance().cardPerfab, grids[0]);
                    cardObject.name = name.ToString();
                    name++;
                    UISprite cardSprite = cardObject.GetComponent <UISprite>();
                    cardSprite.atlas      = GameController.GetInstance().atlas[4];
                    cardSprite.spriteName = cardNode.Attributes["sprite"].Value;
                    CardProperty cardProperty = cardObject.GetComponent <CardProperty>();
                    cardProperty.line   = (Global.Line)System.Enum.Parse(typeof(Global.Line), cardNode.Attributes["line"].Value);
                    cardProperty.effect = (Global.Effect)System.Enum.Parse(typeof(Global.Effect), cardNode.Attributes["effect"].Value);
                    cardProperty.gold   = bool.Parse(cardNode.Attributes["gold"].Value);
                    cardProperty.power  = int.Parse(cardNode.Attributes["power"].Value);
                }
            }

            DrawCards(10);
            Number();
        }