Esempio n. 1
0
 void Start()
 {
     // BlockRootスクリプトを取得.
     this.block_root = this.gameObject.GetComponent<BlockRoot>();
     // BlockRootスクリプトのinitialSetUp()を呼び出す.
     this.block_root.initialSetUp();
 }
Esempio n. 2
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); // 이동할 위치의 블록 이동을 시작한다.
    }
Esempio n. 3
0
    public void initialSetUp()
    {
        this.blocks = new BlockControl[Block.BLOCK_NUM_X, Block.BLOCK_NUM_Y];
        int color_index = 0;

        for (int y = 0; y < Block.BLOCK_NUM_Y; y++)
        {
            for (int x = 0; x < Block.BLOCK_NUM_X; x++)
            {
                GameObject   game_object = Instantiate(this.BlockPrefab) as GameObject;
                BlockControl block       = game_object.GetComponent <BlockControl>();
                this.blocks[x, y] = block;

                block.i_pos.x = x;
                block.i_pos.y = y;

                block.block_root = this;

                Vector3 position = BlockRoot.calcBlockPosition(block.i_pos);

                block.transform.position = position;

                block.setColor((Block.COLOR)color_index);

                block.name = "block(" + block.i_pos.x.ToString() + "," + block.i_pos.y.ToString() + ")";

                color_index = Random.Range(0, (int)Block.COLOR.NORMAL_COLOR_NUM);
            }
        }
    }
Esempio n. 4
0
    public GUIStyle guistyle;             // 폰트 스타일.

    void Start()
    {
        resultCanvas.SetActive(false); // 결과창 꺼놓음
        // BlockRoot 스크립트를 가져온다.
        this.block_root = this.gameObject.GetComponent <BlockRoot>();

        this.block_root.create(); // create() 메서드에서 초기 설정

        // BlockRoot 스크립트의 initialSetUp()을 호출한다.
        this.block_root.initialSetUp();

        // ScoreCounter 가져오기

        this.score_counter = this.gameObject.GetComponent <ScoreCounter>();

        //this.heart_counter = this.gameObject.GetComponent<ScoreCounter>();
        //this.diamond_counter= this.gameObject.GetComponent<ScoreCounter>();
        //this.spade_counter = this.gameObject.GetComponent<ScoreCounter>();
        //this.clober_counter = this.gameObject.GetComponent<ScoreCounter>();

        this.next_step         = STEP.PLAY; // 다음 상태를 '플레이 중'으로.
        this.guistyle.fontSize = 24;        // 폰트 크기를 24로.

        totalScore.text = "0";
    }
Esempio n. 5
0
 void Start()
 {
     // BlockRoot 스크립트 획득.
     this.block_root = this.gameObject.GetComponent <BlockRoot>();
     // BlockRoot스크립트의 initialSetUp()를 호출.
     this.block_root.initialSetUp();
 }
Esempio n. 6
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);                  // 이동할 곳의 블록 이동을 시작.
    }
Esempio n. 7
0
    public void InitialSetUp()
    {
        this.blocks = new BlockControl[Block.BLOCK_NUM_X, Block.BLOCK_NUM_Y];
        int color_index = 0;

        for (int y = 0; y < Block.BLOCK_NUM_Y; y++)
        {
            for (int x = 0; x < Block.BLOCK_NUM_X; x++)
            {
                // BlockPrefab의 인스턴스를 씬에 만든다
                GameObject   game_object = Instantiate(this.BlockPrefab) as GameObject;
                BlockControl block       = game_object.GetComponent <BlockControl>();
                this.blocks[x, y] = block;

                block.i_pos.x    = x;
                block.i_pos.y    = y;
                block.block_root = this;

                Vector2 position = BlockRoot.calcBlockPosition(block.i_pos);
                block.transform.position   = position;
                block.transform.localScale = new Vector3(0.7f, 0.7f, 0.7f);
                block.SetColor((Block.COLOR)color_index);
                block.name = "block(" + block.i_pos.x.ToString() + ", " + block.i_pos.y.ToString() + ")";

                color_index = Random.Range(0, SizeManager.colorNum);
            }
        }
    }
