Exemple #1
0
 /// <summary>
 /// 根据实体当前的状态,来计算这个实体在本列上是否可以编辑。
 /// </summary>
 /// <param name="dataItem"></param>
 /// <returns></returns>
 protected override bool CanEnterEditing(object dataItem)
 {
     return(!ReadOnlyMatrix.CheckIsReadOnly(dataItem as Entity, this.Meta));
 }
 public IRData(Wiimote Owner)
     : base(Owner)
 {
     _ir = new int[4, 8];
     _ir_readonly = new ReadOnlyMatrix<int>(_ir);
 }
Exemple #3
0
 public IRData(Wiimote Owner)
     : base(Owner)
 {
     _ir          = new int[4, 8];
     _ir_readonly = new ReadOnlyMatrix <int>(_ir);
 }
    void Update()
    {
        //Connectie wiimote & IR basic setup
        WiimoteManager.FindWiimotes();
        if (!WiimoteManager.HasWiimote())
        {
            return;
        }
        wiimote = WiimoteManager.Wiimotes[0];
        if (!isInit)
        {
            wiimote.SendPlayerLED(playerLeds[0], playerLeds[1], playerLeds[2], playerLeds[3]);
            wiimote.SetupIRCamera(IRDataType.BASIC);
            isInit = true;
        }

        int response;

        do
        {
            response = wiimote.ReadWiimoteData();
            if (response < 0)
            {
                Debug.Log("Error: " + response);
            }
        } while (response > 0);

        ReadOnlyMatrix <int> ir = wiimote.Ir.ir;
        int dotCount            = 4;

        for (int i = 0; i < 4; i++)
        {
            if (ir[i, 0] == -1 || ir[i, 1] == -1)
            {
                dotCount--;
            }
        }
        if (dotCount < 2)
        {
            return;
        }

        //Wiimote camera movement
        float[] pointer      = wiimote.Ir.GetPointingPosition();
        Vector2 curAnchorMin = IR_pointer.anchorMin;
        Vector2 curAnchorMax = IR_pointer.anchorMax;

        IR_pointer.anchorMin = Vector2.SmoothDamp(curAnchorMin, new Vector2(pointer[0], pointer[1]), ref currentVelocity, 0.1f, 1f);
        IR_pointer.anchorMax = Vector2.SmoothDamp(curAnchorMax, new Vector2(pointer[0], pointer[1]), ref currentVelocity, 0.1f, 1f);

        if (setupCompleted)
        {
            playerCam.transform.LookAt(IR_pointer);

            if (wiimote != null && wiimote.current_ext != ExtensionController.NONE)
            {
                if (wiimote.current_ext == ExtensionController.NUNCHUCK)
                {
                    nunchuckData = wiimote.Nunchuck;
                    isRunning    = nunchuckData.z;
                }
            }

            //Speler status
            if (!jump)
            {
                if (wiimote.Button.b)
                {
                    jump = true;
                }
            }
            if (!isAirborn && characterController.isGrounded)
            {
                //Speler land
                moveDirection.y = 0f;
                isJumping       = false;
            }
            if (!characterController.isGrounded && !isJumping && isAirborn)
            {
                //Speler naar beneden forceren
                moveDirection.y = 0f;
            }

            isAirborn = characterController.isGrounded;
        }
    }