Ejemplo n.º 1
0
        public List <CpgSaveData> Read(int chair)
        {
            if (_saveList[chair].Count != 0)
            {
                return(_saveList[chair]);
            }

            string key       = SaveDataKey + chair;
            string valueJson = PlayerPrefs.GetString(key, "");

            if (valueJson == "")
            {
                YxDebug.Log("当前本地 无吃碰杠保存数据");
                return(null);
            }

            ISFSArray array = SFSArray.NewFromJsonData(valueJson);

            for (int i = 0; i < array.Size(); i++)
            {
                ISFSObject  arrayObj = array.GetSFSObject(i);
                CpgSaveData data     = new CpgSaveData();
                data.type  = (EnGroupType)arrayObj.GetInt(CpgType);
                data.value = arrayObj.GetIntArray(CpgValue);
                data.index = arrayObj.GetInt(CpgIndex);


                _saveList[chair].Add(data);
            }

            return(_saveList[chair]);
        }
Ejemplo n.º 2
0
        private void ConvertCsObj(object csObj, ISFSObject sfsObj)
        {
            Type   type     = csObj.GetType();
            string fullName = type.FullName;
            SerializableSFSType serializableSFSType = csObj as SerializableSFSType;

            if (serializableSFSType == null)
            {
                throw new SFSCodecError(string.Concat("Cannot serialize object: ", csObj, ", type: ", fullName, " -- It doesn't implement the SerializableSFSType interface"));
            }
            ISFSArray iSFSArray = SFSArray.NewInstance();

            sfsObj.PutUtfString(CLASS_MARKER_KEY, fullName);
            sfsObj.PutSFSArray(CLASS_FIELDS_KEY, iSFSArray);
            FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
            FieldInfo[] array  = fields;
            foreach (FieldInfo fieldInfo in array)
            {
                string         name           = fieldInfo.Name;
                object         value          = fieldInfo.GetValue(csObj);
                ISFSObject     iSFSObject     = SFSObject.NewInstance();
                SFSDataWrapper sFSDataWrapper = WrapField(value);
                if (sFSDataWrapper != null)
                {
                    iSFSObject.PutUtfString(FIELD_NAME_KEY, name);
                    iSFSObject.Put(FIELD_VALUE_KEY, sFSDataWrapper);
                    iSFSArray.AddSFSObject(iSFSObject);
                    continue;
                }
                throw new SFSCodecError(string.Concat("Cannot serialize field of object: ", csObj, ", field: ", name, ", type: ", fieldInfo.GetType().Name, " -- unsupported type!"));
            }
        }
Ejemplo n.º 3
0
        private ISFSArray ExpressionAsSFSArray()
        {
            ISFSArray iSFSArray = new SFSArray();

            if (logicOp != null)
            {
                iSFSArray.AddUtfString(logicOp.Id);
            }
            else
            {
                iSFSArray.AddNull();
            }
            iSFSArray.AddUtfString(varName);
            iSFSArray.AddByte((byte)condition.Type);
            iSFSArray.AddUtfString(condition.Symbol);
            if (condition.Type == 0)
            {
                iSFSArray.AddBool(Convert.ToBoolean(varValue));
            }
            else if (condition.Type == 1)
            {
                iSFSArray.AddDouble(Convert.ToDouble(varValue));
            }
            else
            {
                iSFSArray.AddUtfString(Convert.ToString(varValue));
            }
            return(iSFSArray);
        }
Ejemplo n.º 4
0
    private void onFetchBoardListHandler(NEvent evt)
    {
        int count = evt.Data.GetInt("count");



        SFSArray list = (SFSArray)evt.Data.GetSFSArray("list");

        //获取数据容器
        RectTransform grid   = content.transform.Find("scrollRect/grid") as RectTransform;
        RectTransform prefab = content.transform.Find("scrollRect/templete") as RectTransform;

        while (grid.childCount > 0)
        {
            Destroy(grid.GetChild(0).gameObject);
        }


        grid.sizeDelta = new Vector2(grid.sizeDelta.x, (prefab.sizeDelta.y + 10) * count);
        for (int i = 0; i < count; i++)
        {
            RectTransform item = Instantiate <RectTransform>(prefab, grid);
            item.gameObject.SetActive(true);
        }
    }
Ejemplo n.º 5
0
        /// <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);
            }
        }
Ejemplo n.º 6
0
    public void addSuscriber(string name)
    {
        currentConectionName = name;

        Debug.Log("addSuscriber");
        List<RoomVariable> roomVars = new List<RoomVariable>();
        Room room = smartFox.LastJoinedRoom;
        RoomVariable aux = room.GetVariable("RoomVC");
        SFSArray array = (SFSArray)aux.GetSFSArrayValue();

        SFSArray user;
        SFSArray conection;

        for(int i=0; i<array.Size(); i++){
            conection = (SFSArray)array.GetSFSArray(i);
            user = (SFSArray)conection.GetSFSArray(0);
            if (user.GetUtfString(0) == name){

                user = new SFSArray();
                user.AddUtfString(currentName);
                user.AddUtfString(ip);

                array.GetSFSArray(i).AddSFSArray(user);
            }
        }

        roomVars.Add( new SFSRoomVariable("RoomVC", array) );
        smartFox.Send ( new SetRoomVariablesRequest(roomVars, smartFox.LastJoinedRoom) );
        printRoomVC();
    }
Ejemplo n.º 7
0
        private ISFSArray UnrollArray(ArrayList arr)
        {
            ISFSArray   iSFSArray  = SFSArray.NewInstance();
            IEnumerator enumerator = arr.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    object         current        = enumerator.Current;
                    SFSDataWrapper sFSDataWrapper = WrapField(current);
                    if (sFSDataWrapper == null)
                    {
                        throw new SFSCodecError(string.Concat("Cannot serialize field of array: ", current, " -- unsupported type!"));
                    }
                    iSFSArray.Add(sFSDataWrapper);
                }
                return(iSFSArray);
            }
            finally
            {
                IDisposable disposable;
                if ((disposable = enumerator as IDisposable) != null)
                {
                    disposable.Dispose();
                }
            }
        }
Ejemplo n.º 8
0
        private ISFSArray DecodeSFSArray(ByteArray buffer)
        {
            //Discarded unreachable code: IL_00c1
            ISFSArray   iSFSArray   = SFSArray.NewInstance();
            SFSDataType sFSDataType = (SFSDataType)Convert.ToInt32(buffer.ReadByte());

            if (sFSDataType != SFSDataType.SFS_ARRAY)
            {
                throw new SFSCodecError(string.Concat("Invalid SFSDataType. Expected: ", SFSDataType.SFS_ARRAY, ", found: ", sFSDataType));
            }
            int num = buffer.ReadShort();

            if (num < 0)
            {
                throw new SFSCodecError("Can't decode SFSArray. Size is negative: " + num);
            }
            try
            {
                for (int i = 0; i < num; i++)
                {
                    SFSDataWrapper sFSDataWrapper = DecodeObject(buffer);
                    if (sFSDataWrapper != null)
                    {
                        iSFSArray.Add(sFSDataWrapper);
                        continue;
                    }
                    throw new SFSCodecError("Could not decode SFSArray item at index: " + i);
                }
                return(iSFSArray);
            }
            catch (SFSCodecError sFSCodecError)
            {
                throw sFSCodecError;
            }
        }
