Пример #1
0
    void Update()
    {
        keyPressed();
        RFIB.statesUpdate();



        if (Time.time > 3 && autoRun)
        {
            print("StartToBuild...");
            RFIB.startToBuild();
            RFIB.printNoiseIDs();

            autoRun = false;
        }

        if (Flag_Draw3DSpace)
        {
            DrawBlock();
        }

        // 從 Resources 下載入 Cube 物件
        if (Input.GetKeyDown(KeyCode.A))
        {
            UnityEngine.Object obj  = Resources.Load("Cube");
            GameObject         gobj = Instantiate(obj) as GameObject;
            gobj.transform.localScale = new Vector3(2.0f, 2.0f, 2.0f);
        }
    }
Пример #2
0
    readonly int delayForReceivingTime = 200;            // 清空之後停多久才收id

    #endregion

    void Start()
    {
        #region Set RFIB Parameter
        RFIB = new RFIBricks_Cores(ReaderIP, ReaderPower, Sensitive, EnableAntenna, Flag_ToConnectTheReade);
        RFIB.setShowSysMesg(showSysMesg);
        RFIB.setShowReceiveTag(showReceiveTag);
        RFIB.setShowDebugMesg(showDebugMesg);

        RFIB.setSysTagBased(sysTagBased);
        RFIB.setAllowBlockType(RFIBParameter.AllowBlockType);

        RFIB.setRefreshTime(refreshTime);
        RFIB.setDisappearTime(disappearTime);
        RFIB.setDelayForReceivingTime(delayForReceivingTime);

        // 開始接收ID前要將地板配對
        BoardMapping();

        RFIB.startReceive();
        RFIB.startToBuild();
        RFIB.printNoiseIDs();

        #endregion

        tagSensing  = new Dictionary <string, bool>();
        tagMissTime = new Dictionary <string, int>();

        foreach (var dic in gameParameter.characterDic)
        {
            tagSensing.Add(dic.Key, false);
            tagMissTime.Add(dic.Key, 0);
        }
    }
Пример #3
0
    public void KeyPressed()
    {
        GetKey("1", "8940 0000 3333 0000 0001");
        GetKey("2", "8940 0000 3333 0001 0001");
        GetKey("3", "8940 0000 3333 0002 0001");
        GetKey("4", "8940 0000 3333 0003 0001");
        GetKey("5", "8940 0000 3333 0004 0001");
        GetKey("6", "8940 0000 3333 0005 0001");
        GetKey("7", "8940 0000 3333 0006 0001");
        GetKey("8", "8940 0000 3333 0007 0001");
        GetKey("9", "8940 0000 3333 0008 0001");

        GetKey("q", "8940 0000 3333 0011 0001");
        GetKey("w", "8940 0000 3333 0012 0001");
        GetKey("e", "8940 0000 3333 0013 0001");

        #region Information
        if (Input.GetKeyUp(";"))
        {
            string[] tags = RFIB.GetTags();
            for (int i = 0; i < tags.Length; i++)
            {
                Debug.Log(tags[i]);
            }
        }
        if (Input.GetKeyUp("."))
        {
            RFIB.printAllReceivedIDs();
            RFIB.printNoiseIDs();
        }

        #endregion
    }
Пример #4
0
    // 下面這個function就是來偵測地板上方堆了幾個方塊的。
    //private int GetPositionHeight(int X, int Y)
    //{
    //    int MaxHeight = 0;

    //    foreach (int BlockID_intType in RFIB.StackedOrders3D.Keys)
    //    {
    //        if (RFIB.StackedOrders3D[BlockID_intType][0] == X && RFIB.StackedOrders3D[BlockID_intType][1] == Y)
    //        {
    //            if (RFIB.StackedOrders3D[BlockID_intType][2] > MaxHeight)
    //                MaxHeight = RFIB.StackedOrders3D[BlockID_intType][2];
    //        }
    //    }

    //    if (MaxHeight >= 4)
    //        MaxHeight = 4;
    //    return MaxHeight;
    //}

    #endregion

    // 系統編號 此欄空白 方塊種類 編號+上下 方向
    // 9999 0101 就是 (0, 0)
    // 9999 0203 就是 (1, 2)
    public void KeyPressed()
    {
        if (Input.GetKeyDown("1"))
        {
            ChangeTags("8940 0000 9999 0302 0001", "8940 0000 7101 4501 0001");
        }
        if (Input.GetKeyDown("2"))
        {
            ChangeTags("8940 0000 7101 4503 0001", "8940 0000 7101 4601 0001");
        }
        if (Input.GetKeyDown("3"))
        {
            ChangeTags("8940 0000 7101 4603 0001", "8940 0000 7101 4701 0001");
        }
        if (Input.GetKeyDown("4"))
        {
            ChangeTags("8940 0000 9999 0501 0001", "8940 0000 8601 5401 0001");
        }
        if (Input.GetKeyDown("5"))
        {
            ChangeTags("8940 0000 8601 5403 0001", "8940 0000 7101 5501 0001");
        }
        if (Input.GetKeyDown("6"))
        {
            ChangeTags("8940 0000 9999 0206 0001", "8940 0000 9101 5801 0001");
        }
        if (Input.GetKeyDown("7"))
        {
            ChangeTags("8940 0000 9101 5803 0001", "8940 0000 9601 5901 0001");
        }
        if (Input.GetKeyDown("8"))
        {
            touchHandler.touchSensing[14] = true;
        }
        if (Input.GetKeyUp("8"))
        {
            touchHandler.touchSensing[14] = false;
        }

        #region Information
        if (Input.GetKeyUp(";"))
        {
            string[] tags = RFIB.GetTags();
            for (int i = 0; i < tags.Length; i++)
            {
                Debug.Log(tags[i]);
            }
        }
        if (Input.GetKeyUp("."))
        {
            RFIB.printAllReceivedIDs();
            RFIB.printNoiseIDs();
        }

        #endregion
    }
