public void fallBlock(BlockControl block0, Block.DIR4 dir, BlockControl block1)
    {
        // block0とblock1の色、サイズ、消えるまでの時間、表示・非表示、状態を記録
        Block.COLOR color0        = block0.color;
        Block.COLOR color1        = block1.color;
        Vector3     scale0        = block0.transform.localScale;
        Vector3     scale1        = block1.transform.localScale;
        float       vanish_timer0 = block0.vanish_timer;
        float       vanish_timer1 = block1.vanish_timer;
        bool        visible0      = block0.isVisible();
        bool        visible1      = block1.isVisible();

        Block.STEP step0 = block0.step;
        Block.STEP step1 = block1.step;

        //
        block0.setColor(color1);
        block1.setColor(color0);
        block0.transform.localScale = scale1;
        block1.transform.localScale = scale0;
        block0.vanish_timer         = vanish_timer1;
        block1.vanish_timer         = vanish_timer0;
        block0.setVisible(visible1);
        block1.setVisible(visible0);
        block0.step = step1;
        block1.step = step0;
        block0.beginFall(block1);
    }
Exemple #2
0
    public void swapBlock(BlockControl block0, Block.DIR4 dir, BlockControl block1)
    {
        Block.COLOR color0 = block0.color;
        Block.COLOR color1 = block1.color;

        Vector3 scale0 = block0.transform.localScale;
        Vector3 scale1 = block1.transform.localScale;

        float vanish_timer0 = block0.vanish_timer;
        float vanish_timer1 = block1.vanish_timer;

        Vector3 offset0 = BlockRoot.getDirVector(dir);
        Vector3 offset1 = BlockRoot.getDirVector(BlockRoot.getOppositeDir(dir));

        block0.setColor(color1);
        block1.setColor(color0);

        block0.transform.localScale = scale1;
        block1.transform.localScale = scale0;

        block0.vanish_timer = vanish_timer1;
        block1.vanish_timer = vanish_timer0;

        block0.beginSlide(offset0);
        block1.beginSlide(offset1);
    }
    public void swapBlock(BlockControl block0, Block.DIR4 dir, BlockControl block1)
    {
        // それぞれのブロックの色を覚えておく
        Block.COLOR color0 = block0.color;
        Block.COLOR color1 = block1.color;

        // それぞれのブロックの拡大率を覚えておく
        Vector3 scale0 = block0.transform.localScale;
        Vector3 scale1 = block1.transform.localScale;

        // それぞれのブロックの「消える時間」を覚えておく
        float vanish_timer0 = block0.vanish_timer;
        float vanish_timer1 = block1.vanish_timer;

        // それぞれのブロックの移動先を求める
        Vector3 offset0 = BlockRoot.getDirVector(dir);
        Vector3 offset1 = BlockRoot.getDirVector(BlockRoot.getOppositDir(dir));

        // 色を入れ替える
        block0.setColor(color1);
        block1.setColor(color0);

        // 拡大率を入れ替える
        block0.transform.localScale = scale1;
        block1.transform.localScale = scale0;

        // 「消える時間」を入れ替える
        block0.vanish_timer = vanish_timer1;
        block1.vanish_timer = vanish_timer0;

        block0.beginSlide(offset0); // 元のブロックの移動を開始
        block1.beginSlide(offset1); // 元のブロックの移動を開始
    }
Exemple #4
0
    public void swapBlock(BlockControl block0, Block.DIR4 dir, BlockControl block1)
    {
        // 각 블록의 색을 기억해 둔다.
        Block.COLOR color0 = block0.color;
        Block.COLOR color1 = block1.color;
        // 각 블록의.
        // 확대율을 기억해 둔다.
        Vector3 scale0 =
            block0.transform.localScale;
        Vector3 scale1 =
            block1.transform.localScale;
        //  각 블록의 '사라지는 시간'을 기억해 둔다.
        float vanish_timer0 = block0.vanish_timer;
        float vanish_timer1 = block1.vanish_timer;
        // 각 블록이 이동할 곳을 구한다.
        Vector3 offset0 = BlockRoot.getDirVector(dir);
        Vector3 offset1 = BlockRoot.getDirVector(BlockRoot.getOppositDir(dir));

        block0.setColor(color1);                     //  색을 교체한다.
        block1.setColor(color0);
        block0.transform.localScale = scale1;        // 확대율을 교체한다.
        block1.transform.localScale = scale0;
        block0.vanish_timer         = vanish_timer1; // 사라지는 시간을 교체한다.
        block1.vanish_timer         = vanish_timer0;
        block0.beginSlide(offset0);                  // 원래 블록의 이동을 시작.
        block1.beginSlide(offset1);                  // 이동할 곳의 블록 이동을 시작.
    }
Exemple #5
0
    // ================================================================ //

    // 블록을 떨어뜨린다.
    public void             fallBlock(BlockControl block0, Block.DIR4 dir, BlockControl block1)
    {
        // 낙하시킬 블록이 잡는 중이라면 놓는다.
        if (this.grabbed_block == block0 || this.grabbed_block == block1)
        {
            this.hideArrow();
            this.grabbed_block = null;
        }

        //

        Block.COLOR color0 = block0.color;
        Block.COLOR color1 = block1.color;

        Vector3 scale0 = block0.transform.localScale;
        Vector3 scale1 = block1.transform.localScale;

        float vanish_timer0 = block0.vanish_timer;
        float vanish_timer1 = block1.vanish_timer;

        bool visible0 = block0.isVisible();
        bool visible1 = block1.isVisible();

        Block.STEP step0 = block0.step;
        Block.STEP step1 = block1.step;

        float frame0 = 0.0f;
        float frame1 = 0.0f;

        if (color1 == Block.COLOR.NECO)
        {
            frame0 = block0.getNekoMotion()["00_Idle"].time;
            frame1 = block1.getNekoMotion()["00_Idle"].time;
        }

        //

        block0.setColor(color1);
        block1.setColor(color0);

        block0.transform.localScale = scale1;
        block1.transform.localScale = scale0;

        block0.vanish_timer = vanish_timer1;
        block1.vanish_timer = vanish_timer0;

        block0.setVisible(visible1);
        block1.setVisible(visible0);

        block0.step = step1;
        block1.step = step0;

        if (color1 == Block.COLOR.NECO)
        {
            block0.getNekoMotion()["00_Idle"].time = frame1;
            block1.getNekoMotion()["00_Idle"].time = frame0;
        }

        block0.beginFall(block1);
    }
Exemple #6
0
    public void swapBlock(BlockControl block0, Block.DIR4 dir, BlockControl block1)
    {
        // 각각의 블록 패턴을 기억해 둔다.
        Block.PATTERN color0 = block0.pattern;
        Block.PATTERN color1 = block1.pattern;
        // 각각의 블록 숫자를 기억해 둔다.
        Block.NUMBER number0 = block0.num;
        Block.NUMBER number1 = block1.num;

        // 각각의 블록의 확대율을 기억해 둔다.
        Vector3 scale0 = block0.transform.localScale;
        Vector3 scale1 = block1.transform.localScale;
        // 각각의 블록의 '사라지는 시간'을 기억해 둔다.
        float vanish_timer0 = block0.vanish_timer;
        float vanish_timer1 = block1.vanish_timer;
        // 각각의 블록의 이동할 곳을 구한다.
        Vector3 offset0 = BlockRoot.getDirVector(dir);
        Vector3 offset1 = BlockRoot.getDirVector(BlockRoot.getOppositDir(dir));

        // 패턴을 교체한다.
        block0.setColor(color1);
        block1.setColor(color0);
        // 숫자를 교체한다.
        block0.setNumber(number1);
        block1.setNumber(number0);
        // 확대율을 교체한다.
        block0.transform.localScale = scale1;
        block1.transform.localScale = scale0;
        // '사라지는 시간'을 교체한다.
        block0.vanish_timer = vanish_timer1;
        block1.vanish_timer = vanish_timer0;
        block0.beginSlide(offset0); // 원래 블록 이동을 시작한다.
        block1.beginSlide(offset1); // 이동할 위치의 블록 이동을 시작한다.
    }
