/// <summary> /// 与武器接触触发获取事件,如果等级不够则无法获取 /// </summary> /// <param name="player">事件触发者</param> public override void TriggerEvent(Hero player) { if (Enable && player.Level >= this.LevelDemand) { //获取之后更新技能动画 player.SetSkillFlash(CommonAttackFaceFile, GoodAttackFaceFile, BestAttackFaceFile); } base.TriggerEvent(player); }
/// <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); }
/// <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); }
/// <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); }
/// <summary> /// 触发坐标处的事件 /// </summary> /// <param name="pos">在地图上的坐标</param> /// <param name="triggerMethod">触发方式</param> /// <param name="player">触发者</param> public void TriggerEvent(Coord pos, TouchMethod triggerMethod, Hero player) { //委托楼层对象处理 CurFloorNode.TriggerEvent(pos, triggerMethod, player); }
/// <summary> /// 增加魔法 /// </summary> public static void AddMagic(Queue<MotaEventArgs> datas, Hero player) { MotaEventArgs data = datas.Dequeue(); player.Magic += data.Value; EventEffect(data); }
/// <summary> /// 增加敏捷 /// </summary> public static void AddAgility(Queue<MotaEventArgs> datas, Hero player) { MotaEventArgs data = datas.Dequeue(); player.Agility += data.Value; EventEffect(data); }
/// <summary> /// 倍增血量 /// </summary> public static void MulHp(Queue<MotaEventArgs> datas, Hero player) { MotaEventArgs data = datas.Dequeue(); player.Hp += (int)(player.Hp * data.Rate); EventEffect(data); }
/// <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); }
/// <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); }
/// <summary> /// 播放音效(用户定义的音效播放) /// </summary> public static void PlaySound(Queue<MotaEventArgs> datas, Hero player) { MotaEventArgs data = datas.Dequeue(); SoundsList.PlaySound(data.Sound); EventEffect(data); }
/// <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); }
/// <summary> /// 增加道具 /// </summary> public static void AddProperty(Queue<MotaEventArgs> datas, Hero player) { MotaEventArgs data = datas.Dequeue(); player.Pack.AddProperty(data.Prop, data.Value); EventEffect(data); }
/// <summary> /// 重新初始化游戏场景 /// </summary> /// <param name="curFloor">新楼层</param> public void Initialize(int curFloor, Hero player, bool[] reached) { GuidePoint.Exist = false; this.CurHero = player; this.FloorReached = reached; MapViewPic = new Bitmap(GameIni.MapWidth, GameIni.MapHeight); //更新窗口 View.ResetView(CurHero.Station); SetFloor(curFloor); if (OnIniEvent != null) { OnIniEvent(); } }
/// <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); }
/// <summary> /// 调用此事件元素上的接触时事件 /// </summary> /// <param name="player">调用者</param> public virtual void TriggerEvent(Hero player) { if (!Enable) { return; } //拷贝参数数据 Queue<MotaEventArgs> TempData = new Queue<MotaEventArgs>(TouchEventData); if (TouchEvent != null) { //调用方法列表 TouchEvent(TempData, player); } //如果不是重复触发的事件,调用一次之后就要关闭 if (!Repeated) { this.Close(); } }
/// <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); }
/// <summary> /// 触发坐标处的事件 /// </summary> /// <param name="pos">在地图上的坐标</param> /// <param name="triggerMethod">触发方式</param> /// <param name="player">触发者</param> public void TriggerEvent(Coord pos, TouchMethod triggerMethod, Hero player) { if (!InFloor(pos)) { return; } if (EventMap[pos.Row, pos.Col] == null || EventMap[pos.Row, pos.Col].Exist == false) { return; } //如果触发方式符合,则触发事件 if (EventMap[pos.Row, pos.Col].TriggerMethod == triggerMethod) { EventMap[pos.Row, pos.Col].TriggerEvent(player); } }
/// <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; }