コード例 #1
0
ファイル: JhRuleInfo.cs プロジェクト: narakai/chessgame
 public void SetCargs(ISFSObject cargs2)
 {
     string[] keys = cargs2.GetKeys();
     foreach (string s in keys)
     {
         Cargs.Add(s, cargs2.GetUtfString(s));
     }
 }
コード例 #2
0
        private Hashtable RebuildDict(ISFSObject sfsObj)
        {
            Hashtable hashtable = new Hashtable();

            string[] keys = sfsObj.GetKeys();
            foreach (string key in keys)
            {
                hashtable[key] = UnwrapField(sfsObj.GetData(key));
            }
            return(hashtable);
        }
コード例 #3
0
 private ByteArray Obj2bin(ISFSObject obj, ByteArray buffer)
 {
     string[] keys  = obj.GetKeys();
     string[] array = keys;
     foreach (string text in array)
     {
         SFSDataWrapper data = obj.GetData(text);
         buffer = EncodeSFSObjectKey(buffer, text);
         buffer = EncodeObject(buffer, data.Type, data.Data);
     }
     return(buffer);
 }
コード例 #4
0
    public override void OnHandleMessage(ISFSObject data)
    {
        maxCharacters = data.GetInt("maxCharacters");
        ISFSObject characters = data.GetSFSObject("characters");
        Character  character;

        foreach (string key in characters.GetKeys())
        {
            character = new Character();
            Debug.Log("Adding character: " + key);
            if (character.FromSFSObject(characters.GetSFSObject(key)))
            {
                characterList.Add(character);
            }
        }

        Debug.Log("Max: " + maxCharacters);
        Debug.Log("Characters: " + characterList.Count);
    }
コード例 #5
0
ファイル: PludoGameData.cs プロジェクト: narakai/chessgame
        public override void InitCfg(ISFSObject cargs2)
        {
            base.InitCfg(cargs2);
            var keys     = cargs2.GetKeys();
            var keyCount = keys.Length;

            HandUpTime        = ConstantData.ValueHupDefTime;
            ChoosePlaneCdTime = ConstantData.ValueCpDefTime;
            RollDicCdTime     = ConstantData.ValueRollDicDefTime;
            for (int i = 0; i < keyCount; i++)
            {
                var itemKey = keys[i];
                switch (itemKey)
                {
                case ConstantData.KeyCargsCpDicTime:
                    ChoosePlaneCdTime = int.Parse(cargs2.GetUtfString(itemKey));
                    YxDebug.LogError("自定义选择飞机时间:" + ChoosePlaneCdTime);
                    break;

                case ConstantData.KeyCargsRollDicTime:
                    RollDicCdTime = int.Parse(cargs2.GetUtfString(itemKey));
                    YxDebug.LogError("自定义打骰子时间:" + RollDicCdTime);
                    break;

                case ConstantData.KeyCargsHupTime:
                    HandUpTime = int.Parse(cargs2.GetUtfString(itemKey));
                    YxDebug.LogError("自定义投票时间:" + HandUpTime);
                    break;

                case ConstantData.KeyCargsControlDice:
                    ControlDiceNum       = int.Parse(cargs2.GetUtfString(itemKey));
                    CouldShowControlDice = ControlDiceNum > ConstantData.IntValue;
                    YxDebug.LogError("遥控骰子数量:" + ControlDiceNum);
                    break;
                }
            }
            if (gameObject.activeInHierarchy)
            {
                StartCoroutine(ControlDiceAction.WaitExcuteCalls());
            }
        }
