Example #1
0
        /// <summary>
        /// 获取与目标对战的预测伤害
        /// </summary>
        /// <param name="target">对战目标, 主动攻击方</param>
        /// <returns>预测伤害</returns>
        public int HarmTo(ICanShowData target)
        {
            int result = 0;

            //无法攻击, 伤害无穷大
            if (target.Attack <= this.Defence)
            {
                result = int.MaxValue;
            }
            //被防杀,伤害为0
            else if (this.Attack <= target.Defence)
            {
                result = 0;
            }
            else
            {
                //单次伤害 = 攻击力 - 防御力
                int oneHarm = this.Attack - target.Defence;

                //受到攻击的次数 = 目标杀死怪物的攻击次数 - 1
                int harmCount = Common.Ceil(this.Hp, target.Attack - this.Defence) - 1;

                //总伤害 = 单次伤害 * 受到攻击的次数
                result = oneHarm * harmCount;
            }

            return(result);
        }
Example #2
0
        /// <summary>
        /// 以怪物接口打开怪物手册
        /// </summary>
        /// <param name="data">怪物接口</param>
        public override void Open(object data)
        {
            if (!MotaWorld.GetInstance().MapManager.CurHero.Pack.ExistProperty(PropName.怪物侦测器))
            {
                return;
            }

            if (!(data is ICanShowData))
            {
                throw new Exception("错误的怪物类型");
            }

            //打开之前先尝试关闭之前的窗口
            Close();

            Monster = data as ICanShowData;
            Monster.FrameChangeEvent += new EventHandler(OneFlash);
            Monster.Selected          = true;

            //设置窗口位置
            ShowPoint = GetShowPosation();

            Enable = true;
            ReDraw();
        }
Example #3
0
        /// <summary>
        /// 绘制怪物数据
        /// </summary>
        /// <param name="g">画布</param>
        /// <param name="trun">怪物在页面中的出现次序</param>
        /// <param name="monster">怪物元素</param>
        private void DrawMonsterData(Graphics g, int trun, ICanShowData monster)
        {
            ICanShowData hero      = MotaWorld.GetInstance().MapManager.CurHero;
            Font         strFont   = new Font("幼圆", 12, FontStyle.Bold);
            SolidBrush   strBrush  = new SolidBrush(Color.White);
            SolidBrush   harmBrush = new SolidBrush(Color.White);

            //怪物名称
            g.DrawString(monster.Name, strFont, strBrush, new PointF(70, 50 + 62 * trun));

            //怪物生命
            g.DrawString("生命: " + monster.Hp.ToString(), strFont, strBrush, new PointF(170, 50 + 62 * trun));

            //怪物攻击
            g.DrawString("攻击: " + monster.Attack.ToString(), strFont, strBrush, new PointF(280, 50 + 62 * trun));

            //怪物防御
            g.DrawString("防御: " + monster.Defence.ToString(), strFont, strBrush, new PointF(380, 50 + 62 * trun));

            //怪物等级
            g.DrawString("等级: " + monster.Level.ToString(), strFont, strBrush, new PointF(480, 50 + 62 * trun));

            //伤害预测
            int    harm = monster.HarmTo(hero);
            string harmDesc;

            if (harm == int.MaxValue)
            {
                harmDesc        = "无法攻击";
                harmBrush.Color = Color.Red;
            }
            else if (harm == 0)
            {
                harmDesc        = "无危险";
                harmBrush.Color = Color.LightGreen;
            }
            else if (harm < hero.Hp)
            {
                harmDesc        = "受到" + harm.ToString() + "点伤害";
                harmBrush.Color = Color.LightSalmon;
            }
            else
            {
                harmDesc        = "受到" + harm.ToString() + "点伤害";
                harmBrush.Color = Color.DarkGray;
            }
            g.DrawString(harmDesc, strFont, harmBrush, new PointF(70, 72 + 62 * trun));

            //收获
            g.DrawString("金币: " + monster.Coin, strFont, strBrush, new PointF(280, 72 + 62 * trun));
            g.DrawString("经验: " + monster.Exp, strFont, strBrush, new PointF(380, 72 + 62 * trun));
        }
