public void SelectItem(int index)
    {
        for (int i = 0; i < Items.Count; i++)
        {
            if (Items[i].Selected)
            {
                Items[i].Selected = false;
                itemsData.GetArray("Items")[i].Obj.GetValue("selected").Boolean = false;
            }
        }

        Items[index].Selected = true;
        itemsData.GetArray("Items")[index].Obj.GetValue("selected").Boolean = true;

        SelectedItemIndex = index;

        // I am doing this to put all of the information from the user into a JSON String to then be parsed as info to update
        PlayerPrefs.SetString("Items", itemsData.ToString());

        // Instead this is where I would put my updates for thr user

        //  if()
        //  PlayerPrefs.DeleteAll();

        PlayerPrefs.Save();
    }
Esempio n. 2
0
    public void SetResults(JSONObject jsonData)
    {
        spinDataResult = jsonData;
        resultsData    = jsonData.GetArray("items");
        winningGold    = jsonData.GetArray("wGold");
        // Calculate extra data (winning type, winning count from list result items)
        JSONObject extraData = SlotCombination.CalculateCombination(resultsData, GetNumLine());

        winningCount = extraData.GetArray("wCount");
        winningType  = extraData.GetArray("wType");
        //
        isJackpot    = jsonData.GetBoolean("isJP");
        freeSpinLeft = jsonData.GetInt("frLeft");
        isBigWin     = jsonData.GetBoolean("bWin");
        gotFreeSpin  = jsonData.GetInt("frCount") > 0;
        // bool[] winingItems = new bool[15];
        // for (int i = 0; i < winningGold.Length; i++) {
        //  if (winningGold[i].Number > 0) {
        //      for (int j = 0; j < SlotCombination.NUM_REELS; j++) {
        //          winingItems[SlotCombination.COMBINATION[i, j]] = true;
        //      }
        //  }
        // }
        for (int i = 0; i < slotReels.Length; i++)
        {
            slotReels[i].SetResults(new int[3] {
                (int)resultsData[i * 3].Number, (int)resultsData[i * 3 + 1].Number, (int)resultsData[i * 3 + 2].Number
            });
        }
    }
Esempio n. 3
0
        public override void Deserialize(JSONObject obj)
        {
            Name             = obj.GetString(NAME);
            AlternativeNames = new List <string>();
            JSONArray tempArray = obj.GetArray(cAltNames);

            foreach (var val in tempArray)
            {
                AlternativeNames.Add(val.Str);
            }
            Alignment        = (DnDAlignment)(int)obj.GetNumber(ALIGNMENT);
            WorshippingRaces = new List <DnDRace>();
            tempArray        = obj.GetArray(cRaces);
            foreach (var val in tempArray)
            {
                WorshippingRaces.Add((DnDRace)(int)val.Number);
            }
            WorshippingClasses = new List <DnDCharClass>();
            tempArray          = obj.GetArray(cClasses);
            foreach (var val in tempArray)
            {
                WorshippingClasses.Add((DnDCharClass)(int)val.Number);
            }
            Domains   = new List <DnDClericDomain>();
            tempArray = obj.GetArray(cDomains);
            foreach (var val in tempArray)
            {
                Domains.Add((DnDClericDomain)(int)val.Number);
            }
        }
Esempio n. 4
0
  public void SetResults(JSONObject jsonData) {
		spinDataResult = jsonData;
    resultsData = jsonData.GetArray("items");
    winningGold = jsonData.GetArray("wGold");
		// Calculate extra data (winning type, winning count from list result items)
		JSONObject extraData = SlotCombination.CalculateCombination(resultsData, GetNumLine());
    winningCount = extraData.GetArray("wCount");
    winningType = extraData.GetArray("wType");
		//
    isJackpot = jsonData.GetBoolean("isJP");
		freeSpinLeft = jsonData.GetInt("frLeft");
		isBigWin = jsonData.GetBoolean("bWin");
		gotFreeSpin = jsonData.GetInt("frCount") > 0;
		// bool[] winingItems = new bool[15];
		// for (int i = 0; i < winningGold.Length; i++) {
		// 	if (winningGold[i].Number > 0) {
		// 		for (int j = 0; j < SlotCombination.NUM_REELS; j++) {
		// 			winingItems[SlotCombination.COMBINATION[i, j]] = true;
		// 		}
		// 	}
		// }
    for (int i = 0; i < slotReels.Length; i++) {
      slotReels[i].SetResults(new int[3] { (int)resultsData[i * 3].Number, (int)resultsData[i * 3 + 1].Number, (int)resultsData[i * 3 + 2].Number });
    }
  }
Esempio n. 5
0
    private void Awake()
    {
        Debug.Log("Im awake");
        Instance = this;
        //If this is the first time playing
        if (!PlayerPrefs.HasKey("Chars"))
        {
            PlayerPrefs.SetString("Chars", "{\"Chars\":[{\"Name\":\"Char1\",\"Bought\":true,\"Selected\":true,\"Gold price\":10000},{\"Name\":\"Char2\",\"Bought\":false,\"Selected\":false,\"Gold price\":10000},{\"Name\":\"Char3\",\"Bought\":false,\"Selected\":false,\"Gold price\":10000}]}");
            PlayerPrefs.SetInt("Gold", 1000);
        }
        Gold = PlayerPrefs.GetInt("Gold");

        itemsData = JSONObject.Parse(PlayerPrefs.GetString("Chars"));
        items     = new List <shopItem>();

        /*Creating shopItems out of the items stored in the
         * PlayerPrefs string*/
        for (int i = 0; i < itemsData.GetArray("Chars").Length; i++)
        {
            items.Add(new shopItem(itemsData.GetArray("Chars")[i].Obj.GetString("Name"),
                                   itemsData.GetArray("Chars")[i].Obj.GetBoolean("Bought"),
                                   itemsData.GetArray("Chars")[i].Obj.GetBoolean("Selected"),
                                   (int)itemsData.GetArray("Chars")[i].Obj.GetNumber("Gold price")));
            if (items[i].Selected)
            {
                selectedItemIndex = i;
            }
        }
    }
