예제 #1
0
 public void PushBlockRight(ABlock block)
 {
     if (_rightBlock)
     {
         Replace(_rightBlock, -1f);
     }
     _rightBlock = block;
     _rightBlock.transform.SetParent(transform);
     _rightBlock.transform.localPosition = Vector3.zero;
 }
예제 #2
0
 public void PushBlockLeft(ABlock block)
 {
     if (_leftBlock)
     {
         Replace(_leftBlock, 1f);
     }
     _leftBlock = block;
     _leftBlock.transform.SetParent(transform);
     _leftBlock.transform.localPosition = Vector3.zero;
 }
예제 #3
0
        private IEnumerator ScaleUp(ABlock block)
        {
            var maxSize = block.transform.localScale * 2f;

            while (block != null && maxSize.x > block.transform.localScale.x)
            {
                block.transform.localScale = Vector3.Slerp(block.transform.localScale, maxSize, 10f * Time.deltaTime);
                yield return(0);
            }
        }
예제 #4
0
        private void Replace(ABlock block, float dir)
        {
            var rb = block.GetComponent <Rigidbody2D>();

            block.GetComponent <Collider2D>().enabled          = true;
            block.GetComponent <SpriteRenderer>().sortingOrder = 100;
            rb.bodyType = RigidbodyType2D.Dynamic;
            rb.AddTorque(100f * dir, ForceMode2D.Impulse);
            StartCoroutine("ScaleUp", block);
        }
예제 #5
0
 /// <summary>
 /// Pushes a block in the building.
 /// </summary>
 /// <param name="block"></param>
 /// <returns>The total block count</returns>
 public int PushBlock(ABlock block)
 {
     block.transform.SetParent(transform);
     for (int i = 0; i < block.transform.childCount; ++i)
     {
         block.transform.GetChild(i).transform.localScale = Vector3.one * _blockScale;
     }
     block.SetBlockPosition(new Vector3(
                                /*_startPosition.x +*/ _buildingOffsetHorizontal + (block.GetWidth() * (_blocks.Count % _width)),
                                /*_startPosition.y +*/ (block.GetHeight() * (_blocks.Count / _width)),
                                _startPosition.z));
     //block.transform.localPosition = new Vector3(
     //    _startPosition.x + (block.GetWidth() * (_blocks.Count % _width)),
     //    _startPosition.y + (block.GetHeight() * (_blocks.Count / _width)),
     //    _startPosition.z);
     _blocks.Add(block);
     if (_blocks.Count % _width == 0)
     {
         GetComponent <AudioSource>().Play();
         _height += block.GetHeight();
     }
     return(_blocks.Count);
 }
예제 #6
0
 public void PushBlockRight(ABlock block)
 {
     _combinedBlockInstance.PushBlockRight(block);
     CheckCombination();
 }