コード例 #6
0
 public void flattenObject(Dictionary <string, object> map, ISFSObject sfsObj)
 {
     string[] keys = sfsObj.GetKeys();
     foreach (string key in keys)
     {
         SFSDataWrapper data = sfsObj.GetData(key);
         if (data.Type == 18)
         {
             Dictionary <string, object> dictionary = new Dictionary <string, object>();
             map.Add(key, dictionary);
             flattenObject(dictionary, (ISFSObject)data.Data);
         }
         else if (data.Type == 17)
         {
             List <object> list = new List <object>();
             map.Add(key, list);
             flattenArray(list, (ISFSArray)data.Data);
         }
         else
         {
             map.Add(key, data.Data);
         }
     }
 }
コード例 #7
0
    void OnGUI()
    {
        GUI.skin = skin;
        guiColor = Color.white;
        GUIStyle tStyle = new GUIStyle(GUI.skin.button);

        if (loginStep < 4)
        {
            GUI.Label(new Rect((Screen.width - titleTexture.width) / 2, 100, titleTexture.width, titleTexture.height), titleTexture);
        }

        if (errorMsg != null)
        {
            GUIStyle lStyle    = new GUIStyle(GUI.skin.label);
            Vector2  labelSize = lStyle.CalcSize(new GUIContent(errorMsg));
            GUI.contentColor = Color.red;

            GUI.Label(new Rect((Screen.width - labelSize.x) / 2, Screen.height * 2 / 3, labelSize.x, labelSize.y), errorMsg);
            GUI.contentColor = Color.white;
        }

        if (loginStep == 1)
        {
            GUI.Label(new Rect((Screen.width - titleTexture.width) / 2 + 20, (Screen.height - titleTexture.height) / 2 + 32, 500, 40), "Username");

            if (usernameEnabled == true)
            {
                username = GUI.TextField(new Rect((Screen.width - titleTexture.width) / 2 + 20, (Screen.height - titleTexture.height) / 2 + 64, titleTexture.width * .6f, buttonPlay.height), username, 25);
            }

            if (playButtonPressed)
            {
                guiColor.a     = 0.5f;
                GUI.color      = guiColor;
                tStyle.padding = new RectOffset(1, 1, 1, 1);
            }
            else
            {
                tStyle.padding = new RectOffset();
            }

            if (GUI.Button(new Rect((Screen.width - titleTexture.width) / 2 + titleTexture.width * .67f, (Screen.height - titleTexture.height) / 2 + 64, buttonPlay.width, buttonPlay.height), buttonPlay, tStyle) && !playButtonPressed)
            {
                playButtonPressed = true;
                if (sfs == null)
                {
                    // Attempt connection
                    DoConnect();
                }
                else
                {
                    // Skip the connection and attempt login
                    sfs.Send(new LoginRequest(username, "", "SpaceWar"));
                }
            }
            guiColor.a = 1f;
            GUI.color  = guiColor;
        }

        if (loginStep == 2)
        {
            GUI.Label(new Rect((Screen.width - titleTexture.width) / 2 + 150, (Screen.height - titleTexture.height) * 2 / 5, titleTexture.width * .6f, buttonPlay.height), "Select your starship");
            Array models = starshipModels.GetKeys();
            for (int i = 0; i < models.Length; i++)
            {
                ISFSObject starship = starshipModels.GetSFSObject(models.GetValue(i) as String);

                Texture2D btnTexture = buttonAstro;
                switch (starship.GetUtfString("model"))
                {
                case "Astro":
                    btnTexture = buttonAstro;
                    break;

                case "Viking":
                    btnTexture = buttonViking;
                    break;

                case "Raptor":
                    btnTexture = buttonRaptor;
                    break;
                }

                GUI.Label(new Rect((Screen.width - titleTexture.width) / 2 + 70 + i * 200, (Screen.height - titleTexture.height) / 2 + 55, 150, 40), starship.GetUtfString("model"));
                if (GUI.Button(new Rect((Screen.width - titleTexture.width) / 2 + 80 + i * 200, (Screen.height - titleTexture.height) / 2, btnTexture.width, btnTexture.height), btnTexture))
                {
                    UserVariable        shipModelUV = new SFSUserVariable(UV_MODEL, starship.GetUtfString("model"));
                    List <UserVariable> userVars    = new List <UserVariable>();
                    userVars.Add(shipModelUV);
                    sfs.Send(new SetUserVariablesRequest(userVars));
                }
            }
        }

        if (loginStep == 3)
        {
            GUI.Label(new Rect((Screen.width - titleTexture.width) / 2 + 140, (Screen.height - titleTexture.height) * 2 / 5, titleTexture.width * .6f, buttonPlay.height), "Select a solar system");

            // Room select
            for (int i = 0; i < sfs.RoomList.Count; i++)
            {
                Room room = sfs.RoomList[i] as Room;
                GUI.Label(new Rect((Screen.width - titleTexture.width) / 2 + 290 + i * 200, (Screen.height - titleTexture.height) / 2 + 170, 150, 40), room.Name);
                if (GUI.Button(new Rect((Screen.width - titleTexture.width) / 2 + 240 + i * 200, (Screen.height - titleTexture.height) / 2, buttonSol.width, buttonSol.height), buttonSol))
                {
                    // Join the corresponding MMORoom
                    sfs.Send(new JoinRoomRequest(room.Name));
                }
            }
        }
    }