Esempio n. 6
0
        private void DeserializeData(string data)
        {
            mSpells.Clear();
            JSONObject obj = JSONObject.Parse(data);

            if (obj.ContainsKey("version"))
            {
                mVersion = obj.GetString("version");
            }
            if (obj.ContainsKey("message"))
            {
                mMessage = new List <string>();
                JSONArray jsonMessage = obj.GetArray("message");
                foreach (var val in jsonMessage)
                {
                    mMessage.Add(val.Str);
                }
            }
            JSONArray spells = obj.GetArray("spells");

            foreach (var val in spells)
            {
                Spell spell = new Spell();
                spell.InitiateSpell(val.Obj);
                mSpells.Add(spell);
            }
            WriteList();
        }
    public void Awake()
    {
        Instance = this;

        // THIS IS WHERE I WANT HERE  //
        if (!PlayerPrefs.HasKey("Items"))
        {
            PlayerPrefs.SetString("Items", "{\"Items\":[{\"name\":\"Fire Rate\",\"bought\":false,\"selected\":false,\"price\":100},{\"name\":\"Move Speed\",\"bought\":false,\"selected\":false,\"price\":500},{\"name\":\"Hardened Bullets\",\"bought\":false,\"selected\":false,\"price\":1000}]}");
            PlayerPrefs.SetInt("Currency", 10000);
        }
        Currency = PlayerPrefs.GetInt("Currency");

        //where i store the parsed data aka the user data
        itemsData = JSONObject.Parse(PlayerPrefs.GetString("Items"));

        Items = new List <ShopItem>();

        for (int i = 0; i < itemsData.GetArray("Items").Length; i++)
        {
            Items.Add(new ShopItem(itemsData.GetArray("Items")[i].Obj.GetBoolean("bought"), itemsData.GetArray("Items")[i].Obj.GetBoolean("selected"),
                                   (int)itemsData.GetArray("Items")[i].Obj.GetNumber("price"),
                                   itemsData.GetArray("Items")[i].Obj.GetString("name")));

            if (Items[i].Selected)
            {
                SelectedItemIndex = i;
            }
        }
    }
Esempio n. 8
0
        public void InitiateSpell(JSONObject spellObject)
        {
            mName   = spellObject.GetString("name");
            mSchool = (DnDMagicSchool)spellObject.GetNumber("school");
            JSONArray classes = spellObject.GetArray("classes");

            foreach (var val in classes)
            {
                SpellAttribute attribute = new SpellAttribute();
                attribute.attribute      = SpellAttributeType.Class;
                attribute.attributeValue = (int)val.Obj.GetNumber("class");
                attribute.rank           = (int)val.Obj.GetNumber("rank");
                mClasses.Add(attribute);
            }
            JSONArray domains = spellObject.GetArray("domains");

            foreach (var val in domains)
            {
                SpellAttribute attribute = new SpellAttribute();
                attribute.attribute      = SpellAttributeType.Domain;
                attribute.attributeValue = (int)val.Obj.GetNumber("domain");
                attribute.rank           = (int)val.Obj.GetNumber("rank");
                mDomains.Add(attribute);
            }
        }
Esempio n. 9
0
    public List <Jugador> hacerListaDeJugadores(JSONObject json)
    {
        JSONArray      nombres   = json.GetArray("jugadores");
        JSONArray      avatares  = json.GetArray("avatares");
        List <Jugador> jugadores = new List <Jugador>();

        for (int i = 0; i < nombres.Length; i++)
        {
            string  nombre  = nombres[i].Str;
            string  avatar  = avatares[i].Str;
            Jugador jugador = new Jugador(nombre, avatar);
            jugadores.Add(jugador);
        }
        return(jugadores);
    }
Esempio n. 10
0
    private void OnEnable()
    {
        string path = Path.Combine(Application.dataPath + "/Playlists");

        if (Directory.Exists(path))
        {
            foreach (var dir in Directory.GetDirectories(path))
            {
                if (Directory.Exists(dir) && Directory.GetFiles(dir, "info.dat").Length > 0)
                {
                    JSONObject infoFile = JSONObject.Parse(File.ReadAllText(Path.Combine(dir, "info.dat")));

                    var song = new Song();
                    song.Path           = dir;
                    song.Name           = infoFile.GetString("_songName");
                    song.AuthorName     = infoFile.GetString("_songAuthorName");
                    song.BPM            = infoFile.GetNumber("_beatsPerMinute").ToString();
                    song.CoverImagePath = Path.Combine(dir, infoFile.GetString("_coverImageFilename"));
                    song.AudioFilePath  = Path.Combine(dir, infoFile.GetString("_songFilename"));
                    song.Difficulties   = new List <string>();

                    var difficultyBeatmapSets = infoFile.GetArray("_difficultyBeatmapSets");
                    foreach (var beatmapSets in difficultyBeatmapSets)
                    {
                        foreach (var difficultyBeatmaps in beatmapSets.Obj.GetArray("_difficultyBeatmaps"))
                        {
                            song.Difficulties.Add(difficultyBeatmaps.Obj.GetString("_difficulty"));
                        }
                    }

                    AllSongs.Add(song);
                }
            }
        }
    }
Esempio n. 11
0
    public bool SetStudentInfo(string data)
    {
        try
        {
            JSONObject jsonObject = JSONObject.Parse(data);
            JSONArray  jsonArray  = jsonObject.GetArray("response");
            if (jsonArray.Length == 0)
            {
                return(false);
            }

            JSONObject jObject      = jsonArray[0].Obj;
            string     ID           = jObject.GetString("ID");
            int        schoolUnique = System.Convert.ToInt32(jObject.GetString("SchoolUnique").Trim());
            string     schoolName   = jObject.GetString("SchoolName");
            string     schoolGrade  = jObject.GetString("SchoolGrade");
            byte       grade        = System.Convert.ToByte(jObject.GetString("Grade").Trim());
            byte       classNum     = System.Convert.ToByte(jObject.GetString("Class").Trim());
            byte       number       = System.Convert.ToByte(jObject.GetString("Number").Trim());
            string     gender       = jObject.GetString("Gender");
            string     name         = jObject.GetString("Name");

            _studentInfo = new StudentDBInfo(ID, schoolUnique, schoolName, schoolGrade, grade, classNum, number, gender, name);
            _studentInfo.Print();
        }
        catch (Exception e)
        {
            Debug.Log(e.ToString());
            return(false);
        }

        return(true);
    }