Ejemplo n.º 9
0
        public void OnResult(ISFSObject response)
        {
            RStatus = RoomStatus.Over;
            int[]      cards = response.GetIntArray("cards");
            JhUserInfo self  = GetPlayerInfo <JhUserInfo>();

            self.Cards = cards;
            ISFSArray users = response.GetSFSArray("users");

            for (int i = 0; i < users.Count; i++)
            {
                ISFSObject itemData = users.GetSFSObject(i);
                int        seat     = itemData.GetInt("seat");
                JhUserInfo user     = GetPlayerInfo <JhUserInfo>(seat, true);
                user.SetResult(itemData);
            }

            if (response.ContainsKey("compare"))
            {
                ISFSArray arr = response.GetSFSArray("compare");
                for (int i = 0; i < arr.Size(); i++)
                {
                    ISFSObject obj   = arr.GetSFSObject(i);
                    int        seat  = obj.GetInt("seat");
                    JhUserInfo uInfo = GetPlayerInfo <JhUserInfo>(seat, true);
                    uInfo.Cards = obj.GetIntArray("cards");
                    int[] cards1 = obj.GetIntArray("cards");
                    Debug.LogError(" result cards " + uInfo.NickM + "  " + cards1[0] + " " + cards1[1] + " " + cards1[2]);
                }
            }


            bool isWinner = false;

            ResultSfs = SFSArray.NewInstance();
            foreach (var useinfo in UserInfoDict)
            {
                if (useinfo.Value.IsPlayingGame)
                {
                    JhUserInfo jhUserInfo = ((JhUserInfo)useinfo.Value);
                    ISFSObject obj        = jhUserInfo.GetResultSfsObject();
                    obj.PutInt("Chair", useinfo.Key);

                    if (useinfo.Key == 0 && jhUserInfo.IsWinner)
                    {
                        isWinner = true;
                    }
                    obj.PutBool("IsWinner", isWinner);
                    ResultSfs.AddSFSObject(obj);
                }
            }

            EventObj.SendEvent("PlayersViewEvent", "Result", ResultSfs);

            ResultDelay = StartCoroutine(SendToResultView(ResultSfs));

            EventObj.SendEvent("SoundEvent", "PlayerEffect", new JhSound.SoundData(isWinner ? JhSound.EnAudio.Win : JhSound.EnAudio.Lost));
        }
Ejemplo n.º 10
0
	public void initFromSmartfox(SFSArray aArray) {
		if(aArray!=null) {
			Debug.Log("Brands: "+aArray.Size()); 
			for(int i = 0;i<aArray.Size();i++) {
				brands.Add(new Brand((SFSObject) aArray.GetSFSObject(i)));
			}
		}

	}
Ejemplo n.º 11
0
        public virtual ISFSArray ToSFSArray()
        {
            ISFSArray iSFSArray = SFSArray.NewInstance();

            iSFSArray.AddUtfString(name);
            iSFSArray.AddByte((byte)type);
            PopulateArrayWithValue(iSFSArray);
            return(iSFSArray);
        }
Ejemplo n.º 12
0
        public override void Execute(SmartFox sfs)
        {
            ISFSArray iSFSArray = SFSArray.NewInstance();

            foreach (BuddyVariable buddyVariable in buddyVariables)
            {
                iSFSArray.AddSFSArray(buddyVariable.ToSFSArray());
            }
            sfso.PutSFSArray(KEY_BUDDY_VARS, iSFSArray);
        }
Ejemplo n.º 13
0
        public override void Execute(SmartFox sfs)
        {
            ISFSArray iSFSArray = SFSArray.NewInstance();

            foreach (UserVariable userVariable in userVariables)
            {
                iSFSArray.AddSFSArray(userVariable.ToSFSArray());
            }
            sfso.PutSFSArray(KEY_VAR_LIST, iSFSArray);
        }
Ejemplo n.º 14
0
        public void OnGameInfo(ISFSObject data)
        {
            if (data.ContainsKey("tptime"))
            {
                HupTime = data.GetInt("tptime");
            }

            string hupInfo;

            if (data.ContainsKey("hup"))
            {
                hupInfo = data.GetUtfString("hup");
            }
            else
            {
                return;
            }
            //接收重连解散信息
            if (!string.IsNullOrEmpty(hupInfo))
            {
                IsNotFirstTime = true;
                StartTime      = data.ContainsKey("hupstart") ? data.GetLong("hupstart") : 0;
                string[] ids = hupInfo.Split(',');

                for (int i = 0; i < ids.Length; i++)
                {
                    for (int j = 0, max = UserHupUp.Count; j < max; j++)
                    {
                        var id = int.Parse(ids[i]);
                        if (id.Equals(int.Parse(UserHupUp[j].UserInfo.UserId)))
                        {
                            //2发起投票 3同意 -1拒绝
                            UserHupUp[j].Status = i == 0 ? HupType.Start : HupType.TongYi;
                            if (id.Equals(int.Parse(SelfID)))
                            {
                                SelfChoose = true;
                            }
                        }
                    }
                }

                ISFSObject sendObj = SFSObject.NewInstance();
                ISFSArray  arr     = SFSArray.NewInstance();
                foreach (HupUp hupUp in UserHupUp)
                {
                    arr.AddSFSObject(hupUp.GetSfsObject());
                }
                sendObj.PutSFSArray("Users", arr);
                sendObj.PutInt("HupTime", HupTime);
                sendObj.PutLong("StartTime", StartTime);
                sendObj.PutBool("SelfChoose", SelfChoose);
                //发送投票view
                EventObj.SendEvent("HupUpViewEvent", "HupUp", sendObj);
            }
        }
Ejemplo n.º 15
0
        void OnLogin(BaseEvent eventParam)
        {
            Task.Run(() =>
            {
                if (false)
                {
                    Console.WriteLine("OnLogin : "******"\t" + kvp.Key + " : " + kvp.Value);
                    }
                }
                if (!SFClient.UdpInited)
                {
                    SFClient.AddEventListener(SFSEvent.UDP_INIT, new EventListenerDelegate(OnUdpInit));
                    SFClient.InitUDP();
                    return;
                }
                if (eventParam.Params["zone"].ToString() == "1BattleZone")
                {
                    //System.Threading.Thread.Sleep(8000);
                    //Login();
                    //System.Threading.Thread.Sleep(1000);
                    SFClient.Send(new ExtensionRequest("joinRoom", new SFSObject()));
                }

                if (!InBattle)
                {
                    var isfsobject = new SFSObject();
                    isfsobject.PutShort("sid", 0);
                    isfsobject.PutBool("sst", true);
                    var isfsarray = new SFSArray();
                    isfsarray.AddFloat(X);
                    isfsarray.AddFloat(0.0f);
                    isfsarray.AddFloat(Y);
                    isfsobject.PutSFSArray("pos", isfsarray);
                    SFClient.Send(new ExtensionRequest("joinRoom", isfsobject));

                    isfsobject = new SFSObject();
                    isfsobject.PutShort("sid", 1);
                    SFClient.Send(new ExtensionRequest("joinRoom", isfsobject));

                    isfsobject = new SFSObject();
                    isfsobject.PutShort("sid", 8);
                    SFClient.Send(new ExtensionRequest("joinRoom", isfsobject));


                    InBattle   = true;
                    isfsobject = new SFSObject();
                    isfsobject.PutShort("sid", 1);
                    isfsobject.PutShort("spid", 0);
                    SFClient.Send(new ExtensionRequest("spawnMonster", isfsobject));
                }
            });
        }
Ejemplo n.º 16
0
 public static void TryGetValueWitheKey(ISFSObject data, out ISFSArray value, string key)
 {
     if (data.ContainsKey(key))
     {
         value = data.GetSFSArray(key);
     }
     else
     {
         value = new SFSArray();
         TryGetLog(key);
     }
 }
