Beispiel #1
0
 // This is needed to handle server events in queued mode
 void FixedUpdate()
 {
     if (!running)
     {
         return;
     }
     smartFox.ProcessEvents();
     if (smartFox != null)
     {
         smartFox.ProcessEvents();
     }
 }
Beispiel #2
0
 /// <summary>
 /// As Unity is not thread safe, we process the queued up callbacks every physics tick
 /// Nothing will happen without this.
 /// </summary>
 void FixedUpdate()
 {
     if (_sfs != null)
     {
         _sfs.ProcessEvents();
     }
 }
Beispiel #3
0
 // Update is called once per frame
 void Update()
 {
     if (_smartFoxServer != null)
     {
         _smartFoxServer.ProcessEvents();
     }
 }
Beispiel #4
0
 void Update()
 {
     if (sfs != null)
     {
         sfs.ProcessEvents();
     }
 }
Beispiel #5
0
    // Update is called once per frame
    void Update()
    {
        if (sfs != null)
        {
            sfs.ProcessEvents();
        }

        // tab field hack
        if (Input.GetKeyDown(KeyCode.Tab))
        {
            if (usernameInput.isFocused)
            {
                EventSystem.current.SetSelectedGameObject(passwordInput.gameObject, null);
                passwordInput.OnPointerClick(new PointerEventData(EventSystem.current));
            }
            if (passwordInput.isFocused)
            {
                EventSystem.current.SetSelectedGameObject(usernameInput.gameObject, null);
                usernameInput.OnPointerClick(new PointerEventData(EventSystem.current));
            }
        }

        // press enter for login
        if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter))
        {
            OnLoginButtonClick();
        }
    }
Beispiel #6
0
 void Update()
 {
     if (_smartFox != null)
     {
         _smartFox.ProcessEvents();
     }
 }
Beispiel #7
0
 void FixedUpdate()
 {
     if (smartFox != null)
     {
         smartFox.ProcessEvents();
     }
 }
Beispiel #8
0
    void FixedUpdate()
    {
        if (sfs != null)
        {
            sfs.ProcessEvents();

            // If we spawned a local player, send position if movement is dirty

            /*
             * NOTE: We have commented the UserVariable relative to the Y Axis because in this example the Y position is fixed (Y = 1.0).
             * In case your game allows moving on all axis you should transmit all positions.
             *
             * On the server side the UserVariable event is captured and the coordinates are also passed to the MMOApi.SetUserPosition(...) method to update our position in the Room's map.
             * This in turn will keep us in synch with all the other players within our Area of Interest (AoI).
             */
            if (localPlayer != null && localPlayerController != null && localPlayerController.MovementDirty)
            {
                List <UserVariable> userVariables = new List <UserVariable>();
                userVariables.Add(new SFSUserVariable("x", (double)localPlayer.transform.position.x));
                //userVariables.Add(new SFSUserVariable("y", (double)localPlayer.transform.position.y));
                userVariables.Add(new SFSUserVariable("z", (double)localPlayer.transform.position.z));
                userVariables.Add(new SFSUserVariable("rot", (double)localPlayer.transform.rotation.eulerAngles.y));
                sfs.Send(new SetUserVariablesRequest(userVariables));
                localPlayerController.MovementDirty = false;
            }
        }
    }
 public void Update(float deltaTime)
 {
     if (_sfs != null)
     {
         _sfs.ProcessEvents();
     }
 }
Beispiel #10
0
 void FixedUpdate()
 {
     if (SFServer != null)
     {
         SFServer.ProcessEvents();
     }
 }
Beispiel #11
0
    void Update()
    {
        if (sfs != null)
        {
            sfs.ProcessEvents();
            if (localPlayer != null)
            {
                // Cast a line from player to isGrounded game object to tell if the player is on something or not
                // (removed player object from layer mask to avoid line cast with player coliders)
                localPlayerIsGrounded = true;

                // Get input for movement and jump
                move(CrossPlatformInputManager.GetAxisRaw("Horizontal"));
                if (CrossPlatformInputManager.GetButtonDown("Jump"))
                {
                    jump();
                }

                // Change between running and idle animation based on player velocity
                if (localPlayer.GetComponent <Rigidbody2D>().velocity.x == 0 && localPlayer.GetComponent <Rigidbody2D>().velocity.y == 0)
                {
                    localPlayer.GetComponent <Animator>().SetBool("Running", false);
                }
                else
                {
                    localPlayer.GetComponent <Animator>().SetBool("Running", true);
                }
            }
        }
        else if (SmartFoxConnection.IsInitialized)
        {
            sfs = SmartFoxConnection.Connection;
        }
    }
Beispiel #12
0
 private void FixedUpdate()
 {
     if (running)
     {
         smartFox.ProcessEvents();
     }
 }