Esempio n. 12
0
    private void InitCharacters()
    {
        string data = "";

        try
        {
            using (var stream = File.OpenRead(Application.persistentDataPath + charFileName))
            {
                StreamReader reader = new StreamReader(stream);
                data = reader.ReadToEnd();
            }
        }
        catch (Exception) {}

        if (!string.IsNullOrEmpty(data))
        {
            mCharacterLsit.Clear();
            JSONObject obj   = JSONObject.Parse(data);
            JSONArray  array = obj.GetArray("characters");
            foreach (var val in array)
            {
                Character character = new Character();
                character.Deserialize(val.Obj);
                mCharacterLsit.Add(character);
            }
        }
    }
        private void FriendsUsingAppCallBack(IGraphResult result)
        {
            FBLog("FriendsDataCallBack", result.RawResult);
            FacebookHelperResultType resultType = FacebookHelperResultType.ERROR;

            if (result != null && result.Error == null)
            {
                JSONObject jsonObject = JSONObject.Parse(result.RawResult);
                JSONValue  dataArray  = jsonObject.GetArray("data");

                foreach (JSONValue friend in dataArray.Array)
                {
                    string userId   = friend.Obj.GetString("id");
                    string UserName = friend.Obj.GetString("name");
                    Debug.Log("NAME " + UserName);
                    if (PreloadFriendImages)
                    {
                        LoadProfileImage(userId);
                    }
                    FacebookFriend facebookFriend = new FacebookFriend();
                    facebookFriend.Id   = userId;
                    facebookFriend.Name = UserName;
                    Friends.Add(facebookFriend);
                }

                IsFriendsLoaded = true;
                resultType      = FacebookHelperResultType.OK;
            }

            OnFriendsUsingAppAction(resultType);
        }
Esempio n. 14
0
    public bool SetCardiAvgRecordInfo(string data)      // 같은 학교, 학년, 성별, 기준인 학생들 평균 기록
    {
        _avgTrackRecordList.Clear();
        try
        {
            JSONObject jsonObject = JSONObject.Parse(data);
            JSONArray  jsonArray  = jsonObject.GetArray("response");
            if (jsonArray.Length == 0)
            {
                return(false);
            }

            int i = 0;
            while (i < jsonArray.Length)
            {
                JSONObject jObject             = jsonArray[i].Obj;
                int        trackIndex          = System.Convert.ToInt32(jObject.GetString("TrackIndex"));
                int        perTrackElapsedTime = (int)System.Convert.ToDouble(jObject.GetString("PerTrackElapsedTime"));
                _avgTrackRecordList.Add(perTrackElapsedTime);
                ++i;
            }
        }
        catch (Exception e)
        {
            Debug.Log(e.ToString());
            return(false);
        }

        return(true);
    }
Esempio n. 15
0
    void FormatHighscores(string textStream)
    {
        Debug.Log("formathighscores");
        JSONObject results = JSONObject.Parse(textStream);
        JSONArray  query   = results.GetArray("query");

        Debug.Log(query.ToString());

        for (int i = 0; i < query.Length; i++)
        {
            //Debug.Log(query[i].Obj.GetString("player"));
            //Debug.Log(int.Parse(query[i].Obj.GetString("score")));
            //Debug.Log(query[i].Obj.GetString("location"));

            GameObject obj = (GameObject)Instantiate(listLayout);
            obj.SetActive(false);
            Text name    = obj.transform.Find("pl name").GetComponent <Text> ();
            Text score   = obj.transform.Find("pl score").GetComponent <Text> ();
            Text country = obj.transform.Find("country").GetComponent <Text> ();
            name.text    = query [i].Obj.GetString("player");
            score.text   = query [i].Obj.GetNumber("score").ToString();
            country.text = query [i].Obj.GetString("location");
            obj.transform.SetParent(container.transform);
            obj.transform.localScale = new Vector3(1, 1, 1);

            item_list.Add(obj);
        }
        showEntries();
    }
Esempio n. 16
0
    public bool SetTrackRecordInfo(string data)
    {
        _trackRecordList.Clear();
        try
        {
            JSONObject jsonObject = JSONObject.Parse(data);
            JSONArray  jsonArray  = jsonObject.GetArray("response");
            if (jsonArray.Length == 0)
            {
                return(false);
            }

            int i = 0;
            while (i < jsonArray.Length)
            {
                JSONObject jObject           = jsonArray[i].Obj;
                long       trackRecordUnique = System.Convert.ToInt64(jObject.GetString("TrackRecordUnique"));
                long       cardiRecordUnique = System.Convert.ToInt64(jObject.GetString("CardiRecordUnique"));
                int        trackIndex        = System.Convert.ToInt32(jObject.GetString("TrackIndex"));
                int        elapsedTime       = System.Convert.ToInt32(jObject.GetString("ElapsedTime"));

                TrackRecordDBInfo trackRecord = new TrackRecordDBInfo(trackRecordUnique, cardiRecordUnique, trackIndex, elapsedTime);
                _trackRecordList.Add(trackRecord);
                trackRecord.Print();
                ++i;
            }
        }
        catch (Exception e)
        {
            Debug.Log(e.ToString());
            return(false);
        }

        return(true);
    }
