Пример #1
0
    // Use this for initialization
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        client = new FSClient();
        client.Connect("127.0.0.1", 12345, 10);

        // foreach (JoyStick joyStick in joySticks)
        // {
        //     InputCenter.Instance.AddJoyStick(joyStick.frameKey,joyStick.GetInfo());
        // }
        ShapPhysics.Init();
        //V2 v2 = new V2(1, 0);
        //for (int i =0; i <= 360; i+=30)
        //{
        //   // Debug.Log("sin"+i+":"+MathR.SinAngle(new Ratio(i)).ToFloat());
        //   // Debug.Log("cos" + i + ":" + MathR.CosAngle(new Ratio(i)).ToFloat());
        //}

        // InputCenter.Instance.framUpdate += FrameUpdate;
        //  V2 v2 = new V2(-1,-1);
        //  Debug.Log(v2.ToRotation());
        //  Debug.LogError((10 & 2) == 2);
        // Debug.LogError(V2.left+V2.up);
        //Ratio r = new Ratio(16);
        //Debug.Log(r.SQR(r));
        //Debug.Log(r.InvSqrt(16));

        // V2 v2 = new V2(-5, 99);
        // Debug.Log("(-5, 99)" + v2.x * v2.x + "," + v2.y * v2.y);
        //  Debug.Log("normalized"+v2.normalized);
    }
Пример #2
0
 /// <summary>
 /// 连接服务器函数
 /// </summary>
 /// <param name="serverIP">服务器IP地址</param>
 /// <param name="serverPort">服务器端口</param>
 /// <param name="maxUserCount">最大玩家数</param>
 public void Connect(string serverIP, int serverPort, int maxUserCount)
 {
     _serverCon               = new Connection();
     ServerCon.socket         = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     ServerCon.socket.NoDelay = true;
     ServerCon.socket.Connect(serverIP, serverPort);
     ServerCon.socket.BeginReceive(ServerCon.readBuff, 0, ServerCon.BuffRemain, SocketFlags.None, ReceiveCallBack, ServerCon);
     inputCenter = new InputCenter();
     inputCenter.Init(this, maxUserCount);
     objectManager = new NetObjectManager(this);
     physics       = new ShapPhysics();
     physics.Init();
     random = new IDG.FSClient.Random(20190220);
 }
Пример #3
0
 public void Destory()
 {
     this.active       = false;
     Input.framUpdate -= DataFrameUpdate;
     ShapPhysics.Remove(this);
 }