public void Fetch(TwinSpriteDelegate fetchDelegate)
    {
        // No toyx, create session before
        if (toyx == null) {
            infoMessage += "Can't fetching, create session before.\n";
            return;
        }

        toyx.FetchInBackground(delegate(TwinSpriteError error) {

            if (error != null) {
                infoMessage += "Error fetching: "+error.message+"\nError code: " +error.errorCode+"\n";
            } else {
                infoMessage += "Feched: "+toyx+"\n";

                // Fill properties
                experience = toyx.GetInt(EXPERIENCE);
                gold = toyx.GetInt(GOLD);
                level = toyx.GetInt(LEVEL);
                weapon = (WeaponType) toyx.GetInt(WEAPON);

            }

            if (fetchDelegate != null) {
                fetchDelegate.Invoke(error);
            }
        });
    }
Example #2
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);
            }
        });
    }
Example #3
0
    public void Save(TwinSpriteDelegate saveDelegate)
    {
        // If no id, do nothing
        if (toyxId == null || toyxId.Length == 0)
        {
            Debug.Log("No toyxID, playing without toyx.");

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


        // No toyx, create session before
        if (toyx == null)
        {
            infoMessage += "Can't fetching, create session before.\n";
            return;
        }

        // Set properties
        toyx.PutInt(EXPERIENCE, experience);
        toyx.PutInt(GOLD, gold);
        toyx.PutInt(LEVEL, level);
        toyx.PutInt(WEAPON, (int)weapon);

        // Save
        toyx.SaveInBackground(delegate(TwinSpriteError error) {
            if (error != null)
            {
                if (error.errorCode == TwinSpriteError.TwinSpriteNoDataAvaiable)
                {
                    infoMessage += "No data avaiable, fetch it before.\n";
                }
                else
                {
                    infoMessage += "Error saving: " + error.message + "\nError code: " + error.errorCode + "\n";
                }
            }
            else
            {
                infoMessage += "Saved: " + toyx + "\n";
            }

            if (saveDelegate != null)
            {
                saveDelegate.Invoke(error);
            }
        });
    }
Example #4
0
    public void FetchIfNeeded(TwinSpriteDelegate fetchDelegate)
    {
        // If no id, do nothing
        if (toyxId == null || toyxId.Length == 0)
        {
            Debug.Log("No toyxID, playing without toyx.");

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


        // No toyx, create session before
        if (toyx == null)
        {
            infoMessage += "Can't fetching, create session before.\n";
            return;
        }


        toyx.FetchIfNeededInBackground(delegate(TwinSpriteError error) {
            if (error != null)
            {
                infoMessage += "Error fetching: " + error.message + "\nError code: " + error.errorCode + "\n";
            }
            else
            {
                infoMessage += "Feched: " + toyx + "\n";

                // Fill properties
                experience = toyx.GetInt(EXPERIENCE);
                gold       = toyx.GetInt(GOLD);
                level      = toyx.GetInt(LEVEL);
                weapon     = (WeaponType)toyx.GetInt(WEAPON);
            }

            if (fetchDelegate != null)
            {
                fetchDelegate.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);
            }

        });
    }
Example #6
0
 /*** Toyx Functions ***/
 public void CreateSession(TwinSpriteDelegate createSessionDelegate)
 {
     CreateSession(toyxId, createSessionDelegate);
 }
 /*** Toyx Functions ***/
 public void CreateSession(TwinSpriteDelegate createSessionDelegate)
 {
     CreateSession(toyxId, createSessionDelegate);
 }
    public void Save(TwinSpriteDelegate saveDelegate)
    {
        // No toyx, create session before
        if (toyx == null) {
            infoMessage += "Can't fetching, create session before.\n";
            return;
        }

        // Set properties
        toyx.PutInt(EXPERIENCE,experience);
        toyx.PutInt(GOLD,gold);
        toyx.PutInt(LEVEL,level);
        toyx.PutInt(WEAPON, (int)weapon);

        // Save
        toyx.SaveInBackground(delegate(TwinSpriteError error) {
            if (error != null) {

                if (error.errorCode == TwinSpriteError.TwinSpriteNoDataAvaiable) {
                    infoMessage += "No data avaiable, fetch it before.\n";
                } else {
                    infoMessage += "Error saving: "+error.message+"\nError code: " +error.errorCode+"\n";
                }
            } else {
                infoMessage += "Saved: "+toyx+"\n";
            }

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

        });
    }