Beispiel #1
0
    public void OnBtnClick(LMGrindTableEmulatorBtn btn)
    {
        if (activatedButtons.Contains(btn))
        {
            m_btnPressed++;

            if (LMGrindTable.onTurnOffLight != null)
            {
                LMGrindTable.onTurnOffLight(new GrindNode()
                {
                    x = btn.x, y = btn.y
                });
            }

            Debug.Log("Btn Pressed: " + m_btnPressed);

            if (btn.BtnState == EmuTableBtnStates.End)
            {
                bool result = m_btnPressed >= 5;

                if (!result)
                {
                    Restart();
                }
                else
                {
                    Reset();
                }

                // 如果按钮点击量大于等于5,则表示训练通过,反之从来一次
                if (LMGrindTable.onTestFinished != null)
                {
                    LMGrindTable.onTestFinished(result);
                }
            }
            else
            {
                btn.BtnState = EmuTableBtnStates.Pressed;
            }
        }
    }
Beispiel #2
0
    private void SetTransform(LMGrindTableEmulatorBtn btn, int x, int y)
    {
        var r = m_rectTrans.rect;

        var gridSize = new Vector2(r.width / column, r.height / row);
        var spacing  = gridSize * 0.1f;

        // 从左上角开始生成
        var origin = new Vector3(r.width * -0.5f, r.height * 0.5f);

        // 偏移量,以确保按键生成在网格里
        origin.x += gridSize.x * 0.5f;
        origin.y -= gridSize.y * 0.5f;

        // var stepX = r.width / ( column - 1 );
        // var stepY = r.height / ( row - 1 );

        var rect = btn.transform as RectTransform;
        var p    = new Vector2(origin.x + gridSize.x * x, origin.y - gridSize.y * y);

        rect.anchoredPosition = p;
        rect.sizeDelta        = gridSize - spacing;
    }