Exemple #7
0
    public float calcDirOffset(Vector2 position, Block.DIR4 dir)
    {
        float offset = 0.0f;
        // 指定された位置と、ブロックの現在位置との差を表すベクトル 
        Vector2 v = position - new Vector2(this.transform.position.x, this.transform.position.y);

        switch (dir) // 指定された方向によって分岐
        {
        case Block.DIR4.RIGHT:
            offset = v.x;
            break;

        case Block.DIR4.LEFT:
            offset = -v.x;
            break;

        case Block.DIR4.UP:
            offset = v.y;
            break;

        case Block.DIR4.DOWN:
            offset = -v.y;
            break;
        }
        return(offset);
    }
    // 현재 위치와 슬라이드할 곳의 거리가 어느 정도인가 반환한다.
    public float calcDirOffset(Vector2 position, Block.DIR4 dir)
    {
        float offset = 0.0f;
        // 지정된 위치와 블록의 현재 위치의 차를 나타내는 벡터.
        Vector2 v = position - new Vector2(
            this.transform.position.x, this.transform.position.y);

        switch (dir)
        { // 지정된 방향에 따라 갈라진다.
        case Block.DIR4.RIGHT:
            offset = v.x;
            break;

        case Block.DIR4.LEFT:
            offset = -v.x;
            break;

        case Block.DIR4.UP:
            offset = v.y;
            break;

        case Block.DIR4.DOWN:
            offset = -v.y;
            break;
        }
        return(offset);
    }
Exemple #9
0
    public Block.DIR4 calcSlideDir(Vector2 mouse_position)
    {
        Block.DIR4 dir = Block.DIR4.NONE;
        // 指定されたmouse_positionと現在位置との差を示すベクトル
        Vector2 v = mouse_position - new Vector2(this.transform.position.x, this.transform.position.y);

        // ベクトルの大きさが0.1より大きいなら
        // (それより小さい場合は、スライドしていないと見なす)
        if (v.magnitude > 0.1f)
        {
            if (v.y > v.x)
            {
                if (v.y > -v.x)
                {
                    dir = Block.DIR4.UP;
                }
                else
                {
                    dir = Block.DIR4.LEFT;
                }
            }
            else
            {
                if (v.y > -v.x)
                {
                    dir = Block.DIR4.RIGHT;
                }
                else
                {
                    dir = Block.DIR4.DOWN;
                }
            }
        }
        return(dir);
    }
Exemple #10
0
    public Block.DIR4 calcSlideDir(Vector2 mouse_position)
    {                                                                                                        // 마우스 위치를 바탕으로 슬라이드된 방향을 구한다.
        Block.DIR4 dir = Block.DIR4.NONE;
        Vector2    v   = mouse_position - new Vector2(this.transform.position.x, this.transform.position.y); // 지정된 mouse_position과 현재 위치의 차를 나타냄.

        if (v.magnitude > 0.1f)
        { // 벡터의 크기가 0.1보다 크면. 그보다 작으면 슬라이드하지 않은 걸로 간주한다.
            if (v.y > v.x)
            {
                if (v.y > -v.x)
                {
                    dir = Block.DIR4.UP;
                }
                else
                {
                    dir = Block.DIR4.LEFT;
                }
            }
            else
            {
                if (v.y > -v.x)
                {
                    dir = Block.DIR4.RIGHT;
                }
                else
                {
                    dir = Block.DIR4.DOWN;
                }
            }
        }
        return(dir);
    }
Exemple #11
0
    public void swapBlock(BlockControl block0, Block.DIR4 dir, BlockControl block1)
    {
        // 각각의 블록 색을 기억해둔다
        Block.COLOR color0 = block0.color;
        Block.COLOR color1 = block1.color;

        // 각각의 블록의 확대율을 기억해둔다
        Vector3 scale0 = block0.transform.localScale;
        Vector3 scale1 = block1.transform.localScale;

        // 각각의 블록의 사라지는 시간을 기억해둔다
        float vanish_timer0 = block0.vanish_timer;
        float vanish_timer1 = block1.vanish_timer;

        // 각각의 블록의 이동할 곳을 구한다
        Vector3 offset0 = BlockRoot.getDirVector(dir);
        Vector3 offset1 = BlockRoot.getDirVector(BlockRoot.getOppositDir(dir));

        // 색을 교체한다
        block0.SetColor(color1);
        block1.SetColor(color0);

        // 확대율 교체
        block0.transform.localScale = scale1;
        block1.transform.localScale = scale0;

        // 사라지는 시간 교체
        block0.vanish_timer = vanish_timer1;
        block1.vanish_timer = vanish_timer0;

        block0.beginSlide(offset0); // 원래 블록 이동 시작
        block1.beginSlide(offset1); // 이동할 위치의 블록 이동을 시작
    }
Exemple #12
0
    public float calcDirOffset(Vector2 position, Block.DIR4 dir)
    {
        float   offset = 0.0f;
        Vector2 v      = position - new Vector2(this.transform.position.x, this.transform.position.y);

        switch (dir)
        {
        case Block.DIR4.RIGHT:
            offset = v.x;
            break;

        case Block.DIR4.LEFT:
            offset = -v.x;
            break;

        case Block.DIR4.UP:
            offset = v.y;
            break;

        case Block.DIR4.DOWN:
            offset = -v.y;
            break;
        }
        return(offset);
    }
Exemple #13
0
    public void fallBlock(BlockControl block0, Block.DIR4 dir, BlockControl block1)
    {
        // block0과 block1의 색, 크기, 사라질 때까지 걸리는 시간, 표시, 비표시, 상태를 기록.
        Block.COLOR color0        = block0.color;
        Block.COLOR color1        = block1.color;
        Vector3     scale0        = block0.transform.localScale;
        Vector3     scale1        = block1.transform.localScale;
        float       vanish_timer0 = block0.vanish_timer;
        float       vanish_timer1 = block1.vanish_timer;
        bool        visible0      = block0.isVisible();
        bool        visible1      = block1.isVisible();

        Block.STEP step0 = block0.step;
        Block.STEP step1 = block1.step;
        // block0과 block1의 각종 속성을 교체한다.
        block0.SetColor(color1);
        block1.SetColor(color0);
        block0.transform.localScale = scale1;
        block1.transform.localScale = scale0;
        block0.vanish_timer         = vanish_timer1;
        block1.vanish_timer         = vanish_timer0;
        block0.setVisible(visible1);
        block1.setVisible(visible0);
        block0.step = step1;
        block1.step = step0;
        block0.beginFall(block1);
    }
Exemple #14
0
    public Block.DIR4 calcSlideDir(Vector2 mouse_position)
    {
        Block.DIR4 dir = Block.DIR4.NONE;
        // 지정된 mouse_position과 현재 위치의 차를 나타내는 벡터
        Vector2 v = mouse_position - new Vector2(this.transform.position.x, this.transform.position.y);

        // 벡터크기가 0.1보다 크면 (그보다 작으면 슬라이드하지 않은 것으로 간주)
        if (v.magnitude > 0.1f)
        {
            if (v.y > v.x)
            {
                if (v.y > -v.x)
                {
                    dir = Block.DIR4.UP;
                }
                else
                {
                    dir = Block.DIR4.LEFT;
                }
            }
            else
            {
                if (v.y > -v.x)
                {
                    dir = Block.DIR4.RIGHT;
                }
                else
                {
                    dir = Block.DIR4.DOWN;
                }
            }
        }
        return(dir);
    }
Exemple #15
0
    public static Vector3 getDirVector(Block.DIR4 dir)
    {
        Vector3 v = Vector3.zero;

        switch (dir)
        {
        case Block.DIR4.RIGHT:
            v = Vector3.right;
            break;

        case Block.DIR4.LEFT:
            v = Vector3.left;
            break;

        case Block.DIR4.UP:
            v = Vector3.up;
            break;

        case Block.DIR4.DOWN:
            v = Vector3.down;
            break;
        }
        v *= Block.COLLISION_SIZE;
        return(v);
    }
Exemple #16
0
    // 슬라이드 입력 방향을 구한다.
    public Block.DIR4       calcSlideDir(Vector2 mouse_position)
    {
        Block.DIR4 dir = Block.DIR4.NONE;

        Vector2 v = mouse_position - new Vector2(this.transform.position.x, this.transform.position.y);

        if (v.magnitude > 0.1f)
        {
            if (v.y > v.x)
            {
                if (v.y > -v.x)
                {
                    dir = Block.DIR4.UP;
                }
                else
                {
                    dir = Block.DIR4.LEFT;
                }
            }
            else
            {
                if (v.y > -v.x)
                {
                    dir = Block.DIR4.RIGHT;
                }
                else
                {
                    dir = Block.DIR4.DOWN;
                }
            }
        }

        return(dir);
    }
