void OnItemDropped(DropMsg item) { DropMng.Ins.DropItem((int)item.item, new Vector3(item.position.x / 1000.0f, item.position.y / 1000.0f, item.position.z / 1000.0f), new Vector3(item.forward.x / 1000.0f, item.forward.y / 1000.0f, item.forward.z / 1000.0f)); }
//使用作弊码 public static bool UseCheatCode(string cheatcode) { bool ret = false; int param1 = -1; int param2 = -1; string stringparam = ""; Vector3 pos = Vector3.zero; if (CheatOK(cheatcode, "check")) { U3D.ShowTargetBlood(); return(true); } else if (CheatOK(cheatcode, "skill")) { if (U3D.IsMultiplyPlayer()) { return(false); } if (FightState.Exist()) { FightState.Instance.ShowSkillBar(); } return(true); } else if (CheatParam2(cheatcode, "follow", ref param1, ref param2)) { MeteorUnit unit = U3D.GetUnit(param1 - 1); if (unit != null && unit.StateMachine != null) { MeteorUnit target = U3D.GetUnit(param2 - 1); U3D.InsertSystemMsg(string.Format("{0}开始跟随{1}", unit.name, target.name)); unit.FollowTarget = target; } return(true); } else if (CheatParam2(cheatcode, "chase", ref param1, ref param2)) { MeteorUnit unit = U3D.GetUnit(param1 - 1); if (unit != null) { MeteorUnit target = U3D.GetUnit(param2 - 1); if (target != null && !target.SameCamp(unit)) { U3D.InsertSystemMsg(string.Format("{0}开始追杀{1}", unit.name, target.name)); unit.Kill(target); } } return(true); } else if (CheatParam(cheatcode, "wait", ref param1)) { MeteorUnit unit = U3D.GetUnit(param1 - 1); if (unit != null && unit.StateMachine != null) { U3D.InsertSystemMsg(string.Format("{0}空闲下来了", unit.name)); unit.StateMachine.ChangeState(unit.StateMachine.WaitState); } return(true); } else if (CheatOK(cheatcode, "god")) { U3D.GodLike(); ret = true; } else if (CheatOK(cheatcode, "box")) { U3D.Box(); ret = true; } else if (CheatParam(cheatcode, "kill", ref param1)) { if (U3D.IsMultiplyPlayer()) { if (FrameReplay.Ins.Started) { MeteorUnit unit = U3D.GetUnit(param1 - 1); if (unit == null) { return(false); } OperateMsg msg = new OperateMsg(); msg.Operate = (int)OperateType.Kill; msg.KillTarget = (uint)unit.InstanceId; FrameSyncServer.Ins.NetEvent(MeteorMsg.Command.Kill, msg); } } else { U3D.Kill(param1 - 1); MeteorUnit u = U3D.GetUnit(param1 - 1); if (u != null) { U3D.InsertSystemMsg(string.Format("{0}遭遇击杀", u.name)); } } ret = true; } else if (CheatParam(cheatcode, "pose", ref param1)) { if (U3D.IsMultiplyPlayer()) { return(false); } if (Main.Ins.LocalPlayer != null && Main.Ins.LocalPlayer.ActionMgr != null) { Main.Ins.LocalPlayer.ActionMgr.ChangeAction(param1, 0.1f); } ret = true; } else if (CheatParam(cheatcode, "pause", ref param1)) { MeteorUnit unit = U3D.GetUnit(param1 - 1); if (unit != null && unit.StateMachine != null) { unit.AIPause(true, float.MaxValue); U3D.InsertSystemMsg(string.Format("{0}无法动弹", unit.name)); } ret = true; } else if (CheatParam(cheatcode, "resume", ref param1)) { MeteorUnit unit = U3D.GetUnit(param1 - 1); if (unit != null && unit.StateMachine != null) { unit.AIPause(false, 0); U3D.InsertSystemMsg(string.Format("{0}恢复了", unit.name)); } ret = true; } else if (CheatParam(cheatcode, "kick", ref param1)) { if (U3D.IsMultiplyPlayer()) { //检查自己是否房间主人,是则向主机发送指令 if (FrameReplay.Ins.Started) { MeteorUnit unit = U3D.GetUnit(param1 - 1); if (unit == null) { return(false); } OperateMsg msg = new OperateMsg(); msg.Operate = (int)OperateType.Kick; msg.KillTarget = (uint)unit.InstanceId; FrameSyncServer.Ins.NetEvent(MeteorMsg.Command.Kick, msg); } } ret = true; } else if (CheatParam(cheatcode, "skick", ref param1)) { if (U3D.IsMultiplyPlayer()) { //检查自己是否房间主人,是则向主机发送指令 if (FrameReplay.Ins.Started) { MeteorUnit unit = U3D.GetUnit(param1 - 1); if (unit == null) { return(false); } OperateMsg msg = new OperateMsg(); msg.Operate = (int)OperateType.Skick; msg.KillTarget = (uint)unit.InstanceId; FrameSyncServer.Ins.NetEvent(MeteorMsg.Command.Skick, msg); } } ret = true; } else if (CheatParamString(cheatcode, "ai", ref stringparam)) { if (U3D.IsMultiplyPlayer()) { return(false); } if (Main.Ins.GameBattleEx != null) { int r = U3D.AddNPC(stringparam); ret = r > 0; } return(true); } else if (CheatOK(cheatcode, "fps")) { bool show = GameStateMgr.Ins.gameStatus.ShowFPS; show = !show; Main.Ins.ShowFps(show); return(true); } else if (CheatOK(cheatcode, "position")) { if (FightState.Exist()) { FightState.Instance.ShowPosition(); } return(true); } else if (CheatOK(cheatcode, "mhp")) { //不支持这个指令了. //if (FightState.Exist()) { // FightState.Instance.ShowPlayerInfo(); //} return(true); } else if (CheatOK(cheatcode, "mnet") || CheatOK("cheatcode", "serverinfo")) { //显示网络数据传送情况 return(true); } else if (CheatOK(cheatcode, "quit")) { if (U3D.IsMultiplyPlayer()) { return(false); } Application.Quit(); return(true); } else if (CheatParamVector3(cheatcode, "moveto", ref pos)) { if (Main.Ins.LocalPlayer != null && !Main.Ins.LocalPlayer.Dead) { Main.Ins.LocalPlayer.SetPosition(pos); } return(true); } else if (CheatParam(cheatcode, "ang", ref param1)) { if (U3D.IsMultiplyPlayer()) { return(false); } MeteorUnit target = U3D.GetUnit(param1 - 1); if (target != null) { target.angryMax = !target.angryMax; U3D.InsertSystemMsg(string.Format("{0}真气{1}", target.name, target.angryMax ? "满":"空")); } return(true); } else if (CheatParam(cheatcode, "weapon", ref param1)) { if (Main.Ins.LocalPlayer != null) { InventoryItem w = GameStateMgr.Ins.MakeEquip(param1); if (w == null) { U3D.InsertSystemMsg("找不到编号为:" + param1 + "的武器"); return(true); } Main.Ins.LocalPlayer.ChangeWeaponCode(param1); } return(true); } else if (CheatParam(cheatcode, "use", ref param1)) { if (U3D.IsMultiplyPlayer()) { return(false); } if (Main.Ins.LocalPlayer != null) { Option it = MenuResLoader.Ins.GetItemInfo(param1); if (it == null) { U3D.InsertSystemMsg("找不到编号为:" + param1 + "的物品"); return(true); } Main.Ins.LocalPlayer.GetItem(param1); } return(true); } else if (CheatParam(cheatcode, "drop", ref param1)) { if (U3D.IsMultiplyPlayer()) { if (Main.Ins.LocalPlayer != null) { MeteorUnit player = Main.Ins.LocalPlayer; DropMsg msg = new DropMsg(); msg.forward = new _Vector3(); msg.forward.x = Mathf.FloorToInt(player.transform.forward.x * 1000); msg.forward.y = Mathf.FloorToInt(player.transform.forward.y * 1000); msg.forward.z = Mathf.FloorToInt(player.transform.forward.z * 1000); msg.position = new _Vector3(); msg.position.x = Mathf.FloorToInt(player.transform.position.x * 1000); msg.position.y = Mathf.FloorToInt(player.transform.position.y * 1000); msg.position.z = Mathf.FloorToInt(player.transform.position.z * 1000); msg.item = (uint)param1; FrameSyncServer.Ins.NetEvent(MeteorMsg.Command.Drop, msg); } return(true); } if (Main.Ins.LocalPlayer != null) { Option it = MenuResLoader.Ins.GetItemInfo(param1); if (it == null) { U3D.InsertSystemMsg("找不到编号为:" + param1 + "的物品"); return(true); } DropMng.Ins.DropItem(Main.Ins.LocalPlayer, it); } return(true); } else if (CheatOK(cheatcode, "win")) { if (U3D.IsMultiplyPlayer()) { return(false); } if (Main.Ins.GameBattleEx != null) { Main.Ins.GameBattleEx.GameOver(1); } return(true); } else if (CheatOK(cheatcode, "lose")) { if (U3D.IsMultiplyPlayer()) { return(false); } if (Main.Ins.GameBattleEx != null) { Main.Ins.GameBattleEx.GameOver(-1); } } return(ret); }
public override void Update() { for (int i = 0; i < packets.Count; i++) { SortedDictionary <int, byte[]> pack = packets[i]; lock (pack) { try { //在这个循环里,不能跑去修改这个packet,所有重要消息,都通过计时器处理. foreach (var each in pack) { ms.SetLength(0); ms.Write(each.Value, 0, each.Value.Length); ms.Seek(0, SeekOrigin.Begin); switch (each.Key) { //UDP消息 case (int)MeteorMsg.Command.ServerSync: GameFrame frame = Serializer.Deserialize <GameFrame>(ms); OnSyncPlayers(frame); break; case (int)MeteorMsg.Command.NewTurn: if (!FrameReplay.Ins.Started) { return; } if (Main.Ins.GameBattleEx != null) { Main.Ins.GameBattleEx.NetGameOver(); } break; case (int)MeteorMsg.Command.GetItem: //ms = new MemoryStream(each.Value); GetItemMsg getitem = Serializer.Deserialize <GetItemMsg>(ms); OnItemPickuped(getitem); break; case (int)MeteorMsg.Command.Drop: //ms = new MemoryStream(each.Value); DropMsg dropItem = Serializer.Deserialize <DropMsg>(ms); OnItemDropped(dropItem); break; case (int)MeteorMsg.Command.Kill: //ms = new MemoryStream(each.Value); OperateMsg kill = Serializer.Deserialize <OperateMsg>(ms); Kill(kill); break; case (int)MeteorMsg.Command.Kick: //ms = new MemoryStream(each.Value); OperateMsg kick = Serializer.Deserialize <OperateMsg>(ms); OnKicked(kick); break; case (int)MeteorMsg.Command.Skick: //ms = new MemoryStream(each.Value); OperateMsg skick = Serializer.Deserialize <OperateMsg>(ms); OnSkicked(skick); break; } } } catch (Exception exp) { UnityEngine.Debug.LogError(exp.Message + exp.StackTrace); } finally { pack.Clear(); } } } //lock (messageQueue) { // int length = messageQueue.Count; // for (int i = 0; i < length; i++) { // switch (messageQueue[i].Message) { // case (short)LocalMsgType.Connect: OnConnect(messageQueue[i].Result, messageQueue[i].message); break; // } // } // messageQueue.Clear(); //} }