Ejemplo n.º 1
0
        public void ColorTest()
        {
            ST_Color st = new ST_Color(1 / 255f, 2 / 255f, 3 / 255f);

            LBObject lb = new LBObject();

            lb.SetFloat("r", st.r);
            lb.SetFloat("g", st.g);
            lb.SetFloat("b", st.b);

            ClassTest("Color", st, lb);
        }
Ejemplo n.º 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);
             */
        }
Ejemplo n.º 3
0
 private void PrintColor(string prefix, ST_Color color)
 {
     //print(prefix + "(" + color.r + ", " + color.g + ", " + color.b + ")");
 }