Example #1
0
 protected void handleLeaveRecord(Command command)
 {
     Logger.d("handleLeaveRecord");
     RecordMode = false;
     CommandDispatcher.SendCommand(command);
 }
Example #2
0
 void OnDestroy()
 {
     Logger.d("Destroy Wetest sdk");
     CommandDispatcher.CloseServerSocket();
 }
Example #3
0
        protected void NotifyTouchElement()
        {
            try
            {
                Cmd     cmd       = Cmd.TOUCH_NOTIFY;
                Command command   = new Command(cmd, recordSocket);
                Touch[] touchs    = Input.touches;
                int     fingerNum = touchs.Length;
                if (fingerNum == 0)
                {
                    return;
                }
                bool        finded      = false;
                TouchNotify touchNotify = new TouchNotify();
                string      scene       = Application.loadedLevelName;
                touchNotify.scene = scene;
                for (int i = 0; i < fingerNum && i < 5; ++i)
                {
                    Touch t = touchs[i];
                    Logger.d("Touch delta time = {0},x = {1},y={2} ,fingerId = {3},phase = {4}", t.deltaTime * Time.timeScale, t.position.x, t.position.y, t.fingerId, t.phase);
                    //只考虑,一个点的情况,Begin的时候
                    if (t.phase == TouchPhase.Began && !finded)
                    {
                        GameObject selectedObj = null;
                        try
                        {
                            selectedObj = NGUITools.FindElementByUnityPos(new Point(t.position.x, t.position.y));
                        }
                        catch (System.Exception ex)
                        {
                            Logger.v(ex.StackTrace);
                        }
                        if (selectedObj != null && NGUITools.IsInteraction(selectedObj))
                        {
                            finded = true;
                            String name = GameObjectTool.GenerateNamePath(selectedObj);
                            Logger.d("Touch UI = " + name);
                            touchNotify.name = name;
                        }
                    }
                    if (t.phase == TouchPhase.Canceled || t.phase == TouchPhase.Stationary || t.phase == TouchPhase.Moved)
                    {
                        continue;
                    }
                    TouchData td = new TouchData();
                    td.deltatime = DateTime.Now.Ticks / 10000 - startTime;
                    td.fingerId  = (short)t.fingerId;
                    Point point = CoordinateTool.ConvertUnity2Mobile(t.position);
                    td.x         = point.X;
                    td.y         = point.Y;
                    td.relativeX = t.position.x / Screen.width;
                    td.relativeY = (Screen.height - t.position.y) / Screen.height;
                    switch (t.phase)
                    {
                    case TouchPhase.Began:
                        td.phase = (byte)TouchType.TOUCH_DOWN;
                        break;

                    //case TouchPhase.Moved:
                    //    td.bPhase = (byte)ATTouchType.AT_TOUCH_MOVE;
                    //    break;
                    case TouchPhase.Ended:
                        td.phase = (byte)TouchType.TOUCH_UP;
                        break;
                    }
                    touchNotify.touches.Add(td);
                }
                if (touchNotify.touches.Count > 0)
                {
                    command.sendObj = touchNotify;
                    CommandDispatcher.SendCommand(command);
                }
            }
            catch (System.Exception ex)
            {
                Logger.w(ex.Message + "\n" + ex.StackTrace);
                Cmd     cmd     = Cmd.TOUCH_NOTIFY;
                Command command = new Command(cmd, recordSocket);
                command.sendObj = ex.Message + "\n" + ex.StackTrace;
                command.status  = ResponseStatus.UN_KNOW_ERROR;
                CommandDispatcher.SendCommand(command);
            }
        }
Example #4
0
 private void OnApplicationQuit()
 {
     Logger.d("OnApplicationQuit close server socket...");
     CommandDispatcher.CloseServerSocket();
 }