public static string ProcessPlayerCommands(DebugCommand message, Contexts contexts, PlayerEntity player, ICommonSessionObjects sessionObjects, ICurrentTime currentTime) { var result = ""; switch (message.Command) { case DebugCommands.ClientMove: var pos = new Vector3(0, 1000, 0).ShiftedPosition(); var yaw = 0f; switch (message.Args.Length) { case 2: break; case 3: break; case 4: break; } if (message.Args.Length > 0) { float x; if (float.TryParse(message.Args[0], out x)) { pos.x = x; } } if (message.Args.Length == 2) { pos.y = 10000; float z; if (float.TryParse(message.Args[1], out z)) { pos.z = z; } } if (message.Args.Length == 3) { float y; if (float.TryParse(message.Args[1], out y)) { pos.y = y; } float z; if (float.TryParse(message.Args[2], out z)) { pos.z = z; } } pos = pos.ShiftedPosition(); var ray = new Ray(pos, Vector3.down); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { player.position.Value = hit.point; result = "ok"; } else { player.position.Value = pos; result = "没有检测到碰撞,资源未加载完成或此位置没有碰撞,请指定y值"; } break; case DebugCommands.KillMe: player.gamePlay.CurHp = 0; player.gamePlay.ChangeLifeState(EPlayerLifeState.Dead, currentTime.CurrentTime); break; case DebugCommands.DyingMe: player.gamePlay.ChangeLifeState(EPlayerLifeState.Dying, currentTime.CurrentTime); break; case DebugCommands.ShowAniInfo: result = string.Format("{0}\n{1}", player.state, player.thirdPersonAnimator.DebugJumpInfo()); break; case DebugCommands.Speed: if (message.Args.Length < 1) { return("Argument Error!"); } float i; if (!float.TryParse(message.Args[0], out i)) { return("Argument Error! speed should be float"); } if (player != null && player.hasPlayerMove) { result = string.Format("change player:{0} speedAffect from:{1}, to:{2}", player.entityKey.Value.ToString(), player.playerMove.SpeedAffect, i); player.playerMove.SpeedAffect = i; if (message.Args.Length >= 2) { float j; if (!float.TryParse(message.Args[0], out j)) { return("Argument Error! jump should be float"); } player.playerMove.JumpAffect = j; } return(result); } break; case DebugCommands.TestMap: result = BigMapDebug.HandleCommand(player, message.Args); break; case DebugCommands.ChangeBag: player.WeaponController().SwitchBag(int.Parse(message.Args[0])); // contexts.session.clientSessionObjects.UserCmdGenerator.SetUserCmd((cmd) => cmd.BagIndex = 1); break; case DebugCommands.ChangeHp: player.gamePlay.CurHp = int.Parse(message.Args[0]); break; case DebugCommands.SetCurBullet: player.WeaponController().HeldWeaponAgent.BaseComponent.Bullet = int.Parse(message.Args[0]); break; case DebugCommands.SetReservedBullet: if (message.Args.Length > 1) { int slot = int.Parse(message.Args[0]); int count = int.Parse(message.Args[1]); player.WeaponController().SetReservedBullet((EWeaponSlotType)slot, count); } else { int count = int.Parse(message.Args[0]); player.WeaponController().SetReservedBullet(count); } break; case DebugCommands.SetGrenade: //IGrenadeCacheHelper helper = player.WeaponController().GrenadeHelper; //helper.AddCache(37); //helper.AddCache(37); //helper.AddCache(38); //helper.AddCache(39); player.WeaponController().PickUpWeapon(WeaponUtil.CreateScan(37)); break; case DebugCommands.AudioEmitter: var sceneObjectEntityFactory = contexts.session.entityFactoryObject.SceneObjectEntityFactory; sceneObjectEntityFactory.CreateSceneAudioEmitterEntity(player.position.Value, player.entityKey.Value); break; case DebugCommands.AudioBgm: var sceneObjectEntityFactory2 = contexts.session.entityFactoryObject.SceneObjectEntityFactory; sceneObjectEntityFactory2.CreateSceneAudioBgEmitterEntity(player.position.Value, player.entityKey.Value); break; case DebugCommands.Shoot: if (message.Args.Length > 0) { string s = message.Args[0]; if (s == "clean") { GMVariable.CleanShowShootText = true; } } else { GMVariable.ShowShootText = !GMVariable.ShowShootText; } break; case DebugCommands.SetAudio: if (message.Args.Length > 0) { string arg1 = message.Args[0]; switch (arg1) { case "step": int matType = int.Parse(message.Args[1].Trim()); var isUse = (matType > -1); GMVariable.AudioFoostepMatType = matType; player.AudioController().SetGMFootstep(isUse); break; case "log": int logType = int.Parse(message.Args[1].Trim()); if (logType == 1) { GMVariable.AudioPostEventLog = !GMVariable.AudioPostEventLog; } else if (logType == 2) { GMVariable.AudioListenerLog = !GMVariable.AudioListenerLog; } else if (logType == 3) { GMVariable.AudioFootstepLog = !GMVariable.AudioFootstepLog; } break; } } break; case DebugCommands.SetWeapon: int weaponIdToSet = 0; int avatarId = 0; var weaponSlotToSet = 0; if (message.Args.Length > 0) { weaponIdToSet = int.Parse(message.Args[0].Trim()); } if (message.Args.Length > 2) { avatarId = int.Parse(message.Args[1].Trim()); } if (message.Args.Length > 3) { weaponSlotToSet = int.Parse(message.Args[2].Trim()); } var weaponInfo = WeaponUtil.CreateScan(weaponIdToSet, (val) => val.AvatarId = avatarId > 0 ? avatarId : 0); weaponInfo.Bullet = 100; weaponInfo.ReservedBullet = 100; if (weaponSlotToSet != 0) { player.WeaponController().ReplaceWeaponToSlot((EWeaponSlotType)weaponSlotToSet, weaponInfo); } else { player.WeaponController().PickUpWeapon(weaponInfo); } break; case DebugCommands.DropWeapon: var dropSlot = int.Parse(message.Args[0]); player.WeaponController().DropWeapon((EWeaponSlotType)dropSlot); break; case DebugCommands.TestWeaponAssemble: if (null == _twaRootGo) { _twaRootGo = new GameObject("TwaRoot"); _twaRootGo.transform.parent = Camera.main.transform; _twaRootGo.transform.localPosition = new Vector3(0, 0, 2); _twaRootGo.transform.localEulerAngles = new Vector3(0, 90, 0); } if (null == _weaponModelController) { _weaponModelController = new WeaponModelController( //SingletonManager.Get<WeaponResourceConfigManager>(), //SingletonManager.Get<WeaponPartsConfigManager>(), //SingletonManager.Get<WeaponAvatarConfigManager>(), new WeaponModelLoadController <object>( new WeaponModelLoader(sessionObjects.AssetManager), new WeaponModelAssemblyController(_twaRootGo)) ); } var operate = int.Parse(message.Args[0]); var dataId = int.Parse(message.Args[1]); switch (operate) { case 0: _weaponModelController.SetWeapon(dataId); break; case 1: _weaponModelController.SetPart(dataId); break; case 2: _weaponModelController.RemovePart(dataId); break; } break; case DebugCommands.TestCmd: var targ1 = int.Parse(message.Args[0]); switch (targ1) { case 1: GMVariable.ShowSessionTimer = !GMVariable.ShowSessionTimer; // LocalObjectGenerator.Dispose(true); break; case 2: GMVariable.SpreadOffsetFactor = int.Parse(message.Args[1]); break; } break; case DebugCommands.SetAttachment: var res = Core.Enums.EFuncResult.Failed; var apply = 0; if (message.Args.Length == 2) { var slot = int.Parse(message.Args[0]); apply = int.Parse(message.Args[1]); res = player.WeaponController().SetWeaponPart((EWeaponSlotType)slot, apply) ? Core.Enums.EFuncResult.Success : Core.Enums.EFuncResult.Failed; } else { apply = int.Parse(message.Args[0]); res = player.WeaponController().SetWeaponPart(apply) ? Core.Enums.EFuncResult.Success : Core.Enums.EFuncResult.Failed; } switch (res) { case Core.Enums.EFuncResult.Exception: result = "exception occurs"; break; case Core.Enums.EFuncResult.Failed: result = "attachment doesn't match"; break; case Core.Enums.EFuncResult.Success: result = "attach " + apply + " to weapon"; break; } break; case DebugCommands.SetWeaponAttachment: var resu = Core.Enums.EFuncResult.Failed; var id = 0; if (message.Args.Length == 2) { var slot = int.Parse(message.Args[0]); id = int.Parse(message.Args[1]); resu = player.WeaponController().SetWeaponPartByPartId((EWeaponSlotType)slot, id) ? Core.Enums.EFuncResult.Success : Core.Enums.EFuncResult.Failed; } else { id = int.Parse(message.Args[0]); resu = player.WeaponController().SetWeaponPartByPartId(id) ? Core.Enums.EFuncResult.Success : Core.Enums.EFuncResult.Failed; } switch (resu) { case Core.Enums.EFuncResult.Exception: result = "exception occurs"; break; case Core.Enums.EFuncResult.Failed: result = "attachment doesn't match"; break; case Core.Enums.EFuncResult.Success: result = "attach " + id + " to weapon"; break; } break; case DebugCommands.ClearAttachment: var weaponSlot = (EWeaponSlotType)int.Parse(message.Args[0]); var part = (EWeaponPartType)int.Parse(message.Args[1]); player.WeaponController().DeleteWeaponPart(weaponSlot, part); break; case DebugCommands.SwitchAttachment: break; case DebugCommands.SetEquip: player.appearanceInterface.Appearance.ChangeAvatar(int.Parse(message.Args[0])); break; case DebugCommands.ShowAvaliablePartType: int weaponId = player.WeaponController().HeldWeaponAgent.ConfigId; if (weaponId > 0) { var list = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(weaponId).ApplyParts; for (int j = 0; j < list.Count; j++) { result += list[j] + ","; } } break; case DebugCommands.ReloadConfig: ConfigReloadSystem.Reload = true; break; case DebugCommands.ShowArtTools: GameObject.Instantiate(Resources.Load <GameObject>("RuntimeTestTools")); result = "RuntimeTestTools"; break; case DebugCommands.ShowTerrainTrace: SharedConfig.IsShowTerrainTrace = !SharedConfig.IsShowTerrainTrace; break; case DebugCommands.Revive: player.gamePlay.LifeState = (int)EPlayerLifeState.Alive; player.gamePlay.CurHp = player.gamePlay.MaxHp; player.gamePlay.InHurtedCount = 0; break; } return(result); }
public static string ProcessPlayerCommands(DebugCommand message, PlayerEntity player, ICommonSessionObjects sessionObjects, ICurrentTime currentTime) { var result = ""; WeaponBagLogic bagLogicImp; switch (message.Command) { case DebugCommands.ClientMove: var pos = new Vector3(0, 1000, 0); var yaw = 0f; switch (message.Args.Length) { case 2: break; case 3: break; case 4: break; } if (message.Args.Length > 0) { float x; if (float.TryParse(message.Args[0], out x)) { pos.x = x; } } if (message.Args.Length == 2) { pos.y = 10000; float z; if (float.TryParse(message.Args[1], out z)) { pos.z = z; } } if (message.Args.Length == 3) { float y; if (float.TryParse(message.Args[1], out y)) { pos.y = y; } float z; if (float.TryParse(message.Args[2], out z)) { pos.z = z; } } var ray = new Ray(pos, Vector3.down); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { player.position.Value = hit.point; result = "ok"; } else { player.position.Value = pos; result = "没有检测到碰撞,资源未加载完成或此位置没有碰撞,请指定y值"; } break; case DebugCommands.KillMe: player.gamePlay.CurHp = 0; player.gamePlay.ChangeLifeState(Components.Player.EPlayerLifeState.Dead, currentTime.CurrentTime); break; case DebugCommands.ShowAniInfo: result = string.Format("{0}\n{1}", player.state, player.thirdPersonAnimator.DebugJumpInfo()); break; case DebugCommands.TestMap: result = BigMapDebug.HandleCommand(player, message.Args); break; case DebugCommands.ChangeHp: player.gamePlay.CurHp = int.Parse(message.Args[0]); break; case DebugCommands.SetCurBullet: player.GetBagLogicImp().SetWeaponBullet(int.Parse(message.Args[0])); break; case DebugCommands.SetReservedBullet: if (message.Args.Length > 1) { int slot = int.Parse(message.Args[0]); int count = int.Parse(message.Args[1]); player.GetBagLogicImp().SetReservedBullet((EWeaponSlotType)slot, count); } else { int count = int.Parse(message.Args[0]); player.GetBagLogicImp().SetReservedBullet(player.GetBagLogicImp().GetCurrentWeaponSlot(), count); } break; case DebugCommands.SetWeapon: { int weaponIdToSet = 0; int avatarId = 0; var weaponSlotToSet = 0; if (message.Args.Length > 0) { weaponIdToSet = int.Parse(message.Args[0].Trim()); } if (message.Args.Length > 2) { avatarId = int.Parse(message.Args[1].Trim()); } if (message.Args.Length > 3) { weaponSlotToSet = int.Parse(message.Args[2].Trim()); } var weaponInfo = new WeaponInfo { Id = weaponIdToSet, AvatarId = avatarId > 0 ? avatarId : 0, }; if (weaponSlotToSet != 0) { player.playerAction.Logic.ReplaceWeaponToSlot((EWeaponSlotType)weaponSlotToSet, weaponInfo); } else { player.playerAction.Logic.PickUpWeapon(weaponInfo); } } break; case DebugCommands.DropWeapon: var dropSlot = int.Parse(message.Args[0]); player.playerAction.Logic.DropWeapon((EWeaponSlotType)dropSlot); break; case DebugCommands.TestWeaponAssemble: if (null == _twaRootGo) { _twaRootGo = new GameObject("TwaRoot"); _twaRootGo.transform.parent = Camera.main.transform; _twaRootGo.transform.localPosition = new Vector3(0, 0, 2); _twaRootGo.transform.localEulerAngles = new Vector3(0, 90, 0); } if (null == _weaponModelController) { _weaponModelController = new WeaponModelController( SingletonManager.Get <WeaponConfigManager>(), SingletonManager.Get <WeaponPartsConfigManager>(), SingletonManager.Get <WeaponAvatarConfigManager>(), new WeaponModelLoadController <object>( new WeaponModelLoader(sessionObjects.LoadRequestManager), new WeaponModelAssemblyController(_twaRootGo)) ); } var operate = int.Parse(message.Args[0]); var dataId = int.Parse(message.Args[1]); switch (operate) { case 0: _weaponModelController.SetWeapon(dataId); break; case 1: _weaponModelController.SetPart(dataId); break; case 2: _weaponModelController.RemovePart(dataId); break; } break; case DebugCommands.SetAttachment: var res = Core.Enums.EFuncResult.Failed; var id = 0; if (message.Args.Length == 2) { var slot = int.Parse(message.Args[0]); id = int.Parse(message.Args[1]); res = player.GetBagLogicImp().SetWeaponPart((EWeaponSlotType)slot, id); } else { id = int.Parse(message.Args[0]); res = player.GetBagLogicImp().SetCurrentWeaponPart(id); } switch (res) { case Core.Enums.EFuncResult.Exception: result = "exception occurs"; break; case Core.Enums.EFuncResult.Failed: result = "attachment doesn't match"; break; case Core.Enums.EFuncResult.Success: result = "attach " + id + " to weapon"; break; } break; case DebugCommands.ClearAttachment: var weaponSlot = (EWeaponSlotType)int.Parse(message.Args[0]); var part = (EWeaponPartType)int.Parse(message.Args[1]); player.GetBagLogicImp().DeleteWeaponPart(weaponSlot, part); break; case DebugCommands.SwitchAttachment: break; case DebugCommands.SetEquip: player.appearanceInterface.Appearance.ChangeAvatar(int.Parse(message.Args[0])); break; case DebugCommands.ShowAvaliablePartType: var weapon = player.GetBagLogicImp().GetCurrentWeaponInfo(); if (weapon.Id > 0) { var list = SingletonManager.Get <WeaponPartsConfigManager>().GetAvaliablePartTypes(weapon.Id); for (int i = 0; i < list.Count; i++) { result += list[i] + ","; } } break; case DebugCommands.ReloadConfig: ConfigReloadSystem.Reload = true; break; case DebugCommands.ShowArtTools: GameObject.Instantiate(Resources.Load <GameObject>("RuntimeTestTools")); result = "RuntimeTestTools"; break; case DebugCommands.ShowTerrainTrace: SharedConfig.IsShowTerrainTrace = !SharedConfig.IsShowTerrainTrace; break; } return(result); }