Ejemplo n.º 17
0
        protected void OnHupUpResponse(object data)
        {
            ISFSObject obj    = (ISFSObject)data;
            int        id     = obj.GetInt(RequestKey.KeyId);
            int        starus = obj.GetInt(RequestKey.KeyType);

            if (starus == 2)
            {
                SelfChoose = false;
                foreach (HupUp hupUp in UserHupUp)
                {
                    hupUp.Status = 0;
                }
            }
            foreach (HupUp hupUp in UserHupUp)
            {
                if (hupUp.UserInfo.UserId.Equals(id.ToString()))
                {
                    hupUp.Status = (HupType)starus;
                }
            }
            if (id.Equals(int.Parse(SelfID)))
            {
                SelfChoose = true;
            }

            ISFSObject sendObj = SFSObject.NewInstance();

            if (!IsNotFirstTime)
            {
                StartTime      = JhFunc.GetTimeStamp();
                IsNotFirstTime = true;
                sendObj.PutInt("HupTime", HupTime);
                sendObj.PutLong("StartTime", StartTime);
            }

            ISFSArray arr = SFSArray.NewInstance();

            foreach (HupUp hupUp in UserHupUp)
            {
                arr.AddSFSObject(hupUp.GetSfsObject());
            }
            sendObj.PutSFSArray("Users", arr);
            sendObj.PutBool("SelfChoose", SelfChoose);
            //发送投票view
            EventObj.SendEvent("HupUpViewEvent", "HupUp", sendObj);

            if (starus == -1)
            {
                CloseHup();
                Reset();
            }
        }
Ejemplo n.º 18
0
        public ISFSArray ToSFSArray()
        {
            MatchExpression matchExpression = Rewind();
            ISFSArray       iSFSArray       = new SFSArray();

            iSFSArray.AddSFSArray(matchExpression.ExpressionAsSFSArray());
            while (matchExpression.HasNext())
            {
                matchExpression = matchExpression.Next();
                iSFSArray.AddSFSArray(matchExpression.ExpressionAsSFSArray());
            }
            return(iSFSArray);
        }
Ejemplo n.º 19
0
    public void SendPos(Transform player)
    {
        SFSArray positionArray = new SFSArray();

        positionArray.AddFloat(player.position.x);
        positionArray.AddFloat(player.position.z);

        List <UserVariable> userVariables = new List <UserVariable>();

        userVariables.Add(new SFSUserVariable("pos", positionArray, 6));

        SmartFoxConnection.SFS.Send(new SetUserVariablesRequest(userVariables));
    }
Ejemplo n.º 20
0
    public void SendAnimWalk(string xName, float xFloat, string yName, float yFloat)
    {
        SFSArray AnimArray = new SFSArray();

        AnimArray.AddText(xName);
        AnimArray.AddFloat(xFloat);
        AnimArray.AddText(yName);
        AnimArray.AddFloat(yFloat);

        List <UserVariable> userVariables = new List <UserVariable>();

        userVariables.Add(new SFSUserVariable("animWalk", AnimArray, 6));

        SmartFoxConnection.SFS.Send(new SetUserVariablesRequest(userVariables));
    }
        public override void Execute(SmartFox sfs)
        {
            ISFSArray iSFSArray = SFSArray.NewInstance();

            foreach (RoomVariable roomVariable in roomVariables)
            {
                iSFSArray.AddSFSArray(roomVariable.ToSFSArray());
            }
            if (room == null)
            {
                room = sfs.LastJoinedRoom;
            }
            sfso.PutSFSArray(KEY_VAR_LIST, iSFSArray);
            sfso.PutInt(KEY_VAR_ROOM, room.Id);
        }
Ejemplo n.º 22
0
        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);
        }
Ejemplo n.º 23
0
	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;
		}
	}
Ejemplo n.º 24
0
        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());
        }
Ejemplo n.º 25
0
        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);
        }
Ejemplo n.º 26
0
    public void addConection()
    {
        Debug.Log("addConection");
        List<RoomVariable> roomVars = new List<RoomVariable>();
        Room room = smartFox.LastJoinedRoom;
        RoomVariable aux = room.GetVariable("RoomVC");
        SFSArray array = new SFSArray();
        if (aux != null)
            array = (SFSArray)aux.GetSFSArrayValue();

        SFSArray user = new SFSArray();
        user.AddUtfString(currentName);
        user.AddUtfString(ip);
        SFSArray conection = new SFSArray();
        conection.AddSFSArray(user);
        array.AddSFSArray(conection);

        roomVars.Add( new SFSRoomVariable("RoomVC", array) );
        smartFox.Send ( new SetRoomVariablesRequest(roomVars, smartFox.LastJoinedRoom) );
    }
Ejemplo n.º 27
0
	public void onLoggedIn(SFSObject aLoginData,SFSArray aHorses) {
		string challengeGoals = aLoginData.GetUtfString("ChallengeGoals");
		this.appleID = aLoginData.GetUtfString("AppleID");
		this.facebookID = Convert.ToString(aLoginData.GetLong("FacebookID"));
		this.googleID = aLoginData.GetUtfString("GoogleID");
		this.playerID = aLoginData.GetInt("ID");
		this.lastLogin = aLoginData.GetInt("LastLogin");
		this.playerName = aLoginData.GetUtfString("Username");
		this.referralRewardsReceived = aLoginData.GetInt("RewardsReceived");
		this.softCurrency = aLoginData.GetInt("SoftCurrency");
		this.hardCurrency = aLoginData.GetInt("HardCurrency");
		this.privilege = aLoginData.GetInt("Privilege");
		unpackHorses(aHorses); 
		this.selectedRaceHorse = this.horses[0];
		this.loggedIn = true;
		SFSObject obj = new SFSObject();
		obj.PutInt("l",selectedRaceHorse.level);
		SmartfoxConnectionHandler.REF.setMyName(this.playerName);
		SmartfoxConnectionHandler.REF.setMyHorseUserVar(selectedRaceHorse.compressedString(0));
		SmartfoxConnectionHandler.REF.sendMessage("rf2",obj);
	}
Ejemplo n.º 28
0
        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);
	}
Ejemplo n.º 30
0
    override public SFSObject ToSfsObj()
    {
        var data = base.ToSfsObj();

        data.PutUtfString(dataKeys.How.ToString(), How);

        SFSArray CategorieSfsArray = new SFSArray();

        foreach (var item in Categories)
        {
            CategorieSfsArray.AddUtfString(item);
        }
        data.PutSFSArray(dataKeys.categories.ToString(), CategorieSfsArray);

        var ingreadientSfsArray = new SFSArray();

        foreach (var item in Ingreadients)
        {
            ingreadientSfsArray.AddUtfString(item);
        }
        data.PutSFSArray(dataKeys.ingreadiants.ToString(), ingreadientSfsArray);
        return(data);
    }
Ejemplo n.º 31
0
    private void DrawRoomsGUI()
    {
        GUILayout.BeginArea(new Rect(screenW - 190, 290, 180, 150));

        if (GameValues.isHost)
        {
            //start game button event listener
            if (GUI.Button(new Rect(80, 110, 85, 24), "Start Game"))
            {

                // ****** Create the actual game ******* //
                String[] nameParts = this.currentActiveRoom.Name.Split('-');
                String gameName = nameParts[0] + " - Game";

                RoomSettings settings = new RoomSettings(gameName);
                settings.MaxUsers = (short)currentActiveRoom.MaxUsers; // how many players allowed: 12
                settings.Extension = new RoomExtension(GameManager.ExtName, GameManager.ExtClass);
                settings.IsGame = true;

                //get the variables set up from the lobby
                List<RoomVariable> lobbyVars = currentActiveRoom.GetVariables();
                SFSObject lobbyGameInfo = (SFSObject)((RoomVariable)lobbyVars[1]).GetSFSObjectValue();
                //lobbyGameInfo.GetSFSArray("
                //FORMAT BY INDEX
                //0 = (bool)        gameStarted
                //1 = (SFSObject)   gameInfo
                //      -(string)   the host username               key: "host"
                //      -(IntArray) playerIds                       key: "playerIDs"
                //      -(int)      number of Teams                 key: "numTeams"
                //      -(SFSArray) teams                           key: "teams"
                //      -(int)      length of the game in seconds   key: "gameLength"

                SFSRoomVariable gameInfo = new SFSRoomVariable("gameInfo", lobbyGameInfo);
                settings.Variables.Add(gameInfo);

                Debug.Log("numberOfPlayers: " + currentActiveRoom.UserCount);
                SFSRoomVariable userCountVar = new SFSRoomVariable("numberOfPlayers", currentActiveRoom.UserCount);
                settings.Variables.Add(userCountVar);

                SFSArray joinedPlayers = new SFSArray();
                SFSRoomVariable joinedVar = new SFSRoomVariable("playersJoined", joinedPlayers);
                settings.Variables.Add(joinedVar);

                //get the values from the appropriate fields to populate the gameInfo
                smartFox.Send(new CreateRoomRequest(settings, true));

                //let other players know to switch rooms
                List<RoomVariable> roomVars = new List<RoomVariable>();
                roomVars.Add(new SFSRoomVariable("gameStarted", true));
                smartFox.Send(new SetRoomVariablesRequest(roomVars));

            }
        }
        GUILayout.EndArea();
    }
