public void Attack(NetMsg.MsgAttackInfo info) { if (!play.GetMagicSystem().CheckAttackSpeed()) { return; } BaseObject targetobj = play.GetGameMap().FindObjectForID(info.idTarget); if (targetobj == null) { return; } if (targetobj.IsDie()) return; if (targetobj.IsLock()) return; //被锁定了 //与怪物的距离判断-- if (Math.Abs(play.GetCurrentX() - targetobj.GetCurrentX()) > 3 && Math.Abs(play.GetCurrentY() - targetobj.GetCurrentY()) > 3) { SetAutoAttackTarget(null); return; } SetAutoAttackTarget(targetobj); //触发被动技能 if (PassiveMagic(info)) { return; } uint injured = BattleSystem.AdjustDamage(play, targetobj); //经验-- injured = BattleSystem.AdjustDamage(play, targetobj, true); NetMsg.MsgMonsterInjuredInfo injuredinfo = new NetMsg.MsgMonsterInjuredInfo(); injuredinfo.roleid = play.GetTypeId(); injuredinfo.role_x = play.GetCurrentX(); injuredinfo.role_y = play.GetCurrentY(); injuredinfo.injuredvalue = injured; injuredinfo.monsterid = targetobj.GetTypeId(); injuredinfo.tag = 2; byte[] msg = injuredinfo.GetBuffer(); // GetGameMap().BroadcastBuffer(this, msg); play.BroadcastBuffer(msg, true); targetobj.Injured(play, injured, info); play.CanPK(targetobj); // if (info.tag == 2) //普通攻击设置自动攻击对象 // { // targetObject = targetobj; // } // lastattacktime = System.Environment.TickCount; }
void Start() { Debug.Log("hi"); NetMsg msg = new NetMsg(); msg.MessageName = "1024"; msg.MessageBody = new Dictionary<string, BaseMsg>(); BaseMsg bmsg = new BaseMsg(); bmsg.DoubleVal = 1027; msg.MessageBody.Add("helloworld", bmsg); byte[] arr = NetCoding.Serialize(msg); Debug.Log(arr); NetMsg newmsg = NetCoding.Deserialize(arr); Debug.Log(newmsg.MessageName); Debug.Log(newmsg.MessageBody["helloworld"].DoubleVal); }
private void UpdateMessagePump() { if (!IsOnline) { return; } int recHostId, connectionId, channelId; byte[] dataBuffer = new byte[MSG_BYTE_SIZE]; int dataSize; NetworkEventType networkEventType = NetworkTransport.Receive(out recHostId, out connectionId, out channelId, dataBuffer, dataBuffer.Length, out dataSize, out _error); switch (networkEventType) { case NetworkEventType.Nothing: break; case NetworkEventType.ConnectEvent: OnConnect(connectionId, channelId, recHostId); break; case NetworkEventType.DisconnectEvent: Debug.Log(string.Format("User {0} has disconnected", connectionId)); OnDisconnect(connectionId, channelId, recHostId); //ServerClients.Remove(); break; case NetworkEventType.DataEvent: NetMsg netMsg = MsgSerializer.DeserializeNetMsg(dataBuffer); OnData(connectionId, channelId, recHostId, netMsg); break; case NetworkEventType.BroadcastEvent: Debug.Log("Unexpected Network Event"); break; } }
//根据包的内容来决定是哪一个系统处理包 private void ProcessMessage(NetMsg msg) { //要发送的东西时有意义的 if (msg.err != (int)ErrCode.None) { print(msg.err); switch (((ErrCode)msg.err)) { case ErrCode.UpdateDBError: PECommon.Log("数据库更新异常", PECommon.LogType.Error); GameManager.Instance.currentUIManager.showTipsWindow("网络不稳定"); break; case ErrCode.AcctIsOnline: GameManager.Instance.currentUIManager.showTipsWindow("账号已经在线"); break; case ErrCode.WrongPass: GameManager.Instance.currentUIManager.showTipsWindow("账号密码错误"); break; case ErrCode.NameIsExist: GameManager.Instance.currentUIManager.showTipsWindow("名称已经存在"); break; } return; } switch ((CMD)msg.cmd) { //如果是登录包 case CMD.RspLogin: //如果获得了服务器的响应 GameManager.Instance.loginSystem.HandleServerData(msg); break; case CMD.RspRename: GameManager.Instance.characterSelectSystem.RspRename(msg); break; } }
public void UpdateMessagePump() { int receiveHostId; //Web or standalone int ConnectionId; //Which user is send. Use numeric from 0 to MAX_USER. Each new conenct heave lowest free number. int channelId; //Witch lane is he sending taht message from byte[] receiveBuffer = new byte[BYTE_SIZE]; //data in byte type int dataSize; //receive data in byte type NetworkEventType type = NetworkTransport.Receive(out receiveHostId, out ConnectionId, out channelId, receiveBuffer, BYTE_SIZE, out dataSize, out error); //check type of event switch (type) { case NetworkEventType.Nothing: break; case NetworkEventType.ConnectEvent: Debug.Log(string.Format("User {0} has connected!", ConnectionId)); break; case NetworkEventType.DisconnectEvent: Debug.Log(string.Format("User {0} has disconnected!", ConnectionId)); break; //event - data transfer case NetworkEventType.DataEvent: BinaryFormatter binaryFormatter = new BinaryFormatter(); MemoryStream memoryStream = new MemoryStream(receiveBuffer); NetMsg netMsg = (NetMsg)binaryFormatter.Deserialize(memoryStream); //OnData() - method for convert msg to data OnData(ConnectionId, channelId, receiveHostId, netMsg); break; default: case NetworkEventType.BroadcastEvent: Debug.Log("Unexpected network event type"); break; } }
private void AutoCalcPowerIncrease(int tid) { //在线玩家计算体力 NetMsg netMsg = new NetMsg { cmd = (int)MsgCommand.Cmd_PshPower }; netMsg.pshPower = new PushPower(); Dictionary <ServerSession, PlayerData> dictOnlinePlayer = cacheSvc.GetOnlineCache(); foreach (var session in dictOnlinePlayer) { PlayerData playerData = session.Value; ServerSession svcSession = session.Key; int maxPowerVal = CommonTools.CalcPowerLimit(playerData.lv); if (maxPowerVal <= playerData.power) { continue; } playerData.time = TimerSvc.Instance.GetNowTime(); playerData.power += Constants.cPowerAddValPerChange; if (playerData.power >= maxPowerVal) { playerData.power = maxPowerVal; } if (!cacheSvc.UpdatePlayerData(playerData.id, playerData)) { netMsg.err = (int)ErroCode.Error_UpdateDB; } else { netMsg.pshPower.power = playerData.power; svcSession.SendMsg(netMsg); } } }
void NetRespEvent(NetMsg netMsg) { Debug.Log(netMsg.MsgType); switch (netMsg.MsgType) { case NetMsgType.Message: //if (netMsg.cmd != (uint)ProtoCmdId.HeartbeatAck) //{ // Odin.Log.Info("ReceiveMessage:{0}->{1}", (ProtoCmdId)netMsg.cmd, netMsg.cmd); //} //ListenRespEvent.CallRespCb(netMsg); break; case NetMsgType.Connect: //_IsConnected = true; //Odin.Log.Info("Network Connect Success"); ////如果已进入游戏 发送重连协议 //if (isEnterGame) ReconnectReq(); break; case NetMsgType.Error: case NetMsgType.Disconnect: //Disconnect(netMsg); break; case NetMsgType.Debug: //#if UNITY_EDITOR //if (netMsg.cmd != (uint)ProtoCmdId.HeartbeatAck // && netMsg.cmd != (uint)ProtoCmdId.HeartbeatReq) //{ // var debugStr = Encoding.UTF8.GetString(netMsg.Data); // Odin.Log.Info("Network Debug :{0}", debugStr); //} //#endif break; default: //Odin.Log.Error("Unkown MsgType:" + netMsg.MsgType); break; } }
public void SendMsg(NetMsg msg) { try { /* * @wangfw @time:2019-4-3 * 添加新的序列化打包 */ // byte[] data = EncodeTool.EncodeMsg(msg); byte[] data = EncodeTool.NewEncodeObj(msg); //new byte[] packet = EncodeTool.EncodePacket(data); clientSocket.Send(packet); //Debug.Log("SendMsg"); } catch (Exception e) { Debug.LogError(e.Message); } }
public int send(NetMsg netMsg, int offset) { if (netMsg.totalData == null) { encode(netMsg); } int sendNum = socket.Send(netMsg.totalData, offset, netMsg.totalData.Length - offset, SocketFlags.None, out socketError); if (socketError != SocketError.Success) { Debug.LogError("socket send error:" + socketError); return(0); } if (sendNum + offset == netMsg.totalData.Length) { return(-1);//标志,全部发送完成 } return(sendNum); }
public void ReceiveMessage(ClientPeer client, NetMsg msg) { switch (msg.opCode) { case OpCode.account: accountModule.ReceiveMessage(client, msg.subOpCode, msg.value); break; case OpCode.chat: chatModule.ReceiveMessage(client, msg.subOpCode, msg.value); break; case OpCode.match: matchModule.ReceiveMessage(client, msg.subOpCode, msg.value); break; case OpCode.play: playModule.ReceiveMessage(client, msg.subOpCode, msg.value); break; } }
private void OnData(int connectionID, int channelID, int recHostID, NetMsg msg) { switch (msg.RT) { case NetRT.LoginServer: OnLoginMessage(connectionID, channelID, recHostID, msg); break; case NetRT.SectorServer: OnSectorMessage(connectionID, channelID, recHostID, msg); break; case NetRT.ShipCombatServer: break; case NetRT.None: default: Debug.Log("[Network Client]: Unexpected Net RT (" + msg.RT + ")."); break; } }
private void OnClickTake(string name) { string[] nameArr = name.Split('_'); int taskIdx = int.Parse(nameArr[1]); NetMsg netMsg = new NetMsg { cmd = (int)MsgCommand.Cmd_ReqTaskReward, reqTaskReward = new RequestTaskReward { taskId = listTaskData[taskIdx].ID, } }; _netSvc.SendMsg(netMsg); TaskRewardCfg taskDataCfd = _resSvc.GetTaskRewardCfgData(listTaskData[taskIdx].ID); int coin = taskDataCfd.coin; int exp = taskDataCfd.exp; GameRoot.AddTips(Constants.Color("获得奖励:", Constants.TextColor.Blue) + Constants.Color("金币 + " + coin + "经验 +" + exp, Constants.TextColor.Green)); }
private void OnData(int connectionId, int channelId, int recHostId, NetMsg msg) { switch (msg.OP) { case NetOP.None: Debug.Log("Unexpected NETOP"); break; case NetOP.OnCreateAccount: OnCreateAccount((Net_OnCreateAccount)msg); break; case NetOP.OnLoginRequest: OnLoginAccount((Net_OnLoginRequest)msg); break; default: break; } }
private void OnChanged(object source, FileSystemEventArgs e) { Console.WriteLine("File changed"); _log.InfoFormat("File Changed,TIME:{0}", DateTime.Now); _action.Debounce(5000, null, () => { _log.InfoFormat("Exported,TIME:{0}", DateTime.Now); Console.WriteLine("export"); NetMsg msg = new NetMsg { cmd = 1001, desc = "flash导出了symbol", }; MyService.SocketServer.GetSesstionLst().ForEach((session) => { _log.InfoFormat("Send MSG,TIME:{0}", DateTime.Now); session.SendMsg(msg); }); fla2csd.Fla2Csd.tocsd(); }); }
public void ReqLogin(MsgPack netMsgPack) { ReqLogin data = netMsgPack.netMsg.reqLogin; //回应客户端的包 NetMsg rspMsg = new NetMsg { cmd = (int)CMD.RspLogin, rspLogin = new RspLogin(), }; //判断当前账号是否已经上线 //已上线:返回错误信息 if (CacheSvc.Instance.IsAcctOnLine(data.account)) { rspMsg.err = (int)ErrCode.AcctIsOnline; } else { //未上线: //账号是否存在 PlayerData playerData = CacheSvc.Instance.GetPlayerData(data.account, data.password); if (playerData == null) { //存在:检测密码错误 rspMsg.err = (int)ErrCode.WrongPass; } else { rspMsg.rspLogin = new RspLogin { playerData = playerData }; CacheSvc.Instance.AcctOnLine(data.account, netMsgPack.serverSession, playerData); } //账号不存在 //创建默认的账号密码 } netMsgPack.serverSession.SendMsg(rspMsg); }
public void UpdateMessagePump() { if (!isStarted) { return; } bool loop = true; while (loop) { byte[] recBuffer = new byte[BYTE_SIZE]; NetworkEventType type = NetworkTransport.Receive(out int recHostId, out int connectionId, out int channelId, recBuffer, BYTE_SIZE, out int dataSize, out error); switch (type) { case NetworkEventType.DataEvent: BinaryFormatter formatter = new BinaryFormatter(); MemoryStream ms = new MemoryStream(recBuffer); NetMsg msg = (NetMsg)formatter.Deserialize(ms); OnData(connectionId, channelId, recHostId, msg); break; case NetworkEventType.ConnectEvent: break; case NetworkEventType.DisconnectEvent: OnDisconnect(recHostId, connectionId, channelId); break; case NetworkEventType.Nothing: loop = false; break; default: case NetworkEventType.BroadcastEvent: Debug.Log("Unexpected network event type"); break; } } }
private void OnLoginMessage(int connectionID, int channelID, int recHostID, NetMsg msg) { switch (msg.OP) { case NetLoginOP.OnCreateAccount: OnCreateAccount((Net_OnCreateAccount)msg); break; case NetLoginOP.OnLoginRequest: OnLoginRequest(connectionID, (Net_OnLoginRequest)msg); break; case NetLoginOP.OnKeyUpdate: OnKeyUpdate((Net_KeyUpdate)msg); break; case NetLoginOP.None: default: Debug.Log("[Network Client]: Unexpected Net OP (" + msg.OP + ")."); break; } }
public void WriteBuffer(byte[] buffer, int offset, int length) { Debug.Log("luckyhigh start to write"); if (fs == null) { return; } Debug.Log("luckyhigh fs is no null"); int temp = offset - length; byte[] tempBuf = new byte[length]; Array.Copy(buffer, temp, tempBuf, 0, length); double TimeOffset = (DateTime.Now - firstTime).TotalMilliseconds; NetMsg net = new NetMsg(); net.offset = TimeOffset; net.buffer = new List <byte>(tempBuf); byte[] data = ProtoUtil.JceStructToBytes(net); byte[] _len = BitConverter.GetBytes((ushort)(data.Length + PACKAGE_HEADER_SIZE)); if (BitConverter.IsLittleEndian) { Array.Reverse(_len); } byte[] _bufferWithLen = new byte[_len.Length + data.Length]; _len.CopyTo(_bufferWithLen, 0); data.CopyTo(_bufferWithLen, _len.Length); Debug.Log("luckyhigh offset " + TimeOffset + " data Len " + data.Length + " total len " + _bufferWithLen.Length); fs.Write(_bufferWithLen, 0, (int)_bufferWithLen.Length); fs.Flush(); }
public void OnClickEnterGameBtn() { _audioSvc.PlayUIAudio(Constants.cNormalUIBtnSound); if (inputRoleName.text != "") { //发送消息,进入游戏 NetMsg msg = new NetMsg { cmd = (int)MsgCommand.Cmd_ReqRename, reqRename = new RequestRename { name = inputRoleName.text }, }; _netSvc.SendMsg(msg); } else { GameRoot.AddTips("当前名字不合法!"); } }
public void RequestBattle(MsgPack msgPack) { RequestBattle data = msgPack.Msg.RequestBattle; NetMsg netMsg = new NetMsg { cmd = (int)Command.ResponseBattle }; PlayerData playerData = _cacheSvc.GetPlayerDataBySession(msgPack.Session); int power = _resCfgSvc.GetMapData(data.BattleId).Power; if (playerData.Battle < data.BattleId) { netMsg.err = (int)ErrorCode.ClientDataError; } else if (playerData.Power < power) { netMsg.err = (int)ErrorCode.LackPower; } else { playerData.Power -= power; if (_cacheSvc.UpdatePlayerData(playerData.Id, playerData)) { ResponseBattle responseBattle = new ResponseBattle { BattleId = data.BattleId, Power = playerData.Power, }; netMsg.ResponseBattle = responseBattle; } else { netMsg.err = (int)ErrorCode.UpdateDbError; } } msgPack.Session.SendMsg(netMsg); }
private void IoCompleted(object sender, SocketAsyncEventArgs e) { try { if (!CheckSocketState(e)) { return; } switch (e.LastOperation) { case SocketAsyncOperation.Receive: ReceiveCompleted(e); break; case SocketAsyncOperation.Send: SendCompleted(e); break; case SocketAsyncOperation.Connect: PackIdReset(); _onNetRespEvent(NetMsg.Create(NetMsgType.Connect)); ReceiveAsync(); break; case SocketAsyncOperation.Disconnect: Close("LastOperation.Disconnect"); break; default: Close("LastOperation" + e.LastOperation); break; } } catch (Exception ex) { Close("IoCompleted:\n" + ex); } }
private void OnData(int connectionId, int channelId, int recHostId, NetMsg msg) { //switch (msg.OperationCode) //{ // case NetOperationCode.None: // break; // case NetOperationCode.PositionUpdate: // gameManager.RecievePosUpdate((Net_PositionUpdate)msg); // break; // case NetOperationCode.RotationUpdate: // gameManager.RecieveRotUpdate((Net_RotationUpdate)msg); // break; // case NetOperationCode.PositionAndRotationUpdate: // gameManager.RecievePosAndRotUpdate((Net_PositionAndRotationUpdate)msg); // break; // case NetOperationCode.BulletShotUpdate: // gameManager.RecieveBulletShotUpdate((Net_BulletShotUpdate)msg); // break; // case NetOperationCode.PlayerHealthUpdate: // gameManager.RecievePlayerHealthUpdate((Net_PlayerHealthUpdate)msg); // break; // case NetOperationCode.EnemySpawned: // gameManager.RecieveEnemySpawned((Net_EnemySpawned)msg); // break; // case NetOperationCode.EnemyMovementUpdate: // gameManager.ReceiveEnemyMovementUpdate((Net_EnemyMovementUpdate)msg); // break; // case NetOperationCode.VanMovementUpdate: // gameManager.RecieveVanMovementUpdate((Net_VanMovementUpdate)msg); // break; // case NetOperationCode.PlayerDriveUpdate: // gameManager.RecievePlayerDriveUpdate((Net_PlayerDriveUpdate)msg); // break; // case NetOperationCode.PlayerStatChange: // gameManager.ReceivePlayerStatChange((Net_PlayerStatChange)msg); // break; //} }
public void OnHttpError(string errorMsg) { Debug.LogError("HTTP ERROR:" + errorMsg); if (commandInfo.isBackGround) { State = RoutineState.Idle; } else { State = RoutineState.Suspended; // #if !RELEASE // // CommandLineControl.Instance.WriteLine(LogLevel.Error, "network fatal: " + errorMsg); // // #endif var msg = new NetMsg <string>(); msg.code = -1; msg.err = errorMsg; msg.ret = "HTTP_ERROR"; OnException(msg); } }
public NetMsg send_msg(NetMsgType _type,NetMsgDel _del) { NetMsg _nm=new NetMsg(); switch(_type){ case NetMsgType.LOGIN: default: _nm.sub_url="login"; break; case NetMsgType.ENTER_SERVER: _nm.sub_url="enter"; break; case NetMsgType.SAVE_SHIP_DATA: _nm.sub_url="save_ship_data"; break; case NetMsgType.GET_SHIP_DATA: _nm.sub_url="get_ship_data"; break; } _nm.msg_type=_type; _nm.m_del=_del; m_waitl_que.Enqueue(_nm); return _nm; }
void Receive() { this.mRecvStream = new BufferedStream(new NetworkStream(this.mSocket), 4096); while (this.mIsRunning) { try { TProtocol proto = new TBinaryProtocol(new TStreamTransport(this.mRecvStream, this.mRecvStream)); int type = proto.ReadI32(); int len = proto.ReadI32(); byte[] data = new byte[len]; this.mRecvStream.Read(data, 0, len); NetMsg msg = new NetMsg(type, data); // 丢到主线程,由主线程交由Lua解析 SendMsgInMainThread(msg); } catch (System.Exception e) { Debug.LogError(e.Message); Disconnect(); } } }
/// <summary> /// 处理重命名 /// </summary> /// <param name="pack"></param> public void DoneRename(MsgPack packMsg) { RequestRename data = packMsg._msg.reqRename; NetMsg msg = new NetMsg { cmd = (int)MsgCommand.Cmd_RspRename, }; //检查名字是否在数据库中已经存在了 if (cacheSvc.IsNameExist(data.name)) { //存在:返回错误码 msg.err = (int)ErroCode.Error_NameIsExist; } else { //不存在:更新缓存和数据库,再返回给客户端 PlayerData playerData = cacheSvc.GetPlayerDataBySession(packMsg._session); playerData.name = data.name; //更新缓存失败 if (!cacheSvc.UpdatePlayerData(playerData.id, playerData)) { msg.err = (int)ErroCode.Error_UpdateDB; } else { //成功就重命名 msg.rspRename = new ResponseRename { name = data.name, }; } //消息发送出去 packMsg._session.SendMsg(msg); } }
public void Receive(ClientPeer client, NetMsg msg) { switch (msg.opCode) { case OpCode.Account: accountHandler.Receive(client, msg.subCode, msg.value); break; case OpCode.Chat: chatHandler.Receive(client, msg.subCode, msg.value); break; case OpCode.Fight: fightHandler.Receive(client, msg.subCode, msg.value); break; case OpCode.Match: matchHandler.Receive(client, msg.subCode, msg.value); break; default: break; } }
public void SendChat(MsgPack pack) { SendChat data = pack.Msg.SendChat; PlayerData playerData = _cacheSvc.GetPlayerDataBySession(pack.Session); TaskSys.Instance.CalcTaskPrangs(playerData, 6); NetMsg netMsg = new NetMsg { cmd = (int)Command.PshChat, PshChat = new PshChat { Name = playerData.Name, Chat = data.Chat } }; List <ServerSession> list = _cacheSvc.GetOnLineServerSessions(); byte[] bytes = PENet.PETool.PackNetMsg(netMsg); foreach (var t in list) { t.SendMsg(bytes); } }
/// <summary> /// 发送聊天内容 /// </summary> public void OnClickSendChat() { _audioSvc.PlayUIAudio(Constants.cNormalUIBtnSound); if (!bCanSend) { GameRoot.AddTips("发送频率过快!"); return; } if (inputContext.text != null && inputContext.text != "" && inputContext.text != " ") { if (inputContext.text.Length > 12) { GameRoot.AddTips("聊天信息不能超过12个字符!"); } else { NetMsg netMsg = new NetMsg { cmd = (int)MsgCommand.Cmd_SndChat, sndChat = new SendChatInfo { chatInfo = inputContext.text } }; inputContext.text = ""; _netSvc.SendMsg(netMsg); bCanSend = false; _timerSvc.AddTimeTask((int tid) => { bCanSend = true; }, 5.0f, WZTimeUnit.Second); } } else { GameRoot.AddTips("尚未输入聊天的信息"); } }
/// <summary> /// 有重连结果后 调用 /// </summary> /// <returns>反回重连次数是否已用完</returns> private void ConnRespResult(NetMsg netMsg) { if (netMsg.MsgType != NetMsgType.Error && netMsg.MsgType != NetMsgType.Disconnect && netMsg.MsgType != NetMsgType.Connect) { return; } _networkAdapter.DelNetRespEvent(ConnRespResult); if (netMsg.MsgType == NetMsgType.Connect) { _curReConnNum = 0; _reConnectFail = false; _isStartReConnect = false; isStartReconnTiming = false; //Odin.Log.Info("ReConnect Succ"); return; } //Odin.Log.Error("ReConnect:{0} Fail", _curReConnNum); _curReConnNum++; if (_curReConnNum < _maxReConnNum) { //重连失败开启重连计时 isStartReconnTiming = true; return; } _curReConnNum = 0; _isStartReConnect = false; _reConnectFail = true; _reConnectFailCb(); }
/// <summary> /// 处理服务器发来的消息 /// </summary> /// <param name="msg"></param> private void ProcessServerSendMsg(NetMsg msg) { switch (msg.opCode) { case OpCode.Account: accountHander.OnReceive(msg.subCode, msg.value); break; case OpCode.Chat: matchHander.OnReceive(msg.subCode, msg.value); break; case OpCode.Match: chatHander.OnReceive(msg.subCode, msg.value); break; case OpCode.Fight: fightHander.OnReceive(msg.subCode, msg.value); break; default: break; } }
void Update() { if (this.mRecvingMsgQueue.Count == 0) { lock (this.mRecvLock) { if (this.mRecvWaitingMsgQueue.Count > 0) { Queue <NetMsg> temp = this.mRecvingMsgQueue; this.mRecvingMsgQueue = this.mRecvWaitingMsgQueue; this.mRecvWaitingMsgQueue = temp; } } } else { while (this.mRecvingMsgQueue.Count > 0) { NetMsg msg = this.mRecvingMsgQueue.Dequeue(); // 交由Lua解析并处理逻辑 // LuaMgr.Instance().CallTableFunction("NetMsgMgr", "HandleNetMsg", msg.Type, msg.Data); } } }
//public override void RefreshVisibleObject() //刷新可视对象 //{ // base.RefreshVisibleObject(); // mRefreshList.Clear(); // foreach (BaseObject o in mGameMap.mDicObject.Values) // { // if (o.GetGameID() == this.GetGameID()) continue; // //玩家和玩家的视野范围扩大- // // int dis = o.type == OBJECTTYPE.PLAYER ? Define.MAX_PLAY_VISIBLE_DISTANCE : Define.MAX_VISIBLE_DISTANCE; // int dis = Define.MAX_VISIBLE_DISTANCE; // //如果是怪物和npc 掉落物品对象就不发消息了-- 已经在视野范围了嘛 // if ((o.type == OBJECTTYPE.NPC || o.type == OBJECTTYPE.MONSTER || // o.type == OBJECTTYPE.EUDEMON || o.type == OBJECTTYPE.DROPITEM || // o.type == OBJECTTYPE.PLAYER || o.type == OBJECTTYPE.ROBOT) && // this.mVisibleList.ContainsKey(o.GetGameID())) // { // if (!GetPoint().CheckVisualDistance(o.GetCurrentX(), o.GetCurrentY(), dis) // && this.mVisibleList.ContainsKey(o.GetGameID())) // { // this.mVisibleList.Remove(o.GetGameID()); // if (this.mPlayObject.ContainsKey(o.GetGameID())) // { // this.mPlayObject.Remove(o.GetGameID()); // } // } // continue; // } // if (GetPoint().CheckVisualDistance(o.GetCurrentX(), o.GetCurrentY(), dis)) // { // this.mVisibleList[o.GetGameID()] = o; // if (o.type == OBJECTTYPE.MONSTER) // { // MonsterObject mobj = o as MonsterObject; // if (mobj.IsDie()) continue; // } // if (o.type == OBJECTTYPE.NPC || // o.type == OBJECTTYPE.MONSTER || // o.type == OBJECTTYPE.PLAYER || // o.type == OBJECTTYPE.DROPITEM || // o.type == OBJECTTYPE.EUDEMON || // o.type == OBJECTTYPE.ROBOT) // { // mRefreshList[o.GetGameID()] = o; // } // } // else // { // if (!GetPoint().CheckVisualDistance(o.GetCurrentX(), o.GetCurrentY(), dis) // && this.mVisibleList.ContainsKey(o.GetGameID())) // { // this.mVisibleList.Remove(o.GetGameID()); // if ((o.type == OBJECTTYPE.PLAYER || o.type == OBJECTTYPE.EUDEMON || // o.type == OBJECTTYPE.ROBOT) && // mPlayObject.ContainsKey(o.GetGameID())) // { // mPlayObject.Remove(o.GetGameID()); // //清除目标对象 // NetMsg.MsgClearObjectInfo clearobj = new NetMsg.MsgClearObjectInfo(); // clearobj.Create(null, this.GetGamePackKeyEx()); // clearobj.id = o.GetTypeId(); // this.SendData(clearobj.GetBuffer()); // if (o.type == OBJECTTYPE.PLAYER) // { // clearobj = new NetMsg.MsgClearObjectInfo(); // clearobj.Create(null, o.GetGamePackKeyEx()); // clearobj.id = this.GetTypeId(); // o.SendData(clearobj.GetBuffer()); // (o as PlayerObject).GetPlayObjectList().Remove(this.GetGameID()); // } // if (o.type == OBJECTTYPE.EUDEMON) // { // (o as EudemonObject).GetPlayObjectList().Remove(this.GetGameID()); // } // } // } // } // } //} public bool Move(NetMsg.MsgMoveInfo move) { if (!this.GetMagicSystem().CheckMoveSpeed()) { this.ScroolRandom(this.GetCurrentX(), this.GetCurrentY()); return false; } // testeudemon(); byte dir = (byte)((int)move.dir % 8); this.SetDir(dir); short nNewX = GetCurrentX(); short nNewY = GetCurrentY(); nNewX += DIR._DELTA_X[dir]; nNewY += DIR._DELTA_Y[dir]; if (!mGameMap.CanMove(nNewX, nNewY)) { nNewX = this.GetCurrentX(); nNewY = this.GetCurrentY(); if (!mGameMap.CanMove(nNewX, nNewY)) { nNewX = (short)mGameMap.GetMapInfo().recallx; nNewY = (short)mGameMap.GetMapInfo().recally; } //暂时使用随机卷的方式重置玩家坐标 this.ScroolRandom(nNewX, nNewY); // Log.Instance().WriteLog("非法封包..禁止走路!!x:" + nNewX.ToString() + "y:" + nNewY.ToString()); return false; } // 跑步模式的阻挡判断 bool IsRun = false; if (move.ucMode >= DIR.MOVEMODE_RUN_DIR0 && move.ucMode <= DIR.MOVEMODE_RUN_DIR7 && GetBaseAttr().sp > 0 /*没有体力不让跑*/) { nNewX += DIR._DELTA_X[move.ucMode - DIR.MOVEMODE_RUN_DIR0]; nNewY += DIR._DELTA_Y[move.ucMode - DIR.MOVEMODE_RUN_DIR0]; IsRun = true; if (!mGameMap.CanMove(nNewX, nNewY)) { nNewX = this.GetCurrentX(); nNewY = this.GetCurrentY(); if (!mGameMap.CanMove(nNewX, nNewY)) { nNewX = (short)mGameMap.GetMapInfo().recallx; nNewY = (short)mGameMap.GetMapInfo().recally; } //暂时使用随机卷的方式重置玩家坐标 this.ScroolRandom(nNewX, nNewY); //Log.Instance().WriteLog("非法封包..禁止走路!!x:" + nNewX.ToString() + "y:" + nNewY.ToString()); //Log.Instance().WriteLog("这个家伙肯定用了外挂,不如我们把他封号吧,角色名称:" + this.GetName() + // "如果下次他还开外挂,就把他硬盘里的种子全删掉..."); return false; } } //传送点判断 uint mapid = 0; short x = 0; short y = 0; if (ConfigManager.Instance().CheckMapGate(this.GetGameMap().GetMapInfo().id, nNewX, nNewY, ref mapid, ref x, ref y)) { this.ChangeMap(mapid, x, y); return false; } if (GetBaseAttr().sp <= 0) move.ucMode = 0; SetPoint(nNewX, nNewY); GameStruct.Action action = new GameStruct.Action(GameStruct.Action.MOVE); if (IsRun) action.AddObject(move.ucMode); //解除锁定目标 this.GetFightSystem().SetAutoAttackTarget(null); PushAction(action); return true; }
//幻兽魔法攻击 public void MagicAttack(NetMsg.MsgAttackInfo info) { if (!this.IsHaveMagic((ushort)info.usType)) return; GameStruct.MagicTypeInfo typeinfo = ConfigManager.Instance().GetMagicTypeInfo(info.usType); // if (typeinfo == null) return; BaseObject targetobj = null; uint injured = 0; ushort magiclv = this.GetMagicLevel((ushort)info.usType); if (!CheckMagicAttackSpeed((ushort)info.usType, (byte)magiclv)) { return; } switch (typeinfo.sort) { case GameStruct.MagicTypeInfo.MAGICSORT_ATTACK: { targetobj = this.GetGameMap().FindObjectForID(info.idTarget); if (targetobj == null) { return; } if (targetobj.IsDie()) return; if (targetobj.IsLock()) return; //被锁定了 byte bdir = DIR.GetDirByPos(this.GetCurrentX(), this.GetCurrentY(), targetobj.GetCurrentX(), targetobj.GetCurrentY()); this.SetDir(bdir); //距离判断,防止非法封包 if (Math.Abs(this.GetCurrentX() - targetobj.GetCurrentY()) > typeinfo.distance && Math.Abs(this.GetCurrentY() - targetobj.GetCurrentY()) > typeinfo.distance) { return; } //连击技能 if (!play.CanPK(targetobj)) return; //单体魔法攻击 injured = BattleSystem.AdjustDamage(this, targetobj, true); if (injured <= 0) injured = 1; NetMsg.MsgMonsterMagicInjuredInfo magicattack = new NetMsg.MsgMonsterMagicInjuredInfo(); magicattack.time = System.Environment.TickCount; magicattack.roleid = this.GetTypeId(); magicattack.role_x = this.GetCurrentX(); magicattack.role_y = this.GetCurrentY(); magicattack.monsterid = targetobj.GetTypeId(); magicattack.tag = 21; magicattack.magicid = (ushort)info.usType; magicattack.magiclv = magiclv; this.BrocatBuffer(magicattack.GetBuffer()); NetMsg.MsgGroupMagicAttackInfo magicattackex = new NetMsg.MsgGroupMagicAttackInfo(); //有轨迹的魔法-- magicattackex.SetSigleAttack(targetobj.GetTypeId()); magicattackex.nID = this.GetTypeId(); //magicattackex.nX = (short)info.usPosX; //magicattackex.nY = (short)info.usPosY; magicattackex.nMagicID = (ushort)info.usType; magicattackex.nMagicLv = magiclv; magicattackex.bDir = this.GetDir(); magicattackex.AddObject(targetobj.GetTypeId(), (int)injured); this.BrocatBuffer(magicattackex.GetBuffer()); targetobj.Injured(this, injured, info); break; } case GameStruct.MagicTypeInfo.MAGICSORT_BOMB: //范围攻击 { byte bdir = DIR.GetDirByPos(this.GetCurrentX(), this.GetCurrentY(), (short)info.usPosX, (short)info.usPosY); play.SetDir(bdir); NetMsg.MsgGroupMagicAttackInfo magicattackex = new NetMsg.MsgGroupMagicAttackInfo(); magicattackex.nID = this.GetTypeId(); magicattackex.nX = this.GetCurrentX(); magicattackex.nY = this.GetCurrentY(); magicattackex.nMagicID = (ushort)info.usType; magicattackex.nMagicLv = magiclv; magicattackex.bDir = this.GetDir(); //被攻击的对象 List<BaseObject> list = this.GetBombVisibleObj(info); if (list != null) { for (int i = 0; i < list.Count; i++) { injured = BattleSystem.AdjustDamage(this, list[i], true); list[i].Injured(this, injured, info); magicattackex.AddObject(list[i].GetTypeId(), (int)injured); } } byte[] msg = magicattackex.GetBuffer(); this.BrocatBuffer(msg); break; } case GameStruct.MagicTypeInfo.MAGICSORT_FAN: //扇形攻击 { byte bdir = DIR.GetDirByPos(this.GetCurrentX(), this.GetCurrentY(), (short)info.usPosX, (short)info.usPosY); this.SetDir(bdir); NetMsg.MsgGroupMagicAttackInfo magicattackex = new NetMsg.MsgGroupMagicAttackInfo(); magicattackex.nID = this.GetTypeId(); magicattackex.nX = this.GetCurrentX(); magicattackex.nY = this.GetCurrentY(); magicattackex.nMagicID = (ushort)info.usType; magicattackex.nMagicLv = magiclv; magicattackex.bDir = bdir; //被攻击的对象 List<BaseObject> list = this.GetFanVisibleObj(info); if (list != null) { for (int i = 0; i < list.Count; i++) { injured = BattleSystem.AdjustDamage(this, list[i], true); if (injured <= 0) injured = 1; //怪物承受XP技能加倍伤害 if (list[i].type == OBJECTTYPE.MONSTER && typeinfo.use_xp > 0) { injured = injured * GameBase.Config.Define.XP_MULTIPLE; } list[i].Injured(this, injured, info); magicattackex.AddObject(list[i].GetTypeId(), (int)injured); } } byte[] msg = magicattackex.GetBuffer(); this.BrocatBuffer(msg); break; } } }
public override void Injured(BaseObject obj, uint value, NetMsg.MsgAttackInfo info) { mbIsCombo = play.GetFightSystem().IsComboMagic(info.usType); this.GetAttr().life -= (int)value; if (this.GetAttr().life < 0) { this.GetAttr().life = 0; } if (!mbIsCombo && this.GetAttr().life <= 0) { GameStruct.Action action = new GameStruct.Action(GameStruct.Action.DIE, null); this.PushAction(action); } NetMsg.MsgEudemonInfo msg = new NetMsg.MsgEudemonInfo(); msg.id = this.GetTypeId(); msg.AddAttribute(EudemonAttribute.Life, this.GetAttr().life); this.BrocatBuffer(msg.GetBuffer()); }
public bool Eudemon_Injured(BaseObject obj, uint value, NetMsg.MsgAttackInfo info) { int i = mBattleObj.Count; bool bRet = false; //从上到下是因为最上面的是最外面的合体幻兽 while (i > 0) { i--; EudemonObject eudemon_obj = mBattleObj[i]; if (eudemon_obj.GetState() == EUDEMONSTATE.FIT) { eudemon_obj.Injured(obj, value, info); bRet = true; break; } } return bRet; }
//幻兽攻击 public void Eudemon_Attack(NetMsg.MsgAttackInfo info) { EudemonObject obj = GetBattleEudemon(info.roleId); if (obj == null) return; switch (info.tag) { case 2: { obj.Attack(info); break; } case 21: { obj.MagicAttack(info); break; } } }
//获取鼠标范围点的对象 private List<BaseObject> GetPointBombVisibleObj(NetMsg.MsgAttackInfo magicinfo) { List<BaseObject> list_obj = new List<BaseObject>(); GameStruct.MagicTypeInfo typeinfo = ConfigManager.Instance().GetMagicTypeInfo(magicinfo.usType); if (typeinfo == null) return list_obj; int nRange = (int)typeinfo.range; GameStruct.Point point = new GameStruct.Point(); point.x = (short)magicinfo.usPosX; point.y = (short)magicinfo.usPosY; foreach (RefreshObject refobj in play.GetVisibleList().Values) { BaseObject obj = refobj.obj; if (!IsAddMagicVisibleObj(obj)) { continue; } if (point.CheckVisualDistance(obj.GetCurrentX(), obj.GetCurrentY(), nRange)) { list_obj.Add(obj); } } return list_obj; }
public override void Injured(BaseObject obj, uint value,NetMsg.MsgAttackInfo info) { if (value > attr.life) attr.life = 0; else attr.life -= (int)value; GameStruct.Action action; action = new GameStruct.Action(GameStruct.Action.INJURED, null); action.AddObject(obj); action.AddObject(value); action.AddObject(info); this.PushAction(action); }
public override void Injured(BaseObject obj, uint value, NetMsg.MsgAttackInfo info) { this.GetFightSystem().SetFighting(); //幻兽优先受伤害 if (!this.GetEudemonSystem().Eudemon_Injured(obj, value, info)) { //如果没有幻兽抵挡. 玩家就受到真实伤害 this.ChangeAttribute(GameStruct.UserAttribute.LIFE, -(int)value); } GameStruct.Action action; action = new GameStruct.Action(GameStruct.Action.INJURED, null); action.AddObject(obj); action.AddObject(value); action.AddObject(info); this.PushAction(action); }
//获取扇形范围内的对象 private List<BaseObject> GetFanVisibleObj(NetMsg.MsgAttackInfo magicinfo) { List<BaseObject> list_obj = new List<BaseObject>(); GameStruct.MagicTypeInfo typeinfo = ConfigManager.Instance().GetMagicTypeInfo(magicinfo.usType); if (typeinfo == null) return list_obj; int nRange = (int)typeinfo.range + GameBase.Config.Define.MAX_SIZEADD; int nSize = nRange * 2 + 1; int nWidth = (int)typeinfo.width; foreach (RefreshObject refobj in this.GetVisibleList().Values) { BaseObject obj = refobj.obj; if (!play.GetFightSystem().IsAddMagicVisibleObj(obj)) { continue; } GameStruct.Point pos = this.GetPoint(); GameStruct.Point magicpos = new GameStruct.Point(); magicpos.x = (short)magicinfo.usPosX; magicpos.y = (short)magicinfo.usPosY; if (this.GetPoint().CheckFanDistance(obj.GetPoint(), magicpos, nRange)) { list_obj.Add(obj); } } return list_obj; }
//请求交易 public void RequstTrad(NetMsg.MsgTradInfo info) { PlayerObject obj = UserEngine.Instance().FindPlayerObjectToTypeID(info.typeid); if (obj == null) { play.LeftNotice("对方已离线,无法交易!"); return; } if (play.GetTimerSystem().QueryStatus(GameStruct.RoleStatus.STATUS_PTICH) != null) { play.MsgBox("摆摊中无法交易!"); return; } if (obj.GetTimerSystem().QueryStatus(GameStruct.RoleStatus.STATUS_PTICH) != null) { play.MsgBox("对方摆摊中,无法交易!"); return; } if (this.GetTradTarget() == info.typeid) //同意交易 { obj.GetTradSystem().SetTrading(true); play.GetTradSystem().SetTrading(true); return; } else if(this.GetTradTarget() != 0 )//正在交易中- 无法再次交易 { play.LeftNotice("正在交易中,无法再次交易"); return; } //请求交易 //距离判断 int x = Math.Abs(play.GetCurrentX() - obj.GetCurrentX()); int y = Math.Abs(play.GetCurrentY() - obj.GetCurrentY()); if (x > GameBase.Config.Define.MAX_PLAY_VISIBLE_DISTANCE || y > GameBase.Config.Define.MAX_PLAY_VISIBLE_DISTANCE) { play.LeftNotice("距离太远,无法交易"); return; } NetMsg.MsgTradInfo data = new NetMsg.MsgTradInfo(); data.Create(null, obj.GetGamePackKeyEx()); data.typeid = play.GetTypeId(); data.type = NetMsg.MsgTradInfo.REQUEST_TRAD; data.level = play.GetBaseAttr().level; data.fightpower = (short)play.GetFightSoul(); obj.SendData(data.GetBuffer()); obj.GetTradSystem().SetTradTarget(play.GetTypeId()); play.GetTradSystem().SetTradTarget(obj.GetTypeId()); play.LeftNotice("[交易]已经发出交易请求。"); }
//取消交易 public void QuitTrad(NetMsg.MsgTradInfo info) { if (GetTradTarget() == 0) return; this.SetTrading(false); this.SetSureTradTag(false); PlayerObject obj = UserEngine.Instance().FindPlayerObjectToTypeID(GetTradTarget()); if (obj == null) { return; } this.SetTradTarget(0); obj.GetTradSystem().SetTradTarget(0); obj.GetTradSystem().SetTrading(false); obj.GetTradSystem().SetSureTradTag(false); }
//攻击 public void Attack(NetMsg.MsgAttackInfo info) { if (!mAttackSpeed.ToNextTime()) { return; } BaseObject targetobj = play.GetGameMap().FindObjectForID(info.idTarget); if (targetobj == null) { return; } if (mMonsterInfo == null) return; if (targetobj.IsDie()) return; if (targetobj.IsLock()) return; //被锁定了 if (mInfo.bDie) return; //死亡 防作弊 //与怪物的距离判断--反作弊 if (Math.Abs(this.GetCurrentX() - targetobj.GetCurrentX()) > mMonsterInfo.range && Math.Abs(this.GetCurrentY() - targetobj.GetCurrentY()) > mMonsterInfo.range) { return; } if (targetobj.type == OBJECTTYPE.PLAYER) { if (!play.CanPK(targetobj)) return; } if (targetobj.type == OBJECTTYPE.EUDEMON) { if (!play.CanPK((targetobj as EudemonObject).GetOwnerPlay())) { return; } } uint injured = 0; //经验-- //战士幻兽使用近战攻击.法师幻兽使用魔法攻击 switch (mMonsterInfo.eudemon_type) { case GameBase.Config.Define.EUDEMON_TYPE_WARRIOR: case GameBase.Config.Define.EUDEMON_TYPE_WARRIOR_RIG: { injured = BattleSystem.AdjustDamage(this, targetobj); NetMsg.MsgMonsterInjuredInfo injuredinfo = new NetMsg.MsgMonsterInjuredInfo(); injuredinfo.roleid = this.GetTypeId(); injuredinfo.role_x = this.GetCurrentX(); injuredinfo.role_y = this.GetCurrentY(); injuredinfo.injuredvalue = injured; injuredinfo.monsterid = targetobj.GetTypeId(); injuredinfo.tag = 2; byte[] msg = injuredinfo.GetBuffer(); this.BrocatBuffer(msg); break; } case GameBase.Config.Define.EUDEMON_TYPE_MAGE: case GameBase.Config.Define.EUDEMON_TYPE_MAGE_RID: { injured = BattleSystem.AdjustDamage(this, targetobj,true); if (injured == 0) injured = 1; //NetMsg.MsgMonsterMagicInjuredInfo magicattack = new NetMsg.MsgMonsterMagicInjuredInfo(); //magicattack.time = System.Environment.TickCount; //magicattack.roleid = this.GetTypeId(); //magicattack.role_x = this.GetCurrentX(); //magicattack.role_y = this.GetCurrentY(); //magicattack.monsterid = targetobj.GetTypeId(); //magicattack.tag = 21; //magicattack.magicid = 1; //magicattack.magiclv = 0; //this.BrocatBuffer(magicattack.GetBuffer()); NetMsg.MsgGroupMagicAttackInfo magicattackex = new NetMsg.MsgGroupMagicAttackInfo(); //有轨迹的魔法-- magicattackex.SetSigleAttack(targetobj.GetTypeId()); magicattackex.nID = this.GetTypeId(); //magicattackex.nX = (short)info.usPosX; //magicattackex.nY = (short)info.usPosY; magicattackex.nMagicID = 5000; magicattackex.nMagicLv = 0; magicattackex.bDir = this.GetDir(); magicattackex.AddObject(targetobj.GetTypeId(), (int)injured); this.BrocatBuffer(magicattackex.GetBuffer()); break; } } targetobj.Injured(this, injured, info); }
public void MagicAttack(NetMsg.MsgAttackInfo info) { if (!play.GetMagicSystem().isMagic(info.usType)) return; //检测施法速度 ushort magiclv = play.GetMagicSystem().GetMagicLevel(info.usType); if (!play.GetMagicSystem().CheckMagicAttackSpeed((ushort)info.usType, (byte)magiclv)) { return; } //-------------------------------------------------------------------------- //暗黑龙骑--焰魂枪·裂地三段斩 if (info.usType == GameStruct.MagicTypeInfo.YANHUNQIANG_LIEDI) { uint nMagicId = info.usType + mnYanHunQiangIndex; //没有下一段技能 if (!play.GetMagicSystem().isMagic(nMagicId)) { mnYanHunQiangIndex = 0; nMagicId = info.usType; } info.usType = nMagicId; mnYanHunQiangIndex++; if (mnYanHunQiangIndex >= 3) mnYanHunQiangIndex = 0; } //-------------------------------------------------------------------------- //暗黑龙骑- 焰魂枪·流焰 四段斩 if (info.usType == GameStruct.MagicTypeInfo.YANHUNQIANG_LIUYAN) { uint nMagicId = info.usType + mnYanHunQiangExIndex; //没有下一段技能 if (!play.GetMagicSystem().isMagic(nMagicId)) { mnYanHunQiangExIndex = 0; nMagicId = info.usType; } info.usType = nMagicId; mnYanHunQiangExIndex++; if (mnYanHunQiangExIndex >= 4) mnYanHunQiangExIndex = 0; } //------------------------------------------------------------------------ GameStruct.MagicTypeInfo typeinfo = ConfigManager.Instance().GetMagicTypeInfo(info.usType); if (typeinfo == null) return; uint injured = 0; BaseObject targetobj = null; //xp技能校验- if (typeinfo.use_xp > 0 && play.GetTimerSystem().QueryStatus(GameStruct.RoleStatus.STATUS_XPFULL_ATTACK) == null) return; //加经验 if (typeinfo.need_exp > 0 && play.GetBaseAttr().level >= typeinfo.need_level) { play.GetMagicSystem().AddMagicExp(info.usType, 1); } if (typeinfo.use_ep > 0 && play.GetBaseAttr().sp < typeinfo.use_ep) { return; } if (typeinfo.use_mp > 0 && play.GetBaseAttr().mana < typeinfo.use_mp) return; //消耗体力 if (typeinfo.use_ep > 0 && play.GetBaseAttr().sp > typeinfo.use_ep) { play.ChangeAttribute(UserAttribute.SP, (int)-typeinfo.use_ep); } //消耗魔法 if (typeinfo.use_mp > 0 && play.GetBaseAttr().mana > typeinfo.use_mp) { play.ChangeAttribute(UserAttribute.MANA, (int)-typeinfo.use_mp); } switch (typeinfo.sort) { case GameStruct.MagicTypeInfo.MAGICSORT_ATTACK: case GameStruct.MagicTypeInfo.MAGICSORT_JUMP_ATTACK: //跳斩单体攻击 { targetobj = play.GetGameMap().FindObjectForID(info.idTarget); if (targetobj == null) { return; } if (targetobj.IsDie()) return; if (targetobj.IsLock()) return; //被锁定了 byte bdir = DIR.GetDirByPos(play.GetCurrentX(), play.GetCurrentY(), targetobj.GetCurrentX(), targetobj.GetCurrentY()); play.SetDir(bdir); //距离判断,防止非法封包 if (Math.Abs(play.GetCurrentX() - targetobj.GetCurrentY()) > typeinfo.distance && Math.Abs(play.GetCurrentY() - targetobj.GetCurrentY()) > typeinfo.distance) { return; } //连击技能 if (!play.CanPK(targetobj)) return; if (IsComboMagic(typeinfo.typeid)) { this.ComboMagic(info, targetobj); //血袭- 增加buff与状态 if (info.usType == GameStruct.MagicTypeInfo.XUEXI) { play.GetTimerSystem().AddStatus(GameStruct.RoleStatus.STATUS_XUEXI, Define.XUEXI_TIME); } return; } //单体魔法攻击 injured = BattleSystem.AdjustDamage(play, targetobj, true); //怪物承受XP技能加倍伤害 if (targetobj.type == OBJECTTYPE.MONSTER && typeinfo.use_xp > 0) { injured = injured * Define.XP_MULTIPLE; } NetMsg.MsgMonsterMagicInjuredInfo magicattack = new NetMsg.MsgMonsterMagicInjuredInfo(); magicattack.time = System.Environment.TickCount; magicattack.roleid = play.GetTypeId(); magicattack.role_x = play.GetCurrentX(); magicattack.role_y = play.GetCurrentY(); magicattack.monsterid = targetobj.GetTypeId(); magicattack.tag = 21; magicattack.magicid = (ushort)info.usType; magicattack.magiclv = magiclv; play.BroadcastBuffer(magicattack.GetBuffer(), true); NetMsg.MsgGroupMagicAttackInfo magicattackex = new NetMsg.MsgGroupMagicAttackInfo(); //有轨迹的魔法-- magicattackex.SetSigleAttack(targetobj.GetTypeId()); magicattackex.nID = play.GetTypeId(); //magicattackex.nX = (short)info.usPosX; //magicattackex.nY = (short)info.usPosY; magicattackex.nMagicID = (ushort)info.usType; magicattackex.nMagicLv = magiclv; magicattackex.bDir = play.GetDir(); magicattackex.AddObject(targetobj.GetTypeId(),(int) injured); play.BroadcastBuffer(magicattackex.GetBuffer(),true); targetobj.Injured(play, injured, info); ////跳斩单体攻击 //位置还没计算好..2015.10.27 暂时搁置 //位置已解决- 2015.11.1 if (typeinfo.sort == GameStruct.MagicTypeInfo.MAGICSORT_JUMP_ATTACK) { int nNewX = targetobj.GetCurrentX() - (DIR._DELTA_X[bdir] + DIR._DELTA_X[bdir]); int nNewY = targetobj.GetCurrentY() - (DIR._DELTA_Y[bdir] + DIR._DELTA_Y[bdir]); play.SetPoint((short)nNewX,(short) nNewY); } break; } case GameStruct.MagicTypeInfo.MAGICSORT_BOMB: //范围攻击 case GameStruct.MagicTypeInfo.MAGICSORT_JUMPBOMB: //跳斩范围攻击 case GameStruct.MagicTypeInfo.MAGICSORT_POINTBOMB: //指定鼠标位置攻击 { byte bdir = DIR.GetDirByPos(play.GetCurrentX(), play.GetCurrentY(), (short)info.usPosX, (short)info.usPosY); play.SetDir(bdir); //亡灵巫师巫怒噬魂 if (typeinfo.typeid == GameStruct.MagicTypeInfo.WUNUSHIHUN) { if (targetobj == null) { return; } int nNewX = targetobj.GetCurrentX() - (DIR._DELTA_X[bdir] + DIR._DELTA_X[bdir]); int nNewY = targetobj.GetCurrentY() - (DIR._DELTA_Y[bdir] + DIR._DELTA_Y[bdir]); play.SetPoint((short)nNewX, (short)nNewY); targetobj = play.GetGameMap().FindObjectForID(info.idTarget); } if (typeinfo.sort == GameStruct.MagicTypeInfo.MAGICSORT_JUMPBOMB) //跳斩 { if (Math.Abs(play.GetCurrentX() - info.usPosX) > typeinfo.distance && Math.Abs(play.GetCurrentY() - info.usPosY) > typeinfo.distance) { return; } play.SetPoint((short)info.usPosX, (short)info.usPosY); //跳斩嘛。先跳过去 } NetMsg.MsgGroupMagicAttackInfo magicattackex = new NetMsg.MsgGroupMagicAttackInfo(); magicattackex.nID = play.GetTypeId(); magicattackex.nX = play.GetCurrentX(); magicattackex.nY = play.GetCurrentY(); if (typeinfo.sort == GameStruct.MagicTypeInfo.MAGICSORT_POINTBOMB) { magicattackex.nX = (short)info.usPosX; magicattackex.nY = (short)info.usPosY; } magicattackex.nMagicID = (ushort)info.usType; magicattackex.nMagicLv = magiclv; magicattackex.bDir = play.GetDir(); //被攻击的对象 List<BaseObject> list = this.RefreshMagicVisibleObject(typeinfo.typeid,info); if (list != null) { for (int i = 0; i < list.Count; i++) { injured = BattleSystem.AdjustDamage(play, list[i], true); //怪物承受XP技能加倍伤害 if (list[i].type == OBJECTTYPE.MONSTER && typeinfo.use_xp > 0) { injured = injured * Define.XP_MULTIPLE; } list[i].Injured(play, injured, info); magicattackex.AddObject(list[i].GetTypeId(), (int)injured); } } byte[] msg = magicattackex.GetBuffer(); play.BroadcastBuffer(msg, true); //血族 血雨旋涡 if (typeinfo.typeid == GameStruct.MagicTypeInfo.XUEYUXUANWO) { int nAddX = 0; int nAddY = 0; switch(bdir) { case DIR.LEFT_DOWN: case DIR.RIGHT_UP: { nAddX = 10; nAddY = 15; break; } case DIR.LEFT: case DIR.UP: case DIR.RIGHT: case DIR.DOWN: { nAddY = 10; nAddX = 10; break; } case DIR.LEFT_UP: case DIR.RIGHT_DOWN: { nAddX = 15; nAddY = 10; break; } } int nNewX = play.GetCurrentX() + (DIR._DELTA_X[bdir] * nAddX); int nNewY = play.GetCurrentY() + (DIR._DELTA_Y[bdir] * nAddY); play.SetPoint((short)nNewX, (short)nNewY); } break; } case GameStruct.MagicTypeInfo.MAGICSORT_FAN: //扇形攻击 { byte bdir = DIR.GetDirByPos(play.GetCurrentX(), play.GetCurrentY(), (short)info.usPosX, (short)info.usPosY); play.SetDir(bdir); NetMsg.MsgGroupMagicAttackInfo magicattackex = new NetMsg.MsgGroupMagicAttackInfo(); magicattackex.nID = play.GetTypeId(); magicattackex.nX = play.GetCurrentX(); magicattackex.nY = play.GetCurrentY(); magicattackex.nMagicID = (ushort)info.usType; magicattackex.nMagicLv = magiclv; magicattackex.bDir = bdir; //被攻击的对象 List<BaseObject> list = this.RefreshMagicVisibleObject(typeinfo.typeid, info); if (list != null) { for (int i = 0; i < list.Count; i++) { injured = BattleSystem.AdjustDamage(play, list[i], true); //怪物承受XP技能加倍伤害 if (list[i].type == OBJECTTYPE.MONSTER && typeinfo.use_xp > 0) { injured = injured * Define.XP_MULTIPLE; } list[i].Injured(play, injured, info); magicattackex.AddObject(list[i].GetTypeId(), (int)injured); } } byte[] msg = magicattackex.GetBuffer(); play.BroadcastBuffer(msg, true); break; } case GameStruct.MagicTypeInfo.MAGICSORT_LINE: //直线型攻击 { byte bByte = DIR.GetDirByPos(play.GetCurrentX(), play.GetCurrentY(), (short)info.usPosX, (short)info.usPosY); play.SetDir(bByte); NetMsg.MsgMonsterMagicInjuredInfo magicattack = new NetMsg.MsgMonsterMagicInjuredInfo(); magicattack.roleid = play.GetTypeId(); magicattack.role_x = play.GetCurrentX(); magicattack.role_y = play.GetCurrentY(); magicattack.tag = 21; magicattack.magicid = (ushort)info.usType; magicattack.magiclv = magiclv; play.BroadcastBuffer(magicattack.GetBuffer(), true); NetMsg.MsgGroupMagicAttackInfo magicattackex = new NetMsg.MsgGroupMagicAttackInfo(); magicattackex.nID = play.GetTypeId(); magicattackex.nX = (short)info.usPosX; magicattackex.nY = (short)info.usPosY; magicattackex.nMagicID = (ushort)info.usType; magicattackex.nMagicLv = magiclv; magicattackex.bDir = play.GetDir(); List<BaseObject> list = this.RefreshMagicVisibleObject(typeinfo.typeid, info); if (list != null) { for (int i = 0; i < list.Count; i++) { injured = BattleSystem.AdjustDamage(play, list[i], true); //怪物承受XP技能加倍伤害 if (list[i].type == OBJECTTYPE.MONSTER && typeinfo.use_xp > 0) { injured = injured * Define.XP_MULTIPLE; } list[i].Injured(play, injured, info); magicattackex.AddObject(list[i].GetTypeId(), (int)injured); } } play.BroadcastBuffer(magicattackex.GetBuffer(), true); break; } case GameStruct.MagicTypeInfo.MAGICSORT_ATTACHSTATUS: //引诱 { foreach (RefreshObject refobj in play.GetVisibleList().Values) { BaseObject obj = refobj.obj; if (obj.type == OBJECTTYPE.MONSTER) { if ((obj as MonsterObject).GetAi().GetTargetObject() == null) { (obj as MonsterObject).GetAi().SetAttackTarget(play); } } } byte dir = DIR.GetDirByPos(play.GetCurrentX(), play.GetCurrentY(), (short)info.usPosX, (short)info.usPosY); play.SetDir(dir); NetMsg.MsgMonsterMagicInjuredInfo magicinfo = new NetMsg.MsgMonsterMagicInjuredInfo(); magicinfo.roleid = play.GetTypeId(); magicinfo.role_x = play.GetCurrentX(); magicinfo.role_y = play.GetCurrentY(); magicinfo.injuredvalue = 0; magicinfo.monsterid = play.GetTypeId(); magicinfo.tag = 21; magicinfo.magicid = (ushort)info.usType; magicinfo.magiclv = magiclv; byte[] msg = magicinfo.GetBuffer(); play.BroadcastBuffer(msg,true); NetMsg.MsgMagicAttackInfo _info = new NetMsg.MsgMagicAttackInfo(); _info.id = _info.targetid = play.GetTypeId(); _info.magicid = (ushort)info.usType; _info.level = magiclv; _info.dir = dir; msg = _info.GetBuffer(); play.BroadcastBuffer(msg, true); break; } case GameStruct.MagicTypeInfo.MAGICSORT_STEALTH: //潜行 { byte dir = DIR.GetDirByPos(play.GetCurrentX(), play.GetCurrentY(), (short)info.usPosX, (short)info.usPosY); play.SetDir(dir); NetMsg.MsgMonsterMagicInjuredInfo magicinfo = new NetMsg.MsgMonsterMagicInjuredInfo(); magicinfo.roleid = play.GetTypeId(); magicinfo.role_x = play.GetCurrentX(); magicinfo.role_y = play.GetCurrentY(); magicinfo.injuredvalue = 0; magicinfo.monsterid = play.GetTypeId(); magicinfo.tag = 21; magicinfo.magicid = (ushort)info.usType; magicinfo.magiclv = magiclv; byte[] msg = magicinfo.GetBuffer(); play.BroadcastBuffer(msg, true); NetMsg.MsgMagicAttackInfo _info = new NetMsg.MsgMagicAttackInfo(); _info.id = _info.targetid = play.GetTypeId(); _info.magicid = (ushort)info.usType; _info.level = magiclv; _info.dir = dir; msg = _info.GetBuffer(); play.BroadcastBuffer(msg, true); play.GetTimerSystem().AddStatus(GameStruct.RoleStatus.STATUS_STEALTH, Define.STEALTH_TIME); break; } case GameStruct.MagicTypeInfo.MAGICSORT_HIDEDEN://隐身 { byte dir = DIR.GetDirByPos(play.GetCurrentX(), play.GetCurrentY(), (short)info.usPosX, (short)info.usPosY); play.SetDir(dir); NetMsg.MsgMonsterMagicInjuredInfo magicinfo = new NetMsg.MsgMonsterMagicInjuredInfo(); magicinfo.roleid = play.GetTypeId(); magicinfo.role_x = play.GetCurrentX(); magicinfo.role_y = play.GetCurrentY(); magicinfo.injuredvalue = 0; magicinfo.monsterid = play.GetTypeId(); magicinfo.tag = 21; magicinfo.magicid = (ushort)info.usType; magicinfo.magiclv = magiclv; byte[] msg = magicinfo.GetBuffer(); play.BroadcastBuffer(msg, true); NetMsg.MsgMagicAttackInfo _info = new NetMsg.MsgMagicAttackInfo(); _info.id = _info.targetid = play.GetTypeId(); _info.magicid = (ushort)info.usType; _info.level = magiclv; _info.dir = dir; msg = _info.GetBuffer(); play.BroadcastBuffer(msg, true); if (play.GetTimerSystem().QueryStatus(GameStruct.RoleStatus.STATUS_HIDDEN) != null) { play.GetTimerSystem().DeleteStatus(GameStruct.RoleStatus.STATUS_HIDDEN); } else { play.GetTimerSystem().AddStatus(GameStruct.RoleStatus.STATUS_HIDDEN, Define.HIDEDEM_TIME); } break; } case GameStruct.MagicTypeInfo.MAGICSORT_YUANSUZHANGKONG: //法师 元素掌控 { byte dir = DIR.GetDirByPos(play.GetCurrentX(), play.GetCurrentY(), (short)info.usPosX, (short)info.usPosY); play.SetDir(dir); NetMsg.MsgMonsterMagicInjuredInfo magicinfo = new NetMsg.MsgMonsterMagicInjuredInfo(); magicinfo.roleid = play.GetTypeId(); magicinfo.role_x = play.GetCurrentX(); magicinfo.role_y = play.GetCurrentY(); magicinfo.injuredvalue = 0; magicinfo.monsterid = play.GetTypeId(); magicinfo.tag = 21; magicinfo.magicid = (ushort)info.usType; magicinfo.magiclv = magiclv; byte[] msg = magicinfo.GetBuffer(); play.BroadcastBuffer(msg, true); if (play.GetTimerSystem().QueryStatus(GameStruct.RoleStatus.STATUS_YUANSUZHANGKONG) != null) { play.GetTimerSystem().DeleteStatus(GameStruct.RoleStatus.STATUS_YUANSUZHANGKONG); //流星陨火要清空 mnLiuXingYunHuoCount = 0; play.ChangeAttribute(UserAttribute.LIUXINGYUNHUO, mnLiuXingYunHuoCount); } else { play.GetTimerSystem().AddStatus(GameStruct.RoleStatus.STATUS_YUANSUZHANGKONG, 0); } NetMsg.MsgMagicAttackInfo _info = new NetMsg.MsgMagicAttackInfo(); _info.id = _info.targetid = play.GetTypeId(); _info.magicid = (ushort)info.usType; _info.level = magiclv; _info.dir = dir; msg = _info.GetBuffer(); play.BroadcastBuffer(msg, true); break; } case GameStruct.MagicTypeInfo.MAGICSORT_LIUXINGYUNHUO: //法师 流星陨石 { targetobj = play.GetGameMap().FindObjectForID(info.idTarget); if (targetobj == null) { return; } byte dir = DIR.GetDirByPos(play.GetCurrentX(), play.GetCurrentY(), (short)info.usPosX, (short)info.usPosY); play.SetDir(dir); if (mnLiuXingYunHuoCount <= 0) break; NetMsg.MsgMonsterMagicInjuredInfo magicinfo = new NetMsg.MsgMonsterMagicInjuredInfo(); magicinfo.roleid = play.GetTypeId(); magicinfo.role_x = play.GetCurrentX(); magicinfo.role_y = play.GetCurrentY(); magicinfo.injuredvalue = 0; magicinfo.monsterid = play.GetTypeId(); magicinfo.tag = 21; magicinfo.magicid = (ushort)info.usType; magicinfo.magiclv = magiclv; byte[] msg = magicinfo.GetBuffer(); play.BroadcastBuffer(msg, true); for (int i = 0; i < mnLiuXingYunHuoCount; i++) { injured = BattleSystem.AdjustDamage(play, targetobj, true); NetMsg.MsgGroupMagicAttackInfo magicattackex = new NetMsg.MsgGroupMagicAttackInfo(); //有轨迹的魔法-- magicattackex.SetSigleAttack(targetobj.GetTypeId()); magicattackex.nID = play.GetTypeId(); magicattackex.nMagicID = (ushort)info.usType; magicattackex.nMagicLv = magiclv; magicattackex.bDir = play.GetDir(); magicattackex.AddObject(targetobj.GetTypeId(), (int)injured); play.BroadcastBuffer(magicattackex.GetBuffer(), true); targetobj.Injured(play, injured, info); } mnLiuXingYunHuoCount = 0; play.ChangeAttribute(UserAttribute.LIUXINGYUNHUO, mnLiuXingYunHuoCount); break; } case GameStruct.MagicTypeInfo.MAGICSORT_JUYANSHENGDUN://法师 巨岩圣盾 { byte dir = DIR.GetDirByPos(play.GetCurrentX(), play.GetCurrentY(), (short)info.usPosX, (short)info.usPosY); play.SetDir(dir); NetMsg.MsgMonsterMagicInjuredInfo magicinfo = new NetMsg.MsgMonsterMagicInjuredInfo(); magicinfo.roleid = play.GetTypeId(); magicinfo.role_x = play.GetCurrentX(); magicinfo.role_y = play.GetCurrentY(); magicinfo.injuredvalue = 0; magicinfo.monsterid = play.GetTypeId(); magicinfo.tag = 21; magicinfo.magicid = (ushort)info.usType; magicinfo.magiclv = magiclv; byte[] msg = magicinfo.GetBuffer(); play.BroadcastBuffer(msg, true); NetMsg.MsgMagicAttackInfo _info = new NetMsg.MsgMagicAttackInfo(); _info.id = _info.targetid = play.GetTypeId(); _info.magicid = (ushort)info.usType; _info.level = magiclv; _info.dir = dir; msg = _info.GetBuffer(); play.BroadcastBuffer(msg, true); play.GetTimerSystem().AddStatus(GameStruct.RoleStatus.STATUS_JUYANSHENGDUN, 0); break; } case GameStruct.MagicTypeInfo.MAGICSORT_YUANSUZHAOHUAN: //法师 元素召唤 { if (play.IsMountState()) play.TakeOffMount(0); else play.TakeMount(0,Define.YUANSUZHAOHUAN_MOUNTID); break; } case GameStruct.MagicTypeInfo.MAGICSORT_GULINGQIYUE: //亡灵巫师 骨灵契约 { if (play.IsMountState()) play.TakeOffMount(0); else play.TakeMount(0,Define.GULINGQIYUE_MOUNTID); break; } case GameStruct.MagicTypeInfo.MAGICSORT_ZHAOHUANWUHUAN: { NetMsg.MsgMonsterMagicInjuredInfo magicinfo = new NetMsg.MsgMonsterMagicInjuredInfo(); magicinfo.roleid = play.GetTypeId(); magicinfo.role_x = play.GetCurrentX(); magicinfo.role_y = play.GetCurrentY(); magicinfo.injuredvalue = 0; magicinfo.monsterid = play.GetTypeId(); magicinfo.tag = 21; magicinfo.magicid = (ushort)info.usType; magicinfo.magiclv = magiclv; byte[] msg = magicinfo.GetBuffer(); play.BroadcastBuffer(msg, true); NetMsg.MsgMagicAttackInfo _info = new NetMsg.MsgMagicAttackInfo(); _info.id = _info.targetid = play.GetTypeId(); _info.magicid = (ushort)info.usType; _info.level = magiclv; _info.dir = play.GetDir(); msg = _info.GetBuffer(); play.BroadcastBuffer(msg, true); if (play.GetTimerSystem().QueryStatus(GameStruct.RoleStatus.STATUS_ZHAOHUANWUHUAN) != null) { play.GetTimerSystem().DeleteStatus(GameStruct.RoleStatus.STATUS_ZHAOHUANWUHUAN); } else { play.GetTimerSystem().AddStatus(GameStruct.RoleStatus.STATUS_ZHAOHUANWUHUAN); } break; } case GameStruct.MagicTypeInfo.MAGICSORT_JIANGLINGZHOUYU: //亡灵巫师- 降灵咒雨 { byte dir = DIR.GetDirByPos(play.GetCurrentX(), play.GetCurrentY(), (short)info.usPosX, (short)info.usPosY); play.SetDir(dir); NetMsg.MsgMonsterMagicInjuredInfo magicinfo = new NetMsg.MsgMonsterMagicInjuredInfo(); magicinfo.roleid = play.GetTypeId(); magicinfo.role_x = play.GetCurrentX(); magicinfo.role_y = play.GetCurrentY(); magicinfo.injuredvalue = 0; magicinfo.monsterid = play.GetTypeId(); magicinfo.tag = 21; magicinfo.magicid = (ushort)info.usType; magicinfo.magiclv = magiclv; byte[] msg = magicinfo.GetBuffer(); play.BroadcastBuffer(msg, true); NetMsg.MsgMagicAttackInfo _info = new NetMsg.MsgMagicAttackInfo(); _info.id = _info.targetid = play.GetTypeId(); _info.magicid = (ushort)info.usType; _info.level = magiclv; _info.dir = dir; msg = _info.GetBuffer(); play.BroadcastBuffer(msg, true); EffectObject _effobj = new EffectObject(play, Define.JIANGLINGZHOUYU, 10, 14, Define.JIANGLINGZHOUYU_TIME, (short)info.usPosX, (short)info.usPosY); play.GetGameMap().AddObject(_effobj); _effobj.RefreshVisibleObject(); _effobj.SendInfo(play); break; } case GameStruct.MagicTypeInfo.MAGICSORT_ANSHAXIELONG: //暗沙邪龙 { byte dir = DIR.GetDirByPos(play.GetCurrentX(), play.GetCurrentY(), (short)info.usPosX, (short)info.usPosY); play.SetDir(dir); NetMsg.MsgMonsterMagicInjuredInfo magicinfo = new NetMsg.MsgMonsterMagicInjuredInfo(); magicinfo.roleid = play.GetTypeId(); magicinfo.role_x = play.GetCurrentX(); magicinfo.role_y = play.GetCurrentY(); magicinfo.injuredvalue = 0; magicinfo.monsterid = play.GetTypeId(); magicinfo.tag = 21; magicinfo.magicid = (ushort)info.usType; magicinfo.magiclv = magiclv; byte[] msg = magicinfo.GetBuffer(); play.BroadcastBuffer(msg, true); NetMsg.MsgMagicAttackInfo _info = new NetMsg.MsgMagicAttackInfo(); _info.id = _info.targetid = play.GetTypeId(); _info.magicid = (ushort)info.usType; _info.level = magiclv; _info.dir = dir; msg = _info.GetBuffer(); play.BroadcastBuffer(msg, true); play.GetTimerSystem().AddStatus(GameStruct.RoleStatus.STATUS_ANSHAXIELONG); break; } case GameStruct.MagicTypeInfo.MAGICSORT_MINGGUOSHENGNV: //冥国圣女 { byte dir = DIR.GetDirByPos(play.GetCurrentX(), play.GetCurrentY(), (short)info.usPosX, (short)info.usPosY); play.SetDir(dir); NetMsg.MsgMonsterMagicInjuredInfo magicinfo = new NetMsg.MsgMonsterMagicInjuredInfo(); magicinfo.roleid = play.GetTypeId(); magicinfo.role_x = play.GetCurrentX(); magicinfo.role_y = play.GetCurrentY(); magicinfo.injuredvalue = 0; magicinfo.monsterid = play.GetTypeId(); magicinfo.tag = 21; magicinfo.magicid = (ushort)info.usType; magicinfo.magiclv = magiclv; byte[] msg = magicinfo.GetBuffer(); play.BroadcastBuffer(msg, true); NetMsg.MsgMagicAttackInfo _info = new NetMsg.MsgMagicAttackInfo(); _info.id = _info.targetid = play.GetTypeId(); _info.magicid = (ushort)info.usType; _info.level = magiclv; _info.dir = dir; msg = _info.GetBuffer(); play.BroadcastBuffer(msg, true); play.GetTimerSystem().AddStatus(GameStruct.RoleStatus.STATUS_MINGGUOSHENGNV); break; } case GameStruct.MagicTypeInfo.MAGICSORT_WANGNIANWULING: //亡念巫灵 { byte dir = DIR.GetDirByPos(play.GetCurrentX(), play.GetCurrentY(), (short)info.usPosX, (short)info.usPosY); play.SetDir(dir); NetMsg.MsgMonsterMagicInjuredInfo magicinfo = new NetMsg.MsgMonsterMagicInjuredInfo(); magicinfo.roleid = play.GetTypeId(); magicinfo.role_x = play.GetCurrentX(); magicinfo.role_y = play.GetCurrentY(); magicinfo.injuredvalue = 0; magicinfo.monsterid = play.GetTypeId(); magicinfo.tag = 21; magicinfo.magicid = (ushort)info.usType; magicinfo.magiclv = magiclv; byte[] msg = magicinfo.GetBuffer(); play.BroadcastBuffer(msg, true); NetMsg.MsgMagicAttackInfo _info = new NetMsg.MsgMagicAttackInfo(); _info.id = _info.targetid = play.GetTypeId(); _info.magicid = (ushort)info.usType; _info.level = magiclv; _info.dir = dir; msg = _info.GetBuffer(); play.BroadcastBuffer(msg, true); play.GetTimerSystem().AddStatus(GameStruct.RoleStatus.STATUS_WANGNIANWULING); break; } case GameStruct.MagicTypeInfo.MAGICSORT_SHENYUANELING: //深渊恶灵 case GameStruct.MagicTypeInfo.MAGICSORT_DIYUXIEFU: //地狱邪蝠 case GameStruct.MagicTypeInfo.MAGICSORT_SHIHUNWULING://蚀魂巫灵 { targetobj = play.GetGameMap().FindObjectForID(info.idTarget); if (targetobj == null) { return; } uint monster_id = Define.SHENYUANELING_MONSTER_ID; if (typeinfo.sort == GameStruct.MagicTypeInfo.MAGICSORT_DIYUXIEFU) { monster_id = Define.DIYUXIEFU_MONSTER_ID; } else if (typeinfo.sort == GameStruct.MagicTypeInfo.MAGICSORT_SHIHUNWULING) { monster_id = Define.SHIHUNWULING_MONSTER_ID; } GameStruct.MonsterInfo monster_info = ConfigManager.Instance().GetMonsterInfo(monster_id); if(monster_info == null) { Log.Instance().WriteLog("获取深渊恶灵怪物ID失败"); break; } byte dir = DIR.GetDirByPos(play.GetCurrentX(), play.GetCurrentY(), (short)info.usPosX, (short)info.usPosY); play.SetDir(dir); NetMsg.MsgMonsterMagicInjuredInfo magicinfo = new NetMsg.MsgMonsterMagicInjuredInfo(); magicinfo.roleid = play.GetTypeId(); magicinfo.role_x = play.GetCurrentX(); magicinfo.role_y = play.GetCurrentY(); magicinfo.injuredvalue = 0; magicinfo.monsterid = play.GetTypeId(); magicinfo.tag = 21; magicinfo.magicid = (ushort)info.usType; magicinfo.magiclv = magiclv; byte[] msg = magicinfo.GetBuffer(); play.BroadcastBuffer(msg, true); NetMsg.MsgMagicAttackInfo _info = new NetMsg.MsgMagicAttackInfo(); _info.id = _info.targetid = play.GetTypeId(); _info.magicid = (ushort)info.usType; _info.level = magiclv; _info.dir = dir; msg = _info.GetBuffer(); play.BroadcastBuffer(msg, true); //play.GetTimerSystem().AddStatus(GameStruct.RoleStatus.STATUS_SHENYUANELING); int nNewX = targetobj.GetCurrentX() - DIR._DELTA_X[play.GetDir()]; int nNewY = targetobj.GetCurrentY() - DIR._DELTA_Y[play.GetDir()]; MonsterObject Object_CALL = null; if (typeinfo.sort == GameStruct.MagicTypeInfo.MAGICSORT_DIYUXIEFU) { Object_CALL = new DiYuXieFu(play, targetobj, (short)nNewX, (short)nNewY, play.GetDir(), monster_info.id, monster_info.ai); } else if (typeinfo.sort == GameStruct.MagicTypeInfo.MAGICSORT_SHIHUNWULING) { Object_CALL = new ShiHunWuLing(play, targetobj, (short)nNewX, (short)nNewY, play.GetDir(), monster_info.id, monster_info.ai); } else if (typeinfo.sort == GameStruct.MagicTypeInfo.MAGICSORT_SHENYUANELING) { Object_CALL= new ShenYuanELing(play, targetobj, (short)nNewX, (short)nNewY, play.GetDir(), monster_info.id, monster_info.ai); } play.GetGameMap().AddObject(Object_CALL, null); // Object_CALL.RefreshVisibleObject(); Object_CALL.Alive(false); break; } case GameStruct.MagicTypeInfo.MAGICSORT_DRAGON_MOLONGSHOUHU: //暗黑龙骑魔龙守护 { byte dir = DIR.GetDirByPos(play.GetCurrentX(), play.GetCurrentY(), (short)info.usPosX, (short)info.usPosY); play.SetDir(dir); NetMsg.MsgMonsterMagicInjuredInfo magicinfo = new NetMsg.MsgMonsterMagicInjuredInfo(); magicinfo.roleid = play.GetTypeId(); magicinfo.role_x = play.GetCurrentX(); magicinfo.role_y = play.GetCurrentY(); magicinfo.injuredvalue = 0; magicinfo.monsterid = play.GetTypeId(); magicinfo.tag = 21; magicinfo.magicid = (ushort)info.usType; magicinfo.magiclv = magiclv; byte[] msg = magicinfo.GetBuffer(); play.BroadcastBuffer(msg, true); NetMsg.MsgMagicAttackInfo _info = new NetMsg.MsgMagicAttackInfo(); _info.id = _info.targetid = play.GetTypeId(); _info.magicid = (ushort)info.usType; _info.level = magiclv; _info.dir = dir; msg = _info.GetBuffer(); play.BroadcastBuffer(msg, true); play.GetTimerSystem().AddStatus(GameStruct.RoleStatus.STATUS_MOLONGSHOUHU, Define.STATUS_MOLONGSHOUHU_TIME, true); //添加buff图标 break; } case GameStruct.MagicTypeInfo.MAGICSORT_DRAGON_QISHITUANSHOUHU: //骑士团守护 { byte dir = DIR.GetDirByPos(play.GetCurrentX(), play.GetCurrentY(), (short)info.usPosX, (short)info.usPosY); play.SetDir(dir); NetMsg.MsgMonsterMagicInjuredInfo magicinfo = new NetMsg.MsgMonsterMagicInjuredInfo(); magicinfo.roleid = play.GetTypeId(); magicinfo.role_x = play.GetCurrentX(); magicinfo.role_y = play.GetCurrentY(); magicinfo.injuredvalue = 0; magicinfo.monsterid = play.GetTypeId(); magicinfo.tag = 21; magicinfo.magicid = (ushort)info.usType; magicinfo.magiclv = magiclv; byte[] msg = magicinfo.GetBuffer(); play.BroadcastBuffer(msg, true); NetMsg.MsgMagicAttackInfo _info = new NetMsg.MsgMagicAttackInfo(); _info.id = _info.targetid = play.GetTypeId(); _info.magicid = (ushort)info.usType; _info.level = magiclv; _info.dir = dir; msg = _info.GetBuffer(); play.BroadcastBuffer(msg, true); //创建四个守护骑士 GuardKnightObject obj = null; GameStruct.MonsterInfo monster = ConfigManager.Instance().GetMonsterInfo(Define.GUARDKNIGHTID); if (monster == null) { Log.Instance().WriteLog("创建守护骑士失败!!,无此怪物id!"); break; } if (mListQiShiTuanGuard == null) {mListQiShiTuanGuard = new List<BaseObject>();} // else // { RemoveQiShiTuanGuardEffect(); // } short[] _x = { -5, -5, +5, +5 }; short[] _y = { +5, -5, -5, +5 }; byte[] _dir = { DIR.LEFT_DOWN, DIR.LEFT_UP, DIR.RIGHT_UP, DIR.RIGHT_DOWN }; for (int i = 0; i < _x.Length; i++) { short x = (short)(play.GetCurrentX() + _x[i]); short y = (short)(play.GetCurrentY() + _y[i]); obj = new GuardKnightObject(play, x, y, _dir[i], monster.id, monster.ai); play.GetGameMap().AddObject(obj,null); obj.RefreshVisibleObject(); obj.SendInfo(play); mListQiShiTuanGuard.Add(obj); play.AddVisibleObject(obj, true); } //地面特效- EffectObject _effobj = new EffectObject(play, Define.GUARDKNIGHT_EFFID, 10, 15, Define.GUARDKNIGHT_TIME, play.GetCurrentX(), play.GetCurrentY()); play.GetGameMap().AddObject(_effobj); _effobj.RefreshVisibleObject(); _effobj.SendInfo(play); mListQiShiTuanGuard.Add(_effobj); play.AddVisibleObject(_effobj, true); break; } case GameStruct.MagicTypeInfo.MAGICSORT_DRAGON_QISHITUANCHONGFENG: //骑士团冲锋 { byte dir = DIR.GetDirByPos(play.GetCurrentX(), play.GetCurrentY(), (short)info.usPosX, (short)info.usPosY); play.SetDir(dir); NetMsg.MsgMonsterMagicInjuredInfo magicinfo = new NetMsg.MsgMonsterMagicInjuredInfo(); magicinfo.roleid = play.GetTypeId(); magicinfo.role_x = play.GetCurrentX(); magicinfo.role_y = play.GetCurrentY(); magicinfo.injuredvalue = 0; magicinfo.monsterid = play.GetTypeId(); magicinfo.tag = 21; magicinfo.magicid = (ushort)info.usType; magicinfo.magiclv = magiclv; byte[] msg = magicinfo.GetBuffer(); play.BroadcastBuffer(msg, true); NetMsg.MsgMagicAttackInfo _info = new NetMsg.MsgMagicAttackInfo(); _info.id = _info.targetid = play.GetTypeId(); _info.magicid = (ushort)info.usType; _info.level = magiclv; _info.dir = dir; msg = _info.GetBuffer(); play.BroadcastBuffer(msg, true); //创建四个冲锋骑士 FightKnightObject obj = null; GameStruct.MonsterInfo monster = ConfigManager.Instance().GetMonsterInfo(Define.FIGHTKNIGHTID); if (monster == null) { Log.Instance().WriteLog("创建黑暗骑士失败!!,无此怪物id!"); break; } //先不管这个技能了---烦 short[] _x = { -5, -5, +5, +5 }; short[] _y = { +5, -5, -5, +5 }; byte[] _dir = { DIR.LEFT_DOWN, DIR.LEFT_UP, DIR.RIGHT_UP, DIR.RIGHT_DOWN }; for (int i = 0; i < Define.FIGHTKNIGHT_AMOUNT; i++) { short x = (short)(play.GetCurrentX() + _x[i]); short y = (short)(play.GetCurrentY()+ _y[i] ); obj = new FightKnightObject(x, y, play.GetDir(), monster.id, Define.FIGHTKNIGHT_TIME); play.GetGameMap().AddObject(obj, null); obj.RefreshVisibleObject(); obj.SendInfo(play); play.AddVisibleObject(obj, true); } break; } case GameStruct.MagicTypeInfo.MAGICSORT_MIXINSHU: //血族 迷心术 { byte dir = DIR.GetDirByPos(play.GetCurrentX(), play.GetCurrentY(), (short)info.usPosX, (short)info.usPosY); play.SetDir(dir); NetMsg.MsgMonsterMagicInjuredInfo magicinfo = new NetMsg.MsgMonsterMagicInjuredInfo(); magicinfo.roleid = play.GetTypeId(); magicinfo.role_x = play.GetCurrentX(); magicinfo.role_y = play.GetCurrentY(); magicinfo.injuredvalue = 0; magicinfo.monsterid = play.GetTypeId(); magicinfo.tag = 21; magicinfo.magicid = (ushort)info.usType; magicinfo.magiclv = magiclv; byte[] msg = magicinfo.GetBuffer(); play.BroadcastBuffer(msg, true); NetMsg.MsgMagicAttackInfo _info = new NetMsg.MsgMagicAttackInfo(); _info.id = _info.targetid = play.GetTypeId(); _info.magicid = (ushort)info.usType; _info.level = magiclv; _info.dir = dir; msg = _info.GetBuffer(); play.BroadcastBuffer(msg, true); play.GetTimerSystem().AddStatus(GameStruct.RoleStatus.STATUS_MIXINSHU,Define.MIXINSHU_TIME); break; } case GameStruct.MagicTypeInfo.MAGICSORT_SINGLE_DANCING: //单人舞 case GameStruct.MagicTypeInfo.MAGICSORT_DOUBLE_DANCING: //双人舞 { NetMsg.MsgMonsterMagicInjuredInfo magicinfo = new NetMsg.MsgMonsterMagicInjuredInfo(); magicinfo.roleid = play.GetTypeId(); magicinfo.role_x = play.GetCurrentX(); magicinfo.role_y = play.GetCurrentY(); magicinfo.injuredvalue = 0; magicinfo.monsterid = play.GetTypeId(); magicinfo.tag = 21; magicinfo.magicid = (ushort)info.usType; magicinfo.magiclv = magiclv; byte[] msg = magicinfo.GetBuffer(); play.BroadcastBuffer(msg, true); NetMsg.MsgMagicAttackInfo _info = new NetMsg.MsgMagicAttackInfo(); _info.id = _info.targetid = play.GetTypeId(); _info.magicid = (ushort)info.usType; _info.level = magiclv; _info.dir = play.GetDir(); msg = _info.GetBuffer(); play.BroadcastBuffer(msg, true); play.SetDancing((short)info.usType); break; } //{ // break; //} //{ // break; //} } // lastattacktime = System.Environment.TickCount; }
public List<BaseObject> RefreshMagicVisibleObject(uint magicid,NetMsg.MsgAttackInfo magicinfo) { MagicTypeInfo info = ConfigManager.Instance().GetMagicTypeInfo(magicid); List<BaseObject> list = new List<BaseObject>(); list.Clear(); if (info == null) return list; short x = 0; short y = 0; x = play.GetCurrentX(); y = play.GetCurrentY(); switch (info.sort) { case GameStruct.MagicTypeInfo.MAGICSORT_BOMB: //矩形范围攻击,以自身为原点- case GameStruct.MagicTypeInfo.MAGICSORT_JUMPBOMB: //跳斩- { list = this.GetBombVisibleObj(magicinfo); break; } case GameStruct.MagicTypeInfo.MAGICSORT_FAN: //扇形攻击 { list = this.GetFanVisibleObj(magicinfo); break; } case GameStruct.MagicTypeInfo.MAGICSORT_LINE: //直线型攻击 { list = this.GetLineVisibleObj(magicinfo); break; } case GameStruct.MagicTypeInfo.MAGICSORT_POINTBOMB: //鼠标指向范围攻击 { list = this.GetPointBombVisibleObj(magicinfo); break; } } return list; }
public void Move(NetMsg.MsgMoveInfo moveinfo) { EudemonObject obj = GetBattleEudemon(moveinfo.id); if (obj == null) return; obj.Move(moveinfo); }
//请求加为好友 public void RequestAddFriend(NetMsg.MsgFriendInfo info) { PlayerObject target = UserEngine.Instance().FindPlayerObjectToTypeID(info.playerid); if (target == null) { play.LeftNotice("对方已离线,无法添加好友!"); return; } if (mList.Count >= MAX_FRIEND_COUNT) { play.LeftNotice("阁下好友人数已满,无法再次添加!"); return; } for (int i = 0; i < mList.Count; i++) { if (mList[i].friendid == target.GetBaseAttr().player_id) { play.ChatNotice(string.Format("{0}已经是你的好友了!", mList[i].friendname)); return; } } //发给被请求玩家 NetMsg.MsgFriendInfo data = new NetMsg.MsgFriendInfo(); data.Create(null, target.GetGamePackKeyEx()); data.playerid = (uint)play.GetBaseAttr().player_id; data.fightpower = (uint)play.GetFightSoul(); data.type = NetMsg.MsgFriendInfo.TYPE_ADDFRIEND; data.Online = 1; data.level = play.GetBaseAttr().level; data.name = play.GetName(); target.SendData(data.GetBuffer()); // target.GetFriendSystem().SetFriendTarget(play.GetTypeId()) ; play.LeftNotice("已经发送结为好友的请求"); target.LeftNotice(string.Format("血与火的洗礼证明了坚固的友谊,{0}对你报以信任的眼神,你是否接受?", play.GetName())); }
//取直线型内的对象- private List<BaseObject> GetLineVisibleObj(NetMsg.MsgAttackInfo magicinfo) { List<BaseObject> list_obj = new List<BaseObject>(); GameStruct.MagicTypeInfo typeinfo = ConfigManager.Instance().GetMagicTypeInfo(magicinfo.usType); if (typeinfo == null) return list_obj; int nRange = (int)typeinfo.range; play.RefreshVisibleObject(); GameStruct.Point point = play.GetPoint(); // List<GameStruct.Point> setpoint = DDALine(point.x, point.y, (short)magicinfo.usPosX, (short)magicinfo.usPosY, nRange); // if (setpoint == null || setpoint.Count == 0) return list_obj; byte magicDir = DIR.GetDirByPos(play.GetCurrentX(),play.GetCurrentY(),(short)magicinfo.usPosX,(short)magicinfo.usPosY); foreach (RefreshObject refobj in play.GetVisibleList().Values) { BaseObject obj = refobj.obj; if (!IsAddMagicVisibleObj(obj)) { continue; } if (!play.GetPoint().CheckVisualDistance(obj.GetCurrentX(), obj.GetCurrentY(), nRange)) continue; byte targetDir = DIR.GetDirByPos(play.GetCurrentX(), play.GetCurrentY(), obj.GetCurrentX(), obj.GetCurrentY()); if (targetDir == magicDir) { list_obj.Add(obj); } //for (int i = 0; i < setpoint.Count; i++) //{ // if(setpoint[i].x == obj.GetCurrentX() && // setpoint[i].y == obj.GetCurrentY()) // { // list_obj.Add(obj); // } //} } return list_obj; }
public virtual void Injured(BaseObject obj, uint value, NetMsg.MsgAttackInfo info) { }
//被动技能 public bool PassiveMagic(NetMsg.MsgAttackInfo info) { if (mAutoTarget == null) return false; if (IRandom.Random(1, 100) > 50) { return false; } byte bJob = play.GetJob(); switch (bJob) { case JOB.WARRIOR: //战士被动技能 { //风斩、旋风斩、四连斩、六连斩 uint[] magic_id = { 1000, 1002, 1005, 1009 }; List<GameStruct.RoleMagicInfo> list_magic = null; GameStruct.MagicTypeInfo baseMagicInfo = null; Dictionary<uint, GameStruct.RoleMagicInfo> DicInfo = play.GetMagicSystem().GetDicMagic(); foreach (GameStruct.RoleMagicInfo _Info in DicInfo.Values) { for(int i = 0;i < magic_id.Length;i++) { if(_Info.magicid == magic_id[i]) { if (list_magic == null) list_magic = new List<GameStruct.RoleMagicInfo>(); list_magic.Add(_Info); break; } } } if (list_magic == null) return false; int nIndex = IRandom.Random(0, list_magic.Count); baseMagicInfo = ConfigManager.Instance().GetMagicTypeInfo(list_magic[nIndex].magicid, list_magic[nIndex].level); if (IRandom.Random(1, 100) < baseMagicInfo.percent) { info.usType = baseMagicInfo.typeid; info.idTarget = mAutoTarget.GetTypeId(); MagicAttack(info); return true; } break; } } return false; }
//连击技能 private void ComboMagic(NetMsg.MsgAttackInfo info, BaseObject target) { byte[] msg = null; ushort magiclv = play.GetMagicSystem().GetMagicLevel(info.skillid); GameStruct.MagicTypeInfo baseinfo = ConfigManager.Instance().GetMagicTypeInfo(info.usType); //施法动作 NetMsg.MsgMonsterMagicInjuredInfo magicinfo = new NetMsg.MsgMonsterMagicInjuredInfo(); magicinfo.roleid = play.GetTypeId(); magicinfo.role_x = play.GetCurrentX(); magicinfo.role_y = play.GetCurrentY(); magicinfo.injuredvalue = 0; magicinfo.monsterid = play.GetTypeId(); magicinfo.tag = 21; magicinfo.magicid = (ushort)info.usType; magicinfo.magiclv = magiclv; msg = magicinfo.GetBuffer(); play.BroadcastBuffer(msg); //play.GetGameMap().BroadcastBuffer(play, msg); int _locktime = ConfigManager.Instance().GetTrackTime(baseinfo.track_id); int _target_locktime = ConfigManager.Instance().GetTrackTime(baseinfo.track_id2); int trackcount = ConfigManager.Instance().GetTrackNumber(baseinfo.track_id); //锁定自己与目标 play.Lock(_locktime); target.Lock(_target_locktime, target.type == OBJECTTYPE.PLAYER); //计算伤害值 NetMsg.MsgMagicAttackInfo magicattack ; for (int i = 0; i < trackcount; i++) { ////如果是影轮回,就有几率穿透伤害 //magicattack = new NetMsg.MsgMagicAttackInfo(); //magicattack.id = play.GetTypeId(); //magicattack.value = 0; //magicattack.magicid = (ushort)GameStruct.MagicTypeInfo.ZHENSHIDAJI; //magicattack.level = magiclv; //magicattack.targetid = target.GetTypeId(); //msg = magicattack.GetBuffer(); //play.BroadcastBuffer(msg, true); // target.Injured(play, injured, info); //优先攻击合体的幻兽 uint target_id = target.GetTypeId(); if (target.type == OBJECTTYPE.PLAYER) { EudemonObject eudemon_obj = (target as PlayerObject).GetEudemonSystem().GetInjuredEudemon(); if (eudemon_obj != null) { target_id = eudemon_obj.GetTypeId(); } } magicattack = new NetMsg.MsgMagicAttackInfo(); magicattack.id = play.GetTypeId(); uint injured = BattleSystem.AdjustDamage(play, target); magicattack.value = injured; magicattack.magicid = (ushort)info.usType; magicattack.level = magiclv; magicattack.targetid = target_id; msg = magicattack.GetBuffer(); play.BroadcastBuffer(msg, true); target.Injured(play, injured, info); } if (baseinfo.track_id > 0) { //取得攻击方向 byte attackdir = GameStruct.DIR.GetDirByPos(play.GetCurrentX(), play.GetCurrentY(), target.GetCurrentX(), target.GetCurrentY()); play.SetDir(attackdir); target.SetDir(attackdir); NetMsg.MsgCombo combo = new NetMsg.MsgCombo(); combo.CalcTag(info.usType, play, target); short x = 0; short y = 0; GameStruct.TrackInfo trackinfo = ConfigManager.Instance().GetTrackInfo(baseinfo.track_id); GameStruct.TrackInfo track2 = ConfigManager.Instance().GetTrackInfo(baseinfo.track_id2); for (int i = 0; i < trackcount; i++) { //怪物 if (track2.step > 0) { if (GameStruct.DIR.GetNexPoint(target, ref x, ref y)) { target.SetPoint(x, y); } } //角色 if (trackinfo.step > 0) { for (int j = 0; j < trackinfo.step;j++ ) { if (GameStruct.DIR.GetNexPoint(play, ref x, ref y)) { play.SetPoint(x, y); } } } combo.AddComboInfo(info.usType, play, target, trackinfo.action, track2.action); trackinfo = ConfigManager.Instance().GetTrackInfo(trackinfo.id_next); if (track2.id_next != 0) { track2 = ConfigManager.Instance().GetTrackInfo(track2.id_next); } } msg = combo.GetBuffer(); play.BroadcastBuffer(msg, true); } }
public bool Move(NetMsg.MsgMoveInfo move) { byte dir = (byte)((int)move.dir % 8); this.SetDir(dir); short nNewX = this.GetCurrentX(); short nNewY = this.GetCurrentY(); //作弊判断,与宿主距离不得超过格子范围 否则传送回身边 if (Math.Abs(play.GetCurrentX() - this.GetCurrentX()) > GameBase.Config.Define.MAX_EUDEMON_PLAY_DISTANCE || Math.Abs(play.GetCurrentY() - this.GetCurrentY()) > GameBase.Config.Define.MAX_EUDEMON_PLAY_DISTANCE) { nNewX = (short)(play.GetCurrentX()); nNewY = (short)(play.GetCurrentY()); this.SetPoint(nNewX, nNewY); this.SendEudemonInfo(); return false; } nNewX += DIR._DELTA_X[dir]; nNewY += DIR._DELTA_Y[dir]; if (!mGameMap.CanMove(nNewX, nNewY)) { // Log.Instance().WriteLog("非法封包..禁止走路!!x:" + nNewX.ToString() + "y:" + nNewY.ToString()); return false; } //// 跑步模式的阻挡判断 bool IsRun = false; if (move.ucMode >= DIR.MOVEMODE_RUN_DIR0 && move.ucMode <= DIR.MOVEMODE_RUN_DIR7 ) { nNewX += DIR._DELTA_X[move.ucMode - DIR.MOVEMODE_RUN_DIR0]; nNewY += DIR._DELTA_Y[move.ucMode - DIR.MOVEMODE_RUN_DIR0]; IsRun = true; //if (!mGameMap.CanMove(nNewX, nNewY)) //{ // return false; //} } GameStruct.Action action = new GameStruct.Action(GameStruct.Action.MOVE); if (IsRun) action.AddObject(move.ucMode); this.SetPoint(nNewX, nNewY); PushAction(action); return true; }
public void LoadDataFile(string FileName) { try { //首先检查用户数据目录里是否有该文件// //string file_name = CUtility.GetFullFilePath(FileName); string file_name = TempLoad.GetResFullPath(FileName); int item_size = 0; buffer = File.ReadAllBytes(file_name); int data_start = 0; if (buffer.Length > 38 && buffer[0] == 'M' && buffer[1] == 'p' && buffer[2] == 'd' && buffer[3] == '\n') { //取md5码 int index = 4; while (buffer[index] != '\n' && index < 38) //MD5一般32位 { index++; } string md5 = System.Text.Encoding.Default.GetString(buffer, 4, index - 4); if (md5 != GetProtoMd5()) { Debug.LogError(string.Format("Load file({0}) failed, data md5 {1} != {2} (code md5), protobuf struct dismatch.", FileName, md5, GetProtoMd5())); } //取svn版本号 data_start = index + 1; while (buffer.Length > data_start && buffer[data_start] != '\n' && data_start < 50) { data_start++; } //Log.Debug("svn ver:{0}", System.Text.Encoding.Default.GetString(buffer, index+1, data_start - index - 1)); data_start++;//跳过 \n 后面才是数据正文 byte[] tbuf = buffer; buffer = new byte[tbuf.Length - data_start]; Buffer.BlockCopy(tbuf, data_start, buffer, 0, tbuf.Length - data_start); } NetMsg message = new NetMsg(0, buffer); TDataArray datas = message.GetBody <TDataArray>(); List <TData> dataList = GetDataList(datas); int count = dataList.Count; data = new Dictionary <uint, TData>(count); for (int i = 0; i < count; ++i) { try { data.Add(GetKey(dataList[i]), dataList[i]); } catch (System.Exception e) { Debug.LogError(string.Format("Load file({0}) data add key{1} failed, error({2})", FileName, GetKey(dataList[i]), e.ToString())); } } buffer = null; } catch (System.Exception e) { Debug.LogError(string.Format("Load file({0}) failed, error({1})", FileName, e.ToString())); } }
//获取扇形范围内的对象 private List<BaseObject> GetFanVisibleObj(NetMsg.MsgAttackInfo magicinfo) { List<BaseObject> list_obj = new List<BaseObject>(); GameStruct.MagicTypeInfo typeinfo = ConfigManager.Instance().GetMagicTypeInfo(magicinfo.usType); if (typeinfo == null) return list_obj; //play.RefreshVisibleObject(); int nRange = (int)typeinfo.range + Define.MAX_SIZEADD; int nSize = nRange*2 + 1; int nWidth = (int)typeinfo.width; foreach (RefreshObject refobj in play.GetVisibleList().Values) { BaseObject obj = refobj.obj; if (!IsAddMagicVisibleObj(obj)) { continue; } GameStruct.Point pos =play.GetPoint(); GameStruct.Point magicpos = new GameStruct.Point(); magicpos.x = (short)magicinfo.usPosX; magicpos.y = (short)magicinfo.usPosY; //原版代码翻译过来..不好使-- 就用了蹩脚的方法2015.10.26 // GameStruct.Point posThis = new GameStruct.Point(); //bool bFind = true; //for (int i = CutTrail(pos.x - nRange, 0); i <= pos.x + nRange && i < play.GetGameMap().mnWidth; i++) //{ // for (int j = CutTrail(pos.y - nRange, 0); j <= pos.y + nRange && j < play.GetGameMap().mnHeight; j++) // { // posThis.x = (short)i; // posThis.y = (short)j; // if (play.GetPoint().CheckFanDistance(posThis, pos, nRange, nWidth, magicpos)) // { // int idx = POS2INDEX(posThis.x - pos.x + nRange, posThis.y - pos.y + nRange, nSize, nSize); // int objIdx = POS2INDEX(obj.GetCurrentX() - pos.x + nRange, obj.GetCurrentY() - pos.y + nRange, nSize, nSize); // if (idx == objIdx) // { // list_obj.Add(obj); // bFind = true; // break; // } // //inline int POS2INDEX(int x, int y, int cx, int cy) { return (x + y*cx); } // } // if (bFind) // { // break; // } // } //} //bFind = false; // posThis.x = (short)CutTrail(pos.x - nRange, 0); // posThis.y = (short)CutTrail(pos.y - nRange, 0); //if (play.GetPoint().CheckFanDistance(posThis, pos, nRange, nWidth, magicpos)) if(play.GetPoint().CheckFanDistance(obj.GetPoint(),magicpos,nRange)) { list_obj.Add(obj); } } return list_obj; }