private void UpdateUserData() { if (_isUpdataUserDateFlag < 2) { return; } _isUpdataUserDateFlag = 1; _win = _userData.ContainsKey(InteractParameter.Gold) ? _userData.GetInt(InteractParameter.Gold) : 0; NameLabel.text = _userData.GetUtfString(InteractParameter.Nick); SetWinText(_win); var cards = _userData.GetIntArray(InteractParameter.Cards); var count = cards.Length < Cards.Count ? cards.Length : Cards.Count; var z = _userData.GetBool(InteractParameter.IsZ); ZhuangObj.gameObject.SetActive(z); ZhuangRate.text = z ? _userData.GetUtfString(InteractParameter.ZhuangData) : ""; for (var i = 0; i < count; i++) { Cards[i].GetComponent <UISprite>().spriteName = "0x" + cards[i].ToString("X"); } var nd = _userData.GetSFSObject(InteractParameter.NiuData); NiuRate.text = "x" + nd.GetInt(InteractParameter.Rate); if (z || nd.GetBool(InteractParameter.IsWin)) { NiuRate.color = new Color32(255, 255, 255, 255); } else { NiuRate.color = new Color32(0, 240, 2, 255); } NiuLabel.text = GetNiuName(nd); }
protected override void InitGameData(ISFSObject gameInfo) { OwnerId = gameInfo.ContainsKey("ownerId") ? gameInfo.GetInt("ownerId") : -1; _rule = gameInfo.ContainsKey("rule") ? gameInfo.GetUtfString("rule") : ""; IsGameStart = gameInfo.ContainsKey(RequestKey.KeyPlaying) && gameInfo.GetBool(RequestKey.KeyPlaying); _rejoin = gameInfo.ContainsKey("rejoin") && gameInfo.GetBool("rejoin"); if (IsGameStart && _rejoin) { _color1 = gameInfo.GetIntArray("color1"); _color2 = gameInfo.GetIntArray("color2"); _color3 = gameInfo.GetIntArray("color3"); _color4 = gameInfo.GetIntArray("color4"); _curSpeaker = gameInfo.ContainsKey("curP") ? gameInfo.GetInt("curP") : -1; _cd = gameInfo.ContainsKey("cd") ? gameInfo.GetInt("cd") : -1; _st = gameInfo.ContainsKey("st") ? gameInfo.GetLong("st") : -1; _ct = gameInfo.ContainsKey("ct") ? gameInfo.GetLong("ct") : -1; _hup = gameInfo.ContainsKey("hup") ? gameInfo.GetUtfString("hup") : ""; _svt = gameInfo.ContainsKey("svt") ? gameInfo.GetLong("svt") : 0; _hupstart = gameInfo.ContainsKey("hupstart") ? gameInfo.GetLong("hupstart") : 0; _killDragon = gameInfo.ContainsKey("killDragon") ? gameInfo.GetBoolArray("killDragon") : null; _isDragon = gameInfo.ContainsKey("isDragon") ? gameInfo.GetBoolArray("isDragon") : null; } }
public void fromSFSObject(ISFSObject estimacion) { user = estimacion.GetUtfString("user"); valorEstimacion = estimacion.GetFloat("valorEstimacion"); descripcion = estimacion.GetUtfString("descripcion"); id_UserStory = estimacion.GetLong("id_Story"); }
/// <summary> /// 设置庄家信息 /// </summary> public void SetBankerInfo(ISFSObject data) { YxBaseGameUserInfo bankerInfo = null; if (data == null) { bankerInfo = new YxBaseGameUserInfo { NickM = "系统", CoinA = 1147483647, Seat = -1, TotalCount = 0, WinTotalCoin = 0 }; Banker.SetMaxCoin(1147483646); Banker.Info = bankerInfo; } else { var newBanker = new YxBaseGameUserInfo(); newBanker.Parse(data); newBanker.NickM = data.GetUtfString("username"); var oldBnaker = Banker.Info; if (oldBnaker == null || oldBnaker.NickM != newBanker.NickM) { YxDebug.Log("重置庄家信息!!"); newBanker.NickM = data.GetUtfString("username"); newBanker.CoinA = data.GetLong("ttgold"); newBanker.TotalCount = 0; newBanker.WinTotalCoin = 0; bankerInfo = newBanker; Banker.Info = bankerInfo; } } }
private void OnLogin(BaseEvent evt) { User user = (User)evt.Params["user"]; Debug.Log("Hello" + user.Name); if (sfs.RoomList.Count > 0) { sfs.Send(new JoinRoomRequest(sfs.RoomList[0].Name)); Debug.Log(sfs.RoomList[0].Name); } ISFSObject data = (ISFSObject)evt.Params["data"]; if (data != null) { username = data.GetUtfString(SF.USERNAME); mess = data.GetUtfString(SF.MESS); Debug.Log(username + "Thong Bao: " + mess); //SceneManager.LoadScene("Game"); } else { Debug.Log("OnLogin khong co thong bao"); } }
private void JustSetGpsData(UserInfoStruct userinfoStruct, ISFSObject userData) { if (userData.ContainsKey("ip")) { userinfoStruct.Ip = userData.GetUtfString("ip"); } if (userData.ContainsKey("country")) { userinfoStruct.Country = userData.GetUtfString("country"); } //获取gpsx; gpsy if ((userData.ContainsKey("gpsx") && userData.ContainsKey("gpsy")) || (userData.ContainsKey("x") && userData.ContainsKey("y"))) { userinfoStruct.GpsX = userData.ContainsKey("gpsx") ? userData.GetFloat("gpsx") : userData.GetFloat("x"); userinfoStruct.GpsY = userData.ContainsKey("gpsy") ? userData.GetFloat("gpsy") : userData.GetFloat("y"); } else { userinfoStruct.GpsX = -1f; userinfoStruct.GpsY = -1f; } }
private void UpdateUserData() { if (_isUpdataUserDateFlag < 2) { return; } _isUpdataUserDateFlag = 1; _win = _userData.ContainsKey(InteractParameter.Gold) ? _userData.GetInt(InteractParameter.Gold) : 0; NameLabel.text = _userData.GetUtfString(InteractParameter.Nick); SetWinText(_win); var cards = _userData.GetIntArray(InteractParameter.Cards); var count = cards.Length < Cards.Count ? cards.Length : Cards.Count; var z = _userData.GetBool(InteractParameter.IsBanker); ZhuangObj.gameObject.SetActive(z); ZhuangRate.text = z ? _userData.GetUtfString(InteractParameter.ZhuangData) : ""; for (var i = 0; i < count; i++) { Cards[i].GetComponent <UISprite>().spriteName = "A_" + cards[i]; } var nd = _userData.GetSFSObject(InteractParameter.NiuData); NiuLabel.text = GetNiuName(nd); }
/// <summary> /// 大结算周边信息处理 /// </summary> /// <param name="data"></param> private void InfoAbout(ISFSObject data) { if (_roundInfo) { var now = data.GetInt("round"); var total = data.GetInt("maxRound"); _roundInfo.text = string.Format("{0}/{1}", now, total); } if (_nowTime) { var time = data.GetLong("svt"); DateTime nowTime = GetSvtTime(time); _nowTime.text = nowTime.ToString("yyyy-MM-dd hh:mm:ss"); } if (_ruleInfo) { _ruleInfo.text = _gameInfo.GetUtfString("rule"); } if (_roomerInfo) { _roomerInfo.text = _gameInfo.GetUtfString("roomName"); } if (_roomId) { _roomId.text = _gameInfo.GetInt("rid").ToString(); } }
/// <summary> /// 解析Cargs配置信息 /// </summary> /// <param name="cargs"></param> void DissectCargs2(ISFSObject cargs) { var gdata = App.GetGameData <SssGameData>(); if (cargs.ContainsKey("-resulttype")) { gdata.SwatModel = false; } if (cargs.ContainsKey("-daqiang")) { gdata.ShootScore = int.Parse(cargs.GetUtfString("-daqiang")); } if (cargs.ContainsKey("-ante")) { gdata.Ante = int.Parse(cargs.GetUtfString("-ante")); } if (cargs.ContainsKey("-usetype")) { //处理是否是代开模式 gdata.DaiKai = cargs.GetInt("-usetype") == gdata.UserType; } if (cargs.ContainsKey("-specialtypes")) { //添加特殊牌型过滤 string types = cargs.GetUtfString("-specialtypes"); string[] typeArr = types.Split('#'); if (typeArr.Length > 0) { foreach (string s in typeArr) { gdata.SpecialTypes.Add(Int32.Parse(s)); } } } }
private void SetPlayerInfo(ISFSObject userData) { if (userData.ContainsKey("ip")) { IpLabel.text = userData.GetUtfString("ip"); } if (userData.ContainsKey(RequestKey.KeyId)) { _pointSeadId = userData.GetInt(RequestKey.KeyId); IdLabel.text = _pointSeadId.ToString(CultureInfo.InvariantCulture); } if (userData.ContainsKey(RequestKey.KeyName)) { NameLabel.text = userData.GetUtfString(RequestKey.KeyName); } if (userData.ContainsKey(NewRequestKey.KeyAvatar)) { short sex = 0; if (userData.ContainsKey(NewRequestKey.KeySex)) { sex = userData.GetShort(NewRequestKey.KeySex); } DDzUtil.LoadRealHeadIcon(userData.GetUtfString(NewRequestKey.KeyAvatar), sex, HeadTexture); } DetailInfoGob.SetActive(true); }
public void SetData(ISFSObject data) { //解析cargs Cargs = data.GetUtfString(ProtocolKey.KeyCargs); string[] strkey = Cargs.Split(','); for (int i = 0; i < strkey.Length; i++) { string key = strkey[i]; if (mCargs.ContainsKey(key)) { mCargs[key] = int.Parse(strkey[i + 1]); } } //解析cargs2 if (data.ContainsKey("cargs2")) { mCargs2 = data.GetSFSObject("cargs2"); } //游戏规则 if (data.ContainsKey(ProtocolKey.KeyRule)) { LocalConfig.DefaultGameRule = data.GetUtfString(ProtocolKey.KeyRule); } //玩家总数 MaxPlayerCount = data.TryGetInt(ProtocolKey.KeyPlayerNum); ParseConfig(); }
public void HandleMessage(int flags, ISFSObject msgObj) { ProductValueType valueType = ProductHelper.GetProductValueType(flags); if (valueType != ProductValueType.TAB) { string newValue = msgObj.GetUtfString("v"); string newSliderValue = msgObj.GetUtfString("sv"); switch (valueType) { case ProductValueType.PRODUCTION: UpdateProductValue(valueType, newValue, newSliderValue, ref production); UpdateProductionDisplay(); break; case ProductValueType.MARKETING_BUDGET: UpdateProductValue(valueType, newValue, newSliderValue, ref marketingBudget); UpdateMarketingBudgetDisplay(); break; case ProductValueType.SALES_PRICE: UpdateProductValue(valueType, newValue, newSliderValue, ref sales); break; } } else { Debug.LogError("Tab switches should be handled via a room variable now."); } }
public override void SetRuleViewInfo(ISFSObject gameInfo) { if (ItemPrefab == null) { return; } Table.transform.DestroyChildren(); if (!gameInfo.ContainsKey("rule")) { gameObject.SetActive(false); return; } string ruleInfo = gameInfo.GetUtfString("rule"); if (string.IsNullOrEmpty(ruleInfo)) { gameObject.SetActive(false); return; } gameObject.SetActive(true); var ruleSplit = ruleInfo.Split(';'); int len = ruleSplit.Length; var go = CreateItem(); var strRule = string.Empty; for (int i = 0; i < len; i++) { var info = ruleSplit[i].Split(':'); string content = info[1].Replace(' ', '\n'); if (!content.Contains("\n")) { content += "\n"; } strRule += content; } go.SetRuleItem(string.Empty, strRule); Table.repositionNow = true; Table.Reposition(); if (gameInfo.ContainsKey("rid")) { int roomId = gameInfo.GetInt("rid"); ShowLabel(RoomIdLabel, RoomIdFormat, roomId.ToString()); } if (gameInfo.ContainsKey("roomName")) { string gameName = gameInfo.GetUtfString("roomName"); ShowLabel(RoomNameLabel, RoomNameFormat, gameName); } if (gameInfo.ContainsKey("ante")) { int ante = gameInfo.GetInt("ante"); ShowLabel(AnteLabel, AnteFormat, ante.ToString()); } }
private void OnExtensionResponse(BaseEvent evt) { string ResponseType = (string)evt.Params["cmd"]; Debug.Log("Received Response: " + ResponseType); ISFSObject ObjectIn = (SFSObject)evt.Params["params"]; if (ResponseType == "JoinGameLobby") { Debug.Log("Entering Game Lobby..."); SFServer.RemoveAllEventListeners(); SceneManager.LoadScene("GameLobby"); } if (ResponseType == "$SignUp.Submit") { if (!MessageText.activeInHierarchy) { MessageText.SetActive(true); } if (ObjectIn.GetBool("success")) { Debug.Log("Success, thanks for registering"); MessageText.GetComponent <Text>().text = "Success, thanks for registering"; SFServer.Send(new LogoutRequest()); this.LoginPanel.SetActive(true); this.RegisterPanel.SetActive(false); } else { Debug.Log("SignUp Error:" + ObjectIn.GetUtfString("errorMessage")); MessageText.GetComponent <Text>().text = "SignUp Error: " + ObjectIn.GetUtfString("errorMessage"); } } }
public TtResultUserData(ISFSObject data) { UserId = data.GetInt("id"); UserName = data.GetUtfString("nick"); UserHead = data.GetUtfString("avatar"); UserGold = data.GetInt("gold"); Sex = data.GetShort("sex"); }
public static EquippedObject FromSFSData(ISFSObject obj, string properties = null) { EquippedObject equippedObject = new EquippedObject(); equippedObject.equippedObjectType = obj.GetUtfString("type"); equippedObject.EquippedObjectId = obj.GetUtfString("name"); equippedObject.PropertiesJSON = properties; return(equippedObject); }
/// <summary> /// 初始化房间信息 /// </summary> public virtual void InitRoom(ISFSObject gameInfo) { var gdata = App.GetGameData <FillpitGameData>(); gdata.IsDoubleGame = gameInfo.ContainsKey("dr") && gameInfo.GetBool("dr"); gdata.IsLanDi = gameInfo.ContainsKey("lastlandi") && gameInfo.GetBool("lastlandi"); //获取房间配置 if (gameInfo.ContainsKey("rid")) { gdata.IsRoomGame = true; bool played = gameInfo.GetInt("round") > 0; gdata.IsPlayed = played; gdata.RoomPlayed = gameInfo.ContainsKey("roomPlayed") && gameInfo.GetBool("roomPlayed"); WeiChatInvite.SetWeiChatBtnActive(!played); RoomInfo.ShowRoomInfo(gameInfo); } //获取低注值 if (gameInfo.ContainsKey("ante")) { gdata.BaseAnte = gameInfo.GetInt("ante"); gdata.MaxPoolNum = gameInfo.GetInt("betLimit"); if (gameInfo.GetBool("playing")) { gdata.IsGameing = gameInfo.GetBool("playing"); //当前谁说话 if (gameInfo.ContainsKey("current")) { gdata.CurAnte = gameInfo.GetInt("current"); App.GetGameManager <FillpitGameManager>().Speaker(gameInfo.GetInt("current")); } } } if (gameInfo.ContainsKey("cargs2")) { ISFSObject carg = gameInfo.GetSFSObject("cargs2"); if (carg.ContainsKey("-hideN")) { DealerMgr.HideN = int.Parse(carg.GetUtfString("-hideN")); } if (carg.ContainsKey("-turnresult")) { SummaryMgr.ShowTurnResult = !carg.GetUtfString("-turnresult").Equals("0"); } } BetMgr.SetAddBtns(); MenuMgr.OnInitRoom(gameInfo); }
public ResultData(ISFSObject data) { Win = data.GetInt("win"); TtGold = data.GetLong("ttgold"); FoldScore = data.GetInt("foldScore"); Name = data.GetUtfString("name"); FoldCards = data.GetIntArray("foldCards"); Seat = data.GetInt("seat"); Sex = data.GetShort("sex"); Head = data.GetUtfString("avatar"); IsNoFold = data.GetBool("isNoFold"); }
public void DecryptParameters(ISFSObject parameters) { if (parameters.ContainsKey(ENCRYPTED_PARAMETER)) { string utfString = parameters.GetUtfString(ENCRYPTED_PARAMETER); string utfString2 = parameters.GetUtfString(utfString); byte[] bytes = Convert.FromBase64String(utfString2); byte[] bytes2 = Decrypt(bytes); string @string = Encoding.UTF8.GetString(bytes2); parameters.PutUtfString(utfString, @string); } }
// client side: receiving feedback from SERVER private static void OnExtensionResponse(BaseEvent evt) { String cmd = (String)evt.Params["cmd"]; trace("response received: " + cmd); // shows up after "in-class" debug message if (cmd == "remainingCharacters") { ISFSObject responseParams = (SFSObject)evt.Params["params"]; string player = responseParams.GetUtfString("player"); if (player != null) { string chosen = responseParams.GetUtfString("chosenCharacter"); chosenCharText += player + " chose " + chosen + "!\n"; } if (cc != null) { cc.UpdateDisplayText(chosenCharText); cc.DisplayRemainingCharacters(evt); } } else if (cmd == "updateGameState" && (Chat.chatting == null || !Chat.chatting)) { Debug.Log("UGS called in SFS.cs"); Debug.Log("Current SaveGame ID Content before updating gamestate: " + GameBoard.saveGameId); gb.UpdateGameState(evt); if (GameBoard.started == false & GameBoard.saveGameId == "") { Debug.Log("Condition triggered, started = false"); gb.promptHorseAttack(); } } else if (cmd == "nextAction") { ISFSObject responseParams = (SFSObject)evt.Params["params"]; step = responseParams.GetInt("step"); Debug.Log("received step " + step); } else if (cmd == "testgame") { tg.ReceiveInitializedGame(evt); } else if (cmd == "currentSaveGameID") { ISFSObject responseParams = (SFSObject)evt.Params["params"]; string saveGame = responseParams.GetUtfString("savegameID"); Debug.Log("Here is the returned SaveGame after Loading!!!" + saveGame); if (saveGame != "") { GameBoard.saveGameId = saveGame; } } }
/// <summary> /// 设置用户信息 /// </summary> /// <param name="userData"></param> UserInfoStruct SetUserData(ISFSObject userData) { SetContryInfo(userData); var userinfoStruct = new UserInfoStruct(); if (userData.ContainsKey(RequestKey.KeyId)) { userinfoStruct.Id = userData.GetInt(RequestKey.KeyId); } if (userData.ContainsKey("ip")) { userinfoStruct.Ip = userData.GetUtfString("ip"); } if (userData.ContainsKey("country")) { userinfoStruct.Country = userData.GetUtfString("country"); } if (userData.ContainsKey(RequestKey.KeyName)) { userinfoStruct.Name = userData.GetUtfString(RequestKey.KeyName); } //获取gpsx; gpsy if ((userData.ContainsKey("gpsx") && userData.ContainsKey("gpsy")) || (userData.ContainsKey("x") && userData.ContainsKey("y"))) { userinfoStruct.GpsX = userData.ContainsKey("gpsx") ? userData.GetFloat("gpsx") : userData.GetFloat("x"); userinfoStruct.GpsY = userData.ContainsKey("gpsy") ? userData.GetFloat("gpsy") : userData.GetFloat("y"); } else { userinfoStruct.GpsX = -1f; userinfoStruct.GpsY = -1f; } if (userData.ContainsKey(NewRequestKey.KeyAvatar)) { userinfoStruct.HeadImgAvatar = userData.GetUtfString(NewRequestKey.KeyAvatar); } if (userData.ContainsKey(NewRequestKey.KeySex)) { userinfoStruct.Sex = userData.GetShort(NewRequestKey.KeySex); } return(userinfoStruct); }
// Response private static bool SFDispatchRequestPatch(ref ISFSObject __0) { ISFSObject raw = __0; bool log = true; // System if (raw.GetByte("c") == 0) { ISFSObject p = raw.GetSFSObject("p"); // Player movements int a = Convert.ToInt32(raw.GetShort("a")); if (a == 1000 || a == 1002 || a == 1004 || a == 11 || a == 12) { log = false; } } // Game else if (raw.GetByte("c") == 1) { ISFSObject p = raw.GetSFSObject("p"); if (p.GetUtfString("c") == "GameStart") { ISFSObject p2 = p.GetSFSObject("p"); //NetworkMonster monster1 = p2.GetSFSArray("teamMonsters").GetClass(0) as NetworkMonster; //monster1.luma = true; //monster1.Nickname = "gay"; //p2.PutUtfString("nck", "nitro."); //p2.PutInt("tid", 1337); } // Player movements int a = Convert.ToInt32(raw.GetShort("a")); //if (a == 1000 || a == 1002 || a == 1004 || a == 11) log = false; if (a == 13) { string c = p.GetUtfString("c"); if (c == "UPP" || c.StartsWith("PA.")) { log = false; } } } if (log) { Logger.LogLine($"Receiving message (ID {Convert.ToInt32(raw.GetShort("a"))}):\n{raw.GetDump()}", ConsoleColor.Cyan); } return(true); }
public override void InitCfg(ISFSObject cargs2) { base.InitCfg(cargs2); // SingleBet = AnteRate[0]; var time = cargs2.ContainsKey("-tptout") ? cargs2.GetUtfString("-tptout") : "300"; HupUp.HupTime = int.Parse(time); if (IsCreatRoom) { IsReadyCd = cargs2.ContainsKey("-nmno") && Int32.Parse(cargs2.GetUtfString("-nmno")) > 0; CoustemTime = cargs2.ContainsKey("-ctime") ? Int32.Parse(cargs2.GetUtfString("-ctime")) : -1; JhRuleInfo info = (JhRuleInfo)CreateRoomInfo; EventObj.SendEvent("RuleInfoEvent", "RuleInfo", info.Cargs); } }
public void On20Compare(ISFSObject response) { RStatus = RoomStatus.BiPai; int winner = response.GetInt("winseat"); string msg = response.GetUtfString("msg"); List <int> lostList = new List <int>(); foreach (var userInfo in UserInfoDict) { JhUserInfo jhUser = (JhUserInfo)userInfo.Value; if (jhUser.Seat != winner) { jhUser.IsFail = true; lostList.Add(userInfo.Key); } } ISFSObject sendObj = new SFSObject(); sendObj.PutUtfString("msg", msg); sendObj.PutIntArray("lostChair", lostList.ToArray()); EventObj.SendEvent("PlayersViewEvent", "AllBiPai", sendObj); EventObj.SendEvent("SoundEvent", "PlayerEffect", new JhSound.SoundData(JhSound.EnAudio.CompareAnimate)); }
/// <summary> /// Изменилось состояние игры /// </summary> /// <param name="data"></param> void GameStateChange(ISFSObject data) { GameStates gameState = (GameStates)Enum.Parse(typeof(GameStates), data.GetUtfString("gameState")); int time = data.GetInt("time"); if (OnGameStateUpdate != null) OnGameStateUpdate(gameState, time); }
public virtual void Bet(ISFSObject responseData) { var gold = responseData.GetInt(Parameter.Gold); var seat = responseData.GetInt(Parameter.Seat); var p = responseData.GetUtfString("p"); int target = GetInt(p); var gdata = App.GetGameData <BrttzGameData>(); if (seat == gdata.SelfSeat) { SelfMenBet(target, gold); gdata.ThisCanInGold = gdata.ThisCanInGold - gold; App.GetGameManager <BrttzGameManager>().CanQuitGame = false; return; } if (gold > gdata.AnteRate[gdata.AnteRate.Count - 1]) { OtherMenBet(target, gold); return; } var startPos = ChipCfg.StartPos; var len = startPos.Length; if (len > 0) { //InstantiateChip(ChipCfg.DeskAreas[target], startPos[0], gold); InstantiateChip(target, startPos[0], gold); Facade.Instance <MusicManager>().Play("Bet"); } }
public HupData(ISFSObject data) { UserId = data.GetInt("userId"); UserName = data.GetUtfString("username"); Type = data.GetInt("type"); CdTime = data.ContainsKey("cdTime") ? data.GetInt("cdTime") : 300; }
/// <summary> /// 开始下注 /// </summary> /// <param name="responseData"></param> public void OnAnteStart(ISFSObject responseData) { var gdata = App.GetGameData <TtzGameData>(); RobBank.RobParentCtrl(); if (responseData.ContainsKey(InteractParameter.Bkp)) { _bankSeat = responseData.GetInt(InteractParameter.Bkp); YxDebug.Log("庄家坐位:" + _bankSeat); } var cd = responseData.GetInt(InteractParameter.Cd); _cdTime = Time.time + cd; var antes = responseData.GetUtfString(InteractParameter.Antes); _bankAntes = antes.Split(','); foreach (var user in gdata.PlayerList) { var player = (TtzPlayer)user; player.SetBanker(false); } OnBeginAnte(); StartCoroutine(responseData.ContainsKey(InteractParameter.Banks) ? ShowRandomBankAni(responseData) : BankShake()); }
private void OnExtensionResponse(BaseEvent evt) { TextMessage.text = ""; string cmd = (string)evt.Params["cmd"]; ISFSObject objIn = (SFSObject)evt.Params["params"]; string message = ""; if (cmd == CMD_RECOVER) { if (objIn.ContainsKey("errorMessage")) { message = objIn.GetUtfString("errorMessage"); Debug.Log(message); TextMessage.text = message; } else { message = "The password was sent to your email box"; Debug.Log(message); TextMessage.text = message; //forgetPassword.gameObject.SetActive(false); // login.gameObject.SetActive(true); } } }
/// <summary> /// 记录地理位置信息 /// </summary> /// <param name="userData"></param> private void SetContryInfo(ISFSObject userData) { if (userData.ContainsKey(RequestKey.KeyId) && userData.ContainsKey("country")) { UserIdToContry[userData.GetInt(RequestKey.KeyId)] = userData.GetUtfString("country"); } }
public void SetSlots(ISFSObject objIn, bool x) { int end = 0; string info = objIn.GetUtfString("slots"); end = info.Length; for (int i = 0; i < end; i++) { daysSlots [i] = int.Parse(info [i] + ""); } string[] d; if (x) { d = objIn.GetUtfStringArray("dates"); dates.Add("Auction Date"); for (int i = 0; i < d.Length; i++) { dates.Add(d [i]); } AucDate.ClearOptions(); AucDate.AddOptions(dates); } else if (!x) { ErrorMessage.text = "Your auction not rigesterd, try choose another time"; } }
private void OnBuddyMessage(BaseEvent evt) { Buddy buddy; Buddy sender; Boolean isItMe = (bool)evt.Params["isItMe"]; string message = (string)evt.Params["message"]; string buddyName; sender = (Buddy)evt.Params["buddy"]; if (isItMe) { ISFSObject playerData = (SFSObject)evt.Params["data"]; buddyName = playerData.GetUtfString("recipient"); buddy = smartFox.BuddyManager.GetBuddyByName(buddyName); } else { buddy = sender; buddyName = ""; } if (buddy != null) { // Store the message according to the sender's name message = (isItMe ? "To " + buddyName : "From " + buddy.Name) + ": " + message; GameGUI.Inst.WriteToConsoleLog(message); } }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { string aSettlementName = anObjectIn.GetUtfString("Name"); int ID = anObjectIn.GetInt("ID"); float[] location = anObjectIn.GetFloatArray("LocationArray"); int level = anObjectIn.GetInt("CenterNodeLevel"); GameObject aSettlement = ourGWM.createObject("Prefabs/Settlements/" + aSettlementName + "/" + level.ToString()); aSettlement.name = "Settlement_" + aSettlementName + "_" + ID; aSettlement.transform.position = new Vector3(location[0], location[1], location[2]); }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { string aResourceName = anObjectIn.GetUtfString("Name"); int ID = anObjectIn.GetInt("ID"); float[] location = anObjectIn.GetFloatArray("Location"); GameObject aResource = ourGWM.createObject("Prefabs/Resources/" + aResourceName); aResource.name = "Resource_" + aResourceName + "_" + ID; aResource.transform.position = new Vector3(location[0], location[1], location[2]); //Add Newly spawned resource to Dictionary ourGWM.getResourceDictionary().Add(ID, aResource); }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { string aCharacterName = anObjectIn.GetUtfString("CharacterName"); if(aCharacterName == ourGWM.getLPC().GetName()) { return; } else if(ourGWM.getPlayerDictionary().ContainsKey(aCharacterName)) { ourGWM.destroyObject("GameCharacter_" + aCharacterName); ourGWM.getPlayerDictionary().Remove(aCharacterName); } }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { string aCharacterName = anObjectIn.GetUtfString("CharacterName"); if(aCharacterName == ourGWM.getLPC().GetName()) { return; } else if(ourGWM.getPlayerDictionary().ContainsKey(aCharacterName)) { float Rotation = anObjectIn.GetFloat("Rotation"); ourGWM.getPlayerDictionary()[aCharacterName].GetComponent<RemotePlayerController>().SetRotation(Rotation); } }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { string aNPCName = anObjectIn.GetUtfString("Name"); int ID = anObjectIn.GetInt("ID"); float[] location = anObjectIn.GetFloatArray("Location"); GameObject aNPC = ourGWM.createObject("Prefabs/NPC/" + aNPCName); aNPC.name = "NPC_" + aNPCName + "_" + ID; aNPC.AddComponent<RemotePlayerController>(); aNPC.transform.position = new Vector3(location[0], location[1], location[2]); aNPC.GetComponentInChildren<TextMesh>().text = aNPCName; //Add Newly spawned player to Dictionary ourGWM.getNPCDictionary().Add(ID, aNPC); }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { string aCharacterName = anObjectIn.GetUtfString("CharacterName"); if(aCharacterName == ourGWM.getLPC().GetName()) { return; } else if(ourGWM.getPlayerDictionary().ContainsKey(aCharacterName)) { float[] LocationArray = anObjectIn.GetFloatArray("Location"); bool IsMoving = anObjectIn.GetBool("IsMoving"); ourGWM.getPlayerDictionary()[aCharacterName].GetComponent<RemotePlayerController>().SetPlayerMoving(IsMoving); ourGWM.getPlayerDictionary()[aCharacterName].transform.position = new Vector3(LocationArray[0], LocationArray[1], LocationArray[2]); } }
public void Setup(ISFSObject obj) { particleSystem.renderer.sortingLayerName = "2 Middle Lower UI"; this.gwName = obj.GetUtfString("NAME"); this.state = obj.GetUtfString("STATE"); this.owner = obj.GetUtfString("OWNER"); this.atk = obj.GetInt("ATK"); this.def = obj.GetInt("DEF"); this.type = obj.GetUtfString("TYPE"); ISFSArray sws = obj.GetSFSArray("SW"); this.region = obj.GetUtfString("REGION"); this.sw = new string[3]; this.sw[0] = (string) sws.GetElementAt(0); this.sw[1] = (string) sws.GetElementAt(1); this.sw[2] = (string) sws.GetElementAt(2); mg = GameObject.Find("Manager").GetComponent<Manager>(); gameObject.transform.position = new Vector3((float)obj.GetDouble("X")*mg.getScale().x,(float)obj.GetDouble("Y")*mg.getScale().y,1F); gameObject.transform.localScale = new Vector3(0.25f,0.25f,0.25f); }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { GameObject aContributionPanel = ourGWM.createObject("UI/ContributionPanel"); aContributionPanel.name = "ContributionPanel"; aContributionPanel.transform.SetParent(GameObject.Find("UICanvas").transform); aContributionPanel.transform.localPosition = new Vector3(0, 0, 0); aContributionPanel.transform.FindChild("ExitButton").GetComponent<Button>().onClick.AddListener(() => GameObject.Find("SceneScriptsObject").GetComponent<GameUI>().contributionExitButton_Clicked()); aContributionPanel.transform.FindChild("ContributeButton").GetComponent<Button>().onClick.AddListener(() => GameObject.Find("SceneScriptsObject").GetComponent<GameUI>().contributionButton_Clicked()); aContributionPanel.transform.FindChild("NameLabel").GetComponent<Text>().text = anObjectIn.GetUtfString("Name"); aContributionPanel.transform.FindChild("LevelLabel").GetComponent<Text>().text = "(Level " + anObjectIn.GetInt("CenterNodeLevel").ToString() + ")"; aContributionPanel.transform.FindChild("CurrentContributionLabel").GetComponent<Text>().text = anObjectIn.GetInt("Contribution").ToString(); aContributionPanel.transform.FindChild("ContributionCapTotalLabel").GetComponent<Text>().text = anObjectIn.GetInt("ContributionCap").ToString(); aContributionPanel.transform.FindChild("ContributionPB").GetComponent<Scrollbar>().size = (float)anObjectIn.GetInt("CurrentTNL") / (float)anObjectIn.GetInt("TotalTNL"); aContributionPanel.transform.FindChild("ContributionPB").FindChild("ContributionText").GetComponent<Text>().text = anObjectIn.GetInt("CurrentTNL").ToString() + " / " + anObjectIn.GetInt("TotalTNL").ToString(); aContributionPanel.transform.FindChild("CurrentFoodLabel").GetComponent<Text>().text = anObjectIn.GetInt("CurrentFood").ToString(); //Switch Cursor Mode Camera.main.GetComponent<CameraController>().setCursorVisible(true); }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { Debug.Log("Server spawning player."); float[] locationArray = anObjectIn.GetFloatArray("Location"); float aRotation = anObjectIn.GetFloat("Rotation"); string aCharacterName = anObjectIn.GetUtfString("CharacterName"); if(anObjectIn.GetBool("IsLocal")) { GameObject aLocalPlayer = ourGWM.createObject("Prefabs/Player/PlayerBasic"); aLocalPlayer.transform.position = new Vector3(locationArray[0], locationArray[1], locationArray[2]); aLocalPlayer.transform.rotation = Quaternion.identity; // Since this is the local player, lets add a controller and fix the camera aLocalPlayer.AddComponent<LocalPlayerController>(); aLocalPlayer.AddComponent<InputController>(); ourGWM.setLPC(aLocalPlayer.GetComponent<LocalPlayerController>()); ourGWM.getLPC().SetName(aCharacterName); aLocalPlayer.GetComponentInChildren<TextMesh>().text = aCharacterName; GameObject cameraAttach = new GameObject(); cameraAttach.transform.parent = aLocalPlayer.transform; cameraAttach.transform.localPosition = new Vector3(1f, 2.5f, 1.0f); cameraAttach.name = "Camera Target"; Camera.main.transform.parent = cameraAttach.transform; Camera.main.GetComponent<CameraController>().setTarget(cameraAttach); Camera.main.GetComponent<CameraController>().setCursorVisible(false); } else if(!anObjectIn.GetBool("IsLocal")) { GameObject aRemotePlayer = ourGWM.createObject("Prefabs/Player/PlayerBasic"); aRemotePlayer.name = "GameCharacter_" + aCharacterName; aRemotePlayer.AddComponent<RemotePlayerController>(); aRemotePlayer.transform.position = new Vector3(locationArray[0], locationArray[1], locationArray[2]); aRemotePlayer.GetComponent<RemotePlayerController>().SetRotation(aRotation); aRemotePlayer.GetComponentInChildren<TextMesh>().text = aCharacterName; //Add Newly spawned player to Dictionary ourGWM.getPlayerDictionary().Add(aCharacterName, aRemotePlayer); } }
private void HandleChatMessage(ISFSObject dt) { string message = dt.GetUtfString("message"); Chat.Instance.UpdateChat (message); }
public void UpdatePlayerInfo(ISFSObject data, Color myColor) { String colorName = ""; long time = data.GetLong("time"); int s,m,h; string formattedTime; if(myColor == Color.red) colorName = "red"; if(myColor == Color.green) colorName = "green"; if(myColor == Color.cyan) colorName = "cyan"; if(myColor == Color.magenta) colorName = "magenta"; if(myColor == Color.yellow) colorName = "yellow"; int newtime = (int) time/1000; s = (int) newtime%60; m = (int) (newtime/60)%60; h = (int) (newtime/3600)%24; formattedTime = string.Format("{0:00}:{1:00}:{2:00}",h,m,s); GameObject stats = GameObject.Find("StatLabels"); stats.transform.FindChild("Name").GetComponent<UILabel>().text = data.GetUtfString("name"); stats.transform.FindChild("Color").GetComponent<UILabel>().text = colorName; stats.transform.FindChild("Color").GetComponent<UILabel>().color = myColor; stats.transform.FindChild("Money").GetComponent<UILabel>().text = data.GetInt("money").ToString(); stats.transform.FindChild("Timer").GetComponent<UILabel>().text = formattedTime; }
public string GetString(ISFSObject data, string key) { if (receiveEncrypted) { return provider.DecryptString(data.GetByteArray(key)); } else { return data.GetUtfString(key); } }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { GameUI ourGameUI = GameObject.Find("SceneScriptsObject").GetComponent<GameUI>(); ourGameUI.processChat(anObjectIn.GetUtfString("ChatText")); }
/// <summary> /// Кто-то улыбается /// </summary> /// <param name="data"></param> void Smile(ISFSObject data) { Smiles.SmileTypes smileType = (Smiles.SmileTypes)Enum.Parse(typeof(Smiles.SmileTypes), data.GetUtfString("smileType")); string userName = data.GetUtfString("userName"); if (OnSmile != null) OnSmile(smileType, userName); }
public void CreateNewGameObject(ISFSObject obj) { string id = obj.GetUtfString("Id"); //parse id to determine type string[] temp = id.Split('-'); //Debug.Log(temp[0] + " " + temp[1] + " " + temp[2]); int type = int.Parse(temp[1]); GameObject newObject; //Debug.Log("Make new stuff"); switch (type) { case 00: //tank Vector3 pos = new Vector3(obj.GetFloat("px"), obj.GetFloat("py"), obj.GetFloat("pz")); newObject = (GameObject)Instantiate(OtherPlayerTankPrefab, pos, Quaternion.identity); newObject.GetComponent<InputController>().id = temp[0]; newObject.GetComponent<NetTag>().Id = temp[0] + "-00-" + "00"; GameObject.FindWithTag("MainCamera").GetComponent<MainCameraScript>().setEnemies(); GameObject.FindWithTag("MapCamera").GetComponent<MapCameraScript>().setEnemies(); updatePhysList(); break; case 1: //projectile newObject = (GameObject)Instantiate(heatProjectile, new Vector3(obj.GetFloat("ppx"), obj.GetFloat("ppy"), obj.GetFloat("ppz")), Quaternion.Euler(new Vector3(obj.GetFloat("prx"), obj.GetFloat("pry"), obj.GetFloat("prz")))); newObject.rigidbody.velocity = new Vector3(obj.GetFloat("pvx"), obj.GetFloat("pvy"), obj.GetFloat("pvz")); newObject.transform.position += newObject.rigidbody.velocity.normalized * 7; newObject.GetComponent<NetTag>().Id = temp[0] + "-1-" + temp[2]; //primaryCount++; // Recoil /*NetInputController thisRemoteController = GetRemoteController(temp[0] + "-00-" + "00"); thisRemoteController.Hull.rigidbody.AddForceAtPosition(-newObject.rigidbody.velocity * newObject.rigidbody.mass, thisRemoteController.Turret.Muzzle.transform.position, ForceMode.Impulse);*/ updatePhysList(); //Debug.Log("Spawning New Projectile with ID: " + newObject.GetComponent<NetTag>().Id); break; case 2: //missile newObject = (GameObject)Instantiate(ATMissile, new Vector3(obj.GetFloat("ppx"),obj.GetFloat("ppy"),obj.GetFloat("ppz")), Quaternion.Euler(new Vector3(obj.GetFloat("prx"),obj.GetFloat("pry"),obj.GetFloat("prz")))); newObject.GetComponent<GuidedProjectileInputController>().TargetPosition = new Vector3(obj.GetFloat("tx"), obj.GetFloat("ty"), obj.GetFloat("tz")); //ATMissile newObject.rigidbody.velocity = new Vector3(obj.GetFloat("pvx"), obj.GetFloat("pvy"), obj.GetFloat("pvz")); //ATMissile newObject.transform.position += newObject.rigidbody.velocity.normalized * 7; newObject.GetComponent<NetTag>().Id = temp[0] + "-2-" + temp[2]; //secondaryCount++; updatePhysList(); //Debug.Log("Spawning New Missile with ID: " + newObject.GetComponent<NetTag>().Id); break; default: //Debug.Log("Type was: " + type); break; } }
public void gatewayUpdate(ISFSObject data) { Gateway gw = GameObject.Find(data.GetUtfString("STATE").ToLower()).GetComponent<Gateway>(); gw.Update(data); gameObject.GetComponent<TextManager>().printGwInfo(gw); }
public void Update(ISFSObject obj) { this.owner = obj.GetUtfString("OWNER"); this.atk = obj.GetInt("ATK"); this.def = obj.GetInt("DEF"); ISFSArray sws = obj.GetSFSArray("SW"); this.sw = new string[3]; this.sw[0] = (string) sws.GetElementAt(0); this.sw[1] = (string) sws.GetElementAt(1); this.sw[2] = (string) sws.GetElementAt(2); }
// Synchronizing remote animation private void HandleAnimation(ISFSObject dt) { int userId = dt.GetInt("id"); string msg = dt.GetUtfString("msg"); int layer = dt.GetInt("layer"); // Debug.Log("userID"+ userId + " " + layer + " " + msg); if (userId != smartFox.MySelf.Id) { PlayerManager.Instance.SyncAnimation(userId, msg, layer); } }
// Instantiating player (our local FPS model, or remote 3rd person model) private void HandleInstantiatePlayer(ISFSObject dt) { ISFSObject playerData = dt.GetSFSObject("player"); int userId = playerData.GetInt("id"); int score = playerData.GetInt("score"); string avatar = playerData.GetUtfString("avatar"); Debug.Log("DaToS: UID " + userId + "; Avatar " + avatar); // string textura = playerData.GetUtfString("textura"); //Debug.Log("avatar en handle ="+avatar); /* prueba*/ if (avatar.Equals("masculino")) avatar = "Jane-20"; // Debug.Log("textura en handle ="+textura); NetworkTransform ntransform = NetworkTransform.FromSFSObject(playerData); User user = smartFox.UserManager.GetUserById(userId); userName = user.Name; Debug.Log("Nombreeeeeeeeeeeeeee:"+userName); if (userId == smartFox.MySelf.Id) { // Debug.Log("my id = " + userId); PlayerManager.Instance.SpawnPlayer(ntransform, userName, score, avatar); } else { string animacion = dt.GetUtfString("anim"); PlayerManager.Instance.SpawnEnemy(userId, ntransform, userName, score, avatar,animacion); } }
public void showTimer(ISFSObject data) { gameObject.GetComponent<HackSecondsManager>().setAction(data.GetUtfString("ACTION")); gameObject.GetComponent<HackSecondsManager>().setSeconds(data.GetInt("seconds")); }
private void PoliceTextInfo(ISFSObject data) { string action = data.GetUtfString("ACTION"); mg.getNotificationManager().DisplayNews(action); }
private void OnResponseGetAssetsInfo(ISFSObject a_infoData) { //assetsinfo if(a_infoData.GetBool(Keys.SUCCESS)) { ISFSArray l_tempSfsArray = a_infoData.GetSFSArray(Keys.ASSETS_INFO); List<AssetsInfo> l_allCurrentInfoList = new List<AssetsInfo>(); for (int indexAssetInfo = 0; indexAssetInfo < l_tempSfsArray.Count; indexAssetInfo++) { AssetsInfo l_temp = new AssetsInfo(); l_temp.AssetID = (int)(l_tempSfsArray.GetSFSObject(indexAssetInfo)).GetLong("assetsid"); l_temp.ImageTargetID = (l_tempSfsArray.GetSFSObject(indexAssetInfo)).GetUtfString("imagetargetid"); l_temp.URL = (l_tempSfsArray.GetSFSObject(indexAssetInfo)).GetUtfString("assetsurl"); l_temp.AssetName = (l_tempSfsArray.GetSFSObject(indexAssetInfo)).GetUtfString("assetname"); l_allCurrentInfoList.Add(l_temp); } GameBaseEvent l_assetsInfoEvent = new GameBaseEvent(eGameEvents.getAssetsInfo.ToString()); GameEventArgs l_eventArg = new GameEventArgs(); l_eventArg.EventData = (object)l_allCurrentInfoList; l_assetsInfoEvent.Args = l_eventArg; dispatchEvent(this, l_assetsInfoEvent); } else { Debug.Log(a_infoData.GetUtfString(Keys.ERROR)); } }
void OnCircleAndPlayer(ISFSObject data) { PlayerTeam circleTeam = (PlayerTeam) System.Enum.Parse(typeof(PlayerTeam), data.GetUtfString("team")); if(circleTeam != team) return; Circle circle = Circles.Instance.GetCircle(data.GetInt("circleId")); ServerPlayer serverPlayer = ServerPlayers.GetPlayer(data.GetUtfString("userName")); bool isSucceed = data.GetBool("isSucceed"); if (isSucceed) serverPlayer.TruePress(circle); else serverPlayer.FailPress(circle); }
private void recieveExplosionForce(ISFSObject msg) { var force = msg.GetFloat("force"); var pos = msg.GetFloatArray("pos"); var team = msg.GetUtfString("team"); targetPosition = new Vector3(pos[0], Y_PLANE, pos[1]); GameObject newExplosion = Instantiate(ExplosionPF, targetPosition, Quaternion.identity) as GameObject; if (team == "blue") { newExplosion.GetComponent<ParticleSystem>().startColor = new Color(0.0f, 0.5f, 1.0f, 1.0f); } else { newExplosion.GetComponent<ParticleSystem>().startColor = Color.red; } Vector3 lightPosition = targetPosition; lightPosition.y += 10.0f; GameObject explosionLight = Instantiate(ExplosionLightPF, lightPosition, Quaternion.identity) as GameObject; if (team == "blue") { explosionLight.GetComponent<Light>().color = Color.blue; } else { explosionLight.GetComponent<Light>().color = Color.red; } float totalTime = 2.0f * force/160.0f; Destroy(newExplosion, totalTime); totalTime = totalTime/5.0f; Destroy(explosionLight, totalTime); GameObject[] blocksArray = GameObject.FindGameObjectsWithTag("Block"); foreach (GameObject block in blocksArray) { if (block.GetComponent<BoxCollider>().bounds.Contains(targetPosition)) { var extents = block.GetComponent<BoxCollider>().bounds.extents; if(targetPosition.x > block.transform.position.x) targetPosition += new Vector3(extents.x, 0, 0); else targetPosition -= new Vector3(extents.x, 0, 0); if(targetPosition.z > block.transform.position.z) targetPosition += new Vector3(0, 0, extents.z); else targetPosition -= new Vector3(0, 0, extents.z); } block.GetComponent<Rigidbody>().AddExplosionForce(force, targetPosition, 25.0f, 0.0f, ForceMode.Impulse); } }