Ejemplo n.º 32
0
 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));
 }
Ejemplo n.º 33
0
    private void SetupTheFox()
    {
        bool debug = true;
        running = true;
        if (SmartFoxConnection.IsInitialized)
        {
            smartFox = SmartFoxConnection.Connection;
        }
        else
        {
            smartFox = new SmartFox(debug);
        }
        currentRoom = smartFox.LastJoinedRoom;
        clientName = smartFox.MySelf.Name;

        // set up arrays of positions
        positions = new List<Vector3>();
        GameObject[] spawnPoints = GameObject.FindGameObjectsWithTag("SpawnTag");
        for (int i = 0; i < spawnPoints.Length; i++)
        {
            positions.Add(spawnPoints[i].transform.position);
        }

        lobbyGameInfo = (SFSObject)currentRoom.GetVariable("gameInfo").GetSFSObjectValue();

        host = lobbyGameInfo.GetUtfString("host");
        numberOfTeams = lobbyGameInfo.GetInt("numTeams");
        numberOfPlayers = currentRoom.GetVariable("numberOfPlayers").GetIntValue();
        teams = (SFSArray)lobbyGameInfo.GetSFSArray("teams");
        gameLength = lobbyGameInfo.GetInt("gameLength");

        gameLength = (int)lobbyGameInfo.GetInt("gameLength") * 1000;

        SetupListeners();
    }
Ejemplo n.º 34
0
    private void DrawRoomsGUI()
    {
        if (GameValues.isHost)
        {
            //start game button event listener
            if (GUILayout.Button("Start Game") && startGameTime <= 0)
            {

                // ****** Create the actual game ******* //
                String[] nameParts = this.currentActiveRoom.Name.Split('-');
                String gameName = nameParts[0].Trim() + " - Game";
                Debug.Log("Host created game named: " + gameName);

                RoomSettings settings = new RoomSettings(gameName);
                settings.MaxUsers = (short)currentActiveRoom.MaxUsers; // how many players allowed: 12
                settings.Extension = new RoomExtension(GameManager.ExtName, GameManager.ExtClass);
                settings.IsGame = true;
                settings.MaxVariables = 15;

                //get the variables set up from the lobby
                List<RoomVariable> lobbyVars = currentActiveRoom.GetVariables();
                SFSObject lobbyGameInfo = (SFSObject)((RoomVariable)lobbyVars[1]).GetSFSObjectValue();
                //lobbyGameInfo.GetSFSArray("
                //FORMAT BY INDEX
                //0 = (bool)        gameStarted
                //1 = (SFSObject)   gameInfo
                //      -(string)   the host username               key: "host"
                //      -(IntArray) playerIds                       key: "playerIDs"
                //      -(int)      number of Teams                 key: "numTeams"
                //      -(SFSArray) teams                           key: "teams"
                //      -(int)      length of the game in seconds   key: "gameLength"

                SFSRoomVariable gameInfo = new SFSRoomVariable("gameInfo", lobbyGameInfo);
                settings.Variables.Add(gameInfo);

                SFSRoomVariable userCountVar = new SFSRoomVariable("numberOfPlayers", currentActiveRoom.UserCount);
                settings.Variables.Add(userCountVar);

                SFSArray joinedPlayers = new SFSArray();
                SFSRoomVariable joinedVar = new SFSRoomVariable("playersJoined", joinedPlayers);
                settings.Variables.Add(joinedVar);

                //get the values from the appropriate fields to populate the gameInfo
                smartFox.Send(new CreateRoomRequest(settings));

                //start timer
                startGameTime = Time.time + 5.0f;
                Debug.Log("Start the countdown");

                List<RoomVariable> roomVars = new List<RoomVariable>();

                SFSRoomVariable startCountdown = new SFSRoomVariable("startCountdown", true);
                roomVars.Add(startCountdown);
                smartFox.Send(new SetRoomVariablesRequest(roomVars));
            }
        }
        else
        {
            //start game button event listener
            if (GUILayout.Button("Waiting..."))
            {
            }
        }
    }
Ejemplo n.º 35
0
        public void OnGuZhuYiZhi(ISFSObject response)
        {
            int  gold  = response.GetInt("goldinc");
            bool isWin = response.GetBool("result");

            JhUserInfo biUser = GetPlayerInfo <JhUserInfo>(CurrenPlayer, true);

            biUser.CoinA -= gold;
            TotalBet     += gold;
            biUser.IsGzyz = false;
            List <int> lostList = new List <int>();

            if (isWin)
            {
                foreach (var userInfo in UserInfoDict)
                {
                    JhUserInfo jhUser = (JhUserInfo)userInfo.Value;
                    if (jhUser != biUser)
                    {
                        jhUser.IsFail = true;
                        lostList.Add(GetLocalSeat(jhUser.Seat));
                    }
                }
            }
            else
            {
                biUser.IsFail = true;
                lostList.Add(GetLocalSeat(CurrenPlayer));
            }

            if (response.ContainsKey("fancha"))
            {
                ISFSArray arr = response.GetSFSArray("fancha");
                for (int i = 0; i < arr.Count; i++)
                {
                    ISFSObject obj     = arr.GetSFSObject(i);
                    int        seat    = obj.GetInt("seat");
                    int        fancha  = obj.GetInt("gold");
                    JhUserInfo fanUser = GetPlayerInfo <JhUserInfo>(seat, true);
                    fanUser.CoinA += fancha;
                }
            }

            ISFSObject sendObj = SFSObject.NewInstance();

            sendObj.PutInt("Chair", GetLocalSeat(CurrenPlayer));
            sendObj.PutInt("Gold", gold);
            sendObj.PutBool("isWin", isWin);
            sendObj.PutUtfString("Name", biUser.Name);
            sendObj.PutIntArray("LostList", lostList.ToArray());
            //如果存在 反差值的情况 刷新金币
            if (response.ContainsKey("fancha"))
            {
                //刷新金币
                ISFSArray arr = SFSArray.NewInstance();
                foreach (var info in UserInfoDict)
                {
                    JhUserInfo jhInfo = (JhUserInfo)info.Value;
                    if (jhInfo.IsPlaying())
                    {
                        ISFSObject obj = SFSObject.NewInstance();
                        obj.PutInt("Chair", GetLocalSeat(jhInfo.Seat));
                        obj.PutLong("Gold", jhInfo.CoinA);
                        arr.AddSFSObject(obj);
                    }
                }
                sendObj.PutSFSArray("FanCha", arr);
            }

            EventObj.SendEvent("PlayersViewEvent", "GZYZ", sendObj);

            EventObj.SendEvent("SoundEvent", "PlayerEffect", new JhSound.SoundData(JhSound.EnAudio.CompareAnimate));

            EventObj.SendEvent("TableViewEvent", "Bet", TotalBet);
        }