Esempio n. 8
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); // 이동할 위치의 블록 이동을 시작
    }
    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); // 元のブロックの移動を開始
    }
Esempio n. 10
0
    // 블록을 만들어 내고 가로 9칸, 세로 9칸에 배치한다.
    public void initialSetUp()
    {
        this.blocks = new BlockControl[Block.BLOCK_NUM_X, Block.BLOCK_NUM_Y]; // 그리드의 크기를 9×9로 한다.
        int color_index = 0;                                                  // 블록의 색 번호.

        Block.COLOR color = Block.COLOR.FIRST;

        for (int y = 0; y < Block.BLOCK_NUM_Y; y++)
        {     // 처음~마지막행
            for (int x = 0; x < Block.BLOCK_NUM_X; x++)
            { // 왼쪽~오른쪽
              // BlockPrefab의 인스턴스를 씬에 만든다.
                GameObject   game_object = Instantiate(this.BlockPrefab) as GameObject;
                BlockControl block       = game_object.GetComponent <BlockControl>(); // 블록의 BlockControl 클래스를 가져온다.
                this.blocks[x, y] = block;                                            // 블록을 그리드에 저장한다.
                block.i_pos.x     = x;                                                // 블록의 위치 정보(그리드 좌표)를 설정한다.
                block.i_pos.y     = y;
                block.block_root  = this;                                             // 각 BlockControl이 연계할 GameRoot는 자신이라고 설정한다.
                Vector3 position = BlockRoot.calcBlockPosition(block.i_pos);          // 그리드 좌표를 실제 위치(씬의 좌표)로 변환
                block.transform.position = position;                                  // 씬의 블록 위치를 이동한다.
                block.setColor((Block.COLOR)color_index);                             // 블록의 색을 변경한다.
                                                                                      // 블록의 이름을 설정(후술)한다. 나중에 블록 정보 확인때 필요.
                                                                                      // block.setColor((Block.COLOR)color_index); // 주석처리혹은삭제한다.
                // 현재출현확률을바탕으로색을결정한다.
                color = this.selectBlockColor();
                block.setColor(color);

                block.name = "block(" + block.i_pos.x.ToString() + "," + block.i_pos.y.ToString() + ")";
                // 전체 색 중에서 임의로 하나의 색을 선택한다.
                color_index = Random.Range(0, (int)Block.COLOR.NORMAL_COLOR_NUM);
            }
        }
    }
Esempio n. 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.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);
    }
Esempio n. 12
0
 private void Start()
 {
     m_spriteMaskRenderer = GameManager.Instance.GetComponent <MaskCtrl>().m_maskObj.GetComponent <SpriteRenderer>();
     if (m_hasRoot)
     {
         m_root = GetComponentInParent <BlockRoot>();
     }
 }
Esempio n. 13
0
    // Start is called before the first frame update
    void Start()
    {
        // BlockRoot스크립트 가져오기.
        this.block_root    = this.gameObject.GetComponent <BlockRoot>();
        this.score_counter = this.gameObject.GetComponent <ScoreCounter>();

        // BlockRoot스크립트의 initialSetUp()을 호출한다.
        this.block_root.InitialSetUp();
    }
Esempio n. 14
0
 void Start()
 {
     // BlockRoot 스크립트를 가져온다.
     this.block_root = this.gameObject.GetComponent <BlockRoot>();
     // BlockRoot 스크립트의 initialSetUp()을 호출한다.
     this.block_root.create();
     this.block_root.initialSetUp();
     this.score_counter     = this.gameObject.GetComponent <ScoreCounter>(); // ScoreCounter가져오기
     this.next_step         = STEP.PLAY;                                     // 다음상태를'플레이중'으로.
     this.guistyle.fontSize = 24;                                            //
 }