コード例 #8
0
ファイル: NetworkManager.cs プロジェクト: Hargalaten/meGAMEss
 private void UpdateWorldSetup(ISFSObject data)
 {
     String[] keys = data.GetKeys();
     foreach(String currentKey in keys)
     {
         ISFSObject currentObject = data.GetSFSObject(currentKey);
         GameObject currentGw = GameObject.Find(currentObject.GetUtfString("STATE"));
         Gateway gw = currentGw.GetComponent<Gateway>();
         gw.Update(currentObject);
         gw.GetComponent<SpriteRenderer>().color = playerColors[gw.getOwner()];
     }
     ExtensionRequest objectiveRequest = new ExtensionRequest("getObjectives", new SFSObject(), smartFox.LastJoinedRoom);
     smartFox.Send(objectiveRequest);
 }
コード例 #9
0
ファイル: NetworkManager.cs プロジェクト: Hargalaten/meGAMEss
 private void UpdateObjective(ISFSObject data)
 {
     foreach(string currentKey in data.GetKeys())
     {
         ISFSObject currentObject = data.GetSFSObject(currentKey);
         GameObject currentObj = GameObject.Find(currentKey);
         currentObj.GetComponent<UILabel>().text = currentObject.GetInt("SPOTCONQUERED").ToString();
     }
     askPolicePosition();
 }
コード例 #10
0
ファイル: NetworkManager.cs プロジェクト: Hargalaten/meGAMEss
    private void InstantiateWorld(ISFSObject data)
    {
        String[] keys = data.GetKeys();

        foreach(String currentKey in keys)
        {
            ISFSObject currentObject = data.GetSFSObject(currentKey);
            GameObject currentGw = Instantiate(GatewayPrefab) as GameObject;
            currentGw.transform.name = currentObject.GetUtfString("STATE");
            Gateway gw = currentGw.GetComponent<Gateway>();

            gameObject.GetComponent<Manager>().stopParticle(gw);

            GameObject region=GameObject.Find(currentObject.GetUtfString("REGION"));
            gw.transform.parent=region.transform;
            gw.GetComponent<SpriteRenderer>().sprite = gameObject.GetComponent<ResourcesManager>().getGwImage(currentObject.GetUtfString("TYPE"));
            gw.Setup(currentObject);
            gw.GetComponent<SpriteRenderer>().color = playerColors[gw.getOwner()];

            if(gw.getOwner() == smartFox.MySelf.Name)
            {
                gameObject.GetComponent<Manager>().startParticle(gw);
                StartCoroutine( gameObject.GetComponent<Manager>().stopParticle(gw, 6.0f));
            }
        }
    }
コード例 #11
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);
        }
    }
コード例 #12
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);
        }