Ejemplo n.º 36
0
        protected void SendGameStatusToPlayerView()
        {
            ISFSObject sendObj   = SFSObject.NewInstance();
            ISFSArray  sendArray = SFSArray.NewInstance();

            foreach (var info in UserInfoDict)
            {
                JhUserInfo userInfo = (JhUserInfo)info.Value;
                if (userInfo != null)
                {
                    ISFSObject obj = userInfo.GetSfsObject(RStatus);
                    obj.PutInt("Chair", GetLocalSeat(userInfo.Seat));
                    sendArray.AddSFSObject(obj);
                }
            }
            sendObj.PutBool("isShowTimeTip", CoustemTime > 0);

            if (RStatus > RoomStatus.CanStart)
            {
                sendObj.PutInt("CurChair", GetLocalSeat(CurrenPlayer));
                sendObj.PutDouble("CdTime", CdTime);
                sendObj.PutLong("LastTime", LastTime);

                if (CurrenPlayer == SelfSeat)
                {
                    JhUserInfo curUser = GetPlayerInfo <JhUserInfo>(CurrenPlayer, true);
                    if (!curUser.IsGzyz && IsAutoFollow)
                    {
                        sendObj.PutDouble("CdTime", 2.0f);
                    }
                }

                JhUserInfo currP = GetPlayerInfo <JhUserInfo>(CurrenPlayer, true);
                SetCurrenPlayerBeatMinAndMax(currP, sendObj);

                sendObj.PutInt("Banker", GetLocalSeat(BankerSeat));

                if (TotalBet != 0)
                {
                    ISFSArray betArray = SFSArray.NewInstance();
                    int       ttBet    = TotalBet;
                    for (int i = AnteRate.Count - 1; i >= 0; i--)
                    {
                        if (ttBet >= AnteRate[i])
                        {
                            ISFSObject arrO = SFSObject.NewInstance();
                            arrO.PutInt("ChipValue", AnteRate[i]);
                            arrO.PutInt("ChipIndex", i);
                            arrO.PutInt("ChipCnt", ttBet / AnteRate[i]);
                            betArray.AddSFSObject(arrO);
                            ttBet = ttBet % AnteRate[i];
                        }
                    }
                    sendObj.PutSFSArray("ChipList", betArray);
                }
            }

            sendObj.PutSFSArray("Players", sendArray);
            sendObj.PutIntArray("Antes", AnteRate.ToArray());
            sendObj.PutInt("SingleBet", SingleBet);
            sendObj.PutBool("IsPlaying", RStatus > RoomStatus.CanStart && RStatus != RoomStatus.Over);

            SetSfsUserContrl(sendObj);

            EventObj.SendEvent("PlayersViewEvent", "Status", sendObj);
        }
Ejemplo n.º 37
0
    private void UpdateTeamLists()
    {
        ISFSArray arr = new SFSArray();

        redTeam.Clear();
        blueTeam.Clear();
        RoomVariable redVar = smartFox.LastJoinedRoom.GetVariable("red");
        RoomVariable blueVar = smartFox.LastJoinedRoom.GetVariable("blue");
        if(redVar != null) {
            arr = redVar.GetSFSArrayValue();
            for(int i = 0; i < arr.Size(); i++) {
                redTeam.Add(arr.GetUtfString(i));
            }
        }
        if(blueVar != null) {
            arr = blueVar.GetSFSArrayValue();
            for(int i = 0; i < arr.Size(); i++) {
                blueTeam.Add(arr.GetUtfString(i));
            }
        }
    }
Ejemplo n.º 38
0
	public void sendHorsesArray(string aCommand,SFSArray aHorses)
	{
		SFSObject p = new SFSObject();
		p.PutSFSArray("horses",aHorses);
		sfs.Send(new ExtensionRequest(aCommand,p,null));
	}
Ejemplo n.º 39
0
 public SFSArray getListaStoriesToSFSArray()
 {
     SFSArray listaStoriesArray=new SFSArray();
       foreach(UserStory story in this.getListaStories())
         listaStoriesArray.AddSFSObject(story.toSFSObject());
      return listaStoriesArray;
 }
Ejemplo n.º 40
0
    void Start()
    {
        smartFox = SmartFoxConnection.Connection;
        AddEventListeners();

        _roundsInt = rounds;

        UpdateTeamLists();

        SFSArray myTeamUpdate = new SFSArray();

        if (blueTeam.Count < redTeam.Count) {
            isBlueTeam = true;
        }

        List<RoomVariable> roomVars = new List<RoomVariable>();

        if (isBlueTeam)
        {
            blueTeam.Add(smartFox.MySelf.Name);
            foreach(string name in blueTeam)
            {
                myTeamUpdate.AddUtfString(name);
            }
            roomVars.Add(new SFSRoomVariable("blue", myTeamUpdate));

            if (smartFox.LastJoinedRoom.GetVariable("blueRobot").GetStringValue() == "")
            {
                roomVars.Add(new SFSRoomVariable("blueRobot", smartFox.MySelf.Name));
            }
        }
        else
        {
            redTeam.Add(smartFox.MySelf.Name);
            foreach(string name in redTeam)
            {
                myTeamUpdate.AddUtfString(name);
            }
            roomVars.Add(new SFSRoomVariable("red", myTeamUpdate));

            if (smartFox.LastJoinedRoom.GetVariable("redRobot").GetStringValue() == "")
            {
                roomVars.Add(new SFSRoomVariable("redRobot", smartFox.MySelf.Name));
            }
        }

        List<RoomVariable> variables = smartFox.LastJoinedRoom.GetVariables();

        foreach(RoomVariable roomVar in variables)
        {
            Debug.Log(roomVar.Name);
        }

        smartFox.Send(new SetRoomVariablesRequest(roomVars,smartFox.LastJoinedRoom));
    }
Ejemplo n.º 41
0
    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));
    }
Ejemplo n.º 42
0
 public SFSArray getListaCriteriosToSFSArray()
 {
     SFSArray listaCriteriosArray=new SFSArray();
     foreach(AcceptanceCriteria ac in this.getListaAcceptanceCriteria())
         listaCriteriosArray.AddSFSObject(ac.toSFSObject());
     return listaCriteriosArray;
 }
Ejemplo n.º 43
0
 public SFSArray getListaEstimacionToSFSArray()
 {
     SFSArray listaEstimacionArray=new SFSArray();
     foreach(Estimacion est in this.getListaEstimacion())
         listaEstimacionArray.AddSFSObject(est.toSFSObject());
      	return listaEstimacionArray;
 }
