Пример #1
0
 void Start()
 {
     ball           = new BallData(gameObject.name, gameObject.transform.position);
     Gp             = GameProcess.pipeline;
     MsgTemplate    = new SQEle(this.ConvToBytes(), DefaultCallback);
     rb             = GetComponent <Rigidbody>();
     enabled        = false;
     timer          = new Timer(WaitTimeVel);
     BroadcastTimer = new Timer(BroadcastPeriod);
 }
Пример #2
0
    private void StartSendThread()
    {
        byte[] byteData = SQEle.ConvertToBytes("started send thread");
        SQEle  msg      = new SQEle(byteData, testcallback);

        sendQ.Enq(msg);
        SQEle msg_ = sendQ.next();

        SQEle.sock.BeginSend(msg_.data, 0, msg_.data.Length, 0, new AsyncCallback(SendCallBack), msg_);
    }
Пример #3
0
    private void SendCallBack(IAsyncResult ar)
    {
        SQEle msg = (SQEle)ar.AsyncState;

        SQEle.sock.EndSend(ar);
        Debug.Log("sent");
        msg.ServiceCallBack();
        sendQ.EnqEvent.WaitOne();
        var next_msg = sendQ.next();

        if (next_msg.Equals("STOP"))
        {
            return;
        }
        else
        {
            SQEle.sock.BeginSend(next_msg.data, 0, next_msg.data.Length, 0, new AsyncCallback(SendCallBack), next_msg);
        }
    }
Пример #4
0
    void Awake()
    {
        TableData     = new List <BallData>();
        MsgTemplate   = new SQEle(ConvToBytes(), DefaultCallback);
        enabled       = false;
        timer         = new Timer(WaitTimeVel);
        cueController = gameObject.transform.Find("CueBall").GetComponent <CueController>();
        ballData      = new BallData("init", Vector3.zero);
        foreach (Rigidbody rb in gameObject.GetComponentsInChildren <Rigidbody>())
        {
            rbBalls.Add(rb.gameObject.name, rb);
        }
        posball_y = rbBalls["CueBall"].position.y;
        var tableno_str = gameObject.transform.parent.name.Split('_')[1];

        TableNo = int.Parse(tableno_str) - 1;
        GameProcess.tables[TableNo] = this;
        serializable_tabledata      = new SerializableTableData(TableData, TableNo);
        TablePosition    = gameObject.transform.parent.transform.position;
        TablePosition.y += posball_y;
        execution_timer  = new Stopwatch();
        //UnityEngine.Debug.Log(GameProcess.tables[0]);
    }