Exemple #1
0
        void runTest()
        {
            BubbleMatrixGeometry geometry  = new BubbleMatrixGeometry(0.0f, 10.5f, 10.0f, 0.0f, 10, 10, 0.5f);
            Vector3 position1              = new Vector3(0.6f, 9.6f, 0.0f);
            bool    isBaselineAlignedLeft1 = true;
            Vector2 expectedAnswer1        = new Vector2(0f, 0f);
            Vector2 answer1 = BubbleMatrixControllerHelper.CellForPosition(position1, geometry, isBaselineAlignedLeft1);

            Debug.Log("[BubbleMatrixControllerHelper] Test correct?  " + ((expectedAnswer1.x == answer1.x) && (expectedAnswer1.y == answer1.y)));


            position1 = new Vector3(0.6f, 9.6f, 0.0f);
            isBaselineAlignedLeft1 = false;
            expectedAnswer1        = new Vector2(0f, 0f);
            answer1 = BubbleMatrixControllerHelper.CellForPosition(position1, geometry, isBaselineAlignedLeft1);
            Debug.Log("[BubbleMatrixControllerHelper] Test correct?  " + ((expectedAnswer1.x == answer1.x) && (expectedAnswer1.y == answer1.y)));


            position1 = new Vector3(1.2f, 9.6f, 0.0f);
            isBaselineAlignedLeft1 = true;
            expectedAnswer1        = new Vector2(0f, 1f);
            answer1 = BubbleMatrixControllerHelper.CellForPosition(position1, geometry, isBaselineAlignedLeft1);
            bool correct = ((expectedAnswer1.x == answer1.x) && (expectedAnswer1.y == answer1.y));

            Debug.Log("[BubbleMatrixControllerHelper] Test correct?  " + correct);


            position1 = new Vector3(1.2f, 9.6f, 0.0f);
            isBaselineAlignedLeft1 = false;
            expectedAnswer1        = new Vector2(0f, 0f);
            answer1 = BubbleMatrixControllerHelper.CellForPosition(position1, geometry, isBaselineAlignedLeft1);
            correct = ((expectedAnswer1.x == answer1.x) && (expectedAnswer1.y == answer1.y));
            Debug.Log("[BubbleMatrixControllerHelper] Test correct?  " + correct);


            position1 = new Vector3(0.2f, 11.0f, 0.0f);
            isBaselineAlignedLeft1 = false;
            expectedAnswer1        = new Vector2(0f, 0f);
            answer1 = BubbleMatrixControllerHelper.CellForPosition(position1, geometry, isBaselineAlignedLeft1);
            correct = ((expectedAnswer1.x == answer1.x) && (expectedAnswer1.y == answer1.y));
            Debug.Log("[BubbleMatrixControllerHelper] Test correct?  " + correct);



            position1 = new Vector3(-2.2f, 13.0f, 0.0f);
            isBaselineAlignedLeft1 = true;
            expectedAnswer1        = new Vector2(0f, 0f);
            answer1 = BubbleMatrixControllerHelper.CellForPosition(position1, geometry, isBaselineAlignedLeft1);
            correct = ((expectedAnswer1.x == answer1.x) && (expectedAnswer1.y == answer1.y));
            Debug.Log("[BubbleMatrixControllerHelper] Test correct?  " + correct);


            position1 = new Vector3(10.45f, 13.0f, 0.0f);
            isBaselineAlignedLeft1 = false;
            expectedAnswer1        = new Vector2(0f, 9f);
            answer1 = BubbleMatrixControllerHelper.CellForPosition(position1, geometry, isBaselineAlignedLeft1);
            correct = ((expectedAnswer1.x == answer1.x) && (expectedAnswer1.y == answer1.y));
            Debug.Log("[BubbleMatrixControllerHelper] Test correct?  " + correct);
            //public static Vector2 CellForPosition(Vector3 position, BubbleMatrixGeometry geometry, bool isBaselineAlignedLeft){
        }
