Example #1
0
        // Check if there are no more bricks then load next level.
        // TODO(shf): Brick is not used do we need it for this?
        void brickDestruction(HawkBrick brick)
        {
            if (brickManager.remainingBricks.Count <= 0)
            {
                // cleared level
                ballManager.resetBalls();
                collectableManager.resetCollectables();

                isgameStarted = false;
                loadNextLevel();
            }
        }
Example #2
0
        // Event and collectable spawn chance methods
        internal void onBrickDestroy(HawkBrick brick)
        {
            float buffSpawnChance   = UnityEngine.Random.Range(0, 100f);
            float debuffSpawnChance = UnityEngine.Random.Range(0, 100f);

            bool buffSpawned = false;

            if (buffSpawnChance <= collectableManager.buffChance)
            {
                collectableManager.makeBuff(brick);
            }
            if (debuffSpawnChance <= collectableManager.debuffChance && !buffSpawned)
            {
                collectableManager.makeDebuff(brick);
            }
        }
Example #3
0
        private void makeBricks()
        {
            remainingBricks = new List <HawkBrick>();

            int[,] level = levels[currentLevel];

            float currentSpawnX = initialBrickSpawnX;
            float currentSpawnY = initialBrickSpawnY;
            // used to make each new brick closer to camera to avoid
            //  overlapping
            float zShift = 0;

            for (int row = 0; row < maxRows; row++)
            {
                for (int col = 0; col < maxCols; col++)
                {
                    int brickType = level[row, col];

                    if (brickType > 0)
                    {
                        HawkBrick brick = Instantiate(brickPrefab, new Vector3(currentSpawnX, currentSpawnY, 0.0f - zShift), Quaternion.identity) as HawkBrick;
                        brick.Init(bricksContainer.transform, sprites[brickType - 1], brickColors[brickType], brickType);

                        remainingBricks.Add(brick);
                        zShift += 0.0001f;
                    }

                    currentSpawnX += shiftAmount;

                    if (col + 1 == maxCols)
                    {
                        currentSpawnX = initialBrickSpawnX;
                    }
                }

                currentSpawnY -= shiftAmount;
            }
            initialBrickCount = remainingBricks.Count;

            onBricksLoaded?.Invoke();
        }
Example #4
0
 void onBrickDestruction(HawkBrick brick)
 {
     // TODO(shf): Look into other alternatives to this
     onBrickDestroy(brick);
 }
Example #5
0
 void onBrickDestruction(HawkBrick obj)
 {
     updateRemainingBricks();
     updateScoreText(10);
 }
        public void makeDebuff(HawkBrick brick)
        {
            HawkCollectable prefab = availableDeBuffs[Random.Range(0, availableDeBuffs.Count)];

            addToCollectableList(Instantiate(prefab, brick.transform.position, Quaternion.identity) as HawkCollectable);
        }