Example #1
0
        /// <summary>
        /// 停止智能移动
        /// </summary>
        protected override void StopAutoMove()
        {
            base.StopAutoMove();

            //终止界面层的指引指针的显示
            MotaWorld.GetInstance().MapManager.StopGuide();
        }
Example #2
0
        /// <summary>
        /// 以待编辑的元素坐标创建窗口
        /// </summary>
        public FrmEdit(Coord editPos)
        {
            InitializeComponent();

            this.CurPosation  = editPos;
            this.content.Text = MotaWorld.GetInstance().MapManager.GetNodeString(editPos);
        }
Example #3
0
        /// <summary>
        /// 打开怪物手册
        /// </summary>
        /// <param name="data">楼层id</param>
        public override void Open(object data)
        {
            Enable = true;

            //搜寻当前楼层的所有怪物
            FloorNode curFloor = MotaWorld.GetInstance().MapManager.CurFloorNode;

            for (int i = 0; i < curFloor.FloorSize.Row; i++)
            {
                for (int j = 0; j < curFloor.FloorSize.Col; j++)
                {
                    if (curFloor.IsMonster(new Coord(j, i)))
                    {
                        //给怪物列表添加怪物, 不用重复
                        Monster oneMonster = curFloor.EventMap[i, j] as Monster;
                        if (!Monsters.Exists(o => o.MonsterId == oneMonster.MonsterId))
                        {
                            Monsters.Add(oneMonster);
                        }
                    }
                }
            }

            //按对勇士造成的伤害排序
            Monsters.Sort();

            //如果存在怪物,绑定第一个怪物的图像更新事件,实现在窗口中播放动态的怪物图像
            if (Monsters.Count > 0)
            {
                Monsters[0].FrameChangeEvent += new EventHandler(OneFlash);
            }

            ReDraw();
        }
Example #4
0
 /// <summary>
 /// 计算新位置四周的可通行性
 /// </summary>
 private void CaculateAroundPass()
 {
     StartPassable = MotaWorld.GetInstance().MapManager.IsPassable(StartPos, MoveDirection);
     EndPassable   = MotaWorld.GetInstance().MapManager.IsPassable(EndPos, MoveDirection);
     LeftPassable  = MotaWorld.GetInstance().MapManager.IsPassable(LeftPos, MoveDirection);
     RightPassable = MotaWorld.GetInstance().MapManager.IsPassable(RightPos, MoveDirection);
 }
Example #5
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 #6
0
        /// <summary>
        /// 设置事件效果
        /// </summary>
        /// <param name="method">事件参数</param>
        public static void EventEffect(MotaEventArgs data)
        {
            if (data.Method == EffectType.Blood || data.Method == EffectType.Goods || data.Method == EffectType.LevelUp)
            {
                MotaWorld.GetInstance().GoodsGetWindow.Open(new ShortMessage("获得" + data.Name, data.ExistStation));
            }

            //获取物品时显示消息
            if (data.Method == EffectType.Goods)
            {
                //播放音效
                SoundsList.PlaySound(SoundType.获得物品);
            }

            if (data.Method == EffectType.Blood)
            {
                SoundsList.PlaySound(SoundType.获取血瓶);
            }

            //获取道具时提升信息
            if (data.Method == EffectType.Prop)
            {
                MotaWorld.GetInstance().MessageShowWindow.Open(Property.GetDescribe(data.Prop));

                SoundsList.PlaySound(SoundType.获取道具);
            }

            if (data.Method == EffectType.LevelUp)
            {
                SoundsList.PlaySound(SoundType.升级);
            }
        }
Example #7
0
        /// <summary>
        /// 下楼
        /// </summary>
        public static void DownFloor(Queue <MotaEventArgs> datas, Hero player)
        {
            MotaEventArgs data = datas.Dequeue();

            MotaWorld.GetInstance().MapManager.CurFloorIndex = MotaWorld.GetInstance().MapManager.CurFloorNode.PreFloor;
            EventEffect(data);
        }
