Exemple #1
0
        bool IsMirrorPartnerIndex(BoardLogic board, int currentHotIndex, int i, bool isCurrentHotIndex /*for the assert*/)
        {
            bool result = false;

            int mirrorOffsetCount = board.shapeSizes[0];
            int mirrorIndexAt     = currentHotIndex < mirrorOffsetCount ? (currentHotIndex + mirrorOffsetCount) : (currentHotIndex - mirrorOffsetCount);

            if (board.isMirrorLevel && currentHotIndex >= 0 && HasMirrorPartner(board, currentHotIndex, mirrorIndexAt))
            {
                if (currentHotIndex < mirrorOffsetCount)
                {
                    Assert.IsTrue(currentHotIndex + mirrorOffsetCount < GetTotalNumberOfShapeBlocks(board));
                    if ((currentHotIndex + mirrorOffsetCount) == i)
                    {
                        if (isCurrentHotIndex)
                        {
                            Assert.IsTrue(keyStates.isDown(ButtonType.BUTTON_LEFT_MOUSE));
                        }
                        //this would be if you grabbed the 'lower shape' and you want to hightlight the one above
                        result = true;
                    }
                }
                else
                {
                    Assert.IsTrue(currentHotIndex - mirrorOffsetCount >= 0);
                    if ((currentHotIndex - mirrorOffsetCount) == i)
                    {
                        if (isCurrentHotIndex)
                        {
                            Assert.IsTrue(keyStates.isDown(ButtonType.BUTTON_LEFT_MOUSE));
                        }
                        //this would be if you grabbed the 'higher shape'
                        result = true;
                    }
                }
            }
            return(result);
        }
        public void FixedUpdate()
        {
            keyStates.ProcessKeyStates(cameraInScene);

            if (!lastMousePSet)
            {
                lastMouseP    = keyStates.mouseInScreenSpace;
                lastMousePSet = true;
            }
            Vector3 accel = new Vector3(0, 0, 0);

            if (keyStates.isDown(ButtonType.BUTTON_LEFT_MOUSE))
            {
                //get acceleration
                Vector3 diffVec = keyStates.mouseInScreenSpace - lastMouseP;
                diffVec = Vector3.Normalize(diffVec);
                accel   = AccelForce * diffVec;
                // error_printFloat2("diff: ", accel.xy.E);
                //accel.x *= -1; //inverse the pull direction. Since y is down for mouseP, y is already flipped
            }

            camVel += Time.deltaTime * accel + camVel;
            camVel  = camVel - 0.6f * camVel;
            camTransform.position += Time.deltaTime * camVel;

            lastMouseP = keyStates.mouseInScreenSpace;

            if (keyStates.wasReleased(ButtonType.BUTTON_LEFT_MOUSE))
            {
                lastMousePSet = false;
            }
            //float factor = 10.0f;
            //Vector3 newPos = new Vector3();
            //newPos.x = ((int)((camTransform.position.x + 0.5f) * factor)) / factor;
            //newPos.y = ((int)((camTransform.position.y + 0.5f) * factor)) / factor;
            //camTransform.position = newPos;
        }