Ejemplo n.º 44
0
 public override void Execute(SmartFox sfs)
 {
     sfso.PutUtfString(KEY_NAME, settings.Name);
     sfso.PutUtfString(KEY_GROUP_ID, settings.GroupId);
     sfso.PutUtfString(KEY_PASSWORD, settings.Password);
     sfso.PutBool(KEY_ISGAME, settings.IsGame);
     sfso.PutShort(KEY_MAXUSERS, settings.MaxUsers);
     sfso.PutShort(KEY_MAXSPECTATORS, settings.MaxSpectators);
     sfso.PutShort(KEY_MAXVARS, settings.MaxVariables);
     sfso.PutBool(KEY_ALLOW_JOIN_INVITATION_BY_OWNER, settings.AllowOwnerOnlyInvitation);
     if (settings.Variables != null && settings.Variables.Count > 0)
     {
         ISFSArray iSFSArray = SFSArray.NewInstance();
         foreach (RoomVariable variable in settings.Variables)
         {
             if (variable is RoomVariable)
             {
                 RoomVariable roomVariable = variable as RoomVariable;
                 iSFSArray.AddSFSArray(roomVariable.ToSFSArray());
             }
         }
         sfso.PutSFSArray(KEY_ROOMVARS, iSFSArray);
     }
     if (settings.Permissions != null)
     {
         List <bool> list = new List <bool>();
         list.Add(settings.Permissions.AllowNameChange);
         list.Add(settings.Permissions.AllowPasswordStateChange);
         list.Add(settings.Permissions.AllowPublicMessages);
         list.Add(settings.Permissions.AllowResizing);
         sfso.PutBoolArray(KEY_PERMISSIONS, list.ToArray());
     }
     if (settings.Events != null)
     {
         List <bool> list2 = new List <bool>();
         list2.Add(settings.Events.AllowUserEnter);
         list2.Add(settings.Events.AllowUserExit);
         list2.Add(settings.Events.AllowUserCountChange);
         list2.Add(settings.Events.AllowUserVariablesUpdate);
         sfso.PutBoolArray(KEY_EVENTS, list2.ToArray());
     }
     if (settings.Extension != null)
     {
         sfso.PutUtfString(KEY_EXTID, settings.Extension.Id);
         sfso.PutUtfString(KEY_EXTCLASS, settings.Extension.ClassName);
         if (settings.Extension.PropertiesFile != null && settings.Extension.PropertiesFile.Length > 0)
         {
             sfso.PutUtfString(KEY_EXTPROP, settings.Extension.PropertiesFile);
         }
     }
     if (settings is MMORoomSettings)
     {
         MMORoomSettings mMORoomSettings = settings as MMORoomSettings;
         if (mMORoomSettings.DefaultAOI.IsFloat())
         {
             sfso.PutFloatArray(KEY_MMO_DEFAULT_AOI, mMORoomSettings.DefaultAOI.ToFloatArray());
             if (mMORoomSettings.MapLimits != null)
             {
                 sfso.PutFloatArray(KEY_MMO_MAP_LOW_LIMIT, mMORoomSettings.MapLimits.LowerLimit.ToFloatArray());
                 sfso.PutFloatArray(KEY_MMO_MAP_HIGH_LIMIT, mMORoomSettings.MapLimits.HigherLimit.ToFloatArray());
             }
         }
         else
         {
             sfso.PutIntArray(KEY_MMO_DEFAULT_AOI, mMORoomSettings.DefaultAOI.ToIntArray());
             if (mMORoomSettings.MapLimits != null)
             {
                 sfso.PutIntArray(KEY_MMO_MAP_LOW_LIMIT, mMORoomSettings.MapLimits.LowerLimit.ToIntArray());
                 sfso.PutIntArray(KEY_MMO_MAP_HIGH_LIMIT, mMORoomSettings.MapLimits.HigherLimit.ToIntArray());
             }
         }
         sfso.PutShort(KEY_MMO_USER_MAX_LIMBO_SECONDS, (short)mMORoomSettings.UserMaxLimboSeconds);
         sfso.PutShort(KEY_MMO_PROXIMITY_UPDATE_MILLIS, (short)mMORoomSettings.ProximityListUpdateMillis);
         sfso.PutBool(KEY_MMO_SEND_ENTRY_POINT, mMORoomSettings.SendAOIEntryPoint);
     }
     sfso.PutBool(KEY_AUTOJOIN, autoJoin);
     if (roomToLeave != null)
     {
         sfso.PutInt(KEY_ROOM_TO_LEAVE, roomToLeave.Id);
     }
 }
Ejemplo n.º 45
0
    private void DrawUsersGUI(Rect screenPos)
    {
        GUILayout.BeginArea(screenPos);
        GUI.Box(new Rect(0, 0, screenPos.width, screenPos.height), "");
        GUILayout.BeginVertical();
        GUILayout.Label("Users");
        userScrollPosition = GUILayout.BeginScrollView(userScrollPosition, false, true, GUILayout.Width(screenPos.width));
        GUILayout.BeginVertical();
        List<User> userList = currentActiveRoom.UserList;
        foreach (User user in userList)
        {
            GUILayout.Label(user.Name);
        }
        GUILayout.EndVertical();
        GUILayout.EndScrollView();
        GUILayout.BeginHorizontal();
        // Logout button
        if (GUILayout.Button("Logout"))
        {
            smartFox.Send(new LogoutRequest());
        }
        // Game Room button
        if (currentActiveRoom.Name == "The Lobby")
        {
            if (GUILayout.Button("Make Game"))
            {
                Debug.Log("Make Game Button clicked");

                // ****** Create new room ******* //
                int gameLength = 120; //time in seconds

                //let smartfox take care of error if duplicate name
                RoomSettings settings = new RoomSettings(username + " - Room");
                // how many players allowed
                settings.MaxUsers = (short)maxPlayers;
                //settings.GroupId = "create";
                //settings.IsGame = true;

                List<RoomVariable> roomVariables = new List<RoomVariable>();
                //roomVariables.Add(new SFSRoomVariable("host", username));
                roomVariables.Add(new SFSRoomVariable("gameStarted", false));   //a game started bool
                // set up arrays of colors
                //SFSArray nums = new SFSArray();
                //for (int i = 0; i < 5; i++)
                //{
                //    nums.AddInt(i);
                //}
                //roomVariables.Add(new SFSRoomVariable("colorNums", nums));

                SFSObject gameInfo = new SFSObject();
                gameInfo.PutUtfString("host", username);                        //the host
                SFSArray playerIDs = new SFSArray(); //[maxPlayers];
                for (int i = 0; i < maxPlayers; i++)
                {
                    playerIDs.AddInt(i);
                }

                gameInfo.PutSFSArray("playerIDs", playerIDs);                   //the player IDs
                gameInfo.PutInt("numTeams", numTeams);                          //the number of teams

                SFSArray teams = new SFSArray();								//ASSIGN WHICH PLAYERS GO ON WHICH TEAMS
                int counter = 0;
                int[] teamPlayerIndices;										// numTeams = 8, maxPlayers = 16
                for (int i = 0; i < numTeams; i++)								// i = 0, j = 0, j = 1, index = 0, index = 8
                {																// i = 1, j = 0, j = 1, index = 1, index = 9
                    teamPlayerIndices = new int[maxPlayers / numTeams];			// i = 2, j = 0, j = 1, index = 2, index = 10
                    for (int j = 0; j < maxPlayers / numTeams; j++)				// i = 3, j = 0, j = 1, index = 3, index = 11
                    { 															// ...
                        int index = i + (j * numTeams);
                        teamPlayerIndices[j] = index;							// i = 7, j = 0, j = 1, index = 7, index = 15
                    }

                    teams.AddIntArray(teamPlayerIndices);
                }
                gameInfo.PutSFSArray("teams", teams);                           //an array of possible values to be grabbed
                gameInfo.PutInt("gameLength", gameLength);                      //the length of the game

                roomVariables.Add(new SFSRoomVariable("gameInfo", gameInfo));

                settings.Variables = roomVariables;
                smartFox.Send(new CreateRoomRequest(settings, true, CurrentActiveRoom));           // Contains: maxUsers, and roomVariables
                Debug.Log("new room " + username + "- Room");
            }
        }
        GUILayout.EndHorizontal();
        GUILayout.EndVertical();
        GUILayout.EndArea();
    }