Example #8
0
        /// <summary>
        /// 如果拥有楼层传送器,开启选项窗口并默认选中一项
        /// </summary>
        /// <param name="data">选项索引</param>
        public override void Open(object data)
        {
            //如果有其他窗口,禁止开启
            if (MotaWorld.GetInstance().ExistSolo)
            {
                return;
            }

            int index = MotaWorld.GetInstance().MapManager.CurFloorIndex;

            if (data != null)
            {
                //拆箱转换
                index = (int)data;
            }

            if (MotaWorld.GetInstance().MapManager.CurHero.Pack.ExistProperty(PropName.楼层传送器))
            {
                //添加选项
                this.RemoveAllOptions();
                int sumFloor = MotaWorld.GetInstance().MapManager.Tower.MaxFloor;
                for (int i = 0; i < sumFloor; i++)
                {
                    //如果楼层抵达过,则为有效选项,否则为无效选项
                    FloorOption o = new FloorOption(MotaWorld.GetInstance().MapManager.Tower[i].FloorName, MotaWorld.GetInstance().MapManager.FloorReached[i], i);
                    AddOption(o);
                }

                //默认选中当前楼层
                base.Open(index);
            }
        }
Example #9
0
        /// <summary>
        /// 读档
        /// </summary>
        /// <param name="recordFile">记录文件(XML)</param>
        public void Load(string recordFile)
        {
            /*
             * 1. 加载魔塔地图和当前楼层
             *
             * 2. 加载人物
             *
             * 3. 加载抵达楼层信息
             *
             * 4. 道具包
             *
             */
            XDocument recordDocument = XDocument.Load(recordFile);
            XElement  record         = recordDocument.Root;

            XElement mapArgs  = record.Element("map");
            XElement heroArgs = record.Element("hero");

            //加载当前楼层
            int curFloor = LoadCurFloor(mapArgs);

            //加载地图
            bool[] reached = LoadMap(mapArgs);

            //加载人物
            Hero player = Hero.Create(heroArgs);

            //关闭无关窗口
            MotaWorld.GetInstance().CloseWindow();

            CurGame.Initialize(curFloor, player, reached);
        }
Example #10
0
            /// <summary>
            /// 触发选项
            /// </summary>
            public override void onTrigger()
            {
                //跳转楼层
                MotaWorld.GetInstance().MapManager.CurFloorIndex = Floor;

                base.onTrigger();
            }
Example #11
0
 /// <summary>
 /// 拷贝源本到新元素
 /// </summary>
 /// <param name="desPos">目标坐标</param>
 public void CopyTo(Coord desPos)
 {
     if (SouVersion != null)
     {
         MotaWorld.GetInstance().MapManager.CopyNode(SouVersion, desPos);
     }
 }
Example #12
0
        /// <summary>
        /// 移动一个单位距离,具有平滑移动的效果
        /// </summary>
        public virtual void Move()
        {
            if (MoveDirection == Direction.No)
            {
                return;
            }

            //委托移动帮助类完成移动对象的移动
            new MoveHelper(this).Move();

            //如果新的位置不可通行,终止自动移动
            if (AutoMove && !AutoPath.PassableIn(MotaWorld.GetInstance().MapManager.CurFloorNode))
            {
                StopAutoMove();
            }

            //如果抵达自动移动的目标位置,选取新的方向继续自动移动
            if (Reached)
            {
                AutoPath.NextPos();
                if (!AutoPath.ExistPath)
                {
                    StopAutoMove();
                }
            }
        }
Example #13
0
        public override void MoveTo(Coord pos)
        {
            base.MoveTo(pos);

            //开始移动反应
            MotaWorld.GetInstance().CurHero.WaitMonsters++;
        }
