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); }
public void beginSlide(Vector3 offset) { this.position_offset_initial = offset; this.position_offset = this.position_offset_initial; // 状態をSLIDEに変更 this.next_step = Block.STEP.SLIDE; }
public void beginFall(BlockControl start) { this.next_step = Block.STEP.FALL; // 지정된 블록에서 좌표를 계산해 낸다. this.position_offset.y = (float)(start.i_pos.y - this.i_pos.y) * Block.COLLISION_SIZE; }
public void beginSlide(Vector3 offset) { this.position_offset_initial = offset; this.position_offset = this.position_offset_initial; this.next_step = Block.STEP.slide; }
// ================================================================ // // 블록을 떨어뜨린다. 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); }
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); }
public void beginRespawn(int start_i_pos_y) { this.position_offset.y = (float)(start_i_pos_y - this.i_pos.y) * Block.COLLISION_SIZE; this.next_step = Block.STEP.FALL; int color_index = Random.Range((int)Block.COLOR.FIRST, (int)Block.COLOR.LAST + 1); this.setColor((Block.COLOR)color_index); }
public void beginRespawn(int start_ipos_y) { // 지정 위치까지 y좌표를 이동. this.position_offset.y = (float)(start_ipos_y - this.i_pos.y) * Block.COLLISION_SIZE; this.next_step = Block.STEP.fall; int color_index = Random.Range(0, SizeManager.colorNum); this.SetColor((Block.COLOR)color_index); }
public void beginRespawn(int start_ipos_y) { // 指定位置までy座標を移動 this.position_offset.y = (float)(start_ipos_y - this.i_pos.y) * Block.COLLISION_SIZE; this.next_step = Block.STEP.FALL; // 現在のレベルの出現確率に基づいて、ブロックの色を決める Block.COLOR color = this.block_root.selectBlockColor(); this.setColor(color); }
void Start() { this.setColor(this.color); this.next_step = Block.STEP.IDLE; // 다음 블록을 대기중으로. this.counting.heart = 0; this.counting.diamond = 0; this.counting.spade = 0; this.counting.clober = 0; }
public void beginRespawn(int start_ipos_y) { // 색이바꿔낙하상태로하고지정한위치에재배치한다. this.position_offset.y = (float)(start_ipos_y - this.i_pos.y) * Block.COLLISION_SIZE; // 지정위치까지y좌표를이동. this.next_step = Block.STEP.FALL; // 주석처리혹은삭제 // int color_index= Random.Range((int)Block.COLOR.FIRST, (int)Block.COLOR.LAST+ 1); // this.setColor((Block.COLOR)color_index); // 현재레벨의출현확률을바탕으로블록의색을결정한다. Block.COLOR color = this.block_root.selectBlockColor(); this.setColor(color); //this.GetComponent<MeshRenderer>().material.mainTexture = Resources.Load("Sword_Square") as Texture; }
// 색이 바꿔 낙하 상태로 하고 지정한 위치에 재배치한다. public void beginRespawn(int start_ipos_y) { // 지정 위치까지 y좌표를 이동. this.position_offset.y = (float)(start_ipos_y - this.i_pos.y) * Block.COLLISION_SIZE; this.next_step = Block.STEP.FALL; //int color_index = //Random.Range((int)Block.COLOR.FIRST, (int)Block.COLOR.LAST + 1); //this.setColor((Block.COLOR)color_index); // 현재 레벨의 출현 확률을 바탕으로 블록의 색을 결정한다. Block.CARD color = this.block_root.selectBlockColor(); this.setColor(color); }
// 사라진 후에 위에서 내려오는 처리 시작. public void beginRespawn(int start_ipos_y) { this.position_offset.y = (float)(start_ipos_y - this.i_pos.y) * Block.COLLISION_SIZE; this.next_step = Block.STEP.FALL; Block.COLOR color = this.block_root.selectBlockColor(); this.setColor(color); for (int i = 0; i < this.connected_block.Length; i++) { this.connected_block[i].clear(); } }
// ================================================================ // // MonoBehaviour에서 상속. void Awake() { // 각 색 블록 모델을 찾아 둔다.. this.models = new GameObject[(int)Block.COLOR.NORMAL_COLOR_NUM]; this.models_root = this.transform.FindChild("models").gameObject; this.models[(int)Block.COLOR.PINK] = this.models_root.transform.FindChild("block_pink").gameObject; this.models[(int)Block.COLOR.BLUE] = this.models_root.transform.FindChild("block_blue").gameObject; this.models[(int)Block.COLOR.GREEN] = this.models_root.transform.FindChild("block_green").gameObject; this.models[(int)Block.COLOR.ORANGE] = this.models_root.transform.FindChild("block_orange").gameObject; this.models[(int)Block.COLOR.YELLOW] = this.models_root.transform.FindChild("block_yellow").gameObject; this.models[(int)Block.COLOR.MAGENTA] = this.models_root.transform.FindChild("block_purple").gameObject; this.models[(int)Block.COLOR.NECO] = this.models_root.transform.FindChild("neco").gameObject; // 비표시로 하면 가져올 수 없게 되니 주의. this.neko_motion = this.models[(int)Block.COLOR.NECO].GetComponentInChildren <Animation>(); // 일단 전부 비표시. for (int i = 0; i < this.models.Length; i++) { this.models[i].SetActive(false); } // 이 색의 블록만 표시한다. this.setColor(this.color); if (this.next_step == Block.STEP.NONE) { this.next_step = Block.STEP.IDLE; } this.connected_block = new Block.iPosition[(int)Block.DIR4.NUM]; for (int i = 0; i < this.connected_block.Length; i++) { this.connected_block[i].clear(); } // }
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); } }
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; }
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; }
public void beginGrab() { this.next_step = Block.STEP.GRABBED; }
void Start() { this.setColor(this.color); // 색을 칠한다. this.next_step = Block.STEP.IDLE; // 다음 블록을 대기 중으로. }
public void beginRespawn(int start_ipos_y) { // 지정 위치까지 y좌표를 이동. this.position_offset.y = (float)(start_ipos_y - this.i_pos.y) * Block.COLLISION_SIZE; this.next_step = Block.STEP.FALL; int color_index = Random.Range((int)Block.COLOR.FIRST, (int)Block.COLOR.LAST + 1); this.setColor((Block.COLOR)color_index); }
public float step_timer = 0.0f; // 블록이 교체된 때의 이동시간 등. void Start() { this.setColor(this.color); // 색칠을 한다. this.next_step = Block.STEP.IDLE; // 다음 블록을 대기중으로. }
// 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); } }
// Use this for initialization void Start() { this.setColor(this.color); this.next_step=Block.STEP.IDLE; }
public void beginRespawn(int start_ipos_y) { // 지정 위치까지 y좌표를 이동. this.position_offset.y = (float)(start_ipos_y - this.i_pos.y) * Block.COLLISION_SIZE; this.next_step = Block.STEP.FALL; // int color_index = Random.Range( // (int)Block.COLOR.FIRST, (int)Block.COLOR.LAST + 1); // this.setColor((Block.COLOR)color_index); // 현재 레벨의 출현 확률을 바탕으로 블록의 색을 결정한다. Block.COLOR color = this.block_root.selectBlockColor(); this.setColor(color); }
// 잡는 동작 끝. public void endGrab() { this.block_root.hideArrow(); this.next_step = Block.STEP.IDLE; }
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; } }
// Use this for initialization void Start() { this.setColor(this.color); this.next_step = Block.STEP.IDLE; }
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); } }
public void beginRespawn(int start_ipos_y) { // 指定位置までy座標を移動. this.position_offset.y = (float)(start_ipos_y - this.i_pos.y) * Block.COLLISION_SIZE; this.next_step = Block.STEP.FALL; // int color_index = Random.Range( // (int)Block.COLOR.FIRST, (int)Block.COLOR.LAST + 1); // this.setColor((Block.COLOR)color_index); // 現在のレベルの出現確率に基づいて、ブロックの色を決める. Block.COLOR color = this.block_root.selectBlockColor(); this.setColor(color); }
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; }
// 잡는 동작 시작. public void beginGrab() { this.next_step = Block.STEP.GRABBED; }
public void endGrab() { this.next_step = Block.STEP.IDLE; }
// 슬라이드 동작 시작. public void beginSlide(Vector3 offset) { this.position_offset_initial = offset; this.position_offset = this.position_offset_initial; this.next_step = Block.STEP.SLIDE; }
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); } }
// ================================================================ // // MonoBehaviour에서 상속. void Awake() { // 각 색 블록 모델을 찾아 둔다.. this.models = new GameObject[(int)Block.COLOR.NORMAL_COLOR_NUM]; this.models_root = this.transform.FindChild("models").gameObject; this.models[(int)Block.COLOR.PINK] = this.models_root.transform.FindChild("block_pink").gameObject; this.models[(int)Block.COLOR.BLUE] = this.models_root.transform.FindChild("block_blue").gameObject; this.models[(int)Block.COLOR.GREEN] = this.models_root.transform.FindChild("block_green").gameObject; this.models[(int)Block.COLOR.ORANGE] = this.models_root.transform.FindChild("block_orange").gameObject; this.models[(int)Block.COLOR.YELLOW] = this.models_root.transform.FindChild("block_yellow").gameObject; this.models[(int)Block.COLOR.MAGENTA] = this.models_root.transform.FindChild("block_purple").gameObject; this.models[(int)Block.COLOR.NECO] = this.models_root.transform.FindChild("neco").gameObject; // 비표시로 하면 가져올 수 없게 되니 주의. this.neko_motion = this.models[(int)Block.COLOR.NECO].GetComponentInChildren<Animation>(); // 일단 전부 비표시. for(int i = 0;i < this.models.Length;i++) { this.models[i].SetActive(false); } // 이 색의 블록만 표시한다. this.setColor(this.color); if(this.next_step == Block.STEP.NONE) { this.next_step = Block.STEP.IDLE; } this.connected_block = new Block.iPosition[(int)Block.DIR4.NUM]; for(int i = 0;i < this.connected_block.Length;i++) { this.connected_block[i].clear(); } // }
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; } }
public void beginFall(BlockControl start) { this.next_step = Block.STEP.FALL; // 指定されたブロックから座標を割り出す this.position_offset.y = (float)(start.i_pos.y - this.i_pos.y) * Block.COLLISION_SIZE; }
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); } }
void Start() { this.setColor(this.color); // 色塗りを行う this.next_step = Block.STEP.IDLE; // 次のブロックを待機中に }
public Material transparent_material; // 반투명 머티리얼. void Start() { this.setColor(this.pattern); this.setNumber(this.num); this.next_step = Block.STEP.IDLE; // 다음 블록을 대기중으로. }
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(); }
// 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); } }
// 낙하시작(아래에 있는 블록이 사라졌을 때). public void beginFall(BlockControl start) { this.next_step = Block.STEP.FALL; this.position_offset.y = (float)(start.i_pos.y - this.i_pos.y)*Block.COLLISION_SIZE; }
/// //////////////////////////////////////////////////////////////////////////// public void beginGrab() // 잡혔을 때 호출한다. { this.next_step = Block.STEP.GRABBED; }
// 사라진 후에 위에서 내려오는 처리 시작. public void beginRespawn(int start_ipos_y) { this.position_offset.y = (float)(start_ipos_y - this.i_pos.y)*Block.COLLISION_SIZE; this.next_step = Block.STEP.FALL; Block.COLOR color = this.block_root.selectBlockColor(); this.setColor(color); for(int i = 0;i < this.connected_block.Length;i++) { this.connected_block[i].clear(); } }
public void endGrab() // 놓았을 때 호출한다. { this.next_step = Block.STEP.IDLE; }
void Start() { this.setColor(this.color); // 色塗りを行う. this.next_step = Block.STEP.IDLE; // 次のブロックを待機中に. }
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; } }
// ================================================================ // // MonoBehaviour からの継承. void Awake() { // 各色のブロックのモデルを探しておく. this.models = new GameObject[(int)Block.COLOR.NORMAL_COLOR_NUM]; this.models_root = this.transform.FindChild("models").gameObject; this.models[(int)Block.COLOR.PINK] = this.models_root.transform.FindChild("block_pink").gameObject; this.models[(int)Block.COLOR.BLUE] = this.models_root.transform.FindChild("block_blue").gameObject; this.models[(int)Block.COLOR.GREEN] = this.models_root.transform.FindChild("block_green").gameObject; this.models[(int)Block.COLOR.ORANGE] = this.models_root.transform.FindChild("block_orange").gameObject; this.models[(int)Block.COLOR.YELLOW] = this.models_root.transform.FindChild("block_yellow").gameObject; this.models[(int)Block.COLOR.MAGENTA] = this.models_root.transform.FindChild("block_purple").gameObject; this.models[(int)Block.COLOR.NECO] = this.models_root.transform.FindChild("neco").gameObject; // 非表示にするととれなくなるので注意. this.neko_motion = this.models[(int)Block.COLOR.NECO].GetComponentInChildren<Animation>(); // いったん全部非表示. for(int i = 0;i < this.models.Length;i++) { this.models[i].SetActive(false); } // この色のブロックだけ表示する. this.setColor(this.color); if(this.next_step == Block.STEP.NONE) { this.next_step = Block.STEP.IDLE; } this.connected_block = new Block.iPosition[(int)Block.DIR4.NUM]; for(int i = 0;i < this.connected_block.Length;i++) { this.connected_block[i].clear(); } // }