Ejemplo n.º 1
0
    /// <summary>
    /// ブロック配置の初期化
    /// </summary>
    private void InitializeStage()
    {
        var blocks = new List <Block>();

        // 開始位置とブロックのサイズ
        var startPosX = -160;
        var startPosY = -80;
        var width     = 70;
        var height    = 20;

        // ブロックを生成
        // 各ブロックのポジションは開始位置からブロックサイズ分右下にずらす
        for (int i = 0; i < row; i++)
        {
            var posY = startPosY - height * i;
            for (int j = 0; j < column; j++)
            {
                var posX     = startPosX + width * j;
                var position = new Vector2(posX, posY);
                if (row % 2 == 0)
                {
                    var color = Color.gray;
                }
                else
                {
                    var color = Color.red;
                }
                var block = BlockProvider.Create(this.BlocksArea.GetComponent <RectTransform>(), position, Color.gray);
                blocks.Add(block);

                // ブロックがこわれたとき
                block.OnBroken.Subscribe(
                    score => {
                    this.ScoreManager.UpdateScore(score);
                    // ブロック全部壊したらクリア
                    if (this.ScoreManager.Score == block.Score * row * column)
                    {
                        GameClear();
                    }
                }).AddTo(block);
            }
        }

        // ゲームオーバ処理
        this.Ground.OnTriggerEnter2DAsObservable()
        .Subscribe(
            collider => {
            Destroy(collider.gameObject);
            GameOver();
        }
            );
    }
Ejemplo n.º 2
0
        public BlockProvider GetBlockProvider(World world)
        {
            //Check for the folder in the dictionary and if it doesn't exist create it
            BlockProvider blockProvider;

            if (BlockProviders.TryGetValue(world.config.blockFolder, out blockProvider))
            {
                return(blockProvider);
            }

            blockProvider = BlockProvider.Create(world.config.blockFolder, world);
            BlockProviders.Add(world.config.blockFolder, blockProvider);
            return(blockProvider);
        }
Ejemplo n.º 3
0
    void Start()
    {
        int width_step = 4;
        int count      = 0;
        int length     = BlockProvider.BLOCKS.Count;

        foreach (KeyValuePair <string, char[, ]> blueprint in BlockProvider.BLOCKS)
        {
            Block block = BlockProvider.Create(blueprint);
            block.color                   = m_color;
            block.transform.parent        = this.transform;
            block.transform.localPosition = new Vector3((count - length / 2) * width_step, 0, 0);
            count++;
        }
    }