Esempio n. 17
0
    public bool SetMuscRecordInfo(string data)
    {
        _muscRecordList.Clear();
        try
        {
            JSONObject jsonObject = JSONObject.Parse(data);
            JSONArray  jsonArray  = jsonObject.GetArray("response");
            if (jsonArray.Length == 0)
            {
                return(true);
            }

            int i = 0;
            while (i < jsonArray.Length)
            {
                JSONObject jObject      = jsonArray[i].Obj;
                long       recordUnique = System.Convert.ToInt64(jObject.GetString("RecordUnique"));
                DateTime   dateTime     = System.Convert.ToDateTime(jObject.GetString("Date"));
                int        count        = System.Convert.ToInt32(jObject.GetString("Count"));

                MuscRecordDBInfo muscRecord = new MuscRecordDBInfo(recordUnique, dateTime, count);
                _muscRecordList.Add(muscRecord);
                muscRecord.Print();
                ++i;
            }
        }
        catch (Exception e)
        {
            Debug.Log(e.ToString());
            return(false);
        }

        return(true);
    }
Esempio n. 18
0
    public bool SetAgileRecordInfo(string data)
    {
        _agileRecordList.Clear();
        try
        {
            JSONObject jsonObject = JSONObject.Parse(data);
            JSONArray  jsonArray  = jsonObject.GetArray("response");
            if (jsonArray.Length == 0)
            {
                return(true);
            }

            int i = 0;
            while (i < jsonArray.Length)
            {
                JSONObject jObject      = jsonArray[i].Obj;
                long       recordUnique = System.Convert.ToInt64(jObject.GetString("RecordUnique"));
                DateTime   dateTime     = System.Convert.ToDateTime(jObject.GetString("Date"));
                int        meter        = System.Convert.ToInt32(jObject.GetString("Meter"));
                int        elapsedTime  = System.Convert.ToInt32(jObject.GetString("ElapsedTime"));

                AgileRecordDBInfo agileRecord = new AgileRecordDBInfo(recordUnique, dateTime, meter, elapsedTime);
                _agileRecordList.Add(agileRecord);
                agileRecord.Print();
                ++i;
            }
        }
        catch (Exception e)
        {
            Debug.Log(e.ToString());
            return(false);
        }

        return(true);
    }
Esempio n. 19
0
    public void recibirMatriz()
    {
        JSONObject jsonO = mensajes.pedirMatriz();
        string     json  = jsonO.ToString();

        setupSocket();
        writeSocket(json);
        string dataIn = readSocket();

        closeSocket();
        if (dataIn != "" || dataIn == null)
        {
            JSONObject matriz = JSONObject.Parse(dataIn);
            try {
                for (int i = 0; i < controlador.obtenerMesas().GetLength(0); i++)
                {
                    string    idMesa = (i + 1).ToString();
                    JSONArray array  = matriz.GetArray("mesa" + idMesa);
                    controlador.obtenerMesas()[i, 0] = array[0].Str;
                    controlador.obtenerMesas()[i, 1] = array[1].Str;
                    controlador.obtenerMesas()[i, 2] = array[2].Str;
                }
            } catch (Exception e) {
                return;
            }
        }
    }
Esempio n. 20
0
    private void deserializeFlags(JSONObject j)
    {
        //get the JSON array that contains the flags data
        JSONArray flagsJS = j.GetArray("FLAGS");

        if ((flagsJS != null) && (flagsJS.Length > 0))
        {
            //iterate through the JS data
            for (int i = 0; i < flagsJS.Length; i++)
            {
                //get the flag key from the first item in the array
                JSONArray flagJS = flagsJS[i].Array;
                string    key    = flagJS[0].Str;

                //is of type boolean?
                if (flagJS[1].Type == JSONValueType.Boolean)
                {
                    GameManager.Instance.Flags.SetFlag(key, flagJS[1].Boolean);
                }

                //is of type number?
                else if (flagJS[1].Type == JSONValueType.Number)
                {
                    GameManager.Instance.Flags.SetFlag(key, flagJS[1].Number);
                }

                //is of type number?
                else if (flagJS[1].Type == JSONValueType.String)
                {
                    GameManager.Instance.Flags.SetFlag(key, flagJS[1].Str);
                }
            }
        }
    }
Esempio n. 21
0
        private void InitCharacters()
        {
            string data = "";

            data = IOManager.ReadData(mFilePath + cCharFileName);
            if (!string.IsNullOrEmpty(data))
            {
                mCharacters.Clear();
                JSONObject obj   = JSONObject.Parse(data);
                JSONArray  array = obj.GetArray(SerializableObject.CHARACTER_LIST);
                foreach (var val in array)
                {
                    PlayerCharacter newChar = null;
                    CharacterGame   game    = (CharacterGame)(int)val.Array[0].Number;
                    switch (game)
                    {
                    case CharacterGame.DnD_3_5:
                        newChar = new DnDCharacter();
                        break;

                    default:
                        break;
                    }
                    if (newChar != null)
                    {
                        newChar.Deserialize(val.Array[1].Obj);
                        mCharacters.Add(newChar);
                    }
                }
            }
        }
Esempio n. 22
0
    public bool SetMissionInfo(string data)
    {
        _schoolMissionList.Clear();
        try
        {
            JSONObject jsonObject = JSONObject.Parse(data);
            JSONArray  jsonArray  = jsonObject.GetArray("response");
            if (jsonArray.Length == 0)
            {
                return(false);
            }

            int i = 0;
            while (i < jsonArray.Length)
            {
                JSONObject          jObject       = jsonArray[i].Obj;
                long                missionUnique = System.Convert.ToInt64(jObject.GetString("MissionUnique"));
                string              missionDesc   = jObject.GetString("MissionDesc");
                SchoolMissionDBInfo mission       = new SchoolMissionDBInfo(missionUnique, missionDesc);
                _schoolMissionList.Add(mission);
                ++i;
            }
        }
        catch (Exception e)
        {
            Debug.Log(e.ToString());
            return(false);
        }

        return(true);
    }
Esempio n. 23
0
        private List <string> ReadStrings(JSONObject jsonObject, string key)
        {
            List <string> list = new List <string>();;

            if (jsonObject.ContainsKey(key))
            {
                JSONArray array = jsonObject.GetArray(key);
                if (array != null)
                {
                    foreach (JSONValue jsonvalue in array)
                    {
                        list.Add(jsonvalue.Str);
                    }
                }
                else
                {
                    string str = jsonObject.GetString(key);
                    if (str != null)
                    {
                        list.Add(str);
                    }
                }
            }
            return(list);
        }