Example #4
0
        /// <summary>
        /// 与其他人物就可对目标对象造成多少伤害进行比较,如果伤害相同,比较id
        /// </summary>
        /// <param name="obj">可战斗的人物</param>
        /// <returns>如果伤害相同且id相同,返回0,如果伤害比比较对象小,返回-1</returns>
        public int CompareTo(object obj)
        {
            ICanShowData monster = obj as ICanShowData;

            ICanShowData hero = MotaWorld.GetInstance().MapManager.CurHero;

            if (this.HarmTo(hero) == monster.HarmTo(hero))
            {
                return(this.MonsterId.CompareTo(monster.MonsterId));
            }
            if (this.HarmTo(hero) > monster.HarmTo(hero))
            {
                return(1);
            }
            return(-1);
        }
Example #5
0
        /// <summary>
        /// 获取与目标对战的预测伤害
        /// </summary>
        /// <param name="target">对战目标, 主动攻击方</param>
        /// <returns>预测伤害</returns>
        public int HarmTo(ICanShowData target)
        {
            int result = 0;
            //无法攻击, 伤害无穷大
            if (target.Attack <= this.Defence)
            {
                result = int.MaxValue;
            }
            //被防杀,伤害为0
            else if (this.Attack <= target.Defence)
            {
                result = 0;
            }
            else
            {
                //单次伤害 = 攻击力 - 防御力
                int oneHarm = this.Attack - target.Defence;

                //受到攻击的次数 = 目标杀死怪物的攻击次数 - 1
                int harmCount = Common.Ceil(this.Hp, target.Attack - this.Defence) - 1;

                //总伤害 = 单次伤害 * 受到攻击的次数
                result = oneHarm * harmCount;
            }

            return result;
        }
Example #6
0
        /// <summary>
        /// 以怪物接口打开怪物手册
        /// </summary>
        /// <param name="data">怪物接口</param>
        public override void Open(object data)
        {
            if (!MotaWorld.GetInstance().MapManager.CurHero.Pack.ExistProperty(PropName.怪物侦测器))
            {
                return;
            }

            if (!(data is ICanShowData))
            {
                throw new Exception("错误的怪物类型");
            }

            //打开之前先尝试关闭之前的窗口
            Close();

            Monster = data as ICanShowData;
            Monster.FrameChangeEvent += new EventHandler(OneFlash);
            Monster.Selected = true;

            //设置窗口位置
            ShowPoint = GetShowPosation();

            Enable = true;
            ReDraw();
        }
