Beispiel #1
0
    void OnGUI()
    {
        int buttonW = 100, buttonH = 30, gapH = 35;
        int gapVal = 0;

        if (Hero == null)
        {
            if (GUI.Button(new Rect(0, 0, buttonW, buttonH), "connectLocal"))
            {
                NetMgr.getSingleton().connect(serverIPLocal, serverPort, OnConnectedSuccess);
            }
            if (GUI.Button(new Rect(0, gapVal += gapH, buttonW, buttonH), "connectRemote"))
            {
                NetMgr.getSingleton().connect(serverIPRemote, serverPort, OnConnectedSuccess);
            }

            regName = GUI.TextField(new Rect(buttonW, gapVal + gapH, buttonW, buttonH), regName);
            pwd     = GUI.PasswordField(new Rect(buttonW * 2, gapVal + gapH, buttonW, buttonH), pwd, '*');
            if (GUI.Button(new Rect(0, gapVal += gapH, buttonW, buttonH), "regist"))
            {
                JFPackage.PAG_REGIST regist = new JFPackage.PAG_REGIST(0, StringEncoding.GetBytes(regName), StringEncoding.GetBytes(pwd));
                NetMgr.getSingleton().sendMsg(regist);
            }
            if (GUI.Button(new Rect(0, gapVal += gapH, buttonW, buttonH), "autoregist"))
            {
                JFPackage.PAG_REGIST regist = new JFPackage.PAG_REGIST(1, StringEncoding.GetBytes(regName), StringEncoding.GetBytes(pwd));
                NetMgr.getSingleton().sendMsg(regist);
            }
            if (GUI.Button(new Rect(0, gapVal += gapH, buttonW, buttonH), "login"))
            {
                JFPackage.PAG_LOGIN login = new JFPackage.PAG_LOGIN(StringEncoding.GetBytes(regName), StringEncoding.GetBytes(pwd));
                NetMgr.getSingleton().sendMsg(login);
            }
            if (GUI.Button(new Rect(0, gapVal += gapH, buttonW, buttonH), "enterMap"))
            {
                JFPackage.PAG_EnetrMap en = new JFPackage.PAG_EnetrMap(11);
                NetMgr.getSingleton().sendMsg(en);
            }
        }
        else
        {
            if (GUI.Button(new Rect(0, 0, buttonW, buttonH), "Again"))
            {
                HeroAI.reset();
            }

            if (GUI.Button(new Rect(0, gapVal += gapH, buttonW, buttonH), "disconnected"))
            {
                //if(NetMgr.getSingleton().isConnected())
                NetMgr.getSingleton().disConnect();
            }
            if (GUI.Button(new Rect(0, gapVal += gapH, buttonW, buttonH), "relive"))
            {
                JFPackage.PAG_RELIVE re = new JFPackage.PAG_RELIVE(11);
                NetMgr.getSingleton().sendMsg(re);
            }
            // name,hp,mp,def

            Creature target = Hero.Target;
            selfInfo   = Hero._name + ":" + Hero.shiled + ":" + Hero.hp + ":" + Hero.mp + ":" + "(" + Hero.ctl.curPos._x + ":" + Hero.ctl.curPos._z + ")";
            selfInfoEx = Hero.maxHp + ":" + Hero.maxMp;
            if (target != null)
            {
                targetInfo = target._name + ":" + target.shiled + ":" + target.maxHp + ":" + target.hp + ":" + target.maxMp + ":" + target.mp + "(" + target.ctl.curPos._x + ":" + target.ctl.curPos._z + ")";
            }

            GUI.Label(new Rect(0, gapVal += gapH, buttonW * 2, buttonH), selfInfo);
            GUI.Label(new Rect(0, gapVal += gapH, buttonW * 2, buttonH), selfInfoEx);
            GUI.Label(new Rect(0, gapVal += gapH, buttonW * 2, buttonH), targetInfo);
        }
        GUI.Label(new Rect(0, gapVal += gapH, buttonW * 3, buttonH * 2), GameDebug.lastError);
    }