Exemple #2
0
        public static Vector3 PositionForCell(Vector2 cell, BubbleMatrixGeometry geometry, bool isBaselineAlignedLeft)
        {
            // cell.x = row in the matrix
            // cell.y = column in the matrix

            bool  rowIsEven = cell.x % 2 == 0;
            float y         = geometry.rows - cell.x - geometry.bubbleRadius;
            float x;

            if (isBaselineAlignedLeft)
            {
                if (rowIsEven)
                {
                    x = cell.y + geometry.bubbleRadius;
                }
                else
                {
                    x = cell.y + 2 * geometry.bubbleRadius;
                }
            }
            else
            {
                if (rowIsEven)
                {
                    x = cell.y + 2 * geometry.bubbleRadius;
                }
                else
                {
                    x = cell.y + geometry.bubbleRadius;
                }
            }
            return(new Vector3(x, y, geometry.depth));
        }
		void runTest()
		{		
				BubbleMatrixGeometry geometry = new BubbleMatrixGeometry(0.0f, 10.5f, 10.0f, 0.0f, 10, 10, 0.5f);
				Vector3 position1 = new Vector3(0.6f, 9.6f, 0.0f);
				bool isBaselineAlignedLeft1 = true;
				Vector2 expectedAnswer1 = new Vector2(0f,0f);
				Vector2 answer1 =  BubbleMatrixControllerHelper.CellForPosition(position1, geometry, isBaselineAlignedLeft1);
				Debug.Log ("[BubbleMatrixControllerHelper] Test correct?  " + ((expectedAnswer1.x == answer1.x) && (expectedAnswer1.y == answer1.y)));
				
				
				position1 = new Vector3(0.6f, 9.6f, 0.0f);
				isBaselineAlignedLeft1 = false;
				expectedAnswer1 = new Vector2(0f,0f);
				answer1 =  BubbleMatrixControllerHelper.CellForPosition(position1, geometry, isBaselineAlignedLeft1);
				Debug.Log ("[BubbleMatrixControllerHelper] Test correct?  " + ((expectedAnswer1.x == answer1.x) && (expectedAnswer1.y == answer1.y)));
			
				
				position1 = new Vector3(1.2f, 9.6f, 0.0f);
				isBaselineAlignedLeft1 = true;
				expectedAnswer1 = new Vector2(0f,1f);
				answer1 =  BubbleMatrixControllerHelper.CellForPosition(position1, geometry, isBaselineAlignedLeft1);
				bool correct = ((expectedAnswer1.x == answer1.x) && (expectedAnswer1.y == answer1.y));
				Debug.Log ("[BubbleMatrixControllerHelper] Test correct?  " + correct);

				
				position1 = new Vector3(1.2f, 9.6f, 0.0f);
				isBaselineAlignedLeft1 = false;
				expectedAnswer1 = new Vector2(0f,0f);
				answer1 =  BubbleMatrixControllerHelper.CellForPosition(position1, geometry, isBaselineAlignedLeft1);
				correct = ((expectedAnswer1.x == answer1.x) && (expectedAnswer1.y == answer1.y));
				Debug.Log ("[BubbleMatrixControllerHelper] Test correct?  " + correct);
			
				
				position1 = new Vector3(0.2f, 11.0f, 0.0f);
				isBaselineAlignedLeft1 = false;
				expectedAnswer1 = new Vector2(0f,0f);
				answer1 =  BubbleMatrixControllerHelper.CellForPosition(position1, geometry, isBaselineAlignedLeft1);
				correct = ((expectedAnswer1.x == answer1.x) && (expectedAnswer1.y == answer1.y));
				Debug.Log ("[BubbleMatrixControllerHelper] Test correct?  " + correct);
			
			
				
				position1 = new Vector3(-2.2f, 13.0f, 0.0f);
				isBaselineAlignedLeft1 = true;
				expectedAnswer1 = new Vector2(0f,0f);
				answer1 =  BubbleMatrixControllerHelper.CellForPosition(position1, geometry, isBaselineAlignedLeft1);
				correct = ((expectedAnswer1.x == answer1.x) && (expectedAnswer1.y == answer1.y));
				Debug.Log ("[BubbleMatrixControllerHelper] Test correct?  " + correct);
			
				
				position1 = new Vector3(10.45f, 13.0f, 0.0f);
				isBaselineAlignedLeft1 = false;
				expectedAnswer1 = new Vector2(0f,9f);
				answer1 =  BubbleMatrixControllerHelper.CellForPosition(position1, geometry, isBaselineAlignedLeft1);
				correct = ((expectedAnswer1.x == answer1.x) && (expectedAnswer1.y == answer1.y));
				Debug.Log ("[BubbleMatrixControllerHelper] Test correct?  " + correct);
				//public static Vector2 CellForPosition(Vector3 position, BubbleMatrixGeometry geometry, bool isBaselineAlignedLeft){
					
			}
		/*	Returns the position in the matrix given a position and a matrix geometry
		 * @param {Vector3} position. Position of the object
		 * @param {BubbleMatrixGeometry} geometry. Geometry of the matrix
		 * @param {bool} isBaselineAlignedLeft. True if the first(top) row of the matrix is aligned to the left border
		 * @return Vector2 position of the object in the matrix.
		 */
		public static Vector2 CellForPosition(Vector3 position, BubbleMatrixGeometry geometry, bool isBaselineAlignedLeft){	
			int row = geometry.rows - Mathf.FloorToInt(position.y) - 1;
			int column;
			bool rowIsEven = row% 2 == 0;
			if ((rowIsEven && isBaselineAlignedLeft) || (!rowIsEven  && !isBaselineAlignedLeft )){
				column = Mathf.FloorToInt(position.x);
			}else{
				column = Mathf.FloorToInt(position.x - geometry.bubbleRadius);
			}
			Vector2 result =  new Vector2(row, JQMath.TruncateToInterval(column, 0, geometry.columns -1));
			return result;
		}
        public void startGame()
        {
            this._bubblesContainer = GameObject.Find("Bubbles");
            this._bubbleShooter    = GameObject.Find("BubbleShooter");
            this.geometry          = new BubbleMatrixGeometry(leftBorder, rightBorder, topBorder, 0.0f, rows, columns, bubbleRadius);
            this._currentBubble    = this.createBubble();
            this._isPlaying        = true;
            StartCoroutine("addRowScheduler");

            for (int i = 0; i < _defaultRowsCount; i++)
            {
                this.addRow();
            }
        }
		public void startGame(){
			
			this._bubblesContainer = GameObject.Find("Bubbles");
			this._bubbleShooter = GameObject.Find ("BubbleShooter");
			this.geometry = new BubbleMatrixGeometry(leftBorder, rightBorder, topBorder, 0.0f, rows, columns, bubbleRadius);
			this._currentBubble = this.createBubble();
			this._isPlaying = true;
			StartCoroutine("addRowScheduler");
			
			for (int i =0 ; i < _defaultRowsCount; i++){
				this.addRow();
			}
			
		}
