/// <summary> /// 拆分听牌数据,让每行的牌数合理 /// </summary> /// <param name="cardkey"></param> private void SortServDataInfo(int cardkey) { if (_huqueryCacheList.ContainsKey(cardkey)) { var hulistCache = _huqueryCacheList[cardkey].GetSFSArray(_keyHulist); ISFSArray sfsArray = new SFSArray(); foreach (ISFSObject obj in hulistCache) { var sfsobj = new SFSObject(); var cardsOrg = obj.GetIntArray(_keyCards); var legalCadList = new List <int>(); foreach (var cd in cardsOrg) { if (D2MahjongMng.Instance.IsContainMahjongMeKey(cd)) { legalCadList.Add(cd); } } var tai = obj.GetInt(_keyTai); var hua = obj.GetInt(_keyHua); var cnt = obj.GetInt(_keyCnt); sfsobj.PutIntArray(_keyCards, legalCadList.ToArray()); sfsobj.PutInt(_keyTai, tai); sfsobj.PutInt(_keyHua, hua); sfsobj.PutInt(_keyCnt, cnt); sfsArray.AddSFSObject(sfsobj); } _huqueryCacheList[cardkey].PutSFSArray(_keyHulist, sfsArray); } }
public void RefreshPlayerList(string[] sArray) { ISFSArray pingData = new SFSArray(); for (int i = 0; i < sArray.Length; i++) { string[] data = sArray[i].Split(','); ISFSObject obj = new SFSObject(); obj.PutUtfString("name", data[0]); obj.PutLong("ttgold", long.Parse(data[1])); pingData.AddSFSObject(obj); } RefreshPlayerList(pingData); }
public void broadcastPositions() { if(Time.time-lastBroadcastTime>MIN_TIME_BETWEEN_BROADCAST) { SFSObject o = new SFSObject(); SFSArray h = new SFSArray(); for(int i = 0;i<this.sortedHorses.Count;i++) { if(sortedHorses[i].currentPoint==null) return; h.AddSFSObject(sortedHorses[i].dataPackage); } o.PutSFSArray("a",h); o.PutInt("f",this.framesPassed); SmartfoxConnectionHandler.REF.sendRaceMessage("b",o); lastBroadcastTime = Time.time; } }
public void Write(int chair) { SFSArray array = SFSArray.NewInstance(); foreach (CpgSaveData saveData in _saveList[chair]) { ISFSObject obj = new SFSObject(); obj.PutInt(CpgType, (int)saveData.type); obj.PutIntArray(CpgValue, saveData.value); obj.PutInt(CpgIndex, saveData.index); array.AddSFSObject(obj); } string key = SaveDataKey + chair; PlayerPrefs.SetString(key, array.ToJson()); }
public void OnClickOkBtn() { ISFSObject obj = new SFSObject(); ISFSArray arr = new SFSArray(); string errorMsg = string.Empty; if (_lastChoiseItem != null && _lastChoiseItem.Special > 0) { obj.PutInt("special", _lastChoiseItem.Special); } else { if (!NoDaoShui(_lastList, ref errorMsg)) { YxMessageBox.Show(new YxMessageBoxData() { Msg = errorMsg, Delayed = 3, }); YxDebug.Log("不能倒水"); return; } } int beginIndex = 0; for (int i = 0; i < 3; i++) { int count = i == 0 ? 3 : 5; List <int> tempList = _lastList.GetRange(beginIndex, count); ISFSObject arrItem = new SFSObject(); arrItem.PutInt("type", (int)CheckCardType(tempList, i)); Help1.SortList(tempList); arrItem.PutIntArray("cards", tempList.ToArray()); arr.AddSFSObject(arrItem); beginIndex += count; } obj.PutSFSArray("duninfo", arr); obj.PutInt("type", GameRequestType.FinishChoise); App.GetRServer <SssGameServer>().SendGameRequest(obj); }
public void OnClickOkBtn() { ISFSObject obj = new SFSObject(); ISFSArray arr = new SFSArray(); if (_selectInfo != null && _selectInfo.CardType > CardType.none) { obj.PutInt("special", (int)_selectInfo.CardType); } else { string errorMsg = string.Empty; if (CheckIsDaoShui(ref errorMsg)) { YxMessageBox.Show(new YxMessageBoxData() { Msg = errorMsg, Delayed = 3, }); YxDebug.Log("不能倒水"); return; } } for (int i = 0; i < 3; i++) { var lineInfo = Lines[i].LineInfo; ISFSObject arrItem = new SFSObject(); arrItem.PutInt("type", (int)lineInfo.CardType); var tempList = lineInfo.Dun.Cards; Help1.SortList(tempList, false); arrItem.PutIntArray("cards", tempList.ToArray()); arr.AddSFSObject(arrItem); } obj.PutSFSArray("duninfo", arr); //发送到服务器 obj.PutInt("type", GameRequestType.FinishChoise); App.GetRServer <SssGameServer>().SendGameRequest(obj); }
public void updateXPData() { SFSArray sfsArray = new SFSArray(); SFSObject r = new SFSObject(); r.PutDouble("Sp",this.speed); r.PutDouble("Ac",this.accelerationBase); r.PutDouble("Ju",this.jumping); r.PutDouble("St",this._stamina); r.PutDouble("Re",this.recovery); r.PutDouble("Sl",this.stridelength); r.PutDouble("Ca",this.cadence); r.PutDouble("De",this.determination); r.PutDouble("XP",this.xp); r.PutInt("L",this.level); r.PutInt("RT",this.trainingReturnTime); r.PutInt("H",this.hunger); r.PutInt("F",this.fatigue); r.PutDouble("Ha",this.happiness); // Now double instead of int r.PutDouble("Ho",this.horseScore); // Now double instead of int r.PutDouble("Ma",this.maxMPH); r.PutInt("ID",this.horseID); sfsArray.AddSFSObject(r); SmartfoxConnectionHandler.REF.sendHorsesArray("h_xp",sfsArray); }
public override SFSObject toSFSObject() { SFSObject taskObject = new SFSObject (); taskObject.PutLong ("id_Task", this.getId_Task ()); taskObject.PutUtfString ("descripcion", this.getDescripcion ()); taskObject.PutUtfString ("responsable", this.getResponsable ()); taskObject.PutInt ("t_Estimado", this.getT_Estimado ()); taskObject.PutInt ("t_Total", this.getT_Total ()); taskObject.PutUtfString ("estado", this.getEstado ()); taskObject.PutInt ("prioridad", this.getPrioridad ()); taskObject.PutLong ("id_Story", this.getId_Story ()); taskObject.PutUtfString ("titulo", this.getTitulo ()); SFSArray t = new SFSArray (); foreach (long l in idTests) { SFSObject tsfs=new SFSObject(); tsfs.PutLong("Id_Test", l); t.AddSFSObject(tsfs); } taskObject.PutSFSArray ("testsAsociados", t); //taskObject.pua //private ArrayList listaBurnDown; return taskObject; }
private void sendBlockDataSFSMessage(object sender, DoWorkEventArgs e) { var blocks = e.Argument as List<float[]>; var obj = new SFSObject(); obj.PutUtfString("type", "sync"); var blocksArray = new SFSArray(); foreach (var block in blocks) { var blockData = new SFSObject(); blockData.PutFloatArray("position", new[] {block[0], block[1]}); blockData.PutFloatArray("velocity", new[] {block[2], block[3]}); blocksArray.AddSFSObject(blockData); } obj.PutSFSArray("blocks", blocksArray); smartFox.Send (new ObjectMessageRequest(obj)); }
public SFSArray getListaCriteriosToSFSArray() { SFSArray listaCriteriosArray=new SFSArray(); foreach(AcceptanceCriteria ac in this.getListaAcceptanceCriteria()) listaCriteriosArray.AddSFSObject(ac.toSFSObject()); return listaCriteriosArray; }
public SFSArray getListaTareasToSFSArray() { SFSArray listaTareasArray=new SFSArray(); foreach(Task tarea in this.getListaTareas()) listaTareasArray.AddSFSObject(tarea.toSFSObject()); return listaTareasArray; }
public SFSArray getListaEstimacionToSFSArray() { SFSArray listaEstimacionArray=new SFSArray(); foreach(Estimacion est in this.getListaEstimacion()) listaEstimacionArray.AddSFSObject(est.toSFSObject()); return listaEstimacionArray; }
public SFSArray getListaStoriesToSFSArray() { SFSArray listaStoriesArray=new SFSArray(); foreach(UserStory story in this.getListaStories()) listaStoriesArray.AddSFSObject(story.toSFSObject()); return listaStoriesArray; }
private void SendCubesDataToServer(List<Vector3> cubePosList, List<Vector3> cubeRotList) { List<RoomVariable> roomVars = new List<RoomVariable>(); SFSArray array = new SFSArray(); SFSObject sfsObject; for (int i = 0; i < cubeList.Count; i++) { sfsObject = new SFSObject(); sfsObject.PutInt("id", i); int[] sides= {-1,-1,-1,-1,-1,-1}; sfsObject.PutIntArray("sides", sides); sfsObject.PutFloat("x",cubePosList[i].x); sfsObject.PutFloat("y", cubePosList[i].y); sfsObject.PutFloat("z", cubePosList[i].z); sfsObject.PutFloat("rx", cubeRotList[i].x); sfsObject.PutFloat("ry", cubeRotList[i].y); sfsObject.PutFloat("rz", cubeRotList[i].z); array.AddSFSObject(sfsObject); } Debug.Log("sending room"); roomVars.Add(new SFSRoomVariable("cubesInSpace", array)); smartFox.Send(new SetRoomVariablesRequest(roomVars)); }
void OnResponse(BaseEvent eventParam) { if (false) { Console.WriteLine("OnResponse : " + eventParam.Type); foreach (var kvp in eventParam.Params) { Console.WriteLine("\t" + kvp.Key + " : " + kvp.Value); } } var varst = (SFSObject)eventParam.Params["params"]; //Console.WriteLine(varst.GetDump()); Task.Run(() => { var vars = (SFSObject)eventParam.Params["params"]; var array = eventParam.Params["cmd"].ToString().Split('.'); var text = array[0]; if (text == "Chat") { Console.WriteLine(text); } else if (text == "TemtemWelfare") { Console.WriteLine(text); } else if (text == "PA") { Console.WriteLine(text); } else if (text == "GameStart") { if (vars.ContainsKey("inbattle")) { InBattle = vars.GetBool("inbattle"); } GameStarted = true; X = vars.GetFloat("x"); Y = vars.GetFloat("z"); //Thread.Sleep(700); SFClient.Send(new LogoutRequest()); //Task.Run(() => { SFClient.Send(new LogoutRequest()); }); } else if (text == "Monsters") { Console.WriteLine(text); } else if (text == "PickAndBan") { Console.WriteLine(text); } else if (text == "Notifications") { Console.WriteLine(text); } else if (text == "UCP") { Console.WriteLine(text); } else if (text == "Coop") { Console.WriteLine(text); } else if (text == "Friends") { Console.WriteLine(text); } else if (text == "Gameplay") { //Console.WriteLine(text); } else if (text == "Battle") { if (array.Length > 1) { if (array[1] == "CurrentState") { var enemies = vars.GetSFSArray("aiMon"); var count = 0; foreach (temtem.networkserialized.NetworkMonster monster in enemies) { if (monster == null) { continue; } count++; } if (!fleed) { battleTicks.Add(Environment.TickCount); battleTimes.Add(battleTicks.Last() - battleTicks[battleTicks.Count - 2]); Console.WriteLine(DateTime.Now + " : new battle, last battle time " + (battleTimes.Last() / 1000.0f) + ", average time " + battleTimes.Average() / 1000.0f); fleed = true; while (fleeBug) { } fleeBug = true; fleeThread = new Thread(() => { while (fleeBug) { if (!SFClient.IsConnected) { SFClient.KillConnection(); Console.WriteLine("reseting"); Thread.Sleep(2000); return; } var actype4 = new SFSObject(); actype4.PutByte("actype", 4); SFClient.Send(new ExtensionRequest("battle", actype4)); SFClient.Send(new ExtensionRequest("battle", actype4)); var aioArray = new SFSArray(); for (Byte i = 0; i < count; i++) { var aioObj = new SFSObject(); aioObj.PutByte("slot", (Byte)(64 + i)); aioObj.PutByte("techI", i); aioObj.PutByte("actype", 0); aioArray.AddSFSObject(aioObj); } var aio = new SFSObject(); aio.PutSFSArray("aiO", aioArray); Thread.Sleep(2500); if (fleeBug) { SFClient.Send(new ExtensionRequest("battle", aio)); } Thread.Sleep(1000); } }); fleeThread.Start(); } foreach (temtem.networkserialized.NetworkMonster monster in enemies) { if (monster == null) { continue; } var monsterCache = Temtems.AllTemtems[monster.monsterNumber]; Console.WriteLine(" " + monsterCache.name + " (lvl" + monster.level + ") : " + (monster.luma ? "Shiny" : "Normal") + " : " + (monster.gender ? "Female" : "Male")); } } if (array[1] == "BattleFinished") { fleeBug = false; InBattle = false; fleed = false; //Thread.Sleep(2000); SFClient.Send(new LogoutRequest()); } if (array[1] == "BattleTurnResult") { if (vars.ContainsKey("result")) { var result = vars.GetSFSArray("result"); foreach (SFSObject r in result) { if (r.GetBool("runres")) { //Console.WriteLine("run success"); } //Console.WriteLine("run fail"); } } else { Console.WriteLine("no result"); } } } } else if (text == "Inventory") { Console.WriteLine(text); } else if (text == "PromoCode") { Console.WriteLine(text); } else if (text == "UPP") { //Console.WriteLine(text); } else if (text == "Movement") { Console.WriteLine(text); } else if (text == "Breeding") { Console.WriteLine(text); } else if (text == "World") { if (!trigger) { trigger = true; /*Task.Run(() => * { * System.Threading.Thread.Sleep(1000); * Login(); * }); * Task.Run(() => * { * System.Threading.Thread.Sleep(2000); * SFClient.Send(new ExtensionRequest("joinRoom", new SFSObject())); * });*/ } Console.WriteLine(text); } else if (text == "SetNickname") { Console.WriteLine(text); } else if (text == "Trade") { Console.WriteLine(text); } else if (text == "PCControl") { Console.WriteLine(text); } else { Console.WriteLine("unk : " + text); } }); }
private void SendCubesDataToServer(List<Vector3> cubePosList, List<Vector3> cubeRotList) { //pass cubes by room var List<RoomVariable> roomVars = new List<RoomVariable>(); //list of cubes to pass to server SFSArray map = new SFSArray(); SFSObject sfsObject; //convert each cube to a server passible object for (int i = 0; i < cubeList.Count; i++) { sfsObject = new SFSObject(); sfsObject.PutInt("id", i); int[] sides; if (i < numberOfTeams) { sides = new int[] {i, i, i, i, i, i}; } else { sides = new int[] { -1, -1, -1, -1, -1, -1 }; } sfsObject.PutIntArray("sides", sides); sfsObject.PutFloat("x",cubePosList[i].x); sfsObject.PutFloat("y", cubePosList[i].y); sfsObject.PutFloat("z", cubePosList[i].z); sfsObject.PutFloat("rx", cubeRotList[i].x); sfsObject.PutFloat("ry", cubeRotList[i].y); sfsObject.PutFloat("rz", cubeRotList[i].z); map.AddSFSObject(sfsObject); } Debug.Log("sending room"); roomVars.Add(new SFSRoomVariable("cubesInSpace", map)); smartFox.Send(new SetRoomVariablesRequest(roomVars)); }
public SFSArray getListaTestToSFSArray() { SFSArray listaTestsArray=new SFSArray(); foreach(Test t in this.getAssociatedTests()) listaTestsArray.AddSFSObject(t.toSFSObject()); return listaTestsArray; }