Ejemplo n.º 46
0
    public void OnExtensionResponse(BaseEvent evt)
    {
        try
        {
            string     text       = (string)evt.Params["cmd"];
            ISFSObject iSFSObject = (SFSObject)evt.Params["params"];
            switch (text)
            {
            case "pingAck":
                break;

            case "spawnPlayerAck":
                break;

            case "findRoom":
                Logger.trace("[OnExtensionResponse] found room");
                break;

            case "findRoomAck":
                Logger.trace("[OnExtensionResponse]  room found " + evt.Params.ToString());
                break;

            case "startGame":
                Logger.trace("[OnExtensionResponse]  Receiving Message startGame");
                break;

            case "stopGame":
                Logger.trace("[OnExtensionResponse] Receiving stop game");
                break;

            case "sendEvents":
            {
                SFSArray sFSArray = (SFSArray)iSFSObject.GetSFSArray("events");
                for (int j = 0; j < sFSArray.Size(); j++)
                {
                    SFSObject sFSObject2 = (SFSObject)sFSArray.GetSFSObject(j);
                    int       int3       = sFSObject2.GetInt("playerId");
                    PassEventToPlayerObject(sFSObject2, int3);
                }
                break;
            }

            case "queueTime":
                m_qTime = iSFSObject.GetInt("queueTime");
                break;

            case "sendSummary":
            {
                Debug.Log("\n");
                Debug.Log("\n");
                Debug.Log("\n");
                Debug.Log("### receiving summary");
                Debug.Log("\n");
                Debug.Log("\n");
                Logger.trace("Battle Summary Received");
                Logger.traceError("Summary:" + iSFSObject.GetDump());
                int @int = iSFSObject.GetInt("BanzaiTotal");
                int int2 = iSFSObject.GetInt("AtlasTotal");
                Debug.Log("banzai total: " + @int);
                Debug.Log("atlas total: " + int2);
                GameData.BanzaiHacks = @int;
                GameData.AtlasHacks  = int2;
                string[] keys  = iSFSObject.GetKeys();
                string[] array = keys;
                foreach (string text2 in array)
                {
                    if (!text2.Equals("BanzaiTotal") && !text2.Equals("AtlasTotal"))
                    {
                        SFSObject sFSObject = (SFSObject)iSFSObject.GetSFSObject(text2);
                        Logger.traceError("statData: " + sFSObject.GetDump());
                        int playerId = Convert.ToInt32(text2);
                        GameData.addPlayerStats(playerId, sFSObject);
                    }
                }
                GameObject gameObject = GameObject.Find("Game");
                GamePlay   gamePlay   = gameObject.GetComponent("GamePlay") as GamePlay;
                if (gamePlay != null)
                {
                    gamePlay.BattleSummaryReceived();
                }
                else
                {
                    Debug.Log("cant find gameplay");
                }
                break;
            }

            default:
                Logger.trace("[OnExtensionResponse] unhandled event: " + text);
                break;
            }
        }
        catch (Exception ex)
        {
            Logger.traceError("Exception handling response: " + ex.Message + " >>> " + ex.StackTrace);
        }
    }
Ejemplo n.º 47
0
    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;
    }
Ejemplo n.º 48
0
    void Start()
    {
        Debug.Log("start game lobby");
        smartFox = SmartFoxConnection.Connection;
        currentActiveRoom = smartFox.LastJoinedRoom;

        smartFox.AddLogListener(LogLevel.INFO, OnDebugMessage);
        screenW = Screen.width;
        AddEventListeners();

        username = smartFox.MySelf.Name;

        lobbyGameInfo = (SFSObject)currentActiveRoom.GetVariable("gameInfo").GetSFSObjectValue();

        maxPlayers = currentActiveRoom.MaxUsers;
        host = lobbyGameInfo.GetUtfString("host");
        numberOfTeams = lobbyGameInfo.GetInt("numTeams");
        Debug.Log("start number of teams: " + numberOfTeams);
        if (GameValues.isHost)
            currentTeams = new int[8];

        teams = (SFSArray)lobbyGameInfo.GetSFSArray("teams");
        playerPerTeam = numberOfPlayers / numberOfTeams;
        gameLength = (int)lobbyGameInfo.GetInt("gameLength");

        //Make Contents for the popup gameLength list
        gameLengthList[0] = (new GUIContent("60"));
        gameLengthList[1] = (new GUIContent("120"));
        gameLengthList[2] = (new GUIContent("300"));
        gameLengthList[3] = (new GUIContent("600"));

        //Make Contents for the popup number of teams list
        teamNumberList[0] = (new GUIContent("2"));
        teamNumberList[1] = (new GUIContent("3"));
        teamNumberList[2] = (new GUIContent("4"));
        teamNumberList[3] = (new GUIContent("5"));
        teamNumberList[4] = (new GUIContent("6"));
        teamNumberList[5] = (new GUIContent("7"));
        teamNumberList[6] = (new GUIContent("8"));

        //Set team scroll positions to zero
        for(int i = 0; i < 8; i++)
        {
            teamScrollPositions.Add(Vector2.zero);
        }

        //Make a gui style for the lists
        listStyle.normal.textColor = Color.white;
        Texture2D tex = new Texture2D(2, 2);
        Color[] colors = new Color[4];
        for (int i = 0; i < 4; i++)
        {
            colors[i] = Color.white;
        }
        tex.SetPixels(colors);
        tex.Apply();
        listStyle.hover.background = tex;
        listStyle.onHover.background = tex;
        listStyle.padding.left = listStyle.padding.right = listStyle.padding.top = listStyle.padding.bottom = 4;

        if (GameValues.isHost)
        {
            currentIDs.AddInt(0);
            GameValues.playerID = 0;
            GameValues.teamNum = 0;
            currentTeams[0]++;
            List<UserVariable> uData = new List<UserVariable>();
            uData.Add(new SFSUserVariable("playerID", GameValues.playerID));
            uData.Add(new SFSUserVariable("playerTeam", GameValues.teamNum));
            smartFox.Send(new SetUserVariablesRequest(uData));

            SFSObject gameInfo = (SFSObject)currentActiveRoom.GetVariable("gameInfo").GetSFSObjectValue();

            //send back to store on server
            List<RoomVariable> rData = new List<RoomVariable>();
            gameInfo.PutSFSArray("playerIDs", currentIDs);
            rData.Add(new SFSRoomVariable("gameInfo", gameInfo));
            smartFox.Send(new SetRoomVariablesRequest(rData));

        }

        if (currentActiveRoom.ContainsVariable("lastGameScores"))
        {
            Debug.Log("scores from last game are present, adding to the message window...");
            //write out the last games scores to the chat window
            //format:
            //scores: int array
            //winner: string
            SFSObject lastGameData = (SFSObject)currentActiveRoom.GetVariable("lastGameScores").GetSFSObjectValue();
            int[] scoresArray = lastGameData.GetIntArray("scores");
            string[] teamColors = lastGameData.GetUtfStringArray("teamColors");

            messages.Add("Previous Game's Scores");
            messages.Add("The Winner is... " + lastGameData.GetUtfString("winner").ToString());
            for (int i = 0; i < scoresArray.Length; i++)
            {
                string teamName = teamColors[i] + " Team";
                messages.Add(teamName + "\tscored " + scoresArray[i].ToString() + " points.");
            }
        }

        tryJoiningRoom = false;
    }
Ejemplo n.º 49
0
 public SFSArray getListaTestToSFSArray()
 {
     SFSArray listaTestsArray=new SFSArray();
     foreach(Test t in this.getAssociatedTests())
         listaTestsArray.AddSFSObject(t.toSFSObject());
     return listaTestsArray;
 }
Ejemplo n.º 50
0
    private void RemovePlayer(int id, int teamId)
    {
        SFSObject gameInfo = (SFSObject)currentActiveRoom.GetVariable("gameInfo").GetSFSObjectValue();
        SFSArray idsLeft = (SFSArray)gameInfo.GetSFSArray("playerIDs");

        //update room variable
        SFSArray returnInts = new SFSArray();
        returnInts.AddInt(GameValues.playerID);
        Debug.Log("here in stuff: " + returnInts.GetInt(0));
        for (int i = 0; i < idsLeft.Size(); i++)
        {
            returnInts.AddInt(idsLeft.GetInt(i));
            Debug.Log("here in stuff: " + returnInts.GetInt(i + 1));
        }

        for (int i = 0; i < currentIDs.Size(); i++)
        {
            if (currentIDs.GetInt(i) == id)
            {
                currentIDs.RemoveElementAt(i);
                break;
            }
        }

        currentTeams[teamId]--;

        //send back to store on server
        List<RoomVariable> rData = new List<RoomVariable>();
        gameInfo.PutSFSArray("playerIDs", returnInts);
        rData.Add(new SFSRoomVariable("gameInfo", gameInfo));
        smartFox.Send(new SetRoomVariablesRequest(rData));
    }
Ejemplo n.º 51
0
        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);
                }
            });
        }
Ejemplo n.º 52
0
	public void unpackHorses(SFSArray aArray) {
		for(int i = 0;i<aArray.Size();i++) {
			HorseData h = new HorseData((SFSObject) aArray.GetSFSObject(i));
			horses.Add(h);  
		}
	}
