예제 #1
0
        public void OnClicked()
        {
            PlayerInfromation p = GameObject.Find("main").GetComponent <GameController>().p;

            if (p != null)
            {
                int[] inf = LevelToInformation.getProptwo(p.proptwo);
                damage  = inf[0];
                lanlang = inf[1];
                offset  = inf[2];
                this.gameObject.GetComponent <ButtonChange>().time = offset;
            }
            if (storm != null && Time.time > nextTime && GameObject.Find("main").GetComponent <majorCity1>().labliang >= lanlang)
            {
                nextTime = Time.time + offset;
                GameObject life = Instantiate(storm, target.transform.position + new Vector3(0, 13, 0), Quaternion.identity, cam);
                target.GetComponent <majorCity1>().labliang -= lanlang;
                Destroy(life, 8);
                stat = true;
            }
        }
예제 #2
0
        public bool addUser(PlayerInfromation player)
        {
            if (!check())
            {
                return(false);
            }
            XmlNode root = doc.DocumentElement;

            if (selectUser(player.id) != null)
            {
                return(false);
            }
            //玩家根节点
            XmlElement   xelKey = doc.CreateElement("player");
            XmlAttribute xelId  = doc.CreateAttribute("id");

            xelId.InnerText = player.id;
            xelKey.SetAttributeNode(xelId);
            XmlAttribute xeltime = doc.CreateAttribute("time");

            xeltime.InnerText = System.DateTime.Now.ToLongDateString();
            xelKey.SetAttributeNode(xeltime);
            //玩家姓名
            XmlElement xelname = doc.CreateElement("name");

            xelname.InnerText = player.name;
            xelKey.AppendChild(xelname);
            //玩家金币
            XmlElement xelmoney = doc.CreateElement("money");

            xelmoney.InnerText = player.money.ToString();
            xelKey.AppendChild(xelmoney);
            //玩家成绩
            XmlElement xelscore = doc.CreateElement("score");

            xelscore.InnerText = player.score.ToString();
            xelKey.AppendChild(xelscore);
            //玩家level
            XmlElement xellevel = doc.CreateElement("level");

            xellevel.InnerText = player.level.ToString();
            xelKey.AppendChild(xellevel);
            //玩家castle
            XmlElement xelcastle = doc.CreateElement("castle");

            xelcastle.InnerText = player.castle.ToString();
            xelKey.AppendChild(xelcastle);
            //玩家defence
            XmlElement xeldefence = doc.CreateElement("defence");

            xeldefence.InnerText = player.defence.ToString();
            xelKey.AppendChild(xeldefence);
            //玩家propone
            XmlElement xelpropone = doc.CreateElement("propone");

            xelpropone.InnerText = player.propone.ToString();
            xelKey.AppendChild(xelpropone);
            //玩家proptwo
            XmlElement xelproptwo = doc.CreateElement("proptwo");

            xelproptwo.InnerText = player.proptwo.ToString();
            xelKey.AppendChild(xelproptwo);
            //玩家propthree
            XmlElement xelpropthree = doc.CreateElement("propthree");

            xelpropthree.InnerText = player.propthree.ToString();
            xelKey.AppendChild(xelpropthree);

            root.AppendChild(xelKey);
            doc.Save(path);
            updateHash();
            return(true);
        }
예제 #3
0
        // Use this for initialization 初始化
        void Start()
        {
            level      = PlayerPrefs.GetInt("SelectLevel");
            difficulty = PlayerPrefs.GetInt("SelectDifficulty");
            player     = PlayerPrefs.GetString("id");
            cam        = GameObject.Find("ImageTarget-Image-cam1").transform;
            //test.text = "初始化开始!";
            xmlCenter = new XmlPlayerInformation();
            //关卡初始化

            //玩家不存在时新建,存在时加载
            if ((p = xmlCenter.selectUser(player)) == null)
            {
                p           = new PlayerInfromation();
                p.id        = player;
                p.money     = 0;
                p.name      = "play1";
                p.score     = 0;
                p.level     = 0;
                p.castle    = 0;
                p.propone   = 0;
                p.proptwo   = 0;
                p.propthree = 0;
                xmlCenter.addUser(p);
                //test.text += p.id;
            }

            initPlayer(p);
            //确定关卡与难度
            if (level == 1)
            {
                gameLevel = new GameLevel1();
                if (difficulty == 1)
                {
                    gameLevel.gameTime = 5000;
                    gameLevel.maxEnemy = 6;
                }
                else if (difficulty == 2)
                {
                    gameLevel.gameTime = 6000;
                    gameLevel.maxEnemy = 9;
                }
                else
                {
                    gameLevel.gameTime = 7000;
                    gameLevel.maxEnemy = 12;
                }
            }
            else
            if (level == 2)
            {
                gameLevel = new GameLevel2();
                if (difficulty == 1)
                {
                    gameLevel.gameTime = 7000;
                    gameLevel.maxEnemy = 9;
                }
                else if (difficulty == 2)
                {
                    gameLevel.gameTime = 8000;
                    gameLevel.maxEnemy = 12;
                }
                else
                {
                    gameLevel.gameTime = 9000;
                    gameLevel.maxEnemy = 15;
                }
            }
            else
            if (level == 3)
            {
                gameLevel          = new GameLevel3();
                gameLevel.gameTime = 0;
                if (difficulty == 1)
                {
                    gameLevel.maxEnemy = 10;
                }
                else if (difficulty == 2)
                {
                    gameLevel.maxEnemy = 12;
                }
                else
                {
                    gameLevel.maxEnemy = 15;
                }
            }
            else
            if (level == 4)
            {
                gameLevel          = new GameLevel4();
                gameLevel.gameTime = 0;
                if (difficulty == 1)
                {
                    gameLevel.maxEnemy = 5;
                }
                else if (difficulty == 2)
                {
                    gameLevel.maxEnemy = 10;
                }
                else
                {
                    gameLevel.maxEnemy = 15;
                }
            }
            //else if(level == 5)
            //{
            //    PlayerPrefs.SetInt("SelectLevel", 5);
            //    PlayerPrefs.SetInt("SelectDifficulty", 2);
            //    SceneManager.LoadScene("scene/TuoLuoYi");
            //}

            gameLevel.currTime     = 0;
            gameLevel.enemyPrefabs = enemyPrefabs;
            gameLevel.positions    = positions;
        }