Пример #5
0
    // Use this for initialization
    void Start()
    {
        model = GameModel.GetInstance();
        InitPlantTable();

        RFIB = new RFIBricks_Cores(ReaderIP, ReaderPower, Sensitive, EnableAntenna, Flag_ToConnectTheReade);
        //RFIB.setSerialcomPort("COM3"); //arduino connect
        RFIB.setShowSysMesg(true);
        RFIB.setShowReceiveTag(true);
        RFIB.setShowDebugMesg(true);

        RFIB.setSysTagBased("8940 0000");
        RFIB.setAllowBlockType(AllowBlockType);

        RFIB.setRefreshTime(1000);          //clear beffer
        RFIB.setDisappearTime(600);         //id 消失多久才會的消失
        RFIB.setDelayForReceivingTime(400); //清空之後停多久才收id

        BoardMapping();                     // 開始接收ID前要將地板配對

        RFIB.startReceive();

        RFIB.startToBuild();
        RFIB.printNoiseIDs();

        updateFlag = new bool[5, 9];
        errorMap   = new bool[5, 9];
        for (int i = 0; i < 5; i++)
        {
            for (int j = 0; j < 9; j++)
            {
                updateFlag[i, j] = false;
                errorMap[i, j]   = false;
            }
        }

        lastIdStack   = new string[5, 9, 3];
        lastDirection = new string[5, 9, 3];
        lastPlant     = new int[5, 9, 3];
        for (int i = 0; i < 5; i++)
        {
            for (int j = 0; j < 9; j++)
            {
                for (int k = 0; k < 3; k++)
                {
                    lastIdStack[i, j, k]   = "0000";
                    lastDirection[i, j, k] = "000000";
                    lastPlant[i, j, k]     = 0;
                }
            }
        }
    }
Пример #6
0
    public void KeyPressed()
    {
        if (Input.GetKeyUp("0"))
        {
            ChangeTestTag("8940 0000 3333 0004 0012");
        }
        if (Input.GetKeyUp("1"))
        {
            ChangeTestTag("8940 0000 3333 0005 0012");
        }
        if (Input.GetKeyUp("2"))
        {
            ChangeTestTag("8940 0000 1111 0002 0001");
        }
        if (Input.GetKeyUp("3"))
        {
            ChangeTestTag("8940 0000 1111 0003 0001");
        }
        if (Input.GetKeyUp("4"))
        {
            ChangeTestTag("8940 0000 1111 0004 0001");
        }
        if (Input.GetKeyUp("5"))
        {
            ChangeTestTag("8940 0000 1111 0005 0001");
        }
        if (Input.GetKeyUp("6"))
        {
            ChangeTestTag("8940 0000 1111 0006 0001");
        }

        #region Information
        if (Input.GetKeyUp(";"))
        {
            string[] tags = RFIB.GetTags();
            for (int i = 0; i < tags.Length; i++)
            {
                Debug.Log(tags[i]);
            }
        }
        if (Input.GetKeyUp("."))
        {
            RFIB.printAllReceivedIDs();
            RFIB.printNoiseIDs();
        }

        #endregion
    }