Example #7
0
        /// <summary>
        /// 绘制怪物数据到窗口
        /// </summary>
        protected override void ReDraw()
        {
            Graphics vGraphics = Graphics.FromImage(WindowFace);

            vGraphics.Clear(Color.Transparent);

            //临时绘图窗口
            Graphics g = Graphics.FromImage(Canvas);

            g.Clear(Color.BlueViolet);

            Font         strFont   = new Font("微软雅黑", 12, FontStyle.Regular);
            SolidBrush   strBrush  = new SolidBrush(Color.White);
            ICanShowData hero      = MotaWorld.GetInstance().MapManager.CurHero;
            SolidBrush   harmBrush = new SolidBrush(Color.White);   //伤害刷子

            //绘制边框
            g.DrawRectangle(new Pen(Color.LightGreen, 2), new Rectangle(0, 0, Canvas.Width, Canvas.Height));

            //怪物名称
            g.DrawString(Monster.Name, new Font("幼圆", 14, FontStyle.Regular), strBrush, new PointF(90, 20));

            //怪物等级
            g.DrawString("等级: " + Monster.Level.ToString(), strFont, strBrush, new PointF(10, 60));

            //怪物生命
            g.DrawString("生命: " + Monster.Hp.ToString(), strFont, strBrush, new PointF(120, 60));

            //怪物攻击
            g.DrawString("攻击: " + Monster.Attack.ToString(), strFont, strBrush, new PointF(10, 90));

            //怪物防御
            g.DrawString("防御: " + Monster.Defence.ToString(), strFont, strBrush, new PointF(120, 90));

            //怪物敏捷
            g.DrawString("敏捷: " + Monster.Agility.ToString(), strFont, strBrush, new PointF(10, 120));

            //怪物防御
            g.DrawString("魔法: " + Monster.Magic.ToString(), strFont, strBrush, new PointF(120, 120));

            //怪物防御
            g.DrawString("金币: " + Monster.Coin.ToString(), strFont, strBrush, new PointF(10, 150));

            //怪物防御
            g.DrawString("经验: " + Monster.Exp.ToString(), strFont, strBrush, new PointF(120, 150));

            //怪物简介
            g.DrawString(Monster.Description, new Font("幼圆", 12, FontStyle.Regular), strBrush, new Rectangle(10, 180, 230, 60));

            //伤害预测
            int    harm = Monster.HarmTo(hero);
            string harmDesc;

            if (harm == int.MaxValue)
            {
                harmDesc        = "无法攻击";
                harmBrush.Color = Color.Red;
            }
            else if (harm == 0)
            {
                harmDesc        = "无危险";
                harmBrush.Color = Color.LightGreen;
            }
            else if (harm < hero.Hp)
            {
                harmDesc        = "可能造成" + harm.ToString() + "点伤害";
                harmBrush.Color = Color.LightSalmon;
            }
            else
            {
                harmDesc        = "可能造成" + harm.ToString() + "点伤害";
                harmBrush.Color = Color.DarkGray;
            }
            g.DrawString(harmDesc, strFont, harmBrush, new PointF(10, 240));
            Canvas.SetOpacity(0.80F);

            //将临时窗口绘制到视图窗口上,交由其共享到全局视图中。
            vGraphics.DrawImage(Canvas, ShowPoint);

            //绘制连接线
            vGraphics.DrawLine(new Pen(Color.LightGreen, 1), MonsterLinkPoint, WindowLinkPoint);

            //绘制怪物头像
            OneFlash(null, null);
        }
Example #8
0
        /// <summary>
        /// 绘制怪物数据
        /// </summary>
        /// <param name="g">画布</param>
        /// <param name="trun">怪物在页面中的出现次序</param>
        /// <param name="monster">怪物元素</param>
        private void DrawMonsterData(Graphics g, int trun, ICanShowData monster)
        {
            ICanShowData hero = MotaWorld.GetInstance().MapManager.CurHero;
            Font strFont = new Font("幼圆", 12, FontStyle.Bold);
            SolidBrush strBrush = new SolidBrush(Color.White);
            SolidBrush harmBrush = new SolidBrush(Color.White);

            //怪物名称
            g.DrawString(monster.Name, strFont, strBrush, new PointF(70, 50 + 62 * trun));

            //怪物生命
            g.DrawString("生命: " + monster.Hp.ToString(), strFont, strBrush, new PointF(170, 50 + 62 * trun));

            //怪物攻击
            g.DrawString("攻击: " + monster.Attack.ToString(), strFont, strBrush, new PointF(280, 50 + 62 * trun));

            //怪物防御
            g.DrawString("防御: " + monster.Defence.ToString(), strFont, strBrush, new PointF(380, 50 + 62 * trun));

            //怪物等级
            g.DrawString("等级: " + monster.Level.ToString(), strFont, strBrush, new PointF(480, 50 + 62 * trun));

            //伤害预测
            int harm = monster.HarmTo(hero);
            string harmDesc;
            if (harm == int.MaxValue)
            {
                harmDesc = "无法攻击";
                harmBrush.Color = Color.Red;
            }
            else if (harm == 0)
            {
                harmDesc = "无危险";
                harmBrush.Color = Color.LightGreen;
            }
            else if (harm < hero.Hp)
            {
                harmDesc = "受到" + harm.ToString() + "点伤害";
                harmBrush.Color = Color.LightSalmon;
            }
            else
            {
                harmDesc = "受到" + harm.ToString() + "点伤害";
                harmBrush.Color = Color.DarkGray;

            }
            g.DrawString(harmDesc, strFont, harmBrush, new PointF(70, 72 + 62 * trun));

            //收获
            g.DrawString("金币: " + monster.Coin, strFont, strBrush, new PointF(280, 72 + 62 * trun));
            g.DrawString("经验: " + monster.Exp, strFont, strBrush, new PointF(380, 72 + 62 * trun));
        }