示例#1
0
 public void RotateObject(string _rotationAxis, float _rotationDirection, CallBackFunction callBack)
 {
     _currentRotation = gameObject.transform.eulerAngles;
     if (_rotationAxis == "x")
     {
         _targetRotation.x = (_currentRotation.x + (90 * _rotationDirection));
     }
     if (_rotationAxis == "y")
     {
         _targetRotation.y = (_currentRotation.y + (90 * _rotationDirection));
     }
     if (_rotationAxis == "z")
     {
         _targetRotation.z = (_currentRotation.z + (90 * _rotationDirection));
     }
     StartCoroutine(ObjectRotationAnimation(_rotationAxis, _rotationDirection, callBack));
 }
示例#2
0
        static void Receive(object obj)
        {
            Player player = obj as Player;

            while (true)
            {
                byte[] data    = new byte[6];
                int    receive = 0;
                try
                {
                    receive = player.socket.Receive(data);
                }
                catch
                {
                    PlayerDisconnect(player);
                    break;
                }

                if (receive > 0)
                {
                    MemoryStream stream = new MemoryStream(data);
                    BinaryReader binary = new BinaryReader(stream, Encoding.UTF8);
                    ENUM_CMD     type   = (ENUM_CMD)binary.ReadUInt16();
                    uint         length = binary.ReadUInt32();

                    data = new byte[length];
                    player.socket.Receive(data);
                    stream = new MemoryStream(data);

                    if (type != ENUM_CMD.CS_HERO_MOVE_REQ)
                    {
                        Ultilities.Print($"recieved message, type={type}, length={length}");
                    }
                    if (_callbacks.ContainsKey(type))
                    {
                        CallBackFunction func = _callbacks[type];
                        func(player, stream);
                    }
                }
                else
                {
                    PlayerDisconnect(player);
                    break;
                }
            }
        }
示例#3
0
    public void startConversation(Dialogue conv, CallBackFunction callBack = default(CallBackFunction))
    {
        if (!_isInDialogue)
        {
            // Set the current conversation
            foreach (var item in conv.dialogue)
            {
                _currentConversation.Enqueue(item);
            }
            // Disp the dialogue text zone
            RubStates.instance.SetIsInDialogue(true);
            TalkPanel.SetActive(true);
        }

        _isInDialogue = true;

        DisplayNextSentence(_currentConversation, callBack);
    }