Пример #7
0
    void Start()
    {
        #region Set RFIB Parameter
        RFIB = new RFIBricks_Cores(ReaderIP, ReaderPower, Sensitive, EnableAntenna, Flag_ToConnectTheReade);
        RFIB.setShowSysMesg(showSysMesg);
        RFIB.setShowReceiveTag(showReceiveTag);
        RFIB.setShowDebugMesg(showDebugMesg);

        RFIB.setSysTagBased(sysTagBased);
        RFIB.setAllowBlockType(RFIBParameter.AllowBlockType);

        RFIB.setRefreshTime(refreshTime);
        RFIB.setDisappearTime(disappearTime);
        RFIB.setDelayForReceivingTime(delayForReceivingTime);

        // 開始接收ID前要將地板配對
        BoardMapping();

        RFIB.startReceive();
        RFIB.startToBuild();
        RFIB.printNoiseIDs();

        #endregion

        blockId    = new string[RFIBParameter.stageCol, RFIBParameter.stageRow, RFIBParameter.maxHight];
        touchBlock = new bool[RFIBParameter.touchCol, RFIBParameter.touchRow];

        for (int i = 0; i < RFIBParameter.stageCol; i++)
        {
            for (int j = 0; j < RFIBParameter.stageRow; j++)
            {
                for (int k = 0; k < RFIBParameter.maxHight; k++)
                {
                    blockId[i, j, k] = "0000";
                }
            }
        }
        for (int i = 0; i < RFIBParameter.touchCol; i++)
        {
            for (int j = 0; j < RFIBParameter.touchRow; j++)
            {
                touchBlock[i, j] = false;
            }
        }
    }
Пример #8
0
    public void KeyPressed()
    {
        if (mode == 0)
        {
            #region Row
            GetKey("1", "8940 0000 2222 0408 0001");
            GetKey("2", "8940 0000 2222 0407 0001");
            GetKey("3", "8940 0000 2222 0406 0001");
            GetKey("4", "8940 0000 2222 0405 0001");
            GetKey("5", "8940 0000 2222 0404 0001");
            GetKey("6", "8940 0000 2222 0403 0001");
            GetKey("7", "8940 0000 2222 0402 0001");
            GetKey("8", "8940 0000 2222 0401 0001");
            GetKey("9", "8940 0000 2222 0400 0001");

            #endregion

            #region Col
            GetKey("q", "8940 0000 2222 0004 0001");
            GetKey("w", "8940 0000 2222 0104 0001");
            GetKey("e", "8940 0000 2222 0204 0001");
            GetKey("r", "8940 0000 2222 0304 0001");
            GetKey("t", "8940 0000 2222 0404 0001");
            GetKey("y", "8940 0000 2222 0504 0001");
            GetKey("u", "8940 0000 2222 0604 0001");
            GetKey("i", "8940 0000 2222 0704 0001");
            GetKey("o", "8940 0000 2222 0804 0001");

            #endregion

            #region Line
            GetKey("a", "8940 0000 2222 0708 0001");
            GetKey("s", "8940 0000 2222 0707 0001");
            GetKey("d", "8940 0000 2222 0706 0001");
            GetKey("f", "8940 0000 2222 0705 0001");
            GetKey("h", "8940 0000 2222 0704 0001");
            GetKey("j", "8940 0000 2222 0604 0001");
            GetKey("k", "8940 0000 2222 0504 0001");
            GetKey(",", "8940 0000 2222 0404 0001");
            GetKey("m", "8940 0000 2222 0403 0001");
            GetKey("n", "8940 0000 2222 0402 0001");
            GetKey("b", "8940 0000 2222 0401 0001");
            GetKey("v", "8940 0000 2222 0301 0001");
            GetKey("c", "8940 0000 2222 0201 0001");
            GetKey("x", "8940 0000 2222 0101 0001");
            GetKey("z", "8940 0000 2222 0001 0001");

            #endregion
        }
        else if (mode == 1)
        {
            #region two
            GetKey("1", "8940 0000 2222 0005 0001");
            GetKey("2", "8940 0000 2222 0105 0001");
            GetKey("3", "8940 0000 2222 0205 0001");
            GetKey("4", "8940 0000 2222 0204 0001");
            GetKey("5", "8940 0000 2222 0203 0001");
            GetKey("6", "8940 0000 2222 0103 0001");
            GetKey("t", "8940 0000 2222 0003 0001");
            GetKey("r", "8940 0000 2222 0002 0001");
            GetKey("e", "8940 0000 2222 0001 0001");
            GetKey("w", "8940 0000 2222 0000 0001");
            GetKey("q", "8940 0000 2222 0100 0001");
            GetKey("q", "8940 0000 2222 0200 0001");

            #endregion
        }

        if (Input.GetKeyDown("space"))
        {
            mode++;
        }

        #region Information
        if (Input.GetKeyUp(";"))
        {
            string[] tags = RFIB.GetTags();
            for (int i = 0; i < tags.Length; i++)
            {
                Debug.Log(tags[i]);
            }
        }
        if (Input.GetKeyUp("."))
        {
            RFIB.printAllReceivedIDs();
            RFIB.printNoiseIDs();
        }

        #endregion
    }