void Start() { // Block.materials = this.block_materials; this.stack_control = new StackBlockControl(); this.stack_control.StackBlockPrefab = this.StackBlockPrefab; this.stack_control.scene_control = this; this.stack_control.create(); this.vanish_fx_control = GameObject.FindGameObjectWithTag("VanishEffectControl").GetComponent <VanishEffectControl>(); // this.player_control = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerControl>(); this.player_control.scene_control = this; this.bg_control = GameObject.FindGameObjectWithTag("BG").GetComponent <BGControl>(); this.goal_scene = new GoalSceneControl(); this.goal_scene.scene_control = this; this.goal_scene.create(); // this.audios = this.GetComponents <AudioSource>(); // this.slider_value = Mathf.InverseLerp(RotateAction.ROTATE_TIME_SWAP_MIN, RotateAction.ROTATE_TIME_SWAP_MAX, RotateAction.rotate_time_swap); this.height_level = 0; this.bg_control.setHeightRateDirect((float)this.height_level / (float)MAX_HEIGHT_LEVEL); }
public void execute() { StackBlockControl stack_control = this.scene_control.stack_control; PlayerControl player = this.scene_control.player_control; BGControl bg = this.scene_control.bg_control; this.step_timer_prev = this.step_timer; this.step_timer += Time.deltaTime; // -------------------------------------------------------- // // 次の状態に移るかどうかを、チェックする. switch (this.step) { case STEP.START: { this.next_step = STEP.WAIT_SWAP_END; } break; case STEP.WAIT_SWAP_END: { bool is_has_moving_block = false; foreach (StackBlock block in stack_control.blocks) { if (block.step != StackBlock.STEP.IDLE || block.next_step != StackBlock.STEP.NONE) { is_has_moving_block = true; break; } if (block.position_offset.y != 0.0f) { is_has_moving_block = true; break; } } if (!is_has_moving_block) { this.next_step = STEP.WAIT_SWAP_END_AFTER; } } break; case STEP.WAIT_SWAP_END_AFTER: { if (this.step_timer > 1.0f) { this.next_step = STEP.FALL; } } break; case STEP.FALL: { bool is_has_fall_block = false; for (int x = 0; x < StackBlockControl.BLOCK_NUM_X; x++) { StackBlock block = stack_control.blocks[x, StackBlockControl.GROUND_LINE - 1]; if (block.isNowFallAction()) { is_has_fall_block = true; break; } } if (!is_has_fall_block) { this.next_step = STEP.COLOR_CHANGE; } } break; case STEP.COLOR_CHANGE: { if (this.step_timer > 1.0f && player.lx == PLAYER_EATING_POSITION) { this.begin_wait_step(1.0f, STEP.MESSAGE); } } break; case STEP.WAIT: { if (this.step_timer > this.wait.duration) { this.next_step = this.wait.next_step; } } break; } // -------------------------------------------------------- // // 状態が遷移したときの初期化. if (this.next_step != STEP.NONE) { switch (this.next_step) { case STEP.START: { player.setControlable(false); } break; case STEP.FALL: { player.dropBlock(); bg.setHeightRateDirect(1.0f); stack_control.is_scroll_enable = false; stack_control.fall_request = 0; stack_control.blockFallRequest(); for (int x = 0; x < StackBlockControl.BLOCK_NUM_X; x++) { stack_control.blocks[x, StackBlockControl.GROUND_LINE - 1].beginColorChangeAction(Block.COLOR_TYPE.CYAN); } // this.pat_count = 0; } break; case STEP.COLOR_CHANGE: { this.color_change_count = 0; player.SetHeight(-1); } break; case STEP.MESSAGE: { this.message_color = Block.NORMAL_COLOR_FIRST; player.beginGoalAct(); scene_control.playSe(SceneControl.SE.CLEAR); } break; } this.step = this.next_step; this.next_step = STEP.NONE; this.step_timer_prev = -1.0f; this.step_timer = 0.0f; } // -------------------------------------------------------- // // 各状態での実行処理. switch (this.step) { case STEP.COLOR_CHANGE: { if (this.color_change_count < StackBlockControl.BLOCK_NUM_Y - StackBlockControl.GROUND_LINE) { float delay = 0.05f; if (Mathf.FloorToInt(this.step_timer_prev / delay) < Mathf.FloorToInt(this.step_timer / delay)) { int y = StackBlockControl.GROUND_LINE + this.color_change_count; for (int x = 0; x < StackBlockControl.BLOCK_NUM_X; x++) { stack_control.blocks[x, y].beginColorChangeAction(Block.COLOR_TYPE.CYAN); } this.color_change_count++; } } if (player.lx != PLAYER_EATING_POSITION) { float delay = 0.5f; if (this.step_timer > delay * 2.0f) { if (Mathf.FloorToInt(this.step_timer_prev / delay) < Mathf.FloorToInt(this.step_timer / delay)) { if (player.lx > PLAYER_EATING_POSITION) { player.SetLinedPosition(player.lx - 1); } else { player.SetLinedPosition(player.lx + 1); } } } } } break; case STEP.MESSAGE: { float duration = 2.0f; if (this.step_timer >= duration) { if (Mathf.FloorToInt(this.step_timer_prev / duration) < Mathf.FloorToInt(this.step_timer / duration)) { do { this.message_color = Block.getNextNormalColor(this.message_color); } while(this.message_color == Block.COLOR_TYPE.CYAN); this.apply_pattern_to_block(this.message[this.pat_count], this.message_color, Block.COLOR_TYPE.CYAN); this.pat_count = (this.pat_count + 1) % this.message.Length; } } } break; } // ---------------------------------------------------------------- // }