Example #1
0
    public void CreateSession(string id, TwinSpriteDelegate createSessionDelegate)
    {
        // If no id, do nothing
        if (id == null || id.Length == 0)
        {
            Debug.Log("No toyxID, playing without toyx.");

            if (createSessionDelegate != null)
            {
                createSessionDelegate.Invoke(null);
            }
            return;
        }

        // Make the toyx
        toyxId = id;
        toyx   = new Toyx(id);

        toyx.CreateSessionInBackground(delegate(TwinSpriteError error) {
            if (error != null)
            {
                infoMessage += "Error creating session: " + error.message + "\nError code: " + error.errorCode + "\n";
            }
            else
            {
                infoMessage += "Created session!!!\n";
            }

            if (createSessionDelegate != null)
            {
                createSessionDelegate.Invoke(error);
            }
        });
    }
    public void CreateSession(string id, TwinSpriteDelegate createSessionDelegate)
    {
        // Make the toyx
        toyxId = id;
        toyx = new Toyx(id);

        toyx.CreateSessionInBackground(delegate(TwinSpriteError error) {
            if (error != null) {
                infoMessage += "Error creating session: "+error.message+"\nError code: " +error.errorCode+"\n";
            } else {
                infoMessage += "Created session!!!\n";
            }

            if (createSessionDelegate != null) {
                createSessionDelegate.Invoke(error);
            }

        });
    }
    public void LoadPlayer(string toyxId, int player)
    {
        Debug.Log ("Creating P" + player + " session");

                Toyx toyx = new Toyx (toyxId);

                if (player == 1) {
                        _player1Loaded = false;
                        _player1Toyx = toyx;
                } else {
                        _player2Loaded = false;
                        _player2Toyx = toyx;
                }

                IntroGUIManager.Instance.ShowLoading ();

                toyx.CreateSessionInBackground (delegate(TwinSpriteError sessionError) {
                        if (sessionError != null) {
                                Debug.LogError ("Error creating P" + player + " session: " + sessionError.message);
                                _loadError = true;
                        } else {
                                Debug.Log ("P" + player + " session created successfully");
                                Debug.Log ("Fetching P" + player + " data");
                                toyx.FetchInBackground (delegate(TwinSpriteError fetchError) {
                                        if (fetchError != null) {
                                                Debug.LogError ("Error fetching P" + player + " data: " + fetchError.message);
                                                _loadError = true;
                                        } else {
                                                Debug.Log ("P" + player + " fetched successfully");
                                                if (player == 1) {
                                                        _player1Loaded = true;
                                                } else {
                                                        _player2Loaded = true;
                                                }
                                        }
                                });
                        }
                });
    }
Example #4
0
    private void ParseToyx(string toyxId)
    {
        // If no id, do nothing
        if (toyxId == null || toyxId.Length == 0)
        {
            // remove spinner
            loadingBackground.SetActive(false);
            return;
        }


        if (Utils.HasInternetConnection())
        {
            //Fetch from internet
            // Make the toyx
            Toyx toyx = new Toyx(toyxId);

            toyx.CreateSessionInBackground(delegate(TwinSpriteError error1) {
                if (error1 != null)
                {
                    ShowPopup("Error creating session: " + error1.message + "\nError code: " + error1.errorCode);
                }
                else
                {
                    Debug.Log("Created session!!! now fetch it");

                    toyx.FetchInBackground(delegate(TwinSpriteError error2) {
                        if (error2 != null)
                        {
                            ShowPopup("Error fetching: " + error2.message + "\nError code: " + error2.errorCode);
                        }
                        else
                        {
                            Debug.Log("Fetched: " + toyx);

                            long modelID = toyx.GetToyxSnapshot().GetToyxModel().GetId();
                            int charges  = 0;
                            switch (modelID)
                            {
                            case FIREWAVE_MODEL_ID:
                                loadingBackground.SetActive(false); // remove spinner
                                charges = toyx.GetInt(SPECIAL_ATTACK_USES_ATTRIB);
                                UnlockSpecialButton(0, true, charges);
                                break;

                            case EARTHQUAKE_MODEL_ID:
                                loadingBackground.SetActive(false); // remove spinner
                                charges = toyx.GetInt(SPECIAL_ATTACK_USES_ATTRIB);
                                UnlockSpecialButton(1, true, charges);
                                break;

                            default:
                                ShowPopup("Toyx Model not compatible with bossfight powers");
                                break;
                            }
                        }
                    });
                }
            });
        }
        else
        {
            ShowPopup("Toyx Model not compatible with bossfight powers");
        }
    }