Beispiel #13
0
 public void Update()
 {
     if (_sfs != null)
     {
         _sfs.ProcessEvents();
     }
 }
 void Update()
 {
     // As Unity is not thread safe, we process the queued up callbacks on every frame
     if (sfs != null)
     {
         sfs.ProcessEvents();
     }
 }
 public void Update(float deltaTime)
 {
     if (sfs != null)
     {
         sfs.ProcessEvents();
     }
     UpdateControler(deltaTime);
 }
Beispiel #16
0
 void Update()
 {
     ///不断刷新SmartFoxServer事件处理
     if (sfs != null)
     {
         sfs.ProcessEvents();
     }
 }
Beispiel #17
0
    /* ------------------------------------------------------
     * Update is called once per frame
     *
     * FixedUpdate as well, but it handles server events
     * in queued mode
     * ------------------------------------------------------
     */
    void FixedUpdate()
    {
        if (!thisRunning)
        {
            return;
        }

        sfs.ProcessEvents();
    }
Beispiel #18
0
 void Update()
 {
     if (sfs != null)
     {
         sfs.ProcessEvents();
     }
     else
     {
         sfs = gm.startSmartFox();
     }
 }
Beispiel #19
0
 void Update()
 {
     if (sfs != null)
     {
         sfs.ProcessEvents();
     }
     else if (!popUp.activeInHierarchy)
     {
         popUp.SetActive(true);
     }
 }
Beispiel #20
0
    // Update is called once per frame
    void Update()
    {
        //Debug.Log("ChooseDice: " +ChooseDice);
        //Debug.Log("Time.time: " + Time.time);
        //Debug.Log("deltaTime: " + (Time.time - oldTime));
        if (sfs != null)
        {
            sfs.ProcessEvents();
            if (Time.time - oldTime > 1f && ChooseDice == 6)
            {
                oldTime = Time.time;
                //Debug.Log("oldTime:" + oldTime);
                demNguoc();
            }
            if (reset)
            {
                resetDemNguoc();
            }
            else
            {
            }
        }
        else
        {
            Debug.Log(sfs);
        }


        //if (ChooseDice == null)
        //{
        //    Time.timeScale = 0;
        //}
        //else
        //{
        //    if (DiceName != null)
        //    {
        //        //cv.SetActive(true);
        //        cv.transform.GetChild(0).GetComponent<Image>().sprite = Resources.Load<Sprite>(DiceName);
        //        Time.timeScale = 0;
        //        if (DiceName == ChooseDice)
        //        {
        //            Score += 10;
        //        }
        //        else
        //        {
        //            Score -= 10;
        //        }
        //    }

        //}
        //ScoreTxt.text = Score.ToString();
    }
    void Update()
    {
        if (Input.GetKey("escape"))
        {
            Debug.Log("QUIT");
            Application.Quit();
        }

        if (sfs != null)
        {
            sfs.ProcessEvents();
        }
    }
Beispiel #22
0
    void Update()
    {
        //ProcessEvents : Run Listeners
        if (SERVER != null)
        {
            SERVER.ProcessEvents();

            //message =

            if (login)
            {
                login = false;
                SERVER.Send(new LoginRequest("Pollie", "000", "BasicExamples"));
            }
        }
    }
Beispiel #23
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Tab))
     {
         if (this.UsernameTB.isFocused)
         {
             this.PasswordTB.Select();
         }
         else
         {
             this.UsernameTB.Select();
         }
     }
     if (SFServer != null)
     {
         SFServer.ProcessEvents();
     }
 }
    void FixedUpdate()
    {
        if (smartfox != null)
        {
            smartfox.ProcessEvents();

            // If the player made a move, send it to the server
            if (localPlayer != null && localPlayerController != null && localPlayerController.movementDirty)
            {
                List <UserVariable> userVariables = new List <UserVariable>();
                userVariables.Add(new SFSUserVariable("x", (double)localPlayer.transform.position.x));
                userVariables.Add(new SFSUserVariable("z", (double)localPlayer.transform.position.z));
                userVariables.Add(new SFSUserVariable("rot", (double)localPlayer.transform.rotation.eulerAngles.y));
                smartfox.SendUserVariablesRequest(userVariables);

                localPlayerController.movementDirty = false;
            }
        }
    }
Beispiel #25
0
    void FixedUpdate()
    {
        if (sfs != null)
        {
            sfs.ProcessEvents();

            // If we spawned a local player, send position if movement is dirty
            if (localPlayer != null && localPlayerController != null && localPlayerController.MovementDirty)
            {
                List <UserVariable> userVariables = new List <UserVariable>();
                userVariables.Add(new SFSUserVariable("x", (double)localPlayer.transform.position.x));
                userVariables.Add(new SFSUserVariable("y", (double)localPlayer.transform.position.y));
                userVariables.Add(new SFSUserVariable("z", (double)localPlayer.transform.position.z));
                userVariables.Add(new SFSUserVariable("rot", (double)localPlayer.transform.rotation.eulerAngles.y));
                sfs.Send(new SetUserVariablesRequest(userVariables));
                localPlayerController.MovementDirty = false;
            }
        }
    }