Esempio n. 24
0
        private IEnumerator RemoveAttributeRoutine(string key, Action <string, bool> callback = null)
        {
            CloudLogin.Log("CloudLoginUser Remove Attributes: " + key);

            if (CloudLogin.GetGameId() == null)
            {
                throw new CloudLoginException("Please set up your game with CloudLogin.SetUpGame before modifying users");
            }

            var parameters = "?authentication_token=" + GetAuthenticationToken() + "&game_user_attribute_key=" + key;
            var request    = UnityWebRequest.Get(CloudLogin.GetBaseURL() + "/users/" + CurrentUser.id + "/remove_game_user_attributes" + parameters);

            request.SetRequestHeader("authentication_token", CloudLoginUser.CurrentUser.GetAuthenticationToken());

            yield return(request.SendWebRequest());

            if (CloudLoginUtilities.RequestIsSuccessful(request))
            {
                CloudLogin.Log("CloudLoginUser Remove Attributes Success: " + key);

                var        data = request.downloadHandler.text;
                JSONObject json = JSONObject.Parse(data);
                var        game_user_attributes = json.GetArray("game_user_attributes");

                attributes.Clear();
                foreach (var attribute in game_user_attributes)
                {
                    attributes.Add(attribute.Obj.GetString("key"), attribute.Obj.GetString("value"));
                }
            }

            CloudLoginUtilities.HandleCallback(request, "Attribute has been removed", callback);
        }
Esempio n. 25
0
    /*
     * private void SignIn(){
     *
     *      JSONObject body = new JSONObject();
     *      body.Add("FacebookID", "9876");
     *      body.Add("FacebookName", "Chris");
     *      body.Add("FacebookPhotoURL", "http://www/1.jpg");
     *
     *      HTTPClient.Instance.POST (
     *              "http://unity-action.azurewebsites.net/Login",
     *              body.ToString(),
     *              delegate(WWW obj) {
     *              JSONObject json = JSONObject.Parse(obj.text);
     *              Debug.Log("Response is : " + json.ToString());
     *      }
     *      );
     *
     * }*/

    // Get Ranking list From server
    private void GetRanking()
    {
        HTTPClient.Instance.GET(
            "http://unity-action.azurewebsites.net/Rank/1/50",
            delegate(WWW obj) {
            Debug.Log(obj.text);
            // Dialog Push
            JSONObject result = JSONObject.Parse(obj.text);
            JSONArray jarr    = result.GetArray("Data");

            string rankings = "";
            for (int i = 0; i < jarr.Length; i++)
            {
                rankings += jarr[i].Obj["Rank"] + ". " + jarr[i].Obj.GetString("FacebookName") + " \t\tscore :" + jarr[i].Obj["Point"] + "\n\n";
            }

            DialogDataRanking ranking = new DialogDataRanking("Game Over", StagePoint, rankings, delegate(bool yn) {
                if (yn)
                {
                    Debug.Log("OK Pressed");
                    Application.LoadLevel("Lobby");                              //
                }
                else
                {
                    Debug.Log("Cancel Pressed");
                    Application.Quit();
                }
            });
            DialogManager.Instance.Push(ranking);
        }
            );
    }
Esempio n. 26
0
//start socket
    private void Start()
    {
        //get the sample player

        trans = GameObject.Find("SamplePlayer").GetComponent <Transform> ();


        socket = new SocketIOClient.Client("http://localhost:3000/");          //("http://localhost:3000");//


        socket.On("connect", (fn) => {
            //Debug.Log ("connect - socket");

            //Dictionary<string, string> args = new Dictionary<string, string>();


            //args.Add("zcock", "0");
            //args.Add("xcock", "0");

            //socket.Emit("send message", args);

            //socket.Emit("send message", "yo new socket in town");
        });

        socket.On("allppl", (data) => {
            Debug.Log("cockfucker" + data.Json.ToJsonString());

            //string jot =  JSONObject.Parse(data).ToString();
        });

        socket.On("new pos", (data) => {
            fuckdata        = JSONObject.Parse(data.Json.ToJsonString());
            JSONArray awesa = fuckdata.GetArray("args");
            positionData    = awesa.ToString();         //(string) data.Json.ToJsonString();

            usernamesocket = awesa[0].ToString();

            try{
                if (awesa[1].Obj.GetString("xcock") != null && awesa[1].Obj.GetString("zcock") != null)
                {
                    xman = awesa[1].Obj.GetString("xcock");
                    zman = awesa[1].Obj.GetString("zcock");
                }
            }catch {
            }
        });


        socket.On("new message", (data) => {
            //	Debug.Log ("fukeroo"+ data.ToString());

            fuckdata = JSONObject.Parse(data.Json.ToJsonString());
        });
        socket.Error += (sender, e) => {
            //Debug.Log ("socket Error: " + e.Message.ToString ());
        };
        socket.Connect();
    }            //end
Esempio n. 27
0
    public void InitFromColumnValue(string jsonQueryStr)
    {
        readOnly = true;
        string     jsonResult      = userDao.GetUserByColumnValue(jsonQueryStr);
        JSONObject jsonArrayObject = JSONObject.Parse(jsonResult);
        JSONArray  resArr          = jsonArrayObject.GetArray("results");

        RefreshUserSession((resArr.Length > 0) ? resArr[0].ToString() : "");
    }
  void LoadInboxDataSuccess(JSONObject data) {
    PopupManager.Instance.CloseLoadingPopup();
    ErrorCode.USER errorCode = (ErrorCode.USER)data.GetInt("errorCode");
    if (errorCode == ErrorCode.USER.NULL) {
			if (PopupManager.Instance != null && PopupManager.Instance.PopupInbox != null) {
				PopupManager.Instance.PopupInbox.LoadInboxCallback(data.GetArray("inbox"));
			}
		}
  }
 void LoadLeaderboardDataSuccess(JSONObject data) {
   LeaderboardScreen.Tab selectedTab = (LeaderboardScreen.Tab)data.GetInt("type");
   LeaderboardScreen.SetData( data.GetArray("users"), selectedTab);
   Debug.Log("LoadLeaderboardDataSuccess " + data.ToString());
   if (ScreenManager.Instance.LeaderboardScreen != null) {
     ScreenManager.Instance.LeaderboardScreen.ShowTopPlayer(selectedTab);
   }
   PopupManager.Instance.CloseLoadingPopup();
 }
