Example #1
0
    private void _ThreadWork(Vector3[] vec, float time)
    {
        Vector3[] vertices = new Vector3[vec.Length];
        for (int i = 0; i < vertices.Length; i++)
        {
            Vector3 vertex = baseHeight[i];
            vertex.y   += Mathf.Sin(time * speed + baseHeight[i].x + baseHeight[i].y + baseHeight[i].z) * scale;
            vertex.y   += Mathf.PerlinNoise(baseHeight[i].x + noiseWalk, baseHeight[i].y + Mathf.Sin(time * 0.1f)) * noiseStrength;
            vertices[i] = vertex;
        }

        MainThread.Call(() => _Cb(vertices));
    }
Example #2
0
 public void ShowOnMainThread(string message)
 {
     MainThread.Call(_Show, message);
 }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        if (rgc == null)
        {
            rgc = BalanceUnity.ACCESS().GetRGC();

            rgc.OnMatchDisband += packet => {
                MainThread.Call(() =>
                {
                    removeOthers();
                    removePlayer();
                });
            };

            rgc.OnMatchEnd += packet => {
                MainThread.Call(() =>
                {
                    removeOthers();
                    removePlayer();
                });
            };

            rgc.OnMatchExit += () => {
                MainThread.Call(() =>
                {
                    removeOthers();
                    removePlayer();
                });
            };

            rgc.OnOtherMatchExit += otherId => {
                MainThread.Call(() =>
                {
                    removeSingleOther(otherId);
                });
            };

            rgc.OnUdpClientClose += () =>
            {
                Debug.Log("udp disconnected.");

                MainThread.Call(() =>
                {
                    removeOthers();
                    removePlayer();
                });
            };

            rgc.OnMatchStart += packet =>
            {
                Debug.Log("OnMatchStart.");

                MainThread.Call(() =>
                {
                    spawnPlayer();
                });
            };

            rgc.OnMatchValidated += () =>
            {
                Debug.Log("OnMatchValidated.");
            };

            rgc.OnStatesUpdate += states =>
            {
                //Debug.Log("OnStatesUpdate.");

                MainThread.Call(() =>
                {
                    handleStates(states);
                });
            };
        }

        int now = (int)(Time.time * 1000);

        if (now - lastUpdated >= updateMs)
        {
            lastUpdated = now;
            if (rgc.IsInMatch())
            {
                if (Player != null && Player.transform != null)
                {
                    rgc.SendUdpStateUpdate(getStateUpdate());
                }
            }
        }
    }
Example #4
0
 public void SetTextOnMainThread(string text)
 {
     MainThread.Call(SetText, text);
 }
Example #5
0
    public void DecrementPowerUp(PowerTypes powerType, Action doIfHasPower)
    {
        if (!isLocalPlayer)
        {
            return;
        }
        switch (powerType)
        {
        case PowerTypes.Mirror:
            var currentMirrors = CurrentMirrors();
            Debug.LogError("ANZAHL VON MIRRORS: " + currentMirrors);
            //if (currentMirrors == 0) return;
            user["mirrors"] = currentMirrors - 1;
            break;

        case PowerTypes.Noiz:
            var currentNoiz = CurrentNoiz();
            //if (currentNoiz == 0) return;
            user["noiz"] = currentNoiz - 1;
            break;

        case PowerTypes.Boom:
            var currentBooms = CurrentBooms();
            if (currentBooms == 0)
            {
                return;
            }
            user["booms"] = currentBooms - 1;
            break;

        default:
            break;
        }
        if (!user.IsAuthenticated)
        {
            GuiManager.Instance.message.For(2).Show("NOT AUTHENTICATED");
            Debug.LogError("ERROR: " + "NOT AUTHENTICATED");
        }
        user.SaveAsync()
        .ContinueWith(task =>
        {
            if (task.IsCompleted && (task.IsFaulted || task.IsCanceled))
            {
                GuiManager.Instance.message.For(2).ShowOnMainThread("Cant add -1 powerUp");
                Debug.LogError("Cant substract powerup");

                GuiManager.Instance.loading.HideOnMainThread();
                // Errors from Parse Cloud and network interactions
                using (IEnumerator <System.Exception> enumerator = task.Exception.InnerExceptions.GetEnumerator())
                {
                    if (enumerator.MoveNext())
                    {
                        ParseException error = (ParseException)enumerator.Current;
                        GuiManager.Instance.message.For(2).ShowOnMainThread(error.Message);
                        Debug.LogError("ERROR: " + error.Message + " " + error.Code);
                    }
                }
            }
            else
            {
                MainThread.Call(() =>
                {
                    doIfHasPower.Invoke();
                    UpdateUi();
                });

                GuiManager.Instance.message.For(2).ShowOnMainThread("PowerUp -1 :)");
                Debug.LogError("Substacted power up");
            }
        });
    }
Example #6
0
 public void HideOnMainThread()
 {
     MainThread.Call(Hide);
 }
Example #7
0
 public void ShowOnMainThread()
 {
     MainThread.Call(Show);
 }
Example #8
0
 public void ShowUserStatsPage()
 {
     MainThread.Call(ShowPage, "UserStatsPage");
 }
Example #9
0
 public void ShowBattleGroundNamedLobbyPage()
 {
     MainThread.Call(ShowPage, "BattleGroundNamedLobbyPage");
 }
Example #10
0
 public void ShowLoginPage()
 {
     MainThread.Call(ShowPage, "LoginPage");
 }
Example #11
0
 public void ShowUserHomePage()
 {
     MainThread.Call(ShowPage, "UserHomePage");
 }
Example #12
0
 public void ShowQuizPage()
 {
     MainThread.Call(ShowPage, "QuizPage");
 }
Example #13
0
 public void ShowSignUpAditionalInfoPage()
 {
     MainThread.Call(ShowPage, "SignUpAdditionalInfo");
 }
Example #14
0
 public void ShowQuizResultsPage()
 {
     MainThread.Call(ShowPage, "QuizResults");
 }
Example #15
0
 public void ShowSplashPage()
 {
     MainThread.Call(ShowPage, "SplashPage");
 }
Example #16
0
 public void ShowWaitingForUserPage()
 {
     MainThread.Call(ShowPage, "WaitingForUsersPage");
 }