示例#4
0
        public string ColorFrame_OneFrame(
            [MarshalAs(UnmanagedType.FunctionPtr)]
            ref CallBackFunction colorframe_callback
            , ColorImageFormat format = ColorImageFormat.RgbResolution640x480Fps30
            )
        {
            try
            {
                _colorframe_callback = colorframe_callback;
                ColorStream_Enable(format);
                _kinect.ColorFrameReady += ColorFrame_OneFrame;


                return("ready");
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
示例#5
0
        public string DepthFrame_OneFrame(
            [MarshalAs(UnmanagedType.FunctionPtr)]
            ref CallBackFunction depthframe_callback
            , DepthImageFormat format = DepthImageFormat.Resolution80x60Fps30
            )
        {
            try
            {
                _depthframe_callback = depthframe_callback;
                _kinect.ColorStream.Enable(Microsoft.Kinect.ColorImageFormat.RgbResolution640x480Fps30);
                _kinect.DepthStream.Enable((Microsoft.Kinect.DepthImageFormat)format);
                _kinect.DepthFrameReady += DepthFrameReady_OneFrame;

                //画像サイズ設定
                switch (format)
                {
                case DepthImageFormat.Resolution80x60Fps30:
                    _width  = 80;
                    _height = 60;
                    break;

                case DepthImageFormat.Resolution320x240Fps30:
                    _width  = 320;
                    _height = 240;
                    break;

                case DepthImageFormat.Resolution640x480Fps30:
                    _width  = 320;
                    _height = 240;
                    break;
                }

                return("ready");
            }
            catch (Exception ex)
            {
                _kinect.Stop();
                _kinect.Dispose();
                throw new Exception(ex.Message);
            }
        }
        public string ColorFrame_OneFrame(
            [MarshalAs(UnmanagedType.FunctionPtr)] 
            ref CallBackFunction colorframe_callback
            , ColorImageFormat format = ColorImageFormat.RgbResolution640x480Fps30
            )
        {
            try
            {
                _colorframe_callback = colorframe_callback;
                ColorStream_Enable(format);
                _kinect.ColorFrameReady += ColorFrame_OneFrame;

                return "ready";
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }
示例#7
0
    public static void ShowConfirmMustUpdate(string title, string message, CallBackFunction onYes, CallBackFunction onNo, string textButtonYes, string textButtonNo)
    {
        if (Instance.listNotification.Count == 0)
        {
            Instance._StartConfirmMustUpdate(title, message, onYes, onNo, textButtonYes, textButtonNo);
        }

        Instance.listNotification.Add(new Notification(title, message, onYes, onNo, textButtonYes, textButtonNo));
    }
示例#8
0
 public static void ShowConfirmMustUpdate(string title, string message, CallBackFunction onYes, CallBackFunction onNo)
 {
     ShowConfirmMustUpdate(title, message, onYes, onNo, null, null);
 }
示例#9
0
    //----mustUpdate
    void _StartConfirmMustUpdate(string title, string message, CallBackFunction onYes, CallBackFunction onNo, string textButtonYes, string textButtonNo)
    {
        Init(EType.Confirm);

        lbTitle.text   = title;
        lbContent.text = message;

        callbackFuntionNoConfirm  = onNo;
        callbackFuntionYesConfirm = onYes;

        if (string.IsNullOrEmpty(textButtonYes) == false)
        {
            buttonYes.GetComponentInChildren <UILabel>().text = textButtonYes;
        }
        else
        {
            buttonYes.GetComponentInChildren <UILabel>().text = Application.platform == RuntimePlatform.Android ? "Google Play" : Application.platform == RuntimePlatform.IPhonePlayer ? "App Store" : "App Store";
        }

        if (string.IsNullOrEmpty(textButtonNo) == false)
        {
            buttonNo.GetComponentInChildren <UILabel>().text = textButtonNo;
        }
        else
        {
            buttonNo.GetComponentInChildren <UILabel>().text = "Chieuvuong.com";
        }
        buttonClose.gameObject.SetActive(false);
    }
示例#10
0
 internal extern static void webview_bind(
     IntPtr webview,
     [MarshalAs(UnmanagedType.LPStr)] string name,
     CallBackFunction callback,
     IntPtr arg);
示例#11
0
 public void Play(SoundEffect type, CallBackFunction callback)
 {
     StartCoroutine(_Play(type, callback));
 }
示例#12
0
 public static void Wait(float seconds, CallBackFunction callBack)
 {
     Instance.StartCoroutine(Instance.WaitCoroutine(seconds, callBack));
 }
示例#13
0
    IEnumerator _FunctionDelay(CallBackFunction callback, float delay)
    {
        yield return(new WaitForSeconds(delay));

        callback();
    }
示例#14
0
 public void Wait(float seconds, CallBackFunction callBack)
 {
     StartCoroutine(WaitCoroutine(seconds, callBack));
 }
示例#15
0
 public void Wait(CallBackFunction f)
 {
     StartCoroutine(WaitCoroutine(f));
 }
示例#16
0
    // Turning object of _rotationStep degrees while his rotation is not equal to _targetRotation
    // _rotationAxis ( "x", "y", "z" )
    // _rotationDirection ( -1 or 1 )
    // callBack ( void function )
    IEnumerator ObjectRotationAnimation(string _rotationAxis, float _rotationDirection, CallBackFunction callBack)
    {
        // add rotation step to current rotation.
        if (_rotationAxis == "x")
        {
            _currentRotation.x += (_rotationStep * _rotationDirection);
            _isCompleteRotation =
                ((int)_currentRotation.x > (int)_targetRotation.x && _rotationDirection < 0) ||              // for clockwise
                ((int)_currentRotation.x < (int)_targetRotation.x && _rotationDirection > 0);                   // for anti-clockwise
        }
        if (_rotationAxis == "y")
        {
            _currentRotation.y += (_rotationStep * _rotationDirection);
            _isCompleteRotation =
                ((int)_currentRotation.y > (int)_targetRotation.y && _rotationDirection < 0) ||              // for clockwise
                ((int)_currentRotation.y < (int)_targetRotation.y && _rotationDirection > 0);                   // for anti-clockwise
        }
        if (_rotationAxis == "z")
        {
            _currentRotation.z += (_rotationStep * _rotationDirection);
            _isCompleteRotation =
                ((int)_currentRotation.z > (int)_targetRotation.z && _rotationDirection < 0) ||              // for clockwise
                ((int)_currentRotation.z < (int)_targetRotation.z && _rotationDirection > 0);                   // for anti-clockwise
        }

        gameObject.transform.eulerAngles = _currentRotation;
        yield return(new WaitForSeconds(0));

        if (_isCompleteRotation)         // If animation is not finished
        {
            StartCoroutine(ObjectRotationAnimation(_rotationAxis, _rotationDirection, callBack));
        }
        else         // when animation is finished
        {
            gameObject.transform.eulerAngles = _targetRotation;
            callBack();
        }
    }
示例#17
0
    IEnumerator _DoConnection(CallBackFunction callback)
    {
        //Đặt biến không cho gửi kết nối nữa.
        mustThreadConnecting = true;

        es.Engine.Queueing = EsEngine.QueueDispatchType.External;
        Server server = new Server(CServer.SERVER_ID);

        //if (es.Engine.Servers.Contains(server) == false)
        server.AddAvailableConnection(new AvailableConnection(CServer.HOST_NAME, System.Convert.ToInt32(CServer.PORT), TYPE_CONNECT));
        es.Engine.AddServer(server);

        log4net.Config.BasicConfigurator.Configure();

#if UNITY_WEBPLAYER
        if (!Application.isEditor && Application.isWebPlayer)
        {
            if (!Security.PrefetchSocketPolicy(CServer.HOST_NAME, System.Convert.ToInt32(CServer.PORT), 999))
            {
                Debug.LogError("Security Exception. Policy file load failed!");
            }
        }
#endif

        //Set là chưa có thông tin phản hồi về kết nối
        bool?connectionResponseSuccessful = null;

        WaitingView.Show("Kết nối đến máy chủ");

        threadConnect = new System.Threading.Thread(delegate()
        {
            es.Engine.Connect();
            connectionResponseSuccessful = es.Engine.Connected;
        });
        threadConnect.Start();

        while (connectionResponseSuccessful == null)
        {
            yield return(new WaitForEndOfFrame());
        }

        if (isLogged)
        {
            WaitingView.Instance.Close();
        }

        if (!es.Engine.Connected)
        {
            WaitingView.Hide();
            NotificationView.ShowConfirm(
                "Lỗi kết nối TCP/IP.",
                "Không thể kết nối đến máy chủ.\n\n Bạn có muốn thực hiện lại hành động vừa rồi ?",
                delegate()
            {
                DoConnection(callback);
            }, null);
        }
        else
        {
            callback();
        }
        mustThreadConnecting = false;
    }
 public void DoRequest(string request, CallBackFunction callback)
 {
     // do stuff....
     callback(request);
 }
示例#19
0
文件: Program.cs 项目: Todtaure/IKT6
 public static extern void SomeUnmanagedFunctionUsingCallback(double x, CallBackFunction pF);
示例#20
0
    IEnumerator WaitCoroutine(CallBackFunction f)
    {
        yield return(new WaitForSeconds(3));

        f.Invoke();
    }
示例#21
0
        public string DepthFrame_OneFrame(
            [MarshalAs(UnmanagedType.FunctionPtr)] 
            ref CallBackFunction depthframe_callback
            , DepthImageFormat format = DepthImageFormat.Resolution80x60Fps30
            )
        {
            try
            {
                _depthframe_callback = depthframe_callback;
                _kinect.ColorStream.Enable(Microsoft.Kinect.ColorImageFormat.RgbResolution640x480Fps30);
                _kinect.DepthStream.Enable((Microsoft.Kinect.DepthImageFormat)format);
                _kinect.DepthFrameReady += DepthFrameReady_OneFrame;

                //画像サイズ設定
                switch (format)
                {
                    case DepthImageFormat.Resolution80x60Fps30:
                        _width = 80;
                        _height = 60;
                        break;
                    case DepthImageFormat.Resolution320x240Fps30:
                        _width = 320;
                        _height = 240;
                        break;
                    case DepthImageFormat.Resolution640x480Fps30:
                        _width = 320;
                        _height = 240;
                        break;
                }

                return "ready";
            }
            catch (Exception ex)
            {
                _kinect.Stop();
                _kinect.Dispose();
                throw new Exception(ex.Message);
            }
        }
示例#22
0
    IEnumerator WaitCoroutine(float seconds, CallBackFunction callBack)
    {
        yield return(new WaitForSeconds(seconds));

        callBack();
    }
示例#23
0
 //IEnumerator checkConnection()
 //{
 //    WWW www = new WWW(ServerWeb.URL_PING);
 //    yield return www;
 //    if (!www.isDone || !string.IsNullOrEmpty(www.error))
 //    {
 //        if (!dialogIsShowing)
 //        {
 //            ServerMessagesView.MessageServer("Thông báo", "Bạn bị mất kết nối internet!", delegate()
 //            {
 //                dialogIsShowing = false;
 //            }, "Thử lại");
 //            dialogIsShowing = true;
 //            Server.WhenDisconnect();
 //        }
 //        float timePing = 10f;
 //        if (GameManager.Setting.Platform.GetConfigByType(PlatformType.ping_interval) != null)
 //            timePing = float.Parse(GameManager.Setting.Platform.GetConfigByType(PlatformType.ping_interval).Value);
 //        yield return new WaitForSeconds(timePing);// trying again after 2 sec
 //        StartCoroutine(checkConnection());
 //    }
 //    else
 //    {
 //        if (dialogIsShowing)
 //        {
 //            ServerMessagesView.Instance.hideNotification();
 //            dialogIsShowing = !dialogIsShowing;
 //        }
 //        float timePing = 10f;
 //        if (GameManager.Setting.Platform.GetConfigByType(PlatformType.ping_interval) != null)
 //            timePing = float.Parse(GameManager.Setting.Platform.GetConfigByType(PlatformType.ping_interval).Value);
 //        yield return new WaitForSeconds(timePing);// recheck if the internet still exists after 5 sec
 //        StartCoroutine(checkConnection());
 //    }
 //}
 #region CALLBACK METHOD
 public void FunctionDelay(CallBackFunction callback, float delay)
 {
     StartCoroutine(_FunctionDelay(callback, delay));
 }