Example #1
0
 public void SpawnAllBlocks()
 {
     for (byte width = 0; width < HexGrid.Width; width++)
     {
         for (byte height = 0; height < HexGrid.Height; height++)
         {
             Block currentBlock = blockSpawner.SpawnBlock(width, height);
             blockMover.AnimateBlockAt(currentBlock.Coord);
         }
     }
 }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        if (isMovingRight)
        {
            MoveBlockRight();
        }
        else
        {
            MoveBlockLeft();
        }


        if (Input.GetKeyDown(KeyCode.Space))
        {
            blockRB.useGravity = true;
            moveSpeed          = 0;

            // Find spawner, call spawn function
            GameObject   spawner       = GameObject.Find("Block Spawner");
            BlockSpawner spawnerScript = spawner.GetComponent <BlockSpawner>();
            spawnerScript.SpawnBlock();

            Destroy(this);
        }
    }
Example #3
0
 private void CheckBlockOverlap()
 {
     if (_blockSpawner.GetBlockPosition() == _snakeController.GetPosition())
     {
         _blockSpawner.SpawnBlock();
         _snakeController.Grow();
     }
 }
Example #4
0
    private void FullDown()
    {
        while (true)
        {
            if (!MoveDirection(Vector3.down))
            {
                break;
            }
        }

        StopCoroutine(fallingCoroutine);

        if (AddToGrid())
        {
            SoundManager.Instance.PlayOneShot("FX_Common");

            CheckForLines();

            for (int i = 0; i < transform.childCount; i++)
            {
                if (rotationPoint == transform.GetChild(i))
                {
                    continue;
                }

                transform.GetChild(i).parent = spawner.transform;

                i--;
            }

            gameObject.SetActive(false);

            spawner.SpawnBlock();
        }
        else
        {
            spawner.GameOver();
        }
    }
    private void SpawnBlock(bool isHeld)
    {
        if (isHeld && !m_SpawnBlockPressed)
        {
            m_SpawnBlockPressed = true;

            m_CurrentlyControlledBlock = BlockSpawner.SpawnBlock().gameObject.GetComponent <BlockMover>();
        }
        else if (!isHeld)
        {
            m_SpawnBlockPressed = false;
        }
    }