Beispiel #2
0
 void getPackage(int header, int Lenght, uint no, byte[] data)
 {
     if (no == (uint)JFPackage.MSG_ID.LISTKILL)
     {
         JFPackage.PAG_ListKill wp = new JFPackage.PAG_ListKill();
         wp = (JFPackage.PAG_ListKill)JFTools.BytesToStruct(data, wp.GetType());
         _curPackages.Add(wp);
     }
     else if (no == (uint)JFPackage.MSG_ID.NOTIFY)
     {
         JFPackage.PAG_Notify wp = new JFPackage.PAG_Notify();
         wp = (JFPackage.PAG_Notify)JFTools.BytesToStruct(data, wp.GetType());
         _curPackages.Add(wp);
     }
     else if (no == (uint)JFPackage.MSG_ID.RELIVE)
     {
         JFPackage.PAG_RELIVE wp = new JFPackage.PAG_RELIVE();
         wp = (JFPackage.PAG_RELIVE)JFTools.BytesToStruct(data, wp.GetType());
         _curPackages.Add(wp);
     }
     else if (no == (uint)JFPackage.MSG_ID.ENTRPMAP)
     {
         JFPackage.PAG_EnetrMap wp = new JFPackage.PAG_EnetrMap();
         wp = (JFPackage.PAG_EnetrMap)JFTools.BytesToStruct(data, wp.GetType());
         _curPackages.Add(wp);
     }
     else if (no == (uint)JFPackage.MSG_ID.MAPINFO)
     {
         JFPackage.PAG_MAPINF wp = new JFPackage.PAG_MAPINF();
         wp = (JFPackage.PAG_MAPINF)JFTools.BytesToStruct(data, wp.GetType());
         _curPackages.Add(wp);
     }
     else if (no == (uint)JFPackage.MSG_ID.JUMPINMAP)
     {
         JFPackage.PAG_JUMPINMAP wp = new JFPackage.PAG_JUMPINMAP();
         wp = (JFPackage.PAG_JUMPINMAP)JFTools.BytesToStruct(data, wp.GetType());
         _curPackages.Add(wp);
     }
     else if (no == (uint)JFPackage.MSG_ID.ATTR)
     {
         JFPackage.PAG_ATTR wp = new JFPackage.PAG_ATTR();
         wp = (JFPackage.PAG_ATTR)JFTools.BytesToStruct(data, wp.GetType());
         _curPackages.Add(wp);
     }
     else if (no == (uint)JFPackage.MSG_ID.ATTRCHG)
     {
         JFPackage.PAG_ATTRCHG wp = new JFPackage.PAG_ATTRCHG();
         wp = (JFPackage.PAG_ATTRCHG)JFTools.BytesToStruct(data, wp.GetType());
         _curPackages.Add(wp);
     }
     else if (no == (uint)JFPackage.MSG_ID.TEST_STRING)
     {
         JFPackage.PAG_STRING wp = new JFPackage.PAG_STRING();
         wp = (JFPackage.PAG_STRING)JFTools.BytesToStruct(data, wp.GetType());
         _curPackages.Add(wp);
     }
     else if (no == (uint)JFPackage.MSG_ID.TEST_STRUCTURE)
     {
         JFPackage.PAG_STRUCTURE wp = new JFPackage.PAG_STRUCTURE();
         wp = (JFPackage.PAG_STRUCTURE)JFTools.BytesToStruct(data, wp.GetType());
         _curPackages.Add(wp);
     }
     else if (no == (uint)JFPackage.MSG_ID.TEST_ARRAY)
     {
         JFPackage.PAG_ARRAY wp = new JFPackage.PAG_ARRAY();
         wp = (JFPackage.PAG_ARRAY)JFTools.BytesToStruct(data, wp.GetType());
         _curPackages.Add(wp);
     }
     else if (no == (uint)JFPackage.MSG_ID.WALK)
     {
         JFPackage.PAG_WALK wp = new JFPackage.PAG_WALK();
         wp = (JFPackage.PAG_WALK)JFTools.BytesToStruct(data, wp.GetType());
         _curPackages.Add(wp);
     }
     else if (no == (uint)JFPackage.MSG_ID.FIGHT)
     {
         JFPackage.PAG_FIGHT wp = new JFPackage.PAG_FIGHT();
         wp = (JFPackage.PAG_FIGHT)JFTools.BytesToStruct(data, wp.GetType());
         _curPackages.Add(wp);
     }
     else if (no == (uint)JFPackage.MSG_ID.CREATE)
     {
         JFPackage.PAG_CREATE wp = new JFPackage.PAG_CREATE();
         wp = (JFPackage.PAG_CREATE)JFTools.BytesToStruct(data, wp.GetType());
         _curPackages.Add(wp);
     }
     else if (no == (uint)JFPackage.MSG_ID.DELETE)
     {
         JFPackage.PAG_DELETE wp = new JFPackage.PAG_DELETE();
         wp = (JFPackage.PAG_DELETE)JFTools.BytesToStruct(data, wp.GetType());
         _curPackages.Add(wp);
     }
     else if (no == (uint)JFPackage.MSG_ID.REGIST)
     {
         JFPackage.PAG_REGIST wp = new JFPackage.PAG_REGIST();
         wp = (JFPackage.PAG_REGIST)JFTools.BytesToStruct(data, wp.GetType());
         _curPackages.Add(wp);
     }
     else if (no == (uint)JFPackage.MSG_ID.Error)
     {
         JFPackage.PAG_ERROR wp = new JFPackage.PAG_ERROR();
         wp = (JFPackage.PAG_ERROR)JFTools.BytesToStruct(data, wp.GetType());
         _curPackages.Add(wp);
     }
     else
     {
         GameDebug.LogError("getPackage error " + no);
     }
 }