Exemple #17
0
    public static Block.DIR4 getOppositDir(Block.DIR4 dir)
    { // 블록을 서로 교체하기 위해 인수로 지정된 방향의 반대 방향을 반환.
        Block.DIR4 opposit = dir;
        switch (dir)
        {
        case Block.DIR4.RIGHT: opposit = Block.DIR4.LEFT; break;

        case Block.DIR4.LEFT: opposit = Block.DIR4.RIGHT; break;

        case Block.DIR4.UP: opposit = Block.DIR4.DOWN; break;

        case Block.DIR4.DOWN: opposit = Block.DIR4.UP; break;
        }
        return(opposit);
    }
    public static Block.DIR4 getOppositDir(Block.DIR4 dir)
    {
        Block.DIR4 opposit = dir;
        switch (dir)
        {
        case Block.DIR4.RIGHT: opposit = Block.DIR4.LEFT; break;

        case Block.DIR4.LEFT: opposit = Block.DIR4.RIGHT; break;

        case Block.DIR4.UP: opposit = Block.DIR4.DOWN; break;

        case Block.DIR4.DOWN: opposit = Block.DIR4.UP; break;
        }
        return(opposit);
    }
Exemple #19
0
    // 그쪽으로 슬라이드할 수 있는가?
    public bool             isSlidable(Block.DIR4 dir)
    {
        bool ret = false;

        switch (dir)
        {
        case Block.DIR4.RIGHT:  ret = (this.i_pos.x < Block.BLOCK_NUM_X - 1);   break;

        case Block.DIR4.LEFT:   ret = (this.i_pos.x > 0);                                               break;

        case Block.DIR4.UP:             ret = (this.i_pos.y < Block.BLOCK_NUM_Y - 1);   break;

        case Block.DIR4.DOWN:   ret = (this.i_pos.y > 0);                                               break;
        }

        return(ret);
    }
Exemple #20
0
    public static Block.iPosition           getNext_iPosition(Block.iPosition i_pos, Block.DIR4 dir)
    {
        Block.iPosition next_ipos = i_pos;

        switch (dir)
        {
        case Block.DIR4.RIGHT:  next_ipos.x += 1;       break;

        case Block.DIR4.LEFT:   next_ipos.x -= 1;       break;

        case Block.DIR4.UP:             next_ipos.y += 1;       break;

        case Block.DIR4.DOWN:   next_ipos.y -= 1;       break;
        }

        return(next_ipos);
    }
Exemple #21
0
    // 반대 방향을 구한다.
    static public Block.DIR4        getOppose(Block.DIR4 dir)
    {
        Block.DIR4 oppose = Block.DIR4.NONE;

        switch (dir)
        {
        case Block.DIR4.RIGHT:  oppose = Block.DIR4.LEFT;       break;

        case Block.DIR4.LEFT:   oppose = Block.DIR4.RIGHT;      break;

        case Block.DIR4.UP:             oppose = Block.DIR4.DOWN;       break;

        case Block.DIR4.DOWN:   oppose = Block.DIR4.UP; break;
        }

        return(oppose);
    }
Exemple #22
0
    public static Vector3 getDirVector(Block.DIR4 dir)
    {
        Vector3 v = Vector3.zero;

        switch (dir)
        {
        case Block.DIR4.RIGHT: v = Vector3.right; break; // 오른쪽으로 1단위 이동.

        case Block.DIR4.LEFT: v = Vector3.left; break;   // 왼쪽으로 1단위 이동.

        case Block.DIR4.UP: v = Vector3.up; break;       // 위로 1단위 이동.

        case Block.DIR4.DOWN: v = Vector3.down; break;   // 아래로 1단위 이동.
        }
        v *= Block.COLLISION_SIZE;                       // 블록 크기를 곱한다.
        return(v);
    }
Exemple #23
0
    // ================================================================ //

    // dir 방향의 이웃 블록을 얻는다.
    public BlockControl             getNextBlock(BlockControl block, Block.DIR4 dir)
    {
        BlockControl next_block = null;

        switch (dir)
        {
        case Block.DIR4.RIGHT:
        {
            if (block.i_pos.x < Block.BLOCK_NUM_X - 1)
            {
                next_block = this.blocks[block.i_pos.x + 1, block.i_pos.y];
            }
        }
        break;

        case Block.DIR4.LEFT:
        {
            if (block.i_pos.x > 0)
            {
                next_block = this.blocks[block.i_pos.x - 1, block.i_pos.y];
            }
        }
        break;

        case Block.DIR4.UP:
        {
            if (block.i_pos.y < Block.BLOCK_NUM_Y - 1)
            {
                next_block = this.blocks[block.i_pos.x, block.i_pos.y + 1];
            }
        }
        break;

        case Block.DIR4.DOWN:
        {
            if (block.i_pos.y > 0)
            {
                next_block = this.blocks[block.i_pos.x, block.i_pos.y - 1];
            }
        }
        break;
        }

        return(next_block);
    }
    public static Vector3 getDirVector(Block.DIR4 dir)
    {
        Vector3 v = Vector3.zero;

        switch (dir)
        {
        case Block.DIR4.RIGHT: v = Vector3.right; break; // 右に1単位ずらす

        case Block.DIR4.LEFT: v = Vector3.left; break;   // 左に1単位ずらす

        case Block.DIR4.UP: v = Vector3.up; break;       // 上に1単位ずらす

        case Block.DIR4.DOWN: v = Vector3.down; break;   // 下に1単位ずらす
        }

        v *= Block.COLLISION_SIZE; // ブロックのサイズを掛ける
        return(v);
    }
Exemple #25
0
    // 슬라이드 화살표를 표시한다.
    public void             dispArrow(BlockControl block, Block.DIR4 dir)
    {
        this.arrow.gameObject.SetActive(true);
        this.arrow.gameObject.transform.position = block.transform.position + Vector3.back * (Block.COLLISION_SIZE * 5.0f + 0.01f);

        float angle = 0.0f;

        switch (dir)
        {
        case Block.DIR4.RIGHT:  angle = 0.0f; break;

        case Block.DIR4.LEFT:   angle = 180.0f; break;

        case Block.DIR4.UP:             angle = 90.0f; break;

        case Block.DIR4.DOWN:   angle = -90.0f; break;
        }

        this.arrow.gameObject.transform.localRotation = Quaternion.AngleAxis(angle, Vector3.forward);
    }
Exemple #26
0
    // 두 블록을 교체한다.
    public void             swapBlock(BlockControl block0, Block.DIR4 dir, BlockControl block1)
    {
        // 교체 상대는 반대 방향으로 슬라이드.
        block1.slide_dir = BlockRoot.getOppositDir(dir);

        Block.COLOR color0 = block0.color;
        Block.COLOR color1 = block1.color;

        Vector3 scale0 = block0.transform.localScale;
        Vector3 scale1 = block1.transform.localScale;

        float vanish_timer0 = block0.vanish_timer;
        float vanish_timer1 = block1.vanish_timer;

        Vector3 offset0 = BlockRoot.getDirVector(dir);
        Vector3 offset1 = BlockRoot.getDirVector(block1.slide_dir);

        float grab_timer0 = block0.grab_timer;
        float grab_timer1 = block1.grab_timer;

        //

        block0.setColor(color1);
        block1.setColor(color0);

        block0.transform.localScale = scale1;
        block1.transform.localScale = scale0;

        block0.vanish_timer = vanish_timer1;
        block1.vanish_timer = vanish_timer0;

        block0.grab_timer = grab_timer1;
        block1.grab_timer = grab_timer0;

        block0.slide_forward = false;
        block1.slide_forward = true;

        block0.beginSlide(offset0);
        block1.beginSlide(offset1);
    }
