Beispiel #1
0
        /// <summary>
        /// 根据参数配置创建类的实例
        /// </summary>
        /// <param name="createArgs">参数配置</param>
        /// <returns>返回类实例</returns>
        public static Hero Create(XElement createArgs)
        {
            CharacterArgs data = CharacterArgs.CreateFrom(createArgs);

            int row, col;

            try
            {
                row = int.Parse(createArgs.Attribute("row").Value);
                col = int.Parse(createArgs.Attribute("col").Value);
            }
            catch (Exception)
            {
                throw new Exception("错误的位置");
            }
            Coord showPosation = new Coord(col, row);

            string fileName = data.FaceFile;
            Size   unitSize = GetSize(createArgs.Attribute("unitSize").Value);

            Hero player = new Hero(showPosation, data, unitSize);

            //获取背包数据
            player.Pack = Packet.Create(createArgs.Element("packet"));

            //加载技能信息
            if (createArgs.Element("skill") != null)
            {
                XElement faceXml = createArgs.Element("skill").Element("skillImages");
                string[] images  = Weapon.GetSkillImages(faceXml);
                player.SetSkillFlash(images[0], images[1], images[2]);
            }

            return(player);
        }
Beispiel #2
0
        /// <summary>
        /// 根据参数配置创建类的实例
        /// </summary>
        /// <param name="createArgs">参数配置</param>
        /// <returns>返回类实例</returns>
        public static MapEvent Create(XElement createArgs, Coord existCoord)
        {
            CharacterArgs data = CharacterArgs.CreateFrom(createArgs);

            string fileName = data.FaceFile;
            Size   unitSize = GetSize(createArgs.Attribute("unitSize").Value);

            return(new Monster(existCoord, data, unitSize));
        }
Beispiel #3
0
        /// <summary>
        /// 创建英雄的新实例
        /// </summary>
        /// <param name="pos">勇士在地图上的坐标</param>
        /// <param name="data">勇士属性</param>
        /// <param name="unitSize">图像分隔的单位尺寸</param>
        private Hero(Coord pos, CharacterArgs data, Size unitSize)
            : base(pos, data, true, unitSize)
        {
            WaitMonsters = 0;

            //增加勇士独有的技能
            skills.Add(new BestAttack(true));
            skills.Add(new Miss(true));
            //skills.Add(new Recover(true));
        }
Beispiel #4
0
        /// <summary>
        /// 创建英雄的新实例
        /// </summary>
        /// <param name="pos">勇士在地图上的坐标</param>
        /// <param name="data">勇士属性</param>
        /// <param name="unitSize">图像分隔的单位尺寸</param>
        private Hero(Coord pos, CharacterArgs data, Size unitSize)
            : base(pos, data, true, unitSize)
        {
            WaitMonsters = 0;

            //增加勇士独有的技能
            skills.Add(new BestAttack(true));
            skills.Add(new Miss(true));
            //skills.Add(new Recover(true));
        }
Beispiel #5
0
        /// <summary>
        /// 创建人物的新实例
        /// </summary>
        /// <param name="pos">人物在地图上的坐标</param>
        /// <param name="data">人物属性</param>
        /// <param name="isHero">是否是勇士</param>
        /// <param name="unitSize">图像分割的单位尺寸</param>
        protected Character(Coord pos, CharacterArgs data, bool isHero, Size unitSize)
            : base(data.FaceFile, pos, data.Name, unitSize)
        {
            this.Name = data.Name;
            this.Level = data.Level;
            this.Hp = data.Hp;
            this.Attack = data.Attack;
            this.Defence = data.Defence;
            this.Agility = data.Agility;
            this.Magic = data.Magic;
            this.Coin = data.Coin;
            this.Exp = data.Exp;
            this.MonsterId = data.MonsterId;
            this.Description = data.Description;

            //默认拥有的技能, 次序很重要
            skills.Add(new CommonAttack(isHero));
            skills.Add(new HelmSplitter(isHero));
            skills.Add(new GoodAttack(isHero));

            SkillOnIt = null;
        }
Beispiel #6
0
        /// <summary>
        /// 创建人物的新实例
        /// </summary>
        /// <param name="pos">人物在地图上的坐标</param>
        /// <param name="data">人物属性</param>
        /// <param name="isHero">是否是勇士</param>
        /// <param name="unitSize">图像分割的单位尺寸</param>
        protected Character(Coord pos, CharacterArgs data, bool isHero, Size unitSize)
            : base(data.FaceFile, pos, data.Name, unitSize)
        {
            this.Name        = data.Name;
            this.Level       = data.Level;
            this.Hp          = data.Hp;
            this.Attack      = data.Attack;
            this.Defence     = data.Defence;
            this.Agility     = data.Agility;
            this.Magic       = data.Magic;
            this.Coin        = data.Coin;
            this.Exp         = data.Exp;
            this.MonsterId   = data.MonsterId;
            this.Description = data.Description;

            //默认拥有的技能, 次序很重要
            skills.Add(new CommonAttack(isHero));
            skills.Add(new HelmSplitter(isHero));
            skills.Add(new GoodAttack(isHero));

            SkillOnIt = null;
        }
Beispiel #7
0
        /// <summary>
        /// 加载怪物数据
        /// </summary>
        /// <param name="sourceFile">数据文件</param>
        public static void LoadMonsterData(string dataFile)
        {
            XDocument monsterData = XDocument.Load(dataFile);

            XElement root = monsterData.Root;
            IEnumerable <XElement> monsters = root.Elements();

            //根据怪物数量创建数据数组
            Data = new CharacterArgs[monsters.Count()];

            for (int i = 0; i < monsters.Count(); i++)
            {
                XElement      mon = monsters.ElementAt(i);
                CharacterArgs oneData;
                try
                {
                    oneData = new CharacterArgs(
                        int.Parse(mon.Element("id").Value),
                        mon.Element("faceFile").Value,
                        mon.Element("name").Value,
                        int.Parse(mon.Element("level").Value),
                        int.Parse(mon.Element("hp").Value),
                        int.Parse(mon.Element("attack").Value),
                        int.Parse(mon.Element("defence").Value),
                        int.Parse(mon.Element("agility").Value),
                        int.Parse(mon.Element("magic").Value),
                        int.Parse(mon.Element("coin").Value),
                        int.Parse(mon.Element("exp").Value),
                        mon.Element("describe").Value
                        );
                }
                catch (Exception)
                {
                    throw new Exception("读取怪物数据错误");
                }
                Data[i] = oneData;
            }
        }
Beispiel #8
0
 /// <summary>
 /// 创建怪物的新实例
 /// </summary>
 /// <param name="showPos">怪物在地图上的坐标</param>
 /// <param name="data">怪物属性</param>
 /// <param name="unitSize">怪物图像分割的单位尺寸</param>
 private Monster(Coord showPos, CharacterArgs data, Size unitSize)
     : base(showPos, data, false, unitSize)
 {
     CanBattle = true;
 }