Exemple #1
0
        public override void ChildUpdate()
        {
            float perc        = (Time.realtimeSinceStartup - startTimeStamp) / EndSpawn;
            int   targetCubes = Mathf.FloorToInt(Mathf.Lerp(0, numCubes, perc));

            BlockTextureGenerator.Border b = BlockTextureGenerator.Border.BORDER;

            while (numCubesShown < targetCubes)
            {
                GameObject c = GameObject.Instantiate(cube);
                c.transform.SetParent(this.gameObject.transform);
                Vector2 circle = Random.insideUnitCircle * 2f;
                c.transform.localPosition = new Vector3(circle.x, 0.0f, circle.y);
                c.SetActive(true);
                c.transform.localScale = Vector3.one * 0.5f;
                BlockTextureGenerator.BlockType blockType = (BlockTextureGenerator.BlockType)(numCubesShown % 3);
                Texture2D tex = BlockTextureGenerator.Instance.getLevelTexture(level, b, blockType);
                c.GetComponent <Renderer>().material.mainTexture = tex;

                Vector2 xz = Random.insideUnitCircle * 300f;
                c.GetComponent <Rigidbody>().AddForce(new Vector3(xz.x, 400.0f, xz.y));
                cubesMade.Add(c);
                numCubesShown++;
            }
        }
        public void GetSprite(int numLines, out BlockTextureGenerator.Border border, out BlockTextureGenerator.BlockType type, out float alpha)
        {
            alpha  = 0.0f;
            border = BlockTextureGenerator.Border.BORDER;
            switch (numLines)
            {
            default:
            case 1:
                type = BlockTextureGenerator.BlockType.WHITE;
                break;

            case 2:
                type = BlockTextureGenerator.BlockType.PRIMARY;
                break;

            case 3:
                type = BlockTextureGenerator.BlockType.SECONDARY;
                break;

            case 4:
                type  = BlockTextureGenerator.BlockType.SECONDARY;
                alpha = 1.0f;
                break;
            }
        }
Exemple #3
0
        protected void SetLine(int currentLevel, int index, int line)
        {
            BlockTextureGenerator.BlockType type   = (BlockTextureGenerator.BlockType)(line % 3);
            BlockTextureGenerator.Border    border = BlockTextureGenerator.Border.BORDER;

            for (int y = 0; y < 4; y++)
            {
                BlockHandler block = blocks[index][y];
                if (y >= line)
                {
                    block.gameObject.SetActive(false);
                    continue;
                }

                block.SetGlow(line == 4 ? 1.0f : 0.0f);
                block.SetImage(BlockTextureGenerator.Instance.getLevelSprite(currentLevel, border, type));
                block.gameObject.SetActive(true);
            }
        }