Esempio n. 15
0
    void Start()
    {
        // BlockRoot스크립트 가져오기.
        this.block_root = this.gameObject.GetComponent<BlockRoot>();
        // BlockRoot스크립트의 initialSetUp()을 호출한다.
        this.block_root.initialSetUp();

        // ScoreCounter 가져오기
        this.score_counter = this.gameObject.GetComponent<ScoreCounter>();
        this.next_step = STEP.PLAY; // 다음 상태를 '플레이 중'으로.
        this.guistyle.fontSize = 24; // 폰트  크기를 24로.
    }
Esempio n. 16
0
    void Start()
    {
        // BlockRootスクリプトを取得.
        this.block_root = this.gameObject.GetComponent<BlockRoot>();
        // BlockRootスクリプトのinitialSetUp()を呼び出す.
        this.block_root.initialSetUp();

        // ScoreCounterを取得.
        this.score_counter = this.gameObject.GetComponent<ScoreCounter>();
        this.next_step = STEP.PLAY; // 次の状態を「プレイ中」に.
        this.guistyle.fontSize = 24; // フォントのサイズを24に.
    }
Esempio n. 17
0
    public GUIStyle guistyle;             // フォントスタイル

    void Start()
    {
        // BlockRootスクリプトを取得
        this.block_root = this.gameObject.GetComponent <BlockRoot>();
        this.block_root.create();
        // BlockRootスクリプトのinitialSetUp()を呼び出す
        this.block_root.initialSetUp();

        // ScoreCounterを取得
        this.score_counter     = this.gameObject.GetComponent <ScoreCounter>();
        this.next_step         = STEP.PLAY; // 次の状態を「プレイ中」に
        this.guistyle.fontSize = 24;        // フォントのサイズを24に
    }
Esempio n. 18
0
    void Start()
    {
        // BlockRoot 스크립트를 가져온다.
        this.block_root = this.gameObject.GetComponent <BlockRoot>();
        this.block_root.create(); // create() 메서드에서 초기 설정
        // BlockRoot 스크립트의 initialSetUp()을 호출한다.
        this.block_root.initialSetUp(1);

        // ScoreCounter 가져오기
        this.score_counter             = this.gameObject.GetComponent <ScoreCounter>();
        this.next_step                 = STEP.PLAY; // 다음 상태를 '플레이 중'으로.
        this.guistyle.fontSize         = 24;        // 폰트 크기를 24로.
        this.guistyle.normal.textColor = Color.white;
    }
