源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 line
4.0 KiB

  1. CheatCameraView = CheatCameraView or BaseClass(BaseView)
  2. local CheatCameraView = CheatCameraView
  3. function CheatCameraView:__init()
  4. self.base_file = "cheat"
  5. self.layout_file = "CheatCameraView"
  6. self.layer_name = "Top"
  7. self.destroy_imm = true
  8. self.use_background = false
  9. self.change_scene_close = true
  10. self.load_callback = function ()
  11. self:LoadSuccess()
  12. self:AddEvent()
  13. end
  14. self.open_callback = function ( )
  15. self:OpenSuccess()
  16. end
  17. self.destroy_callback = function ( )
  18. self:DestroySuccess()
  19. end
  20. end
  21. function CheatCameraView:Open( )
  22. --self.data = data
  23. BaseView.Open(self)
  24. end
  25. function CheatCameraView:LoadSuccess()
  26. self.distanceName = self:GetChild("distanceName"):GetComponent("Text")
  27. self.distanceInput = self:GetChild("distanceInput"):GetComponent("InputField")
  28. self.fieldName = self:GetChild("fieldName"):GetComponent("Text")
  29. self.fieldInput = self:GetChild("fieldInput"):GetComponent("InputField")
  30. self.rotateName = self:GetChild("rotateName"):GetComponent("Text")
  31. self.rotateInput = self:GetChild("rotateInput"):GetComponent("InputField")
  32. self.heigthName = self:GetChild("heigthName"):GetComponent("Text")
  33. self.heigthInput = self:GetChild("heigthInput"):GetComponent("InputField")
  34. self.sureBtn = self:GetChild("sureBtn").gameObject
  35. self.copyBtn = self:GetChild("copyBtn").gameObject
  36. SetAnchoredPosition(self.transform, -ScreenWidth/2, 0)
  37. end
  38. function CheatCameraView:AddEvent()
  39. local function onBtnClickHandler( target )
  40. if target == self.sureBtn then
  41. self:UpdateView()
  42. MainCamera.Instance.real_now_pos = co.Vector2(0,0)
  43. local main_role = Scene.Instance.main_role
  44. if main_role then
  45. MainCamera.Instance:ChangePosFllowMainrole(main_role.real_pos.x, main_role.real_pos.y, main_role.jump_height)
  46. end
  47. MainCamera.Instance:SetUpdateCameraEnabled(true)
  48. MainCamera.Instance:SetCameraSize(CameraDefaultFieldofView)
  49. elseif target == self.copyBtn then
  50. self:CopyData()
  51. end
  52. end
  53. AddClickEvent(self.sureBtn, onBtnClickHandler)
  54. AddClickEvent(self.copyBtn, onBtnClickHandler)
  55. end
  56. function CheatCameraView:OpenSuccess()
  57. self:UpdateView()
  58. end
  59. function CheatCameraView:UpdateView()
  60. local temp_dist_value = self.distanceInput.text
  61. if temp_dist_value == "" or not temp_dist_value then
  62. temp_dist_value = CameraDistanceWithMainRole
  63. end
  64. local temp_dist_name = "摄像机和主角的平面距离 ("..temp_dist_value.."):"
  65. self.distanceName.text = temp_dist_name
  66. CameraDistanceWithMainRole = temp_dist_value
  67. local temp_field_value = self.fieldInput.text
  68. if temp_field_value == "" or not temp_field_value then
  69. temp_field_value = CameraDefaultFieldofView
  70. end
  71. local temp_field_name = "摄像机可视范围 ("..temp_field_value.."):"
  72. self.fieldName.text = temp_field_name
  73. CameraDefaultFieldofView = temp_field_value
  74. local temp_rotate_value = self.rotateInput.text
  75. if temp_rotate_value == "" or not temp_rotate_value then
  76. temp_rotate_value = SceneCameraRotate
  77. end
  78. local temp_roate_name = "摄像机和地面夹角 ("..temp_rotate_value.."):"
  79. self.rotateName.text = temp_roate_name
  80. SceneCameraRotate = temp_rotate_value
  81. local temp_heigth_value = self.heigthInput.text
  82. if temp_heigth_value == "" or not temp_heigth_value then
  83. temp_heigth_value = SceneCameraHeigth
  84. end
  85. local temp_heigth_name = "摄像机离地面高度 ("..temp_heigth_value.."):"
  86. self.heigthName.text = temp_heigth_name
  87. SceneCameraHeigth = temp_heigth_value
  88. end
  89. function CheatCameraView:CopyData( )
  90. local str1 = string.format("--%s\n%s = %.1f", "摄像机和主角的平面距离", "CameraDistanceWithMainRole", CameraDistanceWithMainRole)
  91. local str2 = string.format("\n--%s\n%s = %.1f", "摄像机可视范围", "CameraDefaultFieldofView", CameraDefaultFieldofView)
  92. local str3 = string.format("\n--%s\n%s = %.1f", "摄像机和地面夹角", "SceneCameraRotate", SceneCameraRotate)
  93. local str4 = string.format("\n--%s\n%s = %.1f", "摄像机离地面高度", "SceneCameraHeigth", SceneCameraHeigth)
  94. local str = str1 .. str2 .. str3 .. str4
  95. Optimizer.CopyOnPC(str)
  96. Message.show("复制成功")
  97. end
  98. function CheatCameraView:DestroySuccess( )
  99. end