Ejemplo n.º 53
0
    private void DrawButtonsGUI(Rect screenPos, int userBoxWidth, int gameBoxWidth)
    {
        GUILayout.BeginArea(screenPos);
        GUILayout.BeginHorizontal();
        // Logout button
         	if (GUILayout.Button("Logout", buttonStyle, GUILayout.MaxWidth(userBoxWidth + 50)))
        {
            smartFox.Send(new LogoutRequest());
        }

        GUILayout.Space(screenPos.width - (userBoxWidth + gameBoxWidth + 125));

        // Game Room button
        if (GUILayout.Button("Make Game", buttonStyle, GUILayout.MaxWidth(gameBoxWidth + 125)))
        {
            if (currentActiveRoom.Name == "The Lobby")
            {

                Debug.Log("Make Game Button clicked");

                if (createdMyRoom)
                {
                    smartFox.Send(new JoinRoomRequest(username + " - Room", "", CurrentActiveRoom.Id));
                    return;
                }

                // ****** Create new room ******* //
                int gameLength = 120; //time in seconds

                //let smartfox take care of error if duplicate name
                RoomSettings settings = new RoomSettings(username + " - Room");
                // how many players allowed
                settings.MaxUsers = (short)maxPlayers;
                //settings.GroupId = "create";
                //settings.IsGame = true;

                List<RoomVariable> roomVariables = new List<RoomVariable>();
                //roomVariables.Add(new SFSRoomVariable("host", username));
                roomVariables.Add(new SFSRoomVariable("gameStarted", false));   //a game started bool

                SFSObject gameInfo = new SFSObject();
                gameInfo.PutUtfString("host", username);                        //the host
                SFSArray playerIDs = new SFSArray(); //[maxPlayers];

                gameInfo.PutSFSArray("playerIDs", playerIDs);                   //the player IDs
                gameInfo.PutInt("numTeams", numTeams);                          //the number of teams

                //hmmmmm
                SFSArray teams = new SFSArray();								//ASSIGN WHICH PLAYERS GO ON WHICH TEAMS
                int[] teamPlayerIndices;										// numTeams = 8, maxPlayers = 16
                for (int i = 0; i < numTeams; i++)								// i = 0, j = 0, j = 1, index = 0, index = 8
                {																// i = 1, j = 0, j = 1, index = 1, index = 9
                    teamPlayerIndices = new int[maxPlayers / numTeams];			// i = 2, j = 0, j = 1, index = 2, index = 10
                    for (int j = 0; j < maxPlayers / numTeams; j++)				// i = 3, j = 0, j = 1, index = 3, index = 11
                    { 															// ...
                        int index = i + (j * numTeams);
                        teamPlayerIndices[j] = index;							// i = 7, j = 0, j = 1, index = 7, index = 15
                    }

                    teams.AddIntArray(teamPlayerIndices);
                }
                gameInfo.PutSFSArray("teams", teams);                           //an array of possible values to be grabbed
                gameInfo.PutInt("gameLength", gameLength);                      //the length of the game

                roomVariables.Add(new SFSRoomVariable("gameInfo", gameInfo));

                settings.Variables = roomVariables;
                smartFox.Send(new CreateRoomRequest(settings, true, CurrentActiveRoom));           // Contains: maxUsers, and roomVariables
                createdMyRoom = true;
                Debug.Log("new room " + username + " - Room ");
            }
        }

        GUILayout.EndHorizontal();
        GUILayout.EndArea();
    }
Ejemplo n.º 54
0
 public void UpdateStolenScore()
 {
     Debug.Log("Stealing a side");
     List<UserVariable> userVars = new List<UserVariable>();
     GameValues.numStolen++;
     GameValues.myScore += (valueNormal + valueSteal);
     Debug.Log("Num Stolen: " + GameValues.numStolen);
     SFSArray scores = new SFSArray();
     scores.AddInt(GameValues.numCaptured);
     scores.AddInt(GameValues.numLocked);
     scores.AddInt(GameValues.numStolen);
     scores.AddInt(GameValues.myScore);
     userVars.Add(new SFSUserVariable("score", scores));
     smartFox.Send(new SetUserVariablesRequest(userVars));
 }
Ejemplo n.º 55
0
 public SFSArray getListaTareasToSFSArray()
 {
     SFSArray listaTareasArray=new SFSArray();
     foreach(Task tarea in this.getListaTareas())
         listaTareasArray.AddSFSObject(tarea.toSFSObject());
      return listaTareasArray;
 }
Ejemplo n.º 56
0
 public void UpdateLockedScore()
 {
     List<UserVariable> userVars = new List<UserVariable>();
     GameValues.numLocked++;
     GameValues.myScore += (valueNormal + valueLock);
     SFSArray scores = new SFSArray();
     scores.AddInt(GameValues.numCaptured);
     scores.AddInt(GameValues.numLocked);
     scores.AddInt(GameValues.numStolen);
     scores.AddInt(GameValues.myScore);
     userVars.Add(new SFSUserVariable("score", scores));
     smartFox.Send(new SetUserVariablesRequest(userVars));
 }
Ejemplo n.º 57
0
    //receives messages from server extension which handles the physics list
    public void onExtensionResponse(BaseEvent evt)
    {
        SFSObject obj;

        //if there was proper detection of who has the lowest ping
        if(evt.Params["data"] != null)
        {
            obj = evt.Params["data"] as SFSObject;
            hierarchy = obj.GetSFSArray("hierarchy") as SFSArray;
        }
        //if there was no proper detection, at least turn an array to use that is likely not optimal
        else if(evt.Params["randomData"] != null)
        {
            obj = evt.Params["randomData"] as SFSObject;
            hierarchy = obj.GetSFSArray("hierarchy") as SFSArray;
        }
    }
Ejemplo n.º 58
0
    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));
    }
Ejemplo n.º 59
0
        private void OnTtResult(object data)
        {
            ItemList.Clear();

            JhGameTable GameData = App.GetGameData <JhGameTable>();

            ISFSObject obj = (ISFSObject)data;

            ISFSArray usersArr = obj.GetSFSArray("users");
            long      time     = obj.GetLong("svt");

            for (int i = 0; i < usersArr.Count; i++)
            {
                ISFSObject objItem = usersArr.GetSFSObject(i);
                if (objItem.GetKeys().Length > 0)
                {
                    var rItem = new TtResultItem
                    {
                        Name     = objItem.GetUtfString("nick"),
                        Avatar   = objItem.GetUtfString("avatar"),
                        Sex      = objItem.GetShort("sex"),
                        Gold     = objItem.GetInt("gold"),
                        WinCnt   = objItem.GetInt("win"),
                        LostCnt  = objItem.GetInt("lose"),
                        BipaiCnt = objItem.GetInt("abandon"),
                        UId      = objItem.GetInt("id")
                    };
                    ItemList.Add(rItem);
                }
            }
            int bigWiner = 0;
            int cnt      = 0;

            for (int i = 0; i < ItemList.Count; i++)
            {
                TtResultItem item = ItemList[i];
                if (item.WinCnt > cnt)
                {
                    bigWiner = i;
                    cnt      = item.WinCnt;
                }
            }

            ItemList[bigWiner].IsBigWinner = true;

            ISFSArray sendArr = SFSArray.NewInstance();

            foreach (TtResultItem item in ItemList)
            {
                sendArr.AddSFSObject(item.GetSfsObj());
            }
            ISFSObject sendObj = SFSObject.NewInstance();

            sendObj.PutSFSArray("Users", sendArr);
            sendObj.PutUtfString("Time", DateTime.FromBinary(time).ToString());
            sendObj.PutInt("MaxLun", GameData.maxRound);
            sendObj.PutInt("RoomID", GameData.CreateRoomInfo.RoomId);
            sendObj.PutInt("Ante", GameData.AnteRate[0]);
            sendObj.PutInt("Ju", GameData.CreateRoomInfo.CurRound);
            EventObj.SendEvent("TtResultViewEvent", "TtResultInfo", sendObj);
        }