Esempio n. 19
0
    // 초기 배치.
    public void             initialSetUp()
    {
        // 블록 생성, 배치.

        this.blocks = new BlockControl[Block.BLOCK_NUM_X, Block.BLOCK_NUM_Y];

        Block.COLOR color = Block.COLOR.FIRST;

        for (int y = 0; y < Block.BLOCK_NUM_Y; y++)
        {
            for (int x = 0; x < Block.BLOCK_NUM_X; x++)
            {
                GameObject game_object = Instantiate(this.blockPrefab) as GameObject;

                BlockControl block = game_object.GetComponent <BlockControl>();

                this.blocks[x, y] = block;

                block.i_pos.x          = x;
                block.i_pos.y          = y;
                block.block_root       = this;
                block.leave_block_root = this.leave_block_root;

                //

                Vector3 position = BlockRoot.calcBlockPosition(block.i_pos);

                block.transform.position = position;

                color = this.selectBlockColor();
                block.setColor(color);

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

        //

        this.block_islands = new int[Block.BLOCK_NUM_X, Block.BLOCK_NUM_Y];

        for (int y = 0; y < Block.BLOCK_NUM_Y; y++)
        {
            for (int x = 0; x < Block.BLOCK_NUM_X; x++)
            {
                this.block_islands[x, y] = -1;
            }
        }
    }
Esempio n. 20
0
    private Animation rocket_motion;                    // (rocket)motion--.


    // ================================================================ //
    // MonoBehaviour으로부터 상속.

    void    Start()
    {
        this.block_root = this.gameObject.GetComponent <BlockRoot>();
        this.block_root.create();
        this.block_root.initialSetUp();

        this.score_counter = this.gameObject.GetComponent <ScoreCounter>();

        this.next_step = STEP.PLAY;

        //this.score_disp = GameObject.FindGameObjectWithTag("Score Disp").GetComponent<ScoreDisp>();

        //this.sound_control = GameObject.Find("SoundRoot").GetComponent<SoundControl>();

        this.rocket_motion = GameObject.Find("rocket_model").gameObject.GetComponentInChildren <Animation>();                   //motion
    }
Esempio n. 21
0
    // 블록을 만들어 내고, 가로 아홉 칸 세로 아홉 칸으로 배치.
    public void initialSetUp()
    {
        // 크기는 9×9로 한다.
        this.blocks =
            new BlockControl[Block.BLOCK_NUM_X, Block.BLOCK_NUM_Y];
        // 블록의 색 번호.
        int color_index = 0;

        Block.COLOR color = Block.COLOR.FIRST;


        for (int y = 0; y < Block.BLOCK_NUM_Y; y++)
        {     // 처음행부터 시작행부터 마지막행까지.
            for (int x = 0; x < Block.BLOCK_NUM_X; x++)
            { // 왼쪽 끝에서부터 오른쪽 끝까지.
             // BlockPrefab의 인스턴스를 씬 위에 만든다.
                GameObject game_object =
                    Instantiate(this.BlockPrefab) as GameObject;
                // 위에서 만든 블록의 BlockControl 클래스를 가져온다.
                BlockControl block = game_object.GetComponent <BlockControl>();
                // 블록을 칸에 넣는다.
                this.blocks[x, y] = block;
                // 블록의 위치 정보(그리드 좌표)를 설정.
                block.i_pos.x = x;
                block.i_pos.y = y;
                // 각 BlockControl이 연계하는 GameRoot는 자신이라고 설정.
                block.block_root = this;
                // 그리드 좌표를 실제 위치(씬 좌표)로 변환.
                Vector3 position = BlockRoot.calcBlockPosition(block.i_pos);
                // 씬 상의 블록 위치를 이동.
                block.transform.position = position;

                // 블록의 색을 변경.
                // block.setColor((Block.COLOR)color_index);
                // 지금의 출현 확률을 바탕으로 색을 결정한다.
                color = this.selectBlockColor();
                block.setColor(color);

                // 블록의 이름을 설정(후술).
                block.name = "block(" + block.i_pos.x.ToString() +
                             "," + block.i_pos.y.ToString() + ")";
                // 모든 종류의 색 중에서 임의로 한 색을 선택.
                color_index =
                    Random.Range(0, (int)Block.COLOR.NORMAL_COLOR_NUM);
            }
        }
    }
    // ブロックを作り出して、横9ます、縦9マスに配置
    public void initialSetUp()
    {
        // マス目のサイズを9×9にする
        this.blocks = new BlockControl[Block.BLOCK_NUM_X, Block.BLOCK_NUM_Y];
        // ブロックの色番号
        int color_index = 0;

        Block.COLOR color = Block.COLOR.FIRST;

        for (int y = 0; y < Block.BLOCK_NUM_Y; y++)     // 先頭行から最終行まで
        {
            for (int x = 0; x < Block.BLOCK_NUM_X; x++) // 左端から右端まで
            {
                // BlockPrefabのインスタンスをシーン上に作る
                GameObject game_object = Instantiate(this.BlockPrefab) as GameObject;
                // 上で作ったブロックのBlockControlクラスを取得
                BlockControl block = game_object.GetComponent <BlockControl>();
                // ブロックをマス目に格納
                this.blocks[x, y] = block;

                // ブロックの位置情報(グリッド座標)を設定
                block.i_pos.x = x;
                block.i_pos.y = y;
                // 各BlockControlが連携するGameRootは自分だと設定
                block.block_root = this;

                // グリッド座標を実際の位置(シーン上の座標)に変換
                Vector3 position = BlockRoot.calcBlockPosition(block.i_pos);
                // シーン上のブロックの位置を移動
                block.transform.position = position;

                // 今の出現確率に基づいて色を決める
                color = this.selectBlockColor();
                block.setColor(color);
                // ブロックの名前を設定(後述)
                block.name = "block(" + block.i_pos.x.ToString() + "," + block.i_pos.y.ToString() + ")";

                // 全種類の色の中から、ランダムに1色を選択
                color_index = Random.Range(0, (int)Block.COLOR.NORMAL_COLOR_NUM);
            }
        }
    }
Esempio n. 23
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);
    }
