private void Update() { if (!CanProcessEvent) { return; } if (state == RightState.Idle) { if (WindowMng.windowMng.IsOtherUIOpen()) { return; } #if UNITY_EDITOR || UNITY_STANDALONE if (Input.GetMouseButtonDown(0)) { var mousePos = Input.mousePosition; if (mousePos.x > Screen.width / 2) { state = RightState.Move; rb.EnterMove(); rf.EnterMove(); useMouse = true; rb.SetFingerPos(mousePos); rf.SetFingerPos(mousePos); CalculateShootDir(); //MyEventSystem.myEventSystem.PushEvent(MyEvent.EventType.EnterShoot); enterTime = Time.time; } } else #endif { foreach (var touch in Input.touches) { fingerId = touch.fingerId; //if (fingerId > 0 && fingerId < Input.touchCount) if (touch.phase == TouchPhase.Began) { if (Input.GetTouch(fingerId).position.x > Screen.width / 2) { state = RightState.Move; var fp = Input.GetTouch(fingerId).position; rb.EnterMove(); rf.EnterMove(); useMouse = false; rb.SetFingerPos(fp); rf.SetFingerPos(fp); CalculateShootDir(); //MyEventSystem.myEventSystem.PushEvent(MyEvent.EventType.EnterShoot); enterTime = Time.time; break; } } } } } else { if (Time.time - enterTime > 0.0f && enterTime != 0) { MyEventSystem.myEventSystem.PushEvent(MyEvent.EventType.EnterShoot); enterTime = 0; } if (WindowMng.windowMng.IsOtherUIOpen()) { state = RightState.Idle; rb.ExitMove(); rf.ExitMove(); useMouse = false; MyEventSystem.PushEventStatic(MyEvent.EventType.ExitShoot); return; } #if UNITY_EDITOR || UNITY_STANDALONE if (useMouse) { if (!Input.GetMouseButton(0)) { state = RightState.Idle; rb.ExitMove(); rf.ExitMove(); useMouse = false; var exit = new MyEvent() { type = MyEvent.EventType.ExitShoot, boolArg = !rb.IsCancel(), }; MyEventSystem.myEventSystem.PushEvent(exit); /* * if (!rb.IsCancel()) * { * //MyEventSystem.PushEventStatic (MyEvent.EventType.Shoot); * GameInterface.gameInterface.PlayerAttack(); * } */ } else { var mousePos = Input.mousePosition; rb.SetFingerPos(mousePos); rf.SetFingerPos(mousePos); CalculateShootDir(); } } else #endif { var find = false; Touch touch = new Touch(); var getTouch = false; foreach (var t in Input.touches) { if (t.fingerId == fingerId) { touch = t; getTouch = true; break; } } if (getTouch) { var phase = touch.phase; find = phase == TouchPhase.Ended || phase == TouchPhase.Canceled; } else { find = true; } if (find) { state = RightState.Idle; rb.ExitMove(); rf.ExitMove(); var exit = new MyEvent() { type = MyEvent.EventType.ExitShoot, boolArg = !rb.IsCancel(), }; MyEventSystem.myEventSystem.PushEvent(exit); /* * if (!rb.IsCancel()) * { * GameInterface.gameInterface.PlayerAttack(); * } */ } else { var pos = touch.position; rb.SetFingerPos(pos); rf.SetFingerPos(pos); CalculateShootDir(); } } } }