Beispiel #26
0
    // Update is called once per frame
    void Update()
    {
        if (img_NhatAnTat.tag == "Active")
        {
            img_NhatAnTat.sprite = spt_NhatAnTat_Active;
            UpDownEffect(obj_NhatAnTat, obj_NhatAnTatPosY, 0.2f);
        }
        else
        {
            img_NhatAnTat.sprite = spt_NhatAnTat_Deactive;
            //UpDownEffect(obj_NhatAnTat, obj_NhatAnTatPosY, 0f);
        }

        if (img_TienLenTruyenThong.tag == "Active")
        {
            img_TienLenTruyenThong.sprite = spt_TienLenTruyenThong_Active;
            UpDownEffect(obj_TienLenTruyenThong, obj_TienLenTruyenThongPosY, 0.2f);
        }
        else
        {
            img_TienLenTruyenThong.sprite = spt_TienLenTruyenThong_Deactive;
            //UpDownEffect(obj_TienLenTruyenThong, obj_TienLenTruyenThongPosY, 0f);
        }

        if (img_DemLa.tag == "Active")
        {
            img_DemLa.sprite = spt_DemLa_Active;
            UpDownEffect(obj_DemLa, obj_DemLaPosY, 0.2f);
        }
        else
        {
            img_DemLa.sprite = spt_DemLa_Deactive;
            //UpDownEffect(obj_DemLa, obj_DemLaPosY, 0f);
        }

        // Proccess Smartfox events
        if (sfs != null)
        {
            sfs.ProcessEvents();
        }

        // Check if Smartfox session ends
    }
Beispiel #27
0
    void Update()
    {
        // As Unity is not thread safe, we process the queued up callbacks on every frame
        if (sfs != null)
        {
            sfs.ProcessEvents();
        }

        //I will use when the user carry the frame
        //if (Input.GetKey(KeyCode.Z))
        // FramePic.transform.parent = null;
        if (name != null)

        {
            temp.SetTexture("", FramePic.GetComponent <Renderer>().material.mainTexture);
            FramePic.GetComponent <Renderer>().material.SetTexture("", FramePicforArrange.GetComponent <Renderer>().material.mainTexture);
            FramePicforArrange.GetComponent <Renderer>().material.SetTexture("", temp.mainTexture);
            name = null;
        }
    }
Beispiel #28
0
    // Update is called once per frame
    void Update()
    {
        if (sfs != null)
        {
            sfs.ProcessEvents();

            if (localPlayer != null && localPlayerController != null && localPlayerController.MovementDirty)
            {
                List <UserVariable> userVariables = new List <UserVariable>();
                userVariables.Add(new SFSUserVariable("x", (double)localPlayer.transform.position.x));
                userVariables.Add(new SFSUserVariable("y", (double)localPlayer.transform.position.y));
                sfs.Send(new SetUserVariablesRequest(userVariables));
                localPlayerController.MovementDirty = false;
            }
        }

        if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter))
        {
            OnSendMessageButtonClick();
        }
    }
Beispiel #29
0
        private void Update()
        {
            if (!inGuild)
            {
                return;
            }

            if (sfs != null)
            {
                sfs.ProcessEvents();
            }

            if (++frameCount % pingRate == 0)
            {
                frameCount = 0;

                if (!isConnected && inGuild && !isConnecting)
                {
                    Connect();
                }
            }
        }
Beispiel #30
0
 void FixedUpdate()
 {
     if (sfs != null)
     {
         sfs.ProcessEvents();
     }
     if (localPlayer != null && localPlayerController != null && localPlayerController.MovementDirty)
     {
         List <UserVariable> userVariables = new List <UserVariable>();
         userVariables.Add(new SFSUserVariable("x", (double)localPlayer.transform.position.x));
         userVariables.Add(new SFSUserVariable("y", (double)localPlayer.transform.position.y));
         userVariables.Add(new SFSUserVariable("rot", (double)localPlayer.transform.rotation.eulerAngles.z));
         sfs.Send(new SetUserVariablesRequest(userVariables));
         localPlayerController.MovementDirty = false;
     }
     if (localPlayer != null && localPlayer.GetComponent <shoot>().shotdirty)
     {
         List <UserVariable> userVariables = new List <UserVariable>();
         userVariables.Add(new SFSUserVariable("shot", localPlayer.GetComponent <shoot>().shotcount));
         sfs.Send(new SetUserVariablesRequest(userVariables));
         localPlayer.GetComponent <shoot>().shotdirty = false;
     }
 }