Esempio n. 24
0
    // 블록을 만들어 내고, 가로9칸 세로9칸에 배치.
    public void initialSetUp()
    {
        // 그리드의 크기를 9×9로 한다.
        this.blocks =
            new BlockControl [Block.BLOCK_NUM_X, Block.BLOCK_NUM_Y];
        // 블록의 색 번호.
        int color_index = 0;

        for (int y = 0; y < Block.BLOCK_NUM_Y; y++)          // 처음부터 마지막행까지.
        {
            for (int x = 0; x < Block.BLOCK_NUM_X; x++)      // 왼쪽부터 오른쪽까지.
            // BlockPrefab의 인스턴스를 씬 상에 만든다.
            {
                GameObject game_object =
                    Instantiate(this.BlockPrefab) as GameObject;
                // 위에서 만든 블록의 BlockControl 클래스를 가져온다.
                BlockControl block = game_object.GetComponent <BlockControl>();
                // 블록을 그리드에 저장.
                this.blocks[x, y] = block;
                // 블록의 위치 정보(그리도 좌표)를 설정.
                block.i_pos.x = x;
                block.i_pos.y = y;
                // 각 BlockControl이 연계할 GameRoot는 자신이라고 설정.
                block.block_root = this;
                // 그리도 좌표를 실제 위치(씬 상의 좌표)로 변환.
                Vector3 position = BlockRoot.calcBlockPosition(block.i_pos);
                // 씬 상의 블록 위치를 이동.
                block.transform.position = position;
                // 블록의 색을 변경.
                block.setColor((Block.COLOR)color_index);
                // 블록의 이름을 설정(후술).
                block.name = "block(" + block.i_pos.x.ToString() +
                             "," + block.i_pos.y.ToString() + ")";
                // 전체 색 중에서 임의로 하나의 색을 선택.
                color_index =
                    Random.Range(0, (int)Block.COLOR.NORMAL_COLOR_NUM);
            }
        }
    }
Esempio n. 25
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;
    }
Esempio n. 26
0
 // Use this for initialization
 void Start()
 {
     this.block_root = this.gameObject.GetComponent <BlockRoot>();
     this.block_root.initialSetUp();
 }