Exemple #27
0
    public BlockControl getNextBlock(
        BlockControl block, Block.DIR4 dir)
    {
        // 슬라이드할 곳의 블록을 여기에 저장.
        BlockControl next_block = null;

        switch (dir)
        {
        case Block.DIR4.RIGHT:
            if (block.i_pos.x < Block.BLOCK_NUM_X - 1)
            {
                // 그리드 안이라면.
                next_block = this.blocks[block.i_pos.x + 1, block.i_pos.y];
            }
            break;

        case Block.DIR4.LEFT:
            if (block.i_pos.x > 0)              // 그리드 안이라면.
            {
                next_block = this.blocks[block.i_pos.x - 1, block.i_pos.y];
            }
            break;

        case Block.DIR4.UP:
            if (block.i_pos.y < Block.BLOCK_NUM_Y - 1)              // 그리드 안이라면.
            {
                next_block = this.blocks[block.i_pos.x, block.i_pos.y + 1];
            }
            break;

        case Block.DIR4.DOWN:
            if (block.i_pos.y > 0)              // 그리드 안이라면.
            {
                next_block = this.blocks[block.i_pos.x, block.i_pos.y - 1];
            }
            break;
        }
        return(next_block);
    }
    // 퇴장 연출용 블록을 만든다.
    public LeaveBlockControl                createLeaveBlock(BlockControl block)
    {
        GameObject game_object = Instantiate(this.blockPrefab) as GameObject;

        LeaveBlockControl leave_block = game_object.GetComponent <LeaveBlockControl>();

        //
        leave_block.leave_block_root   = this;
        leave_block.i_pos              = block.i_pos;
        leave_block.transform.position = block.transform.position;
        leave_block.getModelsRoot().transform.localScale = block.getModelsRoot().transform.localScale;
        leave_block.getModelsRoot().transform.localPosition = block.getModelsRoot().transform.localPosition;
        leave_block.getModelsRoot().transform.localRotation = block.getModelsRoot().transform.localRotation;

        leave_block.setColor(block.color);

        if (block.color == Block.COLOR.NECO)
        {
            leave_block.getNecoMotion()["00_Idle"].time = block.getNekoMotion()["00_Idle"].time;
        }

        for (int i = 0; i < (int)Block.DIR4.NUM; i++)
        {
            Block.DIR4 dir = (Block.DIR4)i;

            leave_block.setConnectedBlock(dir, block.getConnectedBlock(dir));
        }

        // 하이어라키 뷰에서 위치를 확인하기 쉽게 블록 좌표를 이름에 붙여 둔다.
        leave_block.name = "leave_block(" + block.i_pos.x.ToString() + "," + block.i_pos.y.ToString() + ")";

        // 섬(같은 색 블록이 서로 이웃한 덩어리) 블록이
        // 전부 갖춰질 때까지 기다린다 .
        this.waiting_blocks.Add(leave_block);

        return(leave_block);
    }
    public BlockControl getNextBlock(BlockControl block, Block.DIR4 dir)
    {
        BlockControl next_block = null; // スライド先のブロックをここに格納

        switch (dir)
        {
        case Block.DIR4.RIGHT:
            if (block.i_pos.x < Block.BLOCK_NUM_X - 1)     // グリッド内なら
            {
                next_block = this.blocks[block.i_pos.x + 1, block.i_pos.y];
            }
            break;

        case Block.DIR4.LEFT:
            if (block.i_pos.x > 0)     // グリッド内なら
            {
                next_block = this.blocks[block.i_pos.x - 1, block.i_pos.y];
            }
            break;

        case Block.DIR4.UP:
            if (block.i_pos.y < Block.BLOCK_NUM_Y - 1)     // グリッド内なら
            {
                next_block = this.blocks[block.i_pos.x, block.i_pos.y + 1];
            }
            break;

        case Block.DIR4.DOWN:
            if (block.i_pos.y > 0)     // グリッド内なら
            {
                next_block = this.blocks[block.i_pos.x, block.i_pos.y - 1];
            }
            break;
        }
        return(next_block);
    }
Exemple #30
0
    // 블록이 퇴장하는 방향을 정한다.
    private Block.DIR4      select_move_dir(LeaveBlockControl[]     children)
    {
        Block.DIR4 dir = Block.DIR4.RIGHT;

        float cx = 0.0f;

        foreach (LeaveBlockControl block in children)
        {
            cx += (float)block.i_pos.x;
        }

        cx /= (float)children.Length;

        if (cx < (float)Block.BLOCK_NUM_X / 2)
        {
            dir = Block.DIR4.LEFT;
        }
        else
        {
            dir = Block.DIR4.RIGHT;
        }

        return(dir);
    }
    // Update is called once per frame
    void Update()
    {
        Vector3 mouse_position;

        this.block_root.unprojectMousePosition(
            out mouse_position, Input.mousePosition);

        Vector2 mouse_position_xy =
            new Vector2 (mouse_position.x, mouse_position.y);

        if(this.vanish_timer>= 0.0f){
            this.vanish_timer-=Time.deltaTime;
            if(this.vanish_timer<0.0f){
                if(this.step != Block.STEP.SLIDE){
                    this.vanish_timer=-1.0f;
                    this.next_step=Block.STEP.VACANT;
                }else{
                    this.vanish_timer=0.0f;
                }
            }
        }

        this.step_timer += Time.deltaTime;
        float slide_time=0.2f;

        if(this.next_step==Block.STEP.NONE){
            switch(this.step){
            case Block.STEP.SLIDE:
                if(this.step_timer>=slide_time){
                    if(this.vanish_timer==0.0f){
                        this.next_step=Block.STEP.VACANT;
                    }else{
                        this.next_step=Block.STEP.IDLE;
                    }
                }
                break;

            case Block.STEP.IDLE:
                this.renderer.enabled=true;
                break;

            case Block.STEP.FALL:
                if(this.position_offset.y<=0.0f){
                    this.next_step=Block.STEP.IDLE;
                    this.position_offset.y=0.0f;
                }
                break;

            }
        }

        while(this.next_step != Block.STEP.NONE){

              this.step =this.next_step;
              this.next_step=Block.STEP.NONE;

              switch(this.step){

                case Block.STEP.IDLE:
                    this.position_offset=Vector3.zero;
                    this.transform.localScale=Vector3.one*1.0f;
                    break;

                case Block.STEP.GRABBED:
                    this.transform.localScale=Vector3.one*1.2f;
                    break;
                case Block.STEP.RELEASED:
                    this.position_offset=Vector3.zero;
                    this.transform.localScale=Vector3.one*1.0f;
                    break;
                case Block.STEP.VACANT:
                    this.position_offset=Vector3.zero;
                    this.setVisible(false);
                    break;
                case Block.STEP.RESPAWN:
                    int color_index=Random.Range(0,(int)Block.COLOR.NORMAL_COLOR_NUM);
                    this.setColor((Block.COLOR)color_index);
                    this.next_step=Block.STEP.IDLE;
                    break;

           }
            this.step_timer=0.0f;

        }

        switch(this.step){
            case Block.STEP.GRABBED:
                this.slide_dir=this.calcSlideDir(mouse_position_xy);
                break;
            case Block.STEP.SLIDE:
                float rate = this.step_timer/slide_time;
                rate=Mathf.Min(rate,1.0f);
                rate=Mathf.Sin (rate*Mathf.PI/2.0f);
                this.position_offset=Vector3.Lerp(
                    this.position_offset_initial,Vector3.zero,rate);
                break;
            case Block.STEP.FALL:
                this.fall.velocity+=Physics.gravity.y*Time.deltaTime*0.3f;
                this.position_offset.y+=this.fall.velocity*Time.deltaTime;
                if(this.position_offset.y<0.0f){
                    this.position_offset.y=0.0f;
                }
                break;
        }

        Vector3 position= BlockRoot.calcBlockPosition(this.i_pos)+this.position_offset;

        this.transform.position=position;

        this.setColor(this.color);

        if(this.vanish_timer >= 0.0f){
            Color color0=
                Color.Lerp(this.renderer.material.color,Color.white,0.5f);
            Color color1=
                Color.Lerp(this.renderer.material.color,Color.black,0.5f);

            if(this.vanish_timer<Block.VANISH_TIME/2.0f){

                color0.a = this.vanish_timer/(Block.VANISH_TIME/2.0f);
                color1.a=color0.a;

                this.renderer.material=this.transparent_material;
            }

            float rate = 1.0f - this.vanish_timer/Block.VANISH_TIME;
            this.renderer.material.color=Color.Lerp(color0,color1,rate);
        }
    }
Exemple #32
0
    void Update()
    {
        Vector3 mouse_position; // 마우스 위치.
        this.block_root.unprojectMousePosition( // 마우스 위치 획득.
                                               out mouse_position, Input.mousePosition);
        // 획득한 마우스 위치를 X와 Y만으로 한다.
        Vector2 mouse_position_xy =
            new Vector2(mouse_position.x, mouse_position.y);

        this.step_timer += Time.deltaTime;
        float slide_time = 0.2f;
        if(this.next_step == Block.STEP.NONE) { // '상태정보 없음'의 경우.
            switch(this.step) {
            case Block.STEP.SLIDE:
                if(this.step_timer >= slide_time) {
                    // vanish_timer(사라질 때까지의 시간)이 0이면.
                    // VACANT(사라지는)상태로 이행.
                    if(this.vanish_timer == 0.0f) {
                        this.next_step = Block.STEP.VACANT;
                        // vanish_timer가 0이 아니면.
                        // IDLE(대기) 상태로 이행.
                    } else {
                        this.next_step = Block.STEP.IDLE;
                    }
                }
                break;
            }
        }

        // '다음 블록' 상태가 '정보 없음' 이외인 동안.
        // ='다음 블록' 상태가 변경된 경우.
        while(this.next_step != Block.STEP.NONE) {
            this.step = this.next_step;
            this.next_step = Block.STEP.NONE;
            switch(this.step) {
            case Block.STEP.IDLE: // '대기' 상태.
                this.position_offset = Vector3.zero;
                // 블록 표시 크기를 보통 크기로 한다.
                this.transform.localScale = Vector3.one * 1.0f;
                break;
            case Block.STEP.GRABBED: // '잡힌' 상태.
                // 블록 표시 크기를 크게 한다.
                this.transform.localScale = Vector3.one * 1.2f;
                break;
            case Block.STEP.RELEASED: // '떨어져 있는' 상태.
                this.position_offset = Vector3.zero;
                // 블록 표시 크기를 보통 사이즈로 한다.
                this.transform.localScale = Vector3.one * 1.0f;
                break;

            case Block.STEP.VACANT:
                this.position_offset = Vector3.zero;
                break;
            }
            this.step_timer = 0.0f;
        }

        switch(this.step) {
        case Block.STEP.GRABBED: // 잡힌 상태.
            // 잡힌 상태일 때는 항상 슬라이드 방향을 체크.
            this.slide_dir = this.calcSlideDir(mouse_position_xy);
            break;
        case Block.STEP.SLIDE: // 슬라이드(교체) 중.
            // 블록을 서서히 이동하는 처리.
            // (어려운 부분이니 지금은 몰라도 괜찮다).
            float rate = this.step_timer / slide_time;
            rate = Mathf.Min(rate, 1.0f);
            rate = Mathf.Sin(rate*Mathf.PI / 2.0f);
            this.position_offset = Vector3.Lerp(
                this.position_offset_initial, Vector3.zero, rate);
            break;
        }

        //그리드 좌표를 실제 좌표(씬의 좌표)로 변환하고,.
        // position_offset을 추가한다.
        Vector3 position =
            BlockRoot.calcBlockPosition(this.i_pos) + this.position_offset;
        // 실제 위치를 새로운 위치로 변경.
        this.transform.position = position;
    }
Exemple #33
0
    void Update()
    {
        Vector3 mouse_position; // マウスの位置.
        this.block_root.unprojectMousePosition( // マウスの位置を取得.
                                               out mouse_position, Input.mousePosition);
        // 取得したマウス位置を X と Y だけにする.
        Vector2 mouse_position_xy =
            new Vector2(mouse_position.x, mouse_position.y);

        this.step_timer += Time.deltaTime;
        float slide_time = 0.2f;
        if(this.next_step == Block.STEP.NONE) { // 「状態情報なし」の場合.
            switch(this.step) {
            case Block.STEP.SLIDE:
                if(this.step_timer >= slide_time) {
                    // vanish_timer(消えるまでの時間)が0なら、.
                    // VACANT(消える)状態に移行.
                    if(this.vanish_timer == 0.0f) {
                        this.next_step = Block.STEP.VACANT;
                        // vanish_timerが0でないなら、.
                        // IDLE(待機)状態に移行.
                    } else {
                        this.next_step = Block.STEP.IDLE;
                    }
                }
                break;
            }
        }

        // 「次のブロック」の状態が「情報なし」以外である間.
        // =「次のブロック」の状態が変更されていた場合.
        while(this.next_step != Block.STEP.NONE) {
            this.step = this.next_step;
            this.next_step = Block.STEP.NONE;
            switch(this.step) {
            case Block.STEP.IDLE: // 「待機」状態.
                this.position_offset = Vector3.zero;
                // ブロックの表示サイズを通常サイズにする.
                this.transform.localScale = Vector3.one * 1.0f;
                break;
            case Block.STEP.GRABBED: // 「つかまれている」状態.
                // ブロックの表示サイズを大きくする.
                this.transform.localScale = Vector3.one * 1.2f;
                break;
            case Block.STEP.RELEASED: // 「離されている」状態.
                this.position_offset = Vector3.zero;
                // ブロックの表示サイズを通常サイズにする.
                this.transform.localScale = Vector3.one * 1.0f;
                break;

            case Block.STEP.VACANT:
                this.position_offset = Vector3.zero;
                break;
            }
            this.step_timer = 0.0f;
        }

        switch(this.step) {
        case Block.STEP.GRABBED: // 「つかまれた」状態.
            // 「つかまれた」状態のときは、常にスライド方向をチェック.
            this.slide_dir = this.calcSlideDir(mouse_position_xy);
            break;
        case Block.STEP.SLIDE: // スライド(入れ替え)中.
            // ブロックを徐々に移動する処理.
            // (難しいので、今はわからなくても大丈夫です).
            float rate = this.step_timer / slide_time;
            rate = Mathf.Min(rate, 1.0f);
            rate = Mathf.Sin(rate*Mathf.PI / 2.0f);
            this.position_offset = Vector3.Lerp(
                this.position_offset_initial, Vector3.zero, rate);
            break;
        }

        // グリッド座標を実座標(シーン上の座標)に変換し、.
        // position_offsetを加える.
        Vector3 position =
            BlockRoot.calcBlockPosition(this.i_pos) + this.position_offset;
        // 実際の位置を、新しい位置に変更.
        this.transform.position = position;
    }
Exemple #34
0
    void Update()
    {
        Vector3 mouse_position; // マウスの位置.
        this.block_root.unprojectMousePosition( // マウスの位置を取得.
                                               out mouse_position, Input.mousePosition);
        // 取得したマウス位置を1つのVector2にまとめる.
        Vector2 mouse_position_xy =	new Vector2(mouse_position.x, mouse_position.y);

        if(this.vanish_timer >= 0.0f) { // タイマーが0以上なら.
            this.vanish_timer -= Time.deltaTime; // タイマーの値を減らす.
            if(this.vanish_timer < 0.0f) { // タイマーが0未満なら.
                if(this.step != Block.STEP.SLIDE) { // スライド中でないなら.
                    this.vanish_timer = -1.0f;
                    this.next_step = Block.STEP.VACANT; // 状態を「消滅中」に.
                } else {
                    this.vanish_timer = 0.0f;
                }
            }
        }

        this.step_timer += Time.deltaTime;
        float slide_time = 0.2f;

        if(this.next_step == Block.STEP.NONE) { // 「状態情報なし」の場合.
            switch(this.step) {
            case Block.STEP.SLIDE:
                if(this.step_timer >= slide_time) {
                    // vanish_timer(消えるまでの時間)が0なら、.
                    // VACANT(消える)状態に移行.
                    if(this.vanish_timer == 0.0f) {
                        this.next_step = Block.STEP.VACANT;
                        // vanish_timerが0でないなら、.
                        // IDLE(待機)状態に移行.
                    } else {
                        this.next_step = Block.STEP.IDLE;
                    }
                }
                break;

            case Block.STEP.IDLE:
                this.renderer.enabled = true;
                break;
            case Block.STEP.FALL:
                if(this.position_offset.y <= 0.0f) {
                    this.next_step = Block.STEP.IDLE;
                    this.position_offset.y = 0.0f;
                }
                break;

            }
        }

        // 「次のブロック」の状態が「情報なし」以外である間.
        // =「次のブロック」の状態が変更されていた場合.
        while(this.next_step != Block.STEP.NONE) {
            this.step = this.next_step;
            this.next_step = Block.STEP.NONE;
            switch(this.step) {
            case Block.STEP.IDLE: // 「待機」状態.
                this.position_offset = Vector3.zero;
                // ブロックの表示サイズを通常サイズにする.
                this.transform.localScale = Vector3.one * 1.0f;
                break;
            case Block.STEP.GRABBED: // 「つかまれている」状態.
                // ブロックの表示サイズを大きくする.
                this.transform.localScale = Vector3.one * 1.2f;
                break;
            case Block.STEP.RELEASED: // 「離されている」状態.
                this.position_offset = Vector3.zero;
                // ブロックの表示サイズを通常サイズにする.
                this.transform.localScale = Vector3.one * 1.0f;
                break;

            case Block.STEP.VACANT:
                this.position_offset = Vector3.zero;
                this.setVisible(false); // ブロックを非表示に.
                break;

            case Block.STEP.RESPAWN:
                // 色をランダムに選び、ブロックをその色に設定.
                int color_index = Random.Range(
                    0, (int)Block.COLOR.NORMAL_COLOR_NUM);
                this.setColor((Block.COLOR)color_index);
                this.next_step = Block.STEP.IDLE;
                break;
            case Block.STEP.FALL:
                this.setVisible(true); // ブロックを表示.
                this.fall.velocity = 0.0f; // 落下速度をリセット.
                break;
            }
            this.step_timer = 0.0f;
        }

        switch(this.step) {
        case Block.STEP.GRABBED: // 「つかまれた」状態.
            // 「つかまれた」状態のときは、常にスライド方向をチェック.
            this.slide_dir = this.calcSlideDir(mouse_position_xy);
            break;
        case Block.STEP.SLIDE: // スライド(入れ替え)中.
            // ブロックを徐々に移動する処理.
            // (難しいので、今はわからなくても大丈夫です).
            float rate = this.step_timer / slide_time;
            rate = Mathf.Min(rate, 1.0f);
            rate = Mathf.Sin(rate*Mathf.PI / 2.0f);
            this.position_offset = Vector3.Lerp(
                this.position_offset_initial, Vector3.zero, rate);
            break;
        case Block.STEP.FALL:
            // 速度に、重力の影響を与える.
            this.fall.velocity += Physics.gravity.y * Time.deltaTime * 0.3f;
            // 縦方向の位置を計算.
            this.position_offset.y += this.fall.velocity * Time.deltaTime;
            if(this.position_offset.y < 0.0f) { // 落下しきったら.
                this.position_offset.y = 0.0f; // その場に留める.
            }
            break;
        }

        // グリッド座標を実座標(シーン上の座標)に変換し、.
        // position_offsetを加える.
        Vector3 position =
            BlockRoot.calcBlockPosition(this.i_pos) + this.position_offset;
        // 実際の位置を、新しい位置に変更.
        this.transform.position = position;

        this.setColor(this.color);
        if(this.vanish_timer >= 0.0f) {
            Color color0 = // 現在の色と白との中間色.
                Color.Lerp(this.renderer.material.color, Color.white, 0.5f);
            Color color1 = // 現在の色と黒との中間色.
                Color.Lerp(this.renderer.material.color, Color.black, 0.5f);
            // 着火演出時間の半分を過ぎたら.
            if(this.vanish_timer < Block.VANISH_TIME / 2.0f) {
                // 透明度(a)を設定.
                color0.a = this.vanish_timer / (Block.VANISH_TIME / 2.0f);
                color1.a = color0.a;
                // 半透明マテリアルを適用.
                this.renderer.material = this.transparent_material;
            }
            // vanish_timerが減るほど1に近づく.
            float rate = 1.0f - this.vanish_timer / Block.VANISH_TIME;
            // じわ〜っと色を変える.
            this.renderer.material.color = Color.Lerp(color0, color1, rate);
        }
    }
Exemple #35
0
    void Update()
    {
        Vector3 mouse_position; // 마우스 위치.
        this.block_root.unprojectMousePosition( // 마우스 위치를 가져온다.
                                               out mouse_position, Input.mousePosition);
        // 가져온 마우스 위치를 X와 Y만으로 한다(하나의 Vector2로 모은다).
        Vector2 mouse_position_xy =	new Vector2(mouse_position.x, mouse_position.y);

        if(this.vanish_timer >= 0.0f) { // 타이머가 0 이상이면.
            this.vanish_timer -= Time.deltaTime; // 타이머의 값을 줄인다.
            if(this.vanish_timer < 0.0f) { // 타이머가 0 미만이면.
                if(this.step != Block.STEP.SLIDE) { // 슬라이드 중이 아니라면.
                    this.vanish_timer = -1.0f;
                    this.next_step = Block.STEP.VACANT; // 상태를 '소멸 중'으로.
                } else {
                    this.vanish_timer = 0.0f;
                }
            }
        }

        this.step_timer += Time.deltaTime;
        float slide_time = 0.2f;

        if(this.next_step == Block.STEP.NONE) { // 상태 정보가 없는 상태.
            switch(this.step) {
            case Block.STEP.SLIDE:
                if(this.step_timer >= slide_time) {
                    // vanish_timer(사라질 때까지의 시간)가 0이면.
                    // VACANT(사라지는)상태로 전환.
                    if(this.vanish_timer == 0.0f) {
                        this.next_step = Block.STEP.VACANT;
                        // vanish_timer가 0이 아니면.
                        // IDLE(대기)상태로 전환.
                    } else {
                        this.next_step = Block.STEP.IDLE;
                    }
                }
                break;

            case Block.STEP.IDLE:
                this.GetComponent<Renderer>().enabled = true;
                break;
            case Block.STEP.FALL:
                if(this.position_offset.y <= 0.0f) {
                    this.next_step = Block.STEP.IDLE;
                    this.position_offset.y = 0.0f;
                }
                break;

            }
        }

        // '다음 블록'의 상태가 '정보 없음' 이외인 동안에.
        // = '다음 블록'의 상태가 변경된 경우.
        while(this.next_step != Block.STEP.NONE) {
            this.step = this.next_step;
            this.next_step = Block.STEP.NONE;
            switch(this.step) {
            case Block.STEP.IDLE: // '대기' 상태.
                this.position_offset = Vector3.zero;
                // 블록 표시 크기를 일반 크기로 한다.
                this.transform.localScale = Vector3.one * 1.0f;
                break;
            case Block.STEP.GRABBED: // '잡힌 상태'.
                // 블록 표시 크기를 크게 한다.
                this.transform.localScale = Vector3.one * 1.2f;
                break;
            case Block.STEP.RELEASED: // '놓은 상태'.
                this.position_offset = Vector3.zero;
                // 블록 표시 크기를 일반 크기로 한다.
                this.transform.localScale = Vector3.one * 1.0f;
                break;

            case Block.STEP.VACANT:
                this.position_offset = Vector3.zero;
                this.setVisible(false); // 블록이 표시되지 않게.
                break;

            case Block.STEP.RESPAWN:
                // 색을 랜덤하게 선택하여 블록을 선택한 색으로 설정.
                int color_index = Random.Range(
                    0, (int)Block.COLOR.NORMAL_COLOR_NUM);
                this.setColor((Block.COLOR)color_index);
                this.next_step = Block.STEP.IDLE;
                break;
            case Block.STEP.FALL:
                this.setVisible(true); // 블록을 표시.
                this.fall.velocity = 0.0f; // 낙하 속도를 리셋.
                break;
            }
            this.step_timer = 0.0f;
        }

        switch(this.step) {
        case Block.STEP.GRABBED: // '잡힌 상태'.
            // '잡힌 상태'일 때는 항상 슬라이드 방향을 체크.
            this.slide_dir = this.calcSlideDir(mouse_position_xy);
            break;
        case Block.STEP.SLIDE: // 슬라이드(교체) 중.
            // 블록을 서서히 이동하는 처리.
            // (어려우니 지금은 몰라도 괜찮다).
            float rate = this.step_timer / slide_time;
            rate = Mathf.Min(rate, 1.0f);
            rate = Mathf.Sin(rate*Mathf.PI / 2.0f);
            this.position_offset = Vector3.Lerp(
                this.position_offset_initial, Vector3.zero, rate);
            break;
        case Block.STEP.FALL:
            // 속도에 중력의 영향을 준다.
            this.fall.velocity += Physics.gravity.y * Time.deltaTime * 0.3f;
            // 세로 방향 위치를 계산.
            this.position_offset.y += this.fall.velocity * Time.deltaTime;
            if(this.position_offset.y < 0.0f) { // 다 내려왔다면.
                this.position_offset.y = 0.0f; // 그 자리에 머문다.
            }
            break;
        }

        // 그리드 좌표를 실제 좌표(씬의 좌표)로 변환하고.
        // position_offset를 더한다.
        Vector3 position =
            BlockRoot.calcBlockPosition(this.i_pos) + this.position_offset;
        // 실제 위치를 새로운 위치로 변경.
        this.transform.position = position;

        this.setColor(this.color);
        if(this.vanish_timer >= 0.0f) {
            Color color0 = // 현재 색과 흰색의 중간 색.
                Color.Lerp(this.GetComponent<Renderer>().material.color, Color.white, 0.5f);
            Color color1 = // 현재 색과 검은색의 중간 색.
                Color.Lerp(this.GetComponent<Renderer>().material.color, Color.black, 0.5f);
            // 발화 연출 시간의 절반을 지났다면.
            if(this.vanish_timer < Block.VANISH_TIME / 2.0f) {
                // 투명도(a)를 설정.
                color0.a = this.vanish_timer / (Block.VANISH_TIME / 2.0f);
                color1.a = color0.a;
                // 반투명 머티리얼을 적용.
                this.GetComponent<Renderer>().material = this.transparent_material;
            }
            // vanish_timer가 줄어들 수록 1에 가까워진다.
            float rate = 1.0f - this.vanish_timer / Block.VANISH_TIME;
            // 서서히 색을 바꾼다.
            this.GetComponent<Renderer>().material.color = Color.Lerp(color0, color1, rate);
        }
    }
Exemple #36
0
    void Update()
    {
        // ---------------------------------------------------------------- //
        // 3D 공간에서 마우스 위치 좌표를 구해 둔다.

        Vector3		mouse_position;

        this.block_root.unprojectMousePosition(out mouse_position, Input.mousePosition);

        Vector2		mouse_position_xy = new Vector2(mouse_position.x, mouse_position.y);

        // ---------------------------------------------------------------- //

        // 사라지는 연출 타이머.
        if(this.vanish_timer >= 0.0f) {

            this.vanish_timer -= Time.deltaTime;

            if(this.vanish_timer < 0.0f) {

                if(this.step != Block.STEP.SLIDE) {

                    this.vanish_timer = -1.0f;

                    // 퇴장 연출용 블록을 만든다.
                    this.leave_block_root.createLeaveBlock(this);

                    for(int i = 0;i < this.connected_block.Length;i++) {

                        this.connected_block[i].clear();
                    }

                    // (임시).
                    this.next_step = Block.STEP.VACANT;

                } else {

                    this.vanish_timer = 0.0f;
                }
            }

            this.vanish_facing_timer += Time.deltaTime;
        }

        // ---------------------------------------------------------------- //
        // 스텝 내 경과시간을 진행한다.

        this.step_timer += Time.deltaTime;

        // ---------------------------------------------------------------- //
        // 다음 상태로 이행할지 검사한다.

        if(this.next_step == Block.STEP.NONE) {

            switch(this.step) {

                case Block.STEP.IDLE:
                {
                }
                break;

                case Block.STEP.SLIDE:
                {
                    if(this.step_timer >= SLIDE_TIME) {

                        if(this.vanish_timer == 0.0f) {

                            this.next_step = Block.STEP.VACANT;

                        } else {

                            this.next_step = Block.STEP.IDLE;
                        }
                    }
                }
                break;

                case Block.STEP.FALL:
                {
                    if(this.position_offset.y <= 0.0f) {

                        this.next_step = Block.STEP.IDLE;
                        this.position_offset.y = 0.0f;
                    }
                }
                break;
            }
        }

        // ---------------------------------------------------------------- //
        // 상태가 전환됐을 때의 초기화.

        while(this.next_step != Block.STEP.NONE) {

            this.step      = this.next_step;
            this.next_step = Block.STEP.NONE;

            switch(this.step) {

                case Block.STEP.IDLE:
                {
                    this.setVisible(true);
                    this.position_offset = Vector3.zero;
                    this.vanish_spin     = 0.0f;
                    this.vanish_facing_timer = 0.0f;
                }
                break;

                case Block.STEP.GRABBED:
                {
                    this.setVisible(true);
                }
                break;

                case Block.STEP.SLIDE:
                {
                }
                break;

                case Block.STEP.RELEASED:
                {
                    this.setVisible(true);
                    this.position_offset = Vector3.zero;
                }
                break;

                case Block.STEP.VACANT:
                {
                    this.position_offset = Vector3.zero;
                    this.setVisible(false);
                }
                break;

                case Block.STEP.FALL:
                {
                    this.setVisible(true);
                    this.vanish_spin = 0.0f;
                    this.vanish_facing_timer = 0.0f;
                    this.fall.velocity = 0.0f;
                }
                break;
            }

            this.step_timer = 0.0f;
        }

        // ---------------------------------------------------------------- //
        // 각 상태에서의 실행 처리.

        float	scale = 1.0f;

        // 잡힌 스케일.

        if(this.step == Block.STEP.GRABBED) {

            this.grab_timer += Time.deltaTime;

        } else {

            this.grab_timer -= Time.deltaTime;
        }

        this.grab_timer = Mathf.Clamp(this.grab_timer, 0.0f, GRAB_EFFECT_TIME);

        float	grab_ratio = Mathf.Clamp01(this.grab_timer/GRAB_EFFECT_TIME);

        scale = Mathf.Lerp(1.0f, 1.3f, grab_ratio);

        //

        this.models_root.transform.localPosition = Vector3.zero;

        if(this.vanish_timer > 0.0f) {

            // 다른 블록보다 앞에 표시되도록.
            this.models_root.transform.localPosition = Vector3.back;
        }

        switch(this.step) {

            case Block.STEP.IDLE:
            {
            }
            break;

            case Block.STEP.FALL:
            {
                this.fall.velocity += Physics.gravity.y*Time.deltaTime*0.3f;
                this.position_offset.y += this.fall.velocity*Time.deltaTime;

                if(this.position_offset.y < 0.0f) {

                    this.position_offset.y = 0.0f;
                }
            }
            break;

            case Block.STEP.GRABBED:
            {
                // 슬라이드 방향.
                this.slide_dir = this.calcSlideDir(mouse_position_xy);

                // 다른 블록보다 앞쪽에 표시되도록.
                this.models_root.transform.localPosition = Vector3.back;
            }
            break;

            case Block.STEP.SLIDE:
            {
                float	ratio = this.step_timer/SLIDE_TIME;

                ratio = Mathf.Min(ratio, 1.0f);
                ratio = Mathf.Sin(ratio*Mathf.PI/2.0f);

                this.position_offset = Vector3.Lerp(this.position_offset_initial, Vector3.zero, ratio);

                //

                ratio = this.step_timer/SLIDE_TIME;
                ratio = Mathf.Min(ratio, 1.0f);
                ratio = Mathf.Sin(ratio*Mathf.PI);

                if(this.slide_forward) {

                    scale += Mathf.Lerp(0.0f, 0.5f, ratio);

                } else {

                    scale += Mathf.Lerp(0.0f, -0.5f, ratio);
                }
            }
            break;
        }

        // ---------------------------------------------------------------- //
        // 포지션.

        Vector3		position = BlockRoot.calcBlockPosition(this.i_pos) + this.position_offset;

        this.transform.position = position;

        // ---------------------------------------------------------------- //
        // 사라지는 연출.

        this.models_root.transform.localRotation = Quaternion.identity;

        if(this.vanish_timer >= 0.0f) {

            // facing ... 블록의 윗면(돌기가 있는 면)을 앞으로 향하게 회전.
            // vanish ... 빙글빙글 회전.

            float	facing_ratio = Mathf.InverseLerp(0.0f, 0.2f, this.vanish_facing_timer);

            facing_ratio = Mathf.Clamp01(facing_ratio);

            float	vanish_ratio = Mathf.InverseLerp(0.0f, this.block_root.level_control.getVanishTime(), this.vanish_timer);
            float	spin_speed   = vanish_ratio;

            this.vanish_spin += spin_speed*10.0f;

            if(this.color != Block.COLOR.NECO) {

                this.models_root.transform.localRotation *= Quaternion.AngleAxis(-90.0f*facing_ratio, Vector3.right);
                this.models_root.transform.localRotation *= Quaternion.AngleAxis(this.vanish_spin, Vector3.up);
            }
        }

        this.nekoAtama.localScale = Vector3.one*1.0f;
        this.models_root.transform.localScale = Vector3.one*scale;

        // ---------------------------------------------------------------- //

        if(this.color == Block.COLOR.NECO) {

            float	anim_speed = 1.0f;

            if(this.vanish_timer >= 0.0f) {

                float	vanish_ratio = this.calc_neko_vanish_ratio();

                anim_speed  = Mathf.Lerp(1.0f, 1.5f, vanish_ratio);
            }

            this.neko_motion["00_Idle"].speed = anim_speed;
        }
    }
Exemple #37
0
    void Update()
    {
        // ---------------------------------------------------------------- //
        // 3D空間でのマウスの位置座標を求めておく.

        Vector3		mouse_position;

        this.block_root.unprojectMousePosition(out mouse_position, Input.mousePosition);

        Vector2		mouse_position_xy = new Vector2(mouse_position.x, mouse_position.y);

        // ---------------------------------------------------------------- //

        // 消える演出タイマー.
        if(this.vanish_timer >= 0.0f) {

            this.vanish_timer -= Time.deltaTime;

            if(this.vanish_timer < 0.0f) {

                if(this.step != Block.STEP.SLIDE) {

                    this.vanish_timer = -1.0f;

                    // 退場演出用のブロックを作る.
                    this.leave_block_root.createLeaveBlock(this);

                    for(int i = 0;i < this.connected_block.Length;i++) {

                        this.connected_block[i].clear();
                    }

                    // (仮).
                    this.next_step = Block.STEP.VACANT;

                } else {

                    this.vanish_timer = 0.0f;
                }
            }

            this.vanish_facing_timer += Time.deltaTime;
        }

        // ---------------------------------------------------------------- //
        // ステップ内の経過時間を進める.

        this.step_timer += Time.deltaTime;

        // ---------------------------------------------------------------- //
        // 次の状態に移るかどうかを、チェックする.

        if(this.next_step == Block.STEP.NONE) {

            switch(this.step) {

                case Block.STEP.IDLE:
                {
                }
                break;

                case Block.STEP.SLIDE:
                {
                    if(this.step_timer >= SLIDE_TIME) {

                        if(this.vanish_timer == 0.0f) {

                            this.next_step = Block.STEP.VACANT;

                        } else {

                            this.next_step = Block.STEP.IDLE;
                        }
                    }
                }
                break;

                case Block.STEP.FALL:
                {
                    if(this.position_offset.y <= 0.0f) {

                        this.next_step = Block.STEP.IDLE;
                        this.position_offset.y = 0.0f;
                    }
                }
                break;
            }
        }

        // ---------------------------------------------------------------- //
        // 状態が遷移したときの初期化.

        while(this.next_step != Block.STEP.NONE) {

            this.step      = this.next_step;
            this.next_step = Block.STEP.NONE;

            switch(this.step) {

                case Block.STEP.IDLE:
                {
                    this.setVisible(true);
                    this.position_offset = Vector3.zero;
                    this.vanish_spin     = 0.0f;
                    this.vanish_facing_timer = 0.0f;
                }
                break;

                case Block.STEP.GRABBED:
                {
                    this.setVisible(true);
                }
                break;

                case Block.STEP.SLIDE:
                {
                }
                break;

                case Block.STEP.RELEASED:
                {
                    this.setVisible(true);
                    this.position_offset = Vector3.zero;
                }
                break;

                case Block.STEP.VACANT:
                {
                    this.position_offset = Vector3.zero;
                    this.setVisible(false);
                }
                break;

                case Block.STEP.FALL:
                {
                    this.setVisible(true);
                    this.vanish_spin = 0.0f;
                    this.vanish_facing_timer = 0.0f;
                    this.fall.velocity = 0.0f;
                }
                break;
            }

            this.step_timer = 0.0f;
        }

        // ---------------------------------------------------------------- //
        // 各状態での実行処理.

        float	scale = 1.0f;

        // つかまれスケール.

        if(this.step == Block.STEP.GRABBED) {

            this.grab_timer += Time.deltaTime;

        } else {

            this.grab_timer -= Time.deltaTime;
        }

        this.grab_timer = Mathf.Clamp(this.grab_timer, 0.0f, GRAB_EFFECT_TIME);

        float	grab_ratio = Mathf.Clamp01(this.grab_timer/GRAB_EFFECT_TIME);

        scale = Mathf.Lerp(1.0f, 1.3f, grab_ratio);

        //

        this.models_root.transform.localPosition = Vector3.zero;

        if(this.vanish_timer > 0.0f) {

            // 他のブロックより手前に表示されるように.
            this.models_root.transform.localPosition = Vector3.back;
        }

        switch(this.step) {

            case Block.STEP.IDLE:
            {
            }
            break;

            case Block.STEP.FALL:
            {
                this.fall.velocity += Physics.gravity.y*Time.deltaTime*0.3f;
                this.position_offset.y += this.fall.velocity*Time.deltaTime;

                if(this.position_offset.y < 0.0f) {

                    this.position_offset.y = 0.0f;
                }
            }
            break;

            case Block.STEP.GRABBED:
            {
                // スライド方向.
                this.slide_dir = this.calcSlideDir(mouse_position_xy);

                // 他のブロックより手前に表示されるように.
                this.models_root.transform.localPosition = Vector3.back;
            }
            break;

            case Block.STEP.SLIDE:
            {
                float	ratio = this.step_timer/SLIDE_TIME;

                ratio = Mathf.Min(ratio, 1.0f);
                ratio = Mathf.Sin(ratio*Mathf.PI/2.0f);

                this.position_offset = Vector3.Lerp(this.position_offset_initial, Vector3.zero, ratio);

                //

                ratio = this.step_timer/SLIDE_TIME;
                ratio = Mathf.Min(ratio, 1.0f);
                ratio = Mathf.Sin(ratio*Mathf.PI);

                if(this.slide_forward) {

                    scale += Mathf.Lerp(0.0f, 0.5f, ratio);

                } else {

                    scale += Mathf.Lerp(0.0f, -0.5f, ratio);
                }
            }
            break;
        }

        // ---------------------------------------------------------------- //
        // ポジション.

        Vector3		position = BlockRoot.calcBlockPosition(this.i_pos) + this.position_offset;

        this.transform.position = position;

        // ---------------------------------------------------------------- //
        // 消える演出.

        this.models_root.transform.localRotation = Quaternion.identity;

        if(this.vanish_timer >= 0.0f) {

            // facing ... ブロックの上面(ぽっちがある面)を手前にむける回転.
            // vanish ... くるくる回る回転.

            float	facing_ratio = Mathf.InverseLerp(0.0f, 0.2f, this.vanish_facing_timer);

            facing_ratio = Mathf.Clamp01(facing_ratio);

            float	vanish_ratio = Mathf.InverseLerp(0.0f, this.block_root.level_control.getVanishTime(), this.vanish_timer);
            float	spin_speed   = vanish_ratio;

            this.vanish_spin += spin_speed*10.0f;

            if(this.color != Block.COLOR.NECO) {

                this.models_root.transform.localRotation *= Quaternion.AngleAxis(-90.0f*facing_ratio, Vector3.right);
                this.models_root.transform.localRotation *= Quaternion.AngleAxis(this.vanish_spin, Vector3.up);
            }
        }

        this.nekoAtama.localScale = Vector3.one*1.0f;
        this.models_root.transform.localScale = Vector3.one*scale;

        // ---------------------------------------------------------------- //

        if(this.color == Block.COLOR.NECO) {

            float	anim_speed = 1.0f;

            if(this.vanish_timer >= 0.0f) {

                float	vanish_ratio = this.calc_neko_vanish_ratio();

                anim_speed  = Mathf.Lerp(1.0f, 1.5f, vanish_ratio);
            }

            this.neko_motion["00_Idle"].speed = anim_speed;
        }
    }