Esempio n. 30
0
    /* Function for deselecting the previously
     * selected item, and selecting the currently
     * selected item*/
    public void selectItem(int index)
    {
        //Deselecting
        for (int i = 0; i < items.Count; i++)
        {
            if (items[i].Selected)
            {
                items[i].Selected = false;
                itemsData.GetArray("Chars")[i].Obj.GetValue("Selected").Boolean = false;
            }
        }
        //Selecting
        items[index].Selected = true;
        itemsData.GetArray("Chars")[index].Obj.GetValue("Selected").Boolean = true;

        selectedItemIndex = index;
        PlayerPrefs.SetString("Chars", itemsData.ToString());
        PlayerPrefs.Save();
    }
Esempio n. 31
0
    public static JSONArray GetAllRowsFromJson(string jsonStr)
    {
        JSONObject jsonObject = JSONObject.Parse(jsonStr);

        if (jsonObject == null)
        {
            return(null);
        }
        return(jsonObject.GetArray("results"));
    }
Esempio n. 32
0
        protected void DeserializeMainSpells(JSONObject obj)
        {
            mMainSpells.Clear();
            JSONArray array = obj.GetArray(SerializableObject.MAIN_SPELLS);

            foreach (var list in array)
            {
                mMainSpells.Add(DeserializeListWithPair(list.Array));
            }
        }
		public void FromJSON(JSONObject data)
		{
			// clear old values
			Reset();

			JSONArray wasUsedArray = data.GetArray("wasUsed");
			for (int i = 0; i < wasUsedArray.Length; i++)
			{
				wasUsed.Add((int)wasUsedArray[i].Number);
			}
		}
Esempio n. 34
0
 void LoadLeaderboardDataSuccess(JSONObject data)
 {
     LeaderboardScreen.Tab selectedTab = (LeaderboardScreen.Tab)data.GetInt("type");
     LeaderboardScreen.SetData(data.GetArray("users"), selectedTab);
     Debug.Log("LoadLeaderboardDataSuccess " + data.ToString());
     if (ScreenManager.Instance.LeaderboardScreen != null)
     {
         ScreenManager.Instance.LeaderboardScreen.ShowTopPlayer(selectedTab);
     }
     PopupManager.Instance.CloseLoadingPopup();
 }
Esempio n. 35
0
	public void update(JSONObject json, bool all = false)
    {
        is_connected = true;
        id = (int)json.GetNumber("id");
        username = json.GetString("username");
        email = json.GetString("email");
        score = (int)json.GetNumber("score");
        room = json.GetString("room");

        if (!json.ContainsKey("friends"))
        {
            this.friends = new Friends();
            return;
        } // Info private
        phi = (int)json.GetNumber("phi");
		if (all)
			ProcessSwungMens(json.GetArray("swungmens"));


        // -- Friends
        JSONArray friends = json.GetArray("friends");
        this.friends = new Friends(friends);
	}
Esempio n. 36
0
	public void Init(JSONObject jsonData) {
		roomId = jsonData.GetString("roomId");
		userGames.Clear();
		JSONArray userGameArray = jsonData.GetArray("userGames");

		for (int i = 0; i < userGameArray.Length; i++) {
			userGames.Add(new TLMBGame(userGameArray[i].Obj));
		}

		droppedCards = new TLMBCombination(jsonData.GetString("droppedCards"));
		roundDroppedCards = new TLMBCombination(jsonData.GetString("roundDroppedCards"));
		activeUserSeatIndex = jsonData.GetInt("activeUserSeatIndex");
		state = (State)jsonData.GetInt("state");
		gameConfig = new TLMBGameConfig(jsonData.GetObject("gameConfig"));
		remainingSeconds = jsonData.GetInt("remainingSeconds");
	}
Esempio n. 37
0
		protected void DeserializeMainSpells(JSONObject obj)
		{
			mMainSpells.Clear();
			JSONArray array = obj.GetArray(SerializableObject.MAIN_SPELLS);
			foreach (var list in array)
			{
				mMainSpells.Add(DeserializeListWithPair(list.Array));
			}
		}
Esempio n. 38
0
		public override void Load( JSONObject obj )
		{
			Disabled	= obj.GetArray<Point>			("disabled");
			GoalWindows = obj.GetArray<GoalWindowInfo>	("goalWindows");
		}
Esempio n. 39
0
    public static SPServerMessage from_json(JSONObject jso)
    {
        SPServerMessage rtv = new SPServerMessage();

        JSONArray players = jso.GetArray(SN.PLAYERS);
        foreach(JSONValue v in players) {
            rtv._players.Add(SPPlayerObject.from_json(v.Obj));
        }

        JSONArray bullets = jso.GetArray(SN.BULLETS);
        foreach(JSONValue v in bullets) {
            rtv._bullets.Add(SPBulletObject.from_json(v.Obj));
        }

        JSONArray events = jso.GetArray(SN.EVENTS);
        foreach(JSONValue v in events) {
            rtv._events.Add(SPEvent.from_json(v.Obj));
        }

        return rtv;
    }
Esempio n. 40
0
    public static SPClientMessage from_json(JSONObject jso)
    {
        SPClientMessage rtv = new SPClientMessage();

        JSONArray bullets = jso.GetArray(SN.BULLETS);
        foreach(JSONValue v in bullets) {
            rtv._bullets.Add(SPBulletObject.from_json(v.Obj));
        }

        rtv._player = SPPlayerObject.from_json(jso.GetObject(SN.PLAYER));

        return rtv;
    }
 private static Player getPlayer(JSONObject obj)
 {
     JSONArray array = obj.GetArray ("levels");
     Dictionary<string,LevelData> levels = new Dictionary<string, LevelData> ();
     for (int i =0; i < array.Length; i++) {
         JSONObject lvl = array [i].Obj;
         LevelData lData = getLevelData (lvl);
         levels.Add (lData.Id, lData);
     }
     return new Player ((int)obj.GetNumber("id"), obj.GetString("name"), levels);
 }
