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.
134 lines
4.8 KiB
134 lines
4.8 KiB
using ET.FUIPeople; |
|
using FairyGUI; |
|
using UnityEngine; |
|
|
|
namespace ET |
|
{ |
|
public class OperationComponentAwakeSystem: AwakeSystem<OperationComponent> |
|
{ |
|
public override void Awake(OperationComponent self) |
|
{ |
|
self.Awake(); |
|
} |
|
} |
|
|
|
public class OperationComponentUpdateSystem : UpdateSystem<OperationComponent> |
|
{ |
|
public override void Update(OperationComponent self) |
|
{ |
|
self.Update(); |
|
} |
|
} |
|
|
|
[FriendClass(typeof(OperationComponent))] |
|
[FriendClass(typeof(FUIComponent))] |
|
[FriendClass(typeof(FUI))] |
|
public static class OperationComponentSystem |
|
{ |
|
public static void Awake(this OperationComponent self) |
|
{ |
|
self.CameraComp = self.ZoneScene().CurrentScene().GetComponent<CameraComponent>(); |
|
// 操作事件 |
|
var uiComp = self.ZoneScene().GetComponent<FUIComponent>(); |
|
var holder = uiComp.Root.GObject; |
|
SwipeGesture moveGesture = new SwipeGesture(holder); |
|
moveGesture.onBegin.Add(self.OnSwipeDown); |
|
moveGesture.onMove.Add(self.OnSwipeMove); |
|
moveGesture.onEnd.Add(self.OnSwipeUp); |
|
|
|
PinchGesture scaleGesture = new PinchGesture(holder); |
|
scaleGesture.onAction.Add(self.OnPinch); |
|
} |
|
public static void Update(this OperationComponent self) |
|
{ |
|
#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX |
|
if (self.Enabled) |
|
{ |
|
if (!Stage.isTouchOnUI) |
|
{ |
|
self.ProcessMouseEvents(); |
|
} |
|
} |
|
|
|
if (Input.GetKeyDown(KeyCode.P)) |
|
{ |
|
Log.Debug("开启作弊器"); |
|
var com = self.ZoneScene().GetComponent<FUIComponent>(); |
|
var win = com.ShowWindow<FUICommon.FUI_CheatWindow, FUICheatWindowComponent>(); |
|
} |
|
#endif |
|
|
|
if (Input.GetKeyUp(KeyCode.K)) |
|
{ |
|
var fuiComp = self.ZoneScene().GetComponent<FUIComponent>(); |
|
var skillTestWin = fuiComp.GetWindow(FUI_SkillTestWindow.UIResName); |
|
// var skillTestWinComp = fuiComp.ShowWindow<FUI_SkillTestWindow, FUISkillTestWindowComponent>(FUI_SkillTestWindow.UIPackageName); |
|
// skillTestWinComp.ShowInfo(); |
|
|
|
if (skillTestWin == null) |
|
{ |
|
var skillTestWinComp = fuiComp.ShowWindow<FUI_SkillTestWindow, FUISkillTestWindowComponent>(FUI_SkillTestWindow.UIPackageName); |
|
skillTestWinComp.ShowInfo(); |
|
} |
|
else |
|
{ |
|
var skillTestWinComp = skillTestWin as FUISkillTestWindowComponent; |
|
if (skillTestWinComp.IsShowing) |
|
{ |
|
skillTestWin.Window.Hide(); |
|
} |
|
else |
|
{ |
|
skillTestWin.Window.Show(); |
|
} |
|
} |
|
} |
|
} |
|
|
|
public static void OnSwipeDown(this OperationComponent self, EventContext context) |
|
{ |
|
SwipeGesture gesture = (SwipeGesture)context.sender; |
|
self.mouseDownPos = gesture.position; |
|
self.cameraDownPos = self.CameraComp.GetCameraPos(); |
|
} |
|
|
|
public static void OnSwipeMove(this OperationComponent self, EventContext context) |
|
{ |
|
if (self.Enabled && !Stage.isTouchOnUI) |
|
{ |
|
self.IsDragging = true; |
|
SwipeGesture gesture = (SwipeGesture)context.sender; |
|
// 因为下面会改变Camera位置,所以mouseDownPos的toWorld也要重新算 |
|
Vector3 deltaPos = self.CameraComp.ScreenToWorldPoint(gesture.position) - self.CameraComp.ScreenToWorldPoint(self.mouseDownPos); |
|
//Debug.Log(deltaPos); |
|
deltaPos.y = -deltaPos.y; |
|
self.cameraTargetPos = self.cameraDownPos - deltaPos; |
|
|
|
self.CameraComp.SetCameraPosClamped(self.cameraTargetPos); |
|
} |
|
} |
|
|
|
public static void OnSwipeUp(this OperationComponent self, EventContext context) |
|
{ |
|
self.IsDragging = false; |
|
} |
|
|
|
public static void OnPinch(this OperationComponent self, EventContext context) |
|
{ |
|
if (!Stage.isTouchOnUI) |
|
{ |
|
PinchGesture gesture = (PinchGesture)context.sender; |
|
self.CameraComp.ZoomCamera(gesture.delta); |
|
} |
|
} |
|
|
|
public static void ProcessMouseEvents(this OperationComponent self) |
|
{ |
|
if (Input.mouseScrollDelta.y != 0) |
|
{ |
|
self.CameraComp.ZoomCamera(Input.mouseScrollDelta.y); |
|
} |
|
} |
|
|
|
} |
|
} |