Example #14
0
        /// <summary>
        /// 打开对话窗口
        /// </summary>
        public static void OpenDialogue(Queue <MotaEventArgs> datas, Hero player)
        {
            MotaEventArgs data = datas.Dequeue();

            Dialogue[] dialogues = data.Messages;
            MotaWorld.GetInstance().DialogueWindow.Open(dialogues);

            EventEffect(data);
        }
Example #15
0
 /// <summary>
 /// 使用上楼器
 /// </summary>
 public override void Use(IPropUser user)
 {
     //小于最大楼层
     if (MotaWorld.GetInstance().MapManager.CurFloorIndex < MotaWorld.GetInstance().MapManager.Tower.MaxFloor - 1)
     {
         MotaWorld.GetInstance().MapManager.CurFloorIndex = MotaWorld.GetInstance().MapManager.CurFloorNode.NextFloor;
         this.CutDown();
     }
 }
Example #16
0
        private void BingingHero()
        {
            //绑定人物属性到界面
            MotaWorld.GetInstance().MapManager.CurHero.AttributeChange += new EventHandler(AttributeChange);
            MotaWorld.GetInstance().MapManager.CurHero.Pack.PropertyChangeEvent += new EventHandler(PropertyChange);

            AttributeChange(null, null);
            PropertyChange(null, null);
        }
Example #17
0
        /// <summary>
        /// 绑定人物和楼层属性到界面
        /// </summary>
        private void Binding()
        {
            BingingHero();

            //绑定楼层属性到界面
            MotaWorld.GetInstance().MapManager.FloorChangeEvent += new EventHandler(AttributeChange);

            //游戏结束事件
            MotaWorld.GetInstance().GameOverEvent += new EventHandler(FrmMain_GameOverEvent);
        }
Example #18
0
        private void 编辑ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmEdit edit = new FrmEdit(CurEditPos);

            if (edit.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                //保存内容
                MotaWorld.GetInstance().MapManager.LoadNode(edit.CurPosation, edit.EditContent);
            }
        }
Example #19
0
        /// <summary>
        /// 智能移动到指定的位置
        /// </summary>
        /// <param name="pos">指定的位置</param>
        public override void MoveTo(Coord pos)
        {
            base.MoveTo(pos);

            //显示界面指引指针
            if (AutoPath.ExistPath)
            {
                MotaWorld.GetInstance().MapManager.ShowGuide(AutoPath.EndTargetPos);
            }
        }
Example #20
0
        //释放按键,停止人物移动
        private void FrmMain_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == PreKey)
            {
                PreKey = Keys.None;
            }

            if (MotaWorld.GetInstance().MapManager.Enable)
            {
                MotaWorld.GetInstance().MapManager.CurHero.HandleKeyUp(e.KeyCode);
            }
        }
Example #21
0
        /// <summary>
        /// 关闭事件
        /// </summary>
        public static void CloseEvent(Queue <MotaEventArgs> datas, Hero player)
        {
            MotaEventArgs data = datas.Dequeue();
            //如果目标位置存在事件,关闭它
            MapEvent me = MotaWorld.GetInstance().MapManager.Tower[data.DesPosation.Floor].EventMap[data.DesPosation.Seat.Row, data.DesPosation.Seat.Col];

            if (me != null)
            {
                me.Close();
            }
            EventEffect(data);
        }
Example #22
0
        /// <summary>
        /// 关闭地表
        /// </summary>
        public static void CloseGround(Queue <MotaEventArgs> datas, Hero player)
        {
            MotaEventArgs data = datas.Dequeue();
            //如果目标位置存在地表,关闭它
            Background bg = MotaWorld.GetInstance().MapManager.Tower[data.DesPosation.Floor].BackMap[data.DesPosation.Seat.Row, data.DesPosation.Seat.Col];

            if (bg != null)
            {
                bg.Close();
            }
            EventEffect(data);
        }
Example #23
0
        /// <summary>
        /// 使用破墙镐消除使用者前方的障碍物,如果消去成功,物品数量减1
        /// </summary>
        public override void Use(IPropUser user)
        {
            //打破前面的一堵墙
            Coord station = user.Station;

            station.Offset(user.FaceTo);
            if (MotaWorld.GetInstance().MapManager.Destroy(station))
            {
                //如果破坏成功,减掉道具
                this.CutDown();
            }
        }