Esempio n. 42
0
		protected void DeserializeKnownSpells(JSONObject obj)
		{
			mKnownSpells.Clear();
			JSONArray array = obj.GetArray(SerializableObject.KNOWN_SPELLS);
			foreach (var list in array)
			{
				List<Spell> rankList = new List<Spell>();
				foreach(var listObj in list.Array)
				{
					Spell spell = new Spell();
					spell.Deserialize(listObj.Obj);
					rankList.Add(spell);
				}
				mKnownSpells.Add(rankList);
			}
		}
        //retrive all assets in a container
        private IEnumerator RetrieveAsset(string containerID, string assetID)
        {
            string url = this.endpoint + containerID + "/all";

            isResetting = true;

            JSONObject containerJSON = new JSONObject();

            //add container
            if (!this.containers.ContainsKey(containerID)){
                Container container = new Container();
                this.containers.Add(containerID, container);
            }

            //validate credentials
            if (this.accessKey == null || this.secretKey == null) {
                throw new System.MemberAccessException("missing credentials");
            }
            //#if UNITY_IPHONE
            //
            //			float timeOut = Time.time + requestTimeout;
            //			var request = new HTTP.Request("GET", url);
            //			request.SetHeader("Authorization", "Basic " + System.Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(this.accessKey + ":" + this.secretKey)));
            //			request.Send();
            //			while(!request.isDone && Time.time <= timeOut)
            //			{
            //				yield return new WaitForEndOfFrame();
            //			}
            //			if (!request.isDone){ //if request is not done before timeout
            //				yield break;
            //			}
            //			if (request.exception!=null){ // check internet connection
            //				Debug.Log(request.exception);
            //				yield break;
            //			} else {
            //				var response = request.response;
            //				//inspect response code
            //				Debug.Log(response.status);
            //				//inspect headers
            //				Debug.Log(response.GetHeader("Content-Type"));
            //				//Get the body as a byte array
            //				//Debug.Log(response.bytes);
            //				//Or as a string
            //				Debug.Log(response.Text);
            //
            //				containerJSON = JSONObject.Parse(response.Text);
            //			}
            //
            //
            //
            //#else

            Hashtable headers = new Hashtable();
            headers["Authorization"] = "Basic " +
                System.Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(
                    this.accessKey + ":" + this.secretKey));
            WWW www = new WWW(url, null, headers);
            yield return www;
            if (!String.IsNullOrEmpty(www.error)) { //check internet connection
                yield break;
            }
            containerJSON = JSONObject.Parse(www.text);

            //#endif

            //adding assets
            for (int i = 0; i < containerJSON.GetArray("Assets").Length; i++){

                JSONObject assetJSON = JSONObject.Parse(containerJSON.GetArray("Assets")[i].ToString());

                Asset asset = new Asset();
                string currentAssetID = assetJSON.GetString("AssetID");
                if (!this.containers[containerID].assets.ContainsKey(currentAssetID)){
                    this.containers[containerID].assets.Add(currentAssetID, asset);
                }
                Debug.Log ("--- New asset: " + currentAssetID + " ---");

                //adding attributes
                foreach (var keyValuePair in assetJSON.values) {
                    if (keyValuePair.Value.Type == JSONValueType.Object){ //this is how we know if the pair is an attribute pair and not meta data
                        string attributeName = keyValuePair.Key;

                        if (!this.containers[containerID].assets[currentAssetID]
                            .attributes.ContainsKey(attributeName)){

                            JSONObject attributeJSON = JSONObject.Parse(keyValuePair.Value.ToString());
                            //process attributes based on Type
                            string type = attributeJSON.GetString("Type");
                            switch (type)
                            {
                            case "URL":
                            case "FILE":
                            case "STRING":
                                string value = attributeJSON.GetString ("Value");
                                this.containers[containerID].assets[currentAssetID]
                                .attributes.Add(attributeName, value);
                                Debug.Log (attributeName + " : "
                                           + this.containers[containerID]
                                           .assets[currentAssetID]
                                           .attributes[attributeName]);
                                break;
                            case "IMAGE":
                                string imageURL = attributeJSON.GetString ("Value");
                                WWW imageObject = new WWW(imageURL);
                                yield return imageObject;
                                Texture2D image = new Texture2D(imageObject.texture.width, imageObject.texture.height);
                                imageObject.LoadImageIntoTexture(image);
                                this.containers[containerID].assets[currentAssetID]
                                .attributes.Add(attributeName, image);
                                Debug.Log (attributeName + " : "
                                           + this.containers[containerID]
                                           .assets[currentAssetID]
                                           .attributes[attributeName]);
                                break;
                            case "NUMBER":
                                double number = attributeJSON.GetNumber("Value");
                                this.containers[containerID].assets[currentAssetID]
                                .attributes.Add(attributeName, number);
                                Debug.Log (attributeName + " : "
                                           + this.containers[containerID]
                                           .assets[currentAssetID]
                                           .attributes[attributeName]);
                                break;
                            case "NUMBER_ARRAY":
                                int numberArrayLength = attributeJSON.GetArray("Value").Length;
                                double[] number_array = new double[numberArrayLength];
                                for (int j = 0; j<numberArrayLength ;j++){
                                    number_array[j] = attributeJSON.GetArray("Value")[j].Number ;
                                }
                                this.containers[containerID].assets[currentAssetID]
                                .attributes.Add(attributeName, number_array);
                                break;
                            case "STRING_ARRAY":
                                int stringArrayLength = attributeJSON.GetArray("Value").Length;
                                string[] string_array = new string[stringArrayLength];
                                for (int k = 0; k<stringArrayLength ;k++){
                                    string_array[k] = attributeJSON.GetArray("Value")[k].Str ;
                                }
                                this.containers[containerID].assets[currentAssetID]
                                .attributes.Add(attributeName, string_array);
                                break;
                            }
                        }
                    }
                }
            }

            //trigger event OnLoaded
            if (OnLoaded != null) {
                OnLoaded(this.containers[containerID].assets[assetID]);
            }

            isResetting = false;
        }
