Ejemplo n.º 1
0
 /// <summary>
 /// 返回魔塔的唯一实例,如果不存在,创建一个
 /// </summary>
 /// <returns></returns>
 public static MotaWorld GetInstance()
 {
     if (Mota == null)
     {
         Mota = new MotaWorld();
     }
     return Mota;
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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;
            }
        }
Ejemplo n.º 7
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--;
        }
Ejemplo n.º 8
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();
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 重写触发函数,加上开门系统事件
        /// </summary>
        /// <param name="player">调用者</param>
        public override void TriggerEvent(Hero player)
        {
            if (Enable && Key != PropName.事件钥)
            {
                //背包中存在钥匙或不要求钥匙直接开门
                if (MotaWorld.GetInstance().MapManager.CurHero.Pack.ExistProperty(Key) || Key == PropName.NULL)
                {
                    Close();
                }
            }

            //重复撞门都会触发以下事件,直到门消失为止
            base.TriggerEvent(player);
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 设置新的楼层
        /// </summary>
        /// <param name="index">楼层索引</param>
        private void SetFloor(int index)
        {
            curFloorIndex = index;

            if (FloorChangeEvent != null)
            {
                FloorChangeEvent(null, EventArgs.Empty);
            }

            //经过的楼层设置为true
            FloorReached[index] = true;

            //楼层跳转效果
            MotaWorld.GetInstance().SkipFlashWindow.Open(new ShortMessage(CurFloorNode.FloorName, Coord.Empty));
            SoundsList.PlaySound(SoundType.楼层跳转);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 处理按键
        /// </summary>
        /// <param name="code">按键</param>
        /// <returns>返回一个布尔值,标示按键是否被处理</returns>
        public override bool HandleKeyDown(System.Windows.Forms.Keys code)
        {
            if (code == System.Windows.Forms.Keys.J)
            {
                if (MotaWorld.GetInstance().FloorSkipWindow.Enable == true)
                {
                    MotaWorld.GetInstance().FloorSkipWindow.Enable = false;
                }
                else
                {
                    MotaWorld.GetInstance().FloorSkipWindow.Open(null);
                }
                return(true);
            }

            if (Enable)
            {
                //如果窗口有效,则捕获按键
                if (code == System.Windows.Forms.Keys.Up)
                {
                    PreItem();
                }
                else if (code == System.Windows.Forms.Keys.Down)
                {
                    NextItem();
                }
                else if (code == System.Windows.Forms.Keys.Left)
                {
                    //向左选
                    this.SelectedIndex -= GameIni.SkipWindowRow;
                }
                else if (code == System.Windows.Forms.Keys.Right)
                {
                    //向右选
                    this.SelectedIndex += GameIni.SkipWindowRow;
                }
                else if (code == System.Windows.Forms.Keys.Enter)
                {
                    this.Enter();
                    Enable = false;
                }
                return(true);
            }

            return(false);
        }
Ejemplo n.º 13
0
        private void MotaScene_MouseClick(object sender, MouseEventArgs e)
        {
            Coord pos = MotaWorld.GetInstance().MapManager.GetPosation(e.Location);

            if (e.Button == System.Windows.Forms.MouseButtons.Right && Editable)
            {
                CurEditPos = pos;
                cmsMenu.Show(this.MotaScene, e.Location);
                return;
            }

            if (MotaWorld.GetInstance().Enable)
            {
                MotaWorld.GetInstance().HandleMouseClick(e.Location, e.Button == System.Windows.Forms.MouseButtons.Left);
            }

            Tester.ClickTest(pos);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 开门,等待门自动关闭
        /// </summary>
        public override void Close()
        {
            //如果存在此种钥匙,则减去钥匙并开门
            Dynamic = true;

            //减去需求的钥匙,如果钥匙不存在,没有影响
            MotaWorld.GetInstance().MapManager.CurHero.Pack.RemoveProperty(Key);

            if (Key == PropName.NULL || Key == PropName.事件钥)
            {
                SoundsList.PlaySound(SoundType.暗墙);
            }
            else
            {
                SoundsList.PlaySound(SoundType.开门);
            }
            Enable = false;
        }
Ejemplo n.º 15
0
        public FrmMain()
        {
            InitializeComponent();

            SetCursorPicture(true);

            MotaScene.Width  = GameIni.WindowWidth;
            MotaScene.Height = GameIni.WindowHeight;

            timer1.Interval = GameIni.RefreshInterval;


            (PropShow = new PacketBox(this.PropPack.Width, this.PropPack.Height)).Enable = true;

            IniGameSelect();

            MotaWorld.GetInstance().MapManager.OnIniEvent += new MainGame.IniEventHandle(Binding);

            SetBack();
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 触发战斗事件
        /// </summary>
        /// <param name="player">触发者</param>
        public override void TriggerEvent(Hero player)
        {
            //如果可以战斗,打开战斗窗口
            if (CanBattle && !(this.HarmTo(player) == int.MaxValue && player.Level < this.Level))
            {
                IFighter[] fighters = new IFighter[2];
                fighters[0] = player;
                fighters[1] = this;

                //以战斗的双方作为参数开启战斗窗口
                MotaWorld.GetInstance().BattleWindow.Open(fighters);
            }
            else
            {
                //无法战斗
                MotaWorld.GetInstance().MessageShowWindow.Open("攻击力不足,无法与这只怪物战斗!");
                SoundsList.PlaySound(SoundType.错误);
            }

            base.TriggerEvent(player);
        }
Ejemplo n.º 17
0
        //根据按键更新游戏选项或移动人物
        private void FrmMain_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == PreKey)
            {
                if (KeyCount >= 7)
                {
                    KeyCount = 0;
                }
                else
                {
                    KeyCount++;
                    return;
                }
            }
            else
            {
                PreKey = e.KeyCode;
            }

            if (e.KeyCode == Keys.T)
            {
                Test();
            }

            if (e.KeyCode == Keys.U)
            {
                this.Editable = !this.Editable;
            }

            if (MotaWorld.GetInstance().HandleKeyDown(e.KeyCode))
            {
                return;
            }

            GameShow.HandleKeyDown(e.KeyCode);

            GameSelectWindow.Refresh();
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 触发推箱子事件
        /// </summary>
        /// <param name="player">触发者</param>
        public override void TriggerEvent(Hero player)
        {
            //要推到的坐标
            Coord desPoint = this.Station;

            desPoint.Offset(player.FaceTo);

            PushWaitCount++;
            if (PushWaitCount <= GameIni.BoxPushWait)
            {
                return;
            }

            //如果箱子的前方为空,则推动那个位置
            if (MotaWorld.GetInstance().MapManager.ShiftEvent(this.Station, desPoint, player.FaceTo))
            {
                StartMove(player.FaceTo);
                SoundsList.PlaySound(SoundType.推箱子);
                this.MoveCount -= GameIni.BoxMoveTimes;
            }

            base.TriggerEvent(player);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 重写触发函数,加上打开商店窗口的事件
        /// </summary>
        /// <param name="player">调用者</param>
        public override void TriggerEvent(Hero player)
        {
            //获取交易者
            Idealer dealer = MotaWorld.GetInstance().MapManager.CurHero as Idealer;

            //商店引用
            Shop shop = MotaWorld.GetInstance().ShopWindow;

            //重新更新商店选项
            shop.RemoveAllOptions();
            for (int i = 0; i < DealOptions.Length; i++)
            {
                DealOption o = new DealOption(DealOptions[i]);
                shop.AddOption(o);
            }
            //添加交易关闭选项
            shop.AddOption(new DealOption("        关闭商店"));
            shop.ShopMessage = this.ShopMessage;

            shop.Open(dealer);

            base.TriggerEvent(player);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 与装备接触的装备获取事件.
        /// </summary>
        /// <param name="player">调用者</param>
        public override void TriggerEvent(Hero player)
        {
            //如果人物等级高于需求的等级,获取装备
            if (Enable && player.Level >= this.LevelDemand)
            {
                player.Attack  += this.GetAbility.Attack;
                player.Defence += this.GetAbility.Defence;
                player.Agility += this.GetAbility.Agility;
                player.Magic   += this.GetAbility.Magic;

                MotaWorld.GetInstance().MessageShowWindow.Open(Description);
                SoundsList.PlaySound(SoundType.升级);

                this.Exist = false;
            }
            else
            {
                MotaWorld.GetInstance().MessageShowWindow.Open("获取此装备需要达到" + this.LevelDemand + "级,\r\n您的等级不足够获取此装备!");
                SoundsList.PlaySound(SoundType.错误);
            }

            base.TriggerEvent(player);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 帮助可移动对象移动一个单位的距离,并触发相应的地图事件
        /// </summary>
        public void Move()
        {
            //要计算的最终目标地点
            Point desSite = PreSite;

            //记录之前的坐标,用于与新坐标进行比较
            Coord preStation = this.Mover.Station;

            //如果前方可以通行,直接前进
            if (ObstacleFree)
            {
                desSite = NextSite;
            }
            //如果临界,调整位置使人物走到障碍物的边界而不跨越障碍物
            else if (Critical)
            {
                desSite = MoveToCrisisLine();
            }
            //如果被障碍物遮挡,但前方可以通行,则滑动人物越过障碍物
            else if (Passable)
            {
                desSite = Slide();
            }
            //无法移动,触发事件
            else if (CanTrigger)
            {
                MotaWorld.GetInstance().MapManager.TriggerEvent(FaceToPos, TouchMethod.ImmediatelyTouch, Caller);
            }

            this.Mover.Location = desSite;

            //位置不同时触发新位置上的事件
            if (preStation.CompareTo(this.Mover.Station) != 0 && CanTrigger)
            {
                MotaWorld.GetInstance().MapManager.TriggerEvent(this.Mover.Station, TouchMethod.StationTouch, Caller);
            }
        }
Ejemplo n.º 22
0
 /// <summary>
 /// 使用怪物手册, 打开怪物手册窗口
 /// </summary>
 public override void Use(IPropUser user)
 {
     MotaWorld.GetInstance().BookWindow.Open(null);
 }
Ejemplo n.º 23
0
 /// <summary>
 /// 删除目标元素,事件设为空,地表设为默认
 /// </summary>
 /// <param name="souPos">目标元素的坐标</param>
 public void Delete(Coord souPos)
 {
     MotaWorld.GetInstance().MapManager.Delete(souPos);
 }
Ejemplo n.º 24
0
 //刷新魔塔界面
 private void timer1_Tick(object sender, EventArgs e)
 {
     MotaWorld.GetInstance().NextFrame();
     MotaScene.Refresh();
 }
Ejemplo n.º 25
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);
            }
        }
Ejemplo n.º 26
0
 //新的游戏
 void NewGame(object sender, EventArgs e)
 {
     EnterGame();
     MotaWorld.GetInstance().Open(GameIni.MainRecord);
 }
Ejemplo n.º 27
0
 //读取游戏
 void LoadRecord(object sender, EventArgs e)
 {
     EnterGame();
     MotaWorld.GetInstance().Open(GameIni.RecordFile);
 }
Ejemplo n.º 28
0
        /// <summary>
        /// 使人物移动,并调整界面窗口
        /// </summary>
        public override void Move()
        {
            base.Move();

            MotaWorld.GetInstance().MapManager.RefreshView(Location, MoveDirection);
        }
Ejemplo n.º 29
0
 /// <summary>
 /// 设置源本
 /// </summary>
 /// <param name="desPos">源本坐标</param>
 public void SetSource(Coord desPos)
 {
     SouVersion = MotaWorld.GetInstance().MapManager.GetNode(desPos);
 }
Ejemplo n.º 30
0
        /// <summary>
        /// 勇士死亡,游戏失败处理
        /// </summary>
        public override void Death()
        {
            base.Death();

            MotaWorld.GetInstance().GameOver = true;
        }
Ejemplo n.º 31
0
 //绑定魔塔窗口到界面上
 private void MotaScene_Paint(object sender, PaintEventArgs e)
 {
     e.Graphics.DrawImage(MotaWorld.GetInstance().WindowFace, 0, 0, MotaScene.Width, MotaScene.Height);
 }