Example #24
0
 /// <summary>
 /// 更新界面上的人物属性
 /// </summary>
 void AttributeChange(object sender, EventArgs e)
 {
     PlayerAttack.Text  = MotaWorld.GetInstance().CurHero.Attack.ToString();
     PlayerCoins.Text   = MotaWorld.GetInstance().CurHero.Coin.ToString();
     PlayerDefence.Text = MotaWorld.GetInstance().CurHero.Defence.ToString();
     PlayerAgility.Text = MotaWorld.GetInstance().CurHero.Agility.ToString();
     PlayerMagic.Text   = MotaWorld.GetInstance().CurHero.Magic.ToString();
     PlayerExp.Text     = MotaWorld.GetInstance().CurHero.Exp.ToString();
     PlayerLives.Text   = MotaWorld.GetInstance().CurHero.Hp.ToString();
     PlayerLevel.Text   = MotaWorld.GetInstance().CurHero.Level.ToString();
     lblFloor.Text      = "魔 塔 - " + MotaWorld.GetInstance().MapManager.CurFloorNode.FloorName;
 }
Example #25
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 #26
0
        /// <summary>
        /// 打开怪物信息窗口,显示怪物的详细数据
        /// </summary>
        /// <param name="pos">怪物的坐标(在当前楼层中)</param>
        private void ShowMonsterData(Coord pos)
        {
            FloorNode curFloor = MapManager.CurFloorNode;

            if (curFloor.IsMonster(pos))
            {
                MotaWorld.GetInstance().MiniBookWindow.Open(curFloor.EventMap[pos.Row, pos.Col] as Monster);
            }
            else
            {
                MotaWorld.GetInstance().MiniBookWindow.Close();
            }
        }
Example #27
0
        /// <summary>
        /// 使人物移动到当前楼层中指定的位置
        /// </summary>
        /// <param name="pos">目标位置</param>
        public virtual void MoveTo(Coord pos)
        {
            //委托楼层类计算当前楼层的最短路径
            AutoPath.SetPath(MotaWorld.GetInstance().MapManager.CurFloorNode.GetPath(this.Station, pos));

            //初始化目标位置
            AutoPath.NextPos();

            if (AutoPath.ExistPath)
            {
                AutoMove = true;
            }
        }
Example #28
0
        /// <summary>
        /// 进入陷阱事件,损耗一定的生命值,并产生晃动效果
        /// 如果拥有路障道具的话,可以避免生命值的损耗
        /// </summary>
        public static void OnTrap(Queue <MotaEventArgs> datas, Hero player)
        {
            MotaEventArgs data = datas.Dequeue();

            //检查是否拥有自然之靴
            if (!player.Pack.ExistProperty(PropName.自然之靴))
            {
                player.Hp -= data.Value;
                MotaWorld.GetInstance().MapManager.Shake();
            }

            EventEffect(data);
        }
Example #29
0
        private void MotaScene_MouseMove(object sender, MouseEventArgs e)
        {
            MotaWorld.GetInstance().SetEventFoucs(e.Location);

            if (MotaWorld.GetInstance().MapManager.IsMonster(e.Location))
            {
                SetCursorPicture(false);
            }
            else
            {
                SetCursorPicture(true);
            }
        }
Example #30
0
        /// <summary>
        /// 自动移动停止时方法
        /// </summary>
        protected override void StopAutoMove()
        {
            if (base.AutoMove)
            {
                //移动物理位置
                MotaWorld.GetInstance().MapManager.ShiftEvent(base.AutoPath.StartPos, base.AutoPath.EndTargetPos, base.AutoPath.EndDrection);
            }

            base.StopAutoMove();

            //反应结束
            MotaWorld.GetInstance().CurHero.WaitMonsters--;
        }