示例#1
0
        /// <summary>
        /// 将该武将的技能和相应的技能状态以消息的方式传送给所有玩家
        /// </summary>
        /// <param name="aData">游戏数据</param>
        public void ReportSkills(GlobalData aData)
        {
            Beaver root = new Beaver("skills", ChiefName);

            foreach (SkillBase s in Skills)
            {
                root.Add(string.Empty, new Beaver("skill", s.SkillName, s.SkillStatus.ToString()));
            }
            aData.Game.AsynchronousCore.SendMessage(root.ToString());
        }
示例#2
0
        /// <summary>
        /// 产生所有玩家状态的XML消息
        /// </summary>
        /// <param name="aChief">产生信息的武将对象,对于请求公共信息,这里使用null</param>
        /// <returns>XML消息</returns>
        internal string MakeEnvironmentXMLReport(ChiefBase aChief)
        {
            Beaver env     = new Beaver();
            Beaver players = new Beaver();
            Beaver chain   = new Beaver();
            Beaver hands   = null;

            foreach (Player p in GB.GamePlayers.All)
            {
                hands = new Beaver("hands");
                Beaver debuffs = new Beaver();
                Beaver skills  = new Beaver();
                foreach (Card c in p.Debuff)
                {
                    debuffs.Add(string.Empty, new Beaver(c.CardEffect.ToString(), c.ID));
                }
                //new XElement("effect", c.CardEffect),
                //new XElement("card", c.ID)
                //));
                debuffs.SetHeaderElementName("debuffs");
                if (p.Chief != null)
                {
                    foreach (SkillBase s in p.Chief.Skills)
                    {
                        skills.Add(string.Empty, new Beaver(string.Empty, s.SkillName, s.SkillStatus.ToString()));  // new XElement("skill", new XElement("name", s.SkillName), new XElement("status", s.SkillStatus)));
                    }
                    if (p.Chief == aChief)
                    {
                        lock (GB.AsynchronousCore.MessageLocker)
                        {
                            foreach (string item in GB.EventChain)
                            {
                                chain.Add(item);
                            }
                        }
                        hands = MakeHandMessage(p);
                    }
                    skills.SetHeaderElementName("skills");
                }
                if (p.Chief != null && p.Chief == aChief)
                {
                    Beaver player = new Beaver();
                    player.Add(string.Empty, p.UID, p.PlayerName, p.Dead.ToString(), p.MaxHealth.ToString(), p.Health.ToString());
                    player.Add(string.Empty, hands, debuffs, skills, p.Chief == null ? string.Empty : p.Chief.ChiefName,
                               p.Chief != null && p.Chief.ChiefStatus == ChiefBase.Status.Majesty ? ChiefBase.Status.Majesty.ToString() : p.Chief != null && p.Dead ? p.Chief.ChiefStatus.ToString() : ChiefBase.Status.Unknown.ToString());
                    if (p.Weapon != null)
                    {
                        player.Add("weapon", p.Weapon.ID);
                    }
                    if (p.Armor != null)
                    {
                        player.Add("armor", p.Armor.ID);
                    }
                    if (p.Jia1Ma != null)
                    {
                        player.Add("jia1", p.Jia1Ma.ID);
                    }
                    if (p.Jian1Ma != null)
                    {
                        player.Add("jian1", p.Jian1Ma.ID);
                    }
                    players.Add(string.Empty, player);
                    //new XElement("player",
                    //    new XElement("UID", p.UID),
                    //    new XElement("name", p.PlayerName),
                    //    new XElement("dead", p.Dead),
                    //    new XElement("max_health", p.MaxHealth),
                    //    new XElement("health", p.Health),
                    //    p.Weapon == null ? new XElement("weapon") :new XElement("weapon", p.Weapon.ID),
                    //    p.Armor == null ?new XElement("armor") :new XElement("armor" , p.Armor.ID),
                    //    p.Jia1Ma == null ?  new XElement("jia1"):new XElement("jia1",p.Jia1Ma.ID),
                    //    p.Jian1Ma == null ? new XElement("jian1") : new XElement("jian1", p.Jian1Ma.ID),
                    //    hands,
                    //    debuffs,
                    //    new XElement("chief_name", p.Chief == null ? string.Empty : p.Chief.ChiefName),
                    //    new XElement("status", p.Chief != null && p.Chief.ChiefStatus == ChiefBase.Status.Majesty ? ChiefBase.Status.Majesty : p.Chief != null && p.Dead ? p.Chief.ChiefStatus : ChiefBase.Status.Unknown),
                    //    skills
                    //));
                }
                else
                {
                    Beaver player = new Beaver();
                    player.Add(string.Empty, p.UID, p.PlayerName, p.Dead.ToString(), p.MaxHealth.ToString(), p.Health.ToString());
                    player.Add(string.Empty, p.Hands.Count, debuffs, skills, p.Chief == null ? string.Empty : p.Chief.ChiefName,
                               p.Chief != null && p.Chief.ChiefStatus == ChiefBase.Status.Majesty ? ChiefBase.Status.Majesty.ToString() : p.Chief != null && p.Dead ? p.Chief.ChiefStatus.ToString() : ChiefBase.Status.Unknown.ToString());
                    if (p.Weapon != null)
                    {
                        player.Add("weapon", p.Weapon.ID);
                    }
                    if (p.Armor != null)
                    {
                        player.Add("armor", p.Armor.ID);
                    }
                    if (p.Jia1Ma != null)
                    {
                        player.Add("jia1", p.Jia1Ma.ID);
                    }
                    if (p.Jian1Ma != null)
                    {
                        player.Add("jian1", p.Jian1Ma.ID);
                    }
                    players.Add(string.Empty, player);
                    //players.Add(
                    //    new XElement("player",
                    //        new XElement("UID", p.UID),
                    //        new XElement("name", p.PlayerName),
                    //        new XElement("dead", p.Dead),
                    //        new XElement("max_health", p.MaxHealth),
                    //        new XElement("health", p.Health),
                    //        p.Weapon == null ? new XElement("weapon") : new XElement("weapon", p.Weapon.ID),
                    //        p.Armor == null ? new XElement("armor") : new XElement("armor", p.Armor.ID),
                    //        p.Jia1Ma == null ? new XElement("jia1") : new XElement("jia1", p.Jia1Ma.ID),
                    //        p.Jian1Ma == null ? new XElement("jian1") : new XElement("jian1", p.Jian1Ma.ID),
                    //        new XElement("hands_count", p.Hands.Count),
                    //        debuffs,
                    //        new XElement("chief_name", p.Chief == null ? string.Empty : p.Chief.ChiefName),
                    //        new XElement("status", p.Chief != null && p.Chief.ChiefStatus == ChiefBase.Status.Majesty ? ChiefBase.Status.Majesty : p.Chief != null && p.Dead ? p.Chief.ChiefStatus : ChiefBase.Status.Unknown),
                    //        skills
                    //    ));
                }
            }
            if (aChief == null)
            {
                lock (GB.EventChainLocker)
                {
                    foreach (string item in GB.EventChain)
                    {
                        chain.Add(string.Empty, item);
                    }
                }
            }

            //env.Add(players);
            //env.Add(new XElement("latency", GB.WaittingData.Latency));
            //env.Add(new XElement("mode", GB.Mode));
            //env.Add(chain);
            //env.Add(new XElement("active" , GB.gData.Active == null ? string.Empty : GB.gData.Active.ChiefName));
            //env.Add(new XElement("status" , GB.gData.ChiefStatus));

            env.Add(string.Empty, players);
            env.Add("common", GB.WaittingData.Latency, GB.Mode.ToString(), chain, GB.gData.Active == null ? string.Empty : GB.gData.Active.ChiefName, GB.gData.ChiefStatus);
            env.SetHeaderElementName("environment");
            return(env.ToString());
        }