Exemple #7
0
        /*	Returns the position in the matrix given a position and a matrix geometry
         * @param {Vector3} position. Position of the object
         * @param {BubbleMatrixGeometry} geometry. Geometry of the matrix
         * @param {bool} isBaselineAlignedLeft. True if the first(top) row of the matrix is aligned to the left border
         * @return Vector2 position of the object in the matrix.
         */
        public static Vector2 CellForPosition(Vector3 position, BubbleMatrixGeometry geometry, bool isBaselineAlignedLeft)
        {
            int  row = geometry.rows - Mathf.FloorToInt(position.y) - 1;
            int  column;
            bool rowIsEven = row % 2 == 0;

            if ((rowIsEven && isBaselineAlignedLeft) || (!rowIsEven && !isBaselineAlignedLeft))
            {
                column = Mathf.FloorToInt(position.x);
            }
            else
            {
                column = Mathf.FloorToInt(position.x - geometry.bubbleRadius);
            }
            Vector2 result = new Vector2(row, JQMath.TruncateToInterval(column, 0, geometry.columns - 1));

            return(result);
        }
Exemple #8
0
        public void startGame()
        {
            this.geometry          = new BubbleMatrixGeometry(leftBorder, rightBorder, topBorder, 0.0f, rows, columns, bubbleRadius);
            this._bubblesContainer = GameObject.Find("Bubbles");
            this._launchPosition   = new Vector3((rightBorder - leftBorder) / 2.0f - geometry.bubbleRadius / 2.0f, -0.65f, 0);
            this._bubbleShooter    = GameObject.Find("BubbleShooter");
            this._bubbleShooter.transform.position = _launchPosition;
            this._audioManager = FindObjectOfType <AudioManager>();

            prepareCurrentBubble();
            this._isPlaying = true;
            StartCoroutine("addRowScheduler");

            for (int i = 0; i < _defaultRowsCount; i++)
            {
                this.addRow();
            }
        }
		public static Vector3 PositionForCell(Vector2 cell, BubbleMatrixGeometry geometry, bool isBaselineAlignedLeft){	
			// cell.x = row in the matrix
			// cell.y = column in the matrix
			
			bool rowIsEven = cell.x % 2 == 0;
			float y = geometry.rows - cell.x - geometry.bubbleRadius;
			float x;
			if (isBaselineAlignedLeft){
				if (rowIsEven){
					x = cell.y + geometry.bubbleRadius;
				}else{
					x = cell.y +  2 * geometry.bubbleRadius;
				}
			}else{
				if (rowIsEven){
					x = cell.y +  2 * geometry.bubbleRadius;
				}else{
					x = cell.y + geometry.bubbleRadius;
				}
			}
			return new Vector3(x, y, geometry.depth);
		}