Esempio n. 27
0
    public void initialSetUp(int _i) //임시
    {
        int _pattern = 0;
        int _Num     = 0;

        // 그리드의 크기를 9×9로 한다.
        this.blocks =
            new BlockControl[Block.BLOCK_NUM_X, Block.BLOCK_NUM_Y];

        for (int y = 0; y < Block.BLOCK_NUM_Y; y++)
        {     // 처음~마지막행
            for (int x = 0; x < Block.BLOCK_NUM_X; x++)
            { // 왼쪽~오른쪽
              // BlockPrefab의 인스턴스를 씬에 만든다.
                GameObject game_object =
                    Instantiate(this.BlockPrefab) as GameObject;
                // 위에서 만든 블록의 BlockControl 클래스를 가져온다.
                BlockControl block =
                    game_object.GetComponent <BlockControl>();
                // 블록을 그리드에 저장한다.
                this.blocks[x, y] = block;
                // 블록의 위치 정보(그리드 좌표)를 설정한다.
                block.i_pos.x = x;
                block.i_pos.y = y;
                // 각 BlockControl이 연계할 GameRoot는 자신이라고 설정한다.
                block.block_root = this;
                // 그리드 좌표를 실제 위치(씬의 좌표)로 변환한다.
                Vector3 position = BlockRoot.calcBlockPosition(block.i_pos);
                // 씬의 블록 위치를 이동한다.
                block.transform.position = position;
                // 블록의 색을 변경한다.
                //block.setColor((Block.COLOR)color_index);

                // 현재 출현 확률을 바탕으로 색을 결정한다.
                //////////////////
                //color = this.selectBlockColor();
                //block.setColor(color);
                //////////////////

                // 블록의 이름을 설정(후술)한다. 나중에 블록 정보 확인때 필요.
                block.name = "block(" + block.i_pos.x.ToString() +
                             "," + block.i_pos.y.ToString() + ")";

                // 전체 색 중에서 임의로 하나의 색을 선택한다.
                /////////////////////////////
                //color_index =
                //Random.Range(0, (int)Block.COLOR.NORMAL_COLOR_NUM);
                /////////////////////////////

                //전체 패턴중에서 하나를 임의로 선택
                _pattern = Random.Range(0, 4);
                SpriteRenderer Pattern = BlockPrefab.GetComponentInChildren <SpriteRenderer>();

                if (_pattern >= 0 && _pattern < 1)
                {
                    Pattern.sprite = Spade;
                }
                else if (_pattern >= 1 && _pattern < 2)
                {
                    Pattern.sprite = Diamond;
                }
                else if (_pattern >= 2 && _pattern < 3)
                {
                    Pattern.sprite = Heart;
                }
                else if (_pattern >= 3 && _pattern < 4)
                {
                    Pattern.sprite = Clover;
                }

                _Num = Random.Range(0, 14);
                TextMesh Num = BlockPrefab.GetComponentInChildren <TextMesh>();
                if (_Num >= 0 && _pattern < 1)
                {
                    Num.text = "A";
                }
                if (_Num >= 1 && _pattern < 2)
                {
                    Num.text = "2";
                }
                if (_Num >= 2 && _pattern < 3)
                {
                    Num.text = "3";
                }
                if (_Num >= 3 && _pattern < 4)
                {
                    Num.text = "4";
                }
                if (_Num >= 4 && _pattern < 5)
                {
                    Num.text = "5";
                }
                if (_Num >= 5 && _pattern < 6)
                {
                    Num.text = "6";
                }
                if (_Num >= 6 && _pattern < 7)
                {
                    Num.text = "7";
                }
                if (_Num >= 7 && _pattern < 8)
                {
                    Num.text = "8";
                }
                if (_Num >= 8 && _pattern < 9)
                {
                    Num.text = "9";
                }
                if (_Num >= 10 && _pattern < 11)
                {
                    Num.text = "10";
                }
                if (_Num >= 11 && _pattern < 12)
                {
                    Num.text = "J";
                }
                if (_Num >= 12 && _pattern < 13)
                {
                    Num.text = "Q";
                }
                if (_Num >= 13 && _pattern < 14)
                {
                    Num.text = "K";
                }
            }
        }
    }
