Beispiel #1
0
        public void PlayerInfoTest()
        {
            ST_PlayerInfo st = new ST_PlayerInfo();

            st.id       = 100001;
            st.nickname = "冰封百度";
            st.gender   = 1;
            st.isVip    = true;
            st.lv       = 999;
            st.hp       = 999999;
            st.mp       = 999999;
            st.exp      = 9999999;
            st.speed    = 100.5f;

            ClassTest("PlayerInfo", st);
        }
Beispiel #2
0
        public void NestedTypeTest()
        {
            // Class
            ST_PlayerInfo playerInfo = new ST_PlayerInfo();

            playerInfo.id       = 100001;
            playerInfo.nickname = "Zero";
            playerInfo.gender   = 1;
            playerInfo.isVip    = true;
            playerInfo.lv       = 999;
            playerInfo.hp       = 99999;
            playerInfo.mp       = 99999;
            playerInfo.exp      = 99999999;
            playerInfo.speed    = 2.5f;
            ST_Vector3    position = new ST_Vector3(1.123456f, 2.123456f, 3.123456f);
            ST_Color      color    = new ST_Color(1 / 255f, 2 / 255f, 3 / 255f);
            ST_NestedType st       = new ST_NestedType();

            st.playerInfo = playerInfo;
            st.position   = position;
            st.color      = color;

            // LBObject
            LBObject lb           = new LBObject();
            LBObject lbPlayerInfo = new LBObject();
            LBObject lbPosition   = new LBObject();
            LBObject lbColor      = new LBObject();

            lbPlayerInfo.SetUInt("id", playerInfo.id);
            lbPlayerInfo.SetString("nickname", playerInfo.nickname);
            lbPlayerInfo.SetByte("gender", playerInfo.gender);
            lbPlayerInfo.SetBool("isVip", playerInfo.isVip);
            lbPlayerInfo.SetInt("lv", playerInfo.lv);
            lbPlayerInfo.SetInt("hp", playerInfo.hp);
            lbPlayerInfo.SetInt("mp", playerInfo.mp);
            lbPlayerInfo.SetInt("exp", playerInfo.exp);
            lbPlayerInfo.SetFloat("speed", playerInfo.speed);

            lbPosition.SetFloat("x", position.x);
            lbPosition.SetFloat("y", position.y);
            lbPosition.SetFloat("z", position.z);

            lbColor.SetFloat("r", color.r);
            lbColor.SetFloat("g", color.g);
            lbColor.SetFloat("b", color.b);

            lb.SetObject("playerInfo", lbPlayerInfo);
            lb.SetObject("position", lbPosition);
            lb.SetObject("color", lbColor);

            ClassTest("NestedType", st, lb);

            /*
             * // Convert
             * string structName = "NestedType";
             * byte[] bytes = LB.ToBytes(structName, st);
             * //print("==================== NestedType Test ====================");
             *
             * // Parse
             * ST_NestedType vo = LB.ToObject<ST_NestedType>(structName, bytes);
             *
             * // Print
             * //print("LB ByteSize: " + bytes.Length);
             * ST_PlayerInfo pvo = vo.playerInfo;
             * //print("vo.player.id: " + pvo.id);
             * //print("vo.player.nickname: " + pvo.nickname);
             * //print("vo.player.gender: " + pvo.gender);
             * //print("vo.player.isVip: " + pvo.isVip);
             * //print("vo.player.lv: " + pvo.lv);
             * //print("vo.player.hp: " + pvo.hp);
             * //print("vo.player.mp: " + pvo.mp);
             * //print("vo.player.exp: " + pvo.exp);
             * //print("vo.player.speed: " + pvo.speed);
             * PrintVector3("vo.position: ", vo.position);
             * PrintColor("vo.color: ", vo.color);
             */
        }