Esempio n. 44
0
		public override void Deserialize(JSONObject obj)
		{
			mName = obj.GetString(NAME);
			mGender = (CharacterGender)(int)obj.GetNumber(GENDER);
			mExperience = (int)obj.GetNumber(EXPERIENCE);
			mAvatar = obj.GetString(AVATAR);
			mAlignment = (DnDAlignment)(int)obj.GetNumber(ALIGNMENT);
			mRace = (DnDRace)(int)obj.GetNumber(RACE);
			mAge = (int)obj.GetNumber(AGE);
			if (obj.ContainsKey(DEITY))
			{
				mDeity = new DnDDeity();
				mDeity.Deserialize(obj.GetObject(DEITY));
			}
			mSize = (DnDCharacterSize)(int)obj.GetNumber(SIZE);
			// souls:
			JSONObject jSouls = obj.GetObject(CLASS_SOULS);
			var classes = Enum.GetValues(typeof(DnDCharClass)).Cast<DnDCharClass>();
			foreach (DnDCharClass charClass in classes)
			{
				if (jSouls.ContainsKey(charClass.ToString()))
				{
					if (!string.IsNullOrEmpty(jSouls.GetObject(charClass.ToString()).ToString()))
					{
						DnDClassSoul newSoul = null;
						switch (charClass)
						{
							case DnDCharClass.Wizard:
								newSoul = new DnDWizard(this);
								break;
							default:
								break;
						}
						if (newSoul != null)
						{
							newSoul.Deserialize(jSouls.GetObject(charClass.ToString()));
							mClasses.Add(newSoul);
						}
					}
				}
			}
			// abilities:
			JSONArray tempArray = obj.GetArray(ABILITIES);
			foreach (var val in tempArray)
			{
				mAbilities[(DnDAbilities)((int)val.Array[0].Number)] = (int)val.Array[1].Number;
			}
		}
Esempio n. 45
0
		public override void Deserialize(JSONObject obj)
		{
			Name = obj.GetString(NAME);
			AlternativeNames = new List<string>();
			JSONArray tempArray = obj.GetArray(cAltNames);
			foreach (var val in tempArray)
			{
				AlternativeNames.Add(val.Str);
			}
			Alignment = (DnDAlignment)(int)obj.GetNumber(ALIGNMENT);
			WorshippingRaces = new List<DnDRace>();
			tempArray = obj.GetArray(cRaces);
			foreach (var val in tempArray)
			{
				WorshippingRaces.Add((DnDRace)(int)val.Number);
			}
			WorshippingClasses = new List<DnDCharClass>();
			tempArray = obj.GetArray(cClasses);
			foreach (var val in tempArray)
			{
				WorshippingClasses.Add((DnDCharClass)(int)val.Number);
			}
			Domains = new List<DnDClericDomain>();
			tempArray = obj.GetArray(cDomains);
			foreach (var val in tempArray)
			{
				Domains.Add((DnDClericDomain)(int)val.Number);
			}
		}
Esempio n. 46
0
		public override void Deserialize(JSONObject obj)
		{
			mClassLevel = (int)obj.GetNumber(LEVEL);
			DeserializeKnownSpells(obj);
			DeserializeMainSpells(obj);
			DeserializeExtraSpells(obj);
			mSkills = new DnDSkillModel();
			mSkills.Deserialize(obj.GetObject(SKILLS));
			// spec:
			JSONArray tempArray = obj.GetArray(SPECIALIZATION);
			for (int i = 0; i < tempArray.Length; ++i)
			{
				if (i == 0) // first item is the specialization
				{
					mSpecialization = (DnDMagicSchool)((int)tempArray[i].Number);
				}
				else // the other items are the forbidden schools
				{
					mForbiddenSchools.Add((DnDMagicSchool)((int)tempArray[i].Number));
				}
			}
		}
	public SpinData(string username, JSONObject jsonData, bool isYou) {
		Debug.Log("SpinData: " + jsonData.ToString());
		this.isYou = isYou;
		this.username = username;
		JSONArray resultsData = jsonData.GetArray("items");
		JSONObject extraData = SlotCombination.CalculateCombination(resultsData, jsonData.GetInt("nL"));
	  JSONArray winningCount = extraData.GetArray("wCount");  
	  JSONArray winningType = extraData.GetArray("wType");
    JSONArray winningGold = jsonData.GetArray("wGold");
		
    for (int i = 0; i < winningGold.Length; i++) {
      totalDamage += (int)winningGold[i].Number;
    }
		
		if (jsonData.ContainsKey("newBoss")) {
			newBossData = jsonData.GetObject("newBoss");
			JSONArray bossDrops = jsonData.GetArray("dropItems");
			dropCash = (int)bossDrops[0].Number;
			dropGem = (int)bossDrops[1].Number;
			bossDrops = null;
			AccountManager.Instance.bossKilled++;
		}
		

		for (int i = 0; i < winningCount.Length; i++) {
			if (winningCount[i].Number >= 3 || ((int)winningType[i].Number == (int)SlotItem.Type.TILE_1 && winningCount[i].Number >= 2)) {
				spawnSkills.Add(new SpawnableSkill((int)winningType[i].Number, (int)winningCount[i].Number, (int)winningGold[i].Number, isYou));
			}
		}
		extraData = null;
		resultsData = null;
		winningCount = null;
		winningType = null;
		winningGold = null;
	}
Esempio n. 48
0
		protected void DeserializeExtraSpells(JSONObject obj)
		{
			JSONArray array = obj.GetArray(SerializableObject.EXTRA_SPELLS);
			mExtraSpells = DeserializeListWithPair(array);
		}