Esempio n. 28
0
    // Update is called once per frame
    void Update()
    {
        Vector2 mouse_position;

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


        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)
                {
                    // 슬라이드 중인 블록이 소멸되면 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 * 0.7f;
                break;

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

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

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

            case Block.STEP.respawn:
                // 색을 랜덤하게 선택하여 블록을 선택한 색으로 설정.
                int color_index = Random.Range(0, SizeManager.colorNum);
                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);
            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 * 1.5f;
            // 세로 방향 위치를 계산.
            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)
        {
            Renderer rd     = this.GetComponent <Renderer>();
            Color    color0 = Color.Lerp(rd.material.color, Color.white, 0.5f);
            Color    color1 = Color.Lerp(rd.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;

                rd.material = this.transparent_material;
            }
            // vanish_timer가 줄어들수록 1에 가까워진다
            float rate = 1.0f - this.vanish_timer / Block.VANISH_TIME;
            //서서히 색을 바꾼다
            rd.material.color = Color.Lerp(color0, color1, rate);
        }
    }
Esempio n. 29
0
    // 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:
                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;
        }

        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(GetComponent <Renderer>().material.color, Color.white, 0.5f);
            Color color1 = Color.Lerp(GetComponent <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;
                GetComponent <Renderer>().material = this.transparent_material;
            }
            float rate = 1.0f - this.vanish_timer / Block.VANISH_TIME;
            GetComponent <Renderer>().material.color = Color.Lerp(color0, color1, rate);
        }
    }
Esempio n. 30
0
    // ================================================================ //
    // MonoBehaviour からの継承.
    void Start()
    {
        this.block_root = this.gameObject.GetComponent<BlockRoot>();
        this.block_root.create();
        this.block_root.initialSetUp();

        this.score_counter = this.gameObject.GetComponent<ScoreCounter>();

        this.next_step = STEP.PLAY;

        this.score_disp = GameObject.FindGameObjectWithTag("Score Disp").GetComponent<ScoreDisp>();

        this.sound_control = GameObject.Find("SoundRoot").GetComponent<SoundControl>();

        this.rocket_motion = GameObject.Find("rocket_model").gameObject.GetComponentInChildren<Animation>();		//motion
    }
Esempio n. 31
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);

        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)
                {
                    // スライド中にブロックが消滅したら、VACANT(消える)状態に移行
                    if (this.vanish_timer == 0.0f)
                    {
                        this.next_step = Block.STEP.VACANT;
                    }
                    else     // vanish_timerが0でないなら、IDLE(待機)状態に移行
                    {
                        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)
        {
            // 現在のレベルの燃焼時間に設定
            float vanish_time = this.block_root.level_control.getVanishTime();
            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);
        }
    }
Esempio n. 32
0
	void Start() {
		// BlockRoot 스크립트를 가져온다.
		this.block_root = this.gameObject.GetComponent<BlockRoot>();
		// BlockRoot 스크립트의 initialSetUp()을 호출한다.
		this.block_root.initialSetUp();
	}
Esempio n. 33
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;
        }
    }
Esempio n. 34
0
    void Update()
    {
        Vector3 mouse_position;                 // 마우스 위치.

        this.block_root.unprojectMousePosition( // 마우스 위치를 가져온다.
            out mouse_position, Input.mousePosition);
        // 가져온 마우스 위치를 하나의 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);
        }
    }
Esempio n. 35
0
 // Use this for initialization
 void Start()
 {
     this.block_root = this.gameObject.GetComponent<BlockRoot> ();
     this.block_root.initialSetUp ();
 }
Esempio n. 36
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);

        // '다음 블록' 상태가 '정보 없음' 이외인 동안.
        // ='다음 블록' 상태가 변경된 경우.

        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)
                {
                    // 슬라이드 중인 블록이 소멸되면 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);

                int color_index = Random.Range(
                    0, (int)Block.CARD.NORMAL_CARD_NUM);
                this.setColor((Block.CARD)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)
        {
            // 현재 레벨의 연소시간으로 설정.
            float vanish_time = this.block_root.level_control.getVanishTime();

            // 현재 색과 흰색의 중간 색.
            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);
        }

        countBlockDestroy();
    }