public PlayerTimer(PlayerObject _play) { mi64Effect = 0; mi64EffectEx = 0; play = _play; mXpTime = new GameBase.Core.TimeOut(); mXpTime.SetInterval(Define.XP_ADD_SECS); mXpTime.Update(); mnXpVal = 0; mSPTime = new GameBase.Core.TimeOut(); mSPTime.SetInterval(Define.SP_ADD_SECS); mSPTime.Update(); mListStatus = new List<GameStruct.RoleStatus>(); mObject_CALL = null; }
//添加状态 //nStatus 状态id //nTime 持续时间- 秒 0为无限时间 //bCover 是否覆盖该状态 public void AddStatus(int nStatus, int nTime = 0, bool bCover = true) { if (this.QueryStatus(GameStruct.RoleStatus.STATUS_DIE) != null) { return; } bool bAdd = false; bool bSendState = true; GameStruct.RoleStatus status = null; for (int i = 0; i < mListStatus.Count; i++) { status = mListStatus[i]; if (status.nStatus == nStatus) { if (bCover) { status.nTime = nTime * 1000; status.nLastTick = System.Environment.TickCount; } else { status.nTime += nTime * 1000; } bAdd = true; break; } } if (!bAdd) { status = new GameStruct.RoleStatus(); status.nStatus = nStatus; status.nTime = nTime * 1000; mListStatus.Add(status); } int nOldEff = GetEffect(); switch (nStatus) { case GameStruct.RoleStatus.STATUS_XPFULL: //XP爆气-- 下降 { //mi64Effect &= ~ Define.KEEPEFFECT_XPFULL; //play.ChangeAttribute(GameStruct.UserAttribute.STATUS1, 64,true); break; } case GameStruct.RoleStatus.STATUS_XPFULL_ATTACK: //xp爆气- 技能被单击 { this.DeleteStatus(GameStruct.RoleStatus.STATUS_XPFULL); //删除xp爆气buff mXpTime.SetInterval(Define.XP_MAX_FULL_SECS); mXpTime.Update(); mi64Effect |= Define.KEEPEFFECT_XPFULL; break; } case GameStruct.RoleStatus.STATUS_MOLONGSHOUHU: //魔龙守护 { play.ChangeAttribute(GameStruct.UserAttribute.MOLONGSHOUHU_STATUS, 1,true); ushort nMagicLv = play.GetMagicSystem().GetMagicLevel(GameStruct.MagicTypeInfo.MOLONGSHOUHU); GameStruct.MagicTypeInfo magicInfo = ConfigManager.Instance().GetMagicTypeInfo(GameStruct.MagicTypeInfo.MOLONGSHOUHU, (byte)nMagicLv); if (magicInfo != null) { //没有实际效果-- 待修正 //添加buff- int nDefense = (int)magicInfo.power; byte[] data1 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; GameBase.Network.PacketOut outpack = new GameBase.Network.PacketOut(play.GetGamePackKeyEx()); outpack.WriteUInt16(48); outpack.WriteUInt16(1127); outpack.WriteUInt32(play.GetTypeId()); outpack.WriteInt32(nTime); outpack.WriteInt32(nDefense); outpack.WriteBuff(data1); play.SendData(outpack.Flush()); } break; } case GameStruct.RoleStatus.STATUS_STEALTH: //潜行 { mi64Effect |= Define.KEEPEFFECT_LURKER; break; } case GameStruct.RoleStatus.STATUS_CRIME: //闪蓝 { mi64Effect |= Define.KEEPEFFECT_CRIME; break; } case GameStruct.RoleStatus.STATUS_RED: //红名 { mi64Effect |= Define.KEEPEFFECT_RED; break; } case GameStruct.RoleStatus.STATUS_BLOCK: //黑名 { mi64Effect |= Define.KEEPEFFECT_DEEPRED; break; } case GameStruct.RoleStatus.STATUS_FLY: //雷霆万钧单独处理.要把xp满的包发下去 { mi64Effect |= Define.KEEPEFFECT_FLY; NetMsg.MsgUserAttribute msg = new NetMsg.MsgUserAttribute(); msg.role_id = play.GetTypeId(); msg.Create(null, null); msg.AddAttribute(GameStruct.UserAttribute.STATUS, (uint)GetEffect(false)); msg.AddAttribute(GameStruct.UserAttribute.STATUS1, (uint)GetEffect());//这是xp满的标识 play.BroadcastBuffer(msg.GetBuffer(), true); bSendState = false; break; } case GameStruct.RoleStatus.STATUS_HIDDEN: { mi64Effect |= Define.KEEPEFFECT_HIDDEN; break; } case GameStruct.RoleStatus.STATUS_HEILONGWU: { mi64Effect |= Define.KEEPEFFECT_HEILONGWU; break; } case GameStruct.RoleStatus.STATUS_YUANSUZHANGKONG: { //修改元素掌控状态 play.ChangeAttribute(GameStruct.UserAttribute.YUANSUZHANGKONG,512,true); //添加buff byte[] data1 = { 48, 0, 103, 4 }; byte[] data2 = { 128, 81, 1, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0 }; GameBase.Network.PacketOut outpack = new GameBase.Network.PacketOut(play.GetGamePackKeyEx()); outpack.WriteBuff(data1); outpack.WriteUInt32(play.GetTypeId()); outpack.WriteBuff(data2); play.SendData(outpack.Flush()); bSendState = false; break; } case GameStruct.RoleStatus.STATUS_JUYANSHENGDUN: //法师 巨岩圣盾 { byte[] data1 = { 48, 0, 103, 4 }; byte[] data2 = { 132, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0 }; GameBase.Network.PacketOut outpack = new GameBase.Network.PacketOut(play.GetGamePackKeyEx()); outpack.WriteBuff(data1); outpack.WriteUInt32(play.GetTypeId()); outpack.WriteBuff(data2); play.SendData(outpack.Flush()); bSendState = false; break; } case GameStruct.RoleStatus.STATUS_ANSHAXIELONG://亡灵巫师- 暗杀邪龙 { if (mObject_CALL != null) { mObject_CALL.ClearThis(); } GameStruct.MonsterInfo monster = ConfigManager.Instance().GetMonsterInfo(Define.ANSHAXIELONG_MONSTER_ID); if (monster == null) { Log.Instance().WriteLog("创建暗沙邪龙失败!!,无此怪物id!"); break; } int nx = play.GetCurrentX()+GameStruct.DIR._DELTA_X[play.GetDir()]; int ny = play.GetCurrentY() + GameStruct.DIR._DELTA_Y[play.GetDir()]; mObject_CALL = new AnShaXieLongObject(play, (short)nx, (short)ny, play.GetDir(), monster.id, monster.ai); play.GetGameMap().AddObject(mObject_CALL, null); mObject_CALL.RefreshVisibleObject(); mObject_CALL.Alive(false); break; } case GameStruct.RoleStatus.STATUS_MINGGUOSHENGNV: //冥国圣女 { if (mObject_CALL != null) { mObject_CALL.ClearThis(); } GameStruct.MonsterInfo monster = ConfigManager.Instance().GetMonsterInfo(Define.MINGGUOSHENGNV_MONSTER_ID); if (monster == null) { Log.Instance().WriteLog("创建冥国圣女失败!!,无此怪物id!"); break; } int nx = play.GetCurrentX() + GameStruct.DIR._DELTA_X[play.GetDir()]; int ny = play.GetCurrentY() + GameStruct.DIR._DELTA_Y[play.GetDir()]; mObject_CALL = new MingGuoShengNv(play, (short)nx, (short)ny, play.GetDir(), monster.id, monster.ai); play.GetGameMap().AddObject(mObject_CALL, null); mObject_CALL.RefreshVisibleObject(); mObject_CALL.Alive(false); break; } case GameStruct.RoleStatus.STATUS_WANGNIANWULING: //亡念巫灵 { if (mObject_CALL != null) { mObject_CALL.ClearThis(); } GameStruct.MonsterInfo monster = ConfigManager.Instance().GetMonsterInfo(Define.WANGNIANWULONG_MONSTER_ID); if (monster == null) { Log.Instance().WriteLog("创建亡念巫灵失败!!,无此怪物id!"); break; } int nx = play.GetCurrentX() + GameStruct.DIR._DELTA_X[play.GetDir()]; int ny = play.GetCurrentY() + GameStruct.DIR._DELTA_Y[play.GetDir()]; mObject_CALL = new WangNianWuLing(play, (short)nx, (short)ny, play.GetDir(), monster.id, monster.ai); play.GetGameMap().AddObject(mObject_CALL, null); mObject_CALL.RefreshVisibleObject(); mObject_CALL.Alive(false); break; } case GameStruct.RoleStatus.STATUS_HUASHENWANGLING: { mi64EffectEx |= Define.KEEPEFFECT_HUASHENWULING; break; } case GameStruct.RoleStatus.STATUS_HUASHENWUSHI: { DeleteStatus(GameStruct.RoleStatus.STATUS_HUASHENWANGLING); break; } case GameStruct.RoleStatus.STATUS_ZHAOHUANWUHUAN: { mi64Effect |= Define.KEEPEFFECT_ZHAOHUANWUHUAN; break; } case GameStruct.RoleStatus.STATUS_MIXINSHU: //血族 迷心术 { mi64EffectEx |= Define.KEEPEFFECT_MIXINSHU; GameBase.Network.PacketOut outpack = new GameBase.Network.PacketOut(play.GetGamePackKeyEx()); //buff byte[] data = { 120, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; outpack.WriteUInt16(48); outpack.WriteUInt16(1127); outpack.WriteUInt32(play.GetTypeId()); outpack.WriteBuff(data); play.SendData(outpack.Flush()); break; } case GameStruct.RoleStatus.STATUS_XUEXI: //血族 血袭 { mi64EffectEx |= Define.KEEPEFFECT_XUEXI; GameBase.Network.PacketOut outpack = new GameBase.Network.PacketOut(play.GetGamePackKeyEx()); byte[] data = { 60, 0, 0, 0, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; outpack.WriteUInt16(48); outpack.WriteUInt16(1127); outpack.WriteUInt32(play.GetTypeId()); outpack.WriteBuff(data); play.SendData(outpack.Flush()); break; } case GameStruct.RoleStatus.STATUS_DIE: //死亡状态 { mi64Effect |= Define.KEEPEFFECT_DIE; break; } } if (bSendState) { this.SendState(); // play.ChangeAttribute(state, GetEffect(state == GameStruct.UserAttribute.STATUS1),true); } //if (GetEffect() != nOldEff) //{ // play.ChangeAttribute(state, GetEffect()); //} }
//复活幻兽 //target 死亡的怪物- 只有打怪才会加幻兽灵气 public void Eudemon_Alive(MonsterObject taget) { for (int i = 0; i < mBattleObj.Count; i++) { EudemonObject obj = mBattleObj[i]; if (obj.GetState() == EUDEMONSTATE.BATTLE && obj.GetAttr().bDie) { obj.GetAttr().life += (int)(obj.GetAttr().life_max * 0.1) ; //杀死一个怪物加5点 NetMsg.MsgEudemonInfo msg = new NetMsg.MsgEudemonInfo(); msg.id = obj.GetTypeId(); msg.AddAttribute(EudemonAttribute.Life, obj.GetAttr().life); PacketOut outpack = new PacketOut(); if (obj.GetAttr().life >= obj.GetAttr().life_max ) { // 收到网络协议:长度:24协议号:2037 //{24,0,245,7,1,0,0,0,252,159,138,131,1,0,0,0,6,0,0,0,65,0,0,0} obj.GetAttr().life = obj.GetAttr().life_max; outpack.WriteInt16(24); outpack.WriteInt16(2037); outpack.WriteInt32(1); outpack.WriteUInt32(obj.GetTypeId()); outpack.WriteInt32(1); outpack.WriteInt32(6); outpack.WriteInt32(obj.GetAttr().life); obj.BrocatBuffer(outpack.Flush()); //收到网络协议:长度:20协议号:1017 //{20,0,249,3,252,159,138,131,1,0,0,0,0,0,0,0,65,0,0,0} outpack = new PacketOut(); outpack.WriteInt16(20); outpack.WriteInt16(1017); outpack.WriteUInt32(obj.GetTypeId()); outpack.WriteInt32(1); outpack.WriteInt32(0); outpack.WriteInt32(obj.GetAttr().life); obj.BrocatBuffer(outpack.Flush()); //收到网络协议:长度:20协议号:1017 //{20,0,249,3,252,159,138,131,1,0,0,0,26,0,0,0,4,0,0,0} outpack = new PacketOut(); outpack.WriteInt16(20); outpack.WriteInt16(1017); outpack.WriteUInt32(obj.GetTypeId()); outpack.WriteInt32(1); outpack.WriteInt32(26); outpack.WriteInt32(4); obj.BrocatBuffer(outpack.Flush()); //收到网络协议:长度:20协议号:1017 //{20,0,249,3,252,159,138,131,1,0,0,0,26,0,0,0,0,0,0,0} outpack = new PacketOut(); outpack.WriteInt16(20); outpack.WriteInt16(1017); outpack.WriteUInt32(obj.GetTypeId()); outpack.WriteInt32(1); outpack.WriteInt32(26); outpack.WriteInt32(0); obj.BrocatBuffer(outpack.Flush()); obj.GetAttr().bDie = false; obj.SendEudemonInfo(); } else { // 收到网络协议:长度:40协议号:1022 outpack.WriteInt16(40); outpack.WriteInt16(1022); outpack.WriteInt32(System.Environment.TickCount); outpack.WriteUInt32(obj.GetTypeId()); outpack.WriteUInt32(taget.GetTypeId()); outpack.WriteInt16(obj.GetCurrentX()); outpack.WriteInt16(obj.GetCurrentY()); outpack.WriteInt32(32); outpack.WriteInt16(4); outpack.WriteInt32(obj.GetAttr().life); outpack.WriteInt32(0); outpack.WriteInt32(0); outpack.WriteInt16(0); obj.BrocatBuffer(outpack.Flush()); } break; } } }
//创建怪物 public void CreateMonster(GameStruct.GeneratorInfo info) { GameStruct.MonsterInfo minfo = ConfigManager.Instance().GetMonsterInfo(info.monsterid); if (minfo == null) { Log.Instance().WriteLog("无法找到怪物id:" + info.monsterid.ToString()); return; } MonsterObject obj ; Random rd = new Random(); for (int i = 0; i < info.amount; i++) { short cx = 0; short cy = 0; byte index = 0; while (true) { cx = (short)rd.Next((int)info.bound_x, (int)(info.bound_x + info.bound_cx)); cy = (short)rd.Next((int)info.bound_y, (int)(info.bound_y + info.bound_cy)); if (CanMove(cx, cy)) { break; } index++; if (index >= 100) { cx = cy = 0; break; } } if (cx == 0 && cy == 0) { Log.Instance().WriteLog("创建怪物失败,无法找到落脚点" + this.GetMapInfo().name + "怪物名称:" + minfo.name + "地图id:"+ info.mapid.ToString()+" x:"+info.bound_x.ToString()+" y:"+info.bound_y.ToString()); return; } obj = new MonsterObject(minfo.id, minfo.ai,cx,cy,true); if (info.dir == DIR.MAX_DIRSIZE) { obj.SetDir(GameStruct.DIR.Random_Dir()); } else { obj.SetDir(info.dir); } obj.SetRebirthTime(info.time); AddObject(obj); } }