// 攻撃のコントロール. private void attack_control() { if(!this.is_playable) { return; } if(this.attack_timer > 0.0f) { // 攻撃判定発生中. this.attack_timer -= Time.deltaTime; // 攻撃判定終了チェック. if(this.attack_timer <= 0.0f) { // コライダー(攻撃の当たり判定)の当たり判定を無効にする. // attack_collider.SetPowered(false); } } else { this.attack_disable_timer -= Time.deltaTime; if(this.attack_disable_timer > 0.0f) { // まだ攻撃できない中. } else { this.attack_disable_timer = 0.0f; if(this.is_attack_input()) { // コライダー(攻撃の当たり判定)の当たり判定を有効にする. // attack_collider.SetPowered(true); this.attack_timer = PlayerControl.ATTACK_TIME; this.attack_disable_timer = PlayerControl.ATTACK_DISABLE_TIME; // 攻撃モーションを再生する. Animation animation = this.transform.GetComponentInChildren<Animation>(); // 同じモーションを初めから再生し直したいときは、一度 stop() しないとだめっぽい. //animation.Stop(); // 次に再生するモーションを選ぶ. // // 『おに』の吹き飛ぶ方向を決める時に『直前の攻撃モーション』を知りたいので、 // 再生後ではなく再生前にモーションの選択をする. // switch(this.attack_motion) { default: case ATTACK_MOTION.RIGHT: this.attack_motion = ATTACK_MOTION.LEFT; break; case ATTACK_MOTION.LEFT: this.attack_motion = ATTACK_MOTION.RIGHT; break; } switch(this.attack_motion) { default: case ATTACK_MOTION.RIGHT: animation.CrossFade("P_attack_R", 0.2f); break; case ATTACK_MOTION.LEFT: animation.CrossFade("P_attack_L", 0.2f); break; } // 攻撃モーションが終わったら、走りモーションに戻る. animation.CrossFadeQueued("P_run"); this.attack_voice_audio.PlayOneShot(this.AttackSound[this.attack_sound_index]); this.attack_sound_index = (this.attack_sound_index + 1)%this.AttackSound.Length; this.sword_audio.PlayOneShot(this.SwordSound); } } } }
private void AttackControl() { if (!this.isPlayable) { return; } if (this.attackTimer > 0.0f) { this.attackTimer -= Time.deltaTime; if (this.attackTimer <= 0.0f) { // コライダー(攻撃の当たり判定)の当たり判定を無効にする. // attack_collider.SetPowered(false); } } else { this.attack_disable_timer -= Time.deltaTime; if (this.attack_disable_timer > 0.0f) { // まだ攻撃できない中. } else { this.attack_disable_timer = 0.0f; if (this.is_attack_input()) { attack_collider.SetPowered(true); this.attackTimer = PlayerControl.ATTACK_TIME; this.attack_disable_timer = PlayerControl.ATTACK_DISABLE_TIME; switch (this.attack_motion) { default: case ATTACK_MOTION.RIGHT: this.attack_motion = ATTACK_MOTION.LEFT; break; case ATTACK_MOTION.LEFT: this.attack_motion = ATTACK_MOTION.RIGHT; break; } switch (this.attack_motion) { default: case ATTACK_MOTION.RIGHT: this.animator.SetTrigger("attack_r"); break; case ATTACK_MOTION.LEFT: this.animator.SetTrigger("attack_l"); break; } this.attack_voice_audio.PlayOneShot(this.AttackSound[this.attack_sound_index]); this.attack_sound_index = (this.attack_sound_index + 1) % this.AttackSound.Length; this.sword_audio.PlayOneShot(this.SwordSound); } } } }
// 攻击控制 private void attack_control() { if (!this.is_playable) { return; } if (this.attack_timer > 0.0f) { // 正在进行攻击判定 this.attack_timer -= Time.deltaTime; // 攻击判定结束检测 if (this.attack_timer <= 0.0f) { // 使碰撞器(攻击成功否)的碰撞判定无效 // attack_collider.SetPowered(false); } } else { this.attack_disable_timer -= Time.deltaTime; if (this.attack_disable_timer > 0.0f) { // 仍旧不可攻击 } else { this.attack_disable_timer = 0.0f; if (this.is_attack_input()) { // 使碰撞器(攻击成功与否)的攻击判定有效 // attack_collider.SetPowered(true); this.attack_timer = PlayerControl.ATTACK_TIME; this.attack_disable_timer = PlayerControl.ATTACK_DISABLE_TIME; // 播放攻击动作 // 选择下一个播放的动作 // // 因为要在决定“怪物”飞散的方向时知道“上一个攻击动作” // 应该在播放前而非在播放后选择动作 // switch (this.attack_motion) { default: case ATTACK_MOTION.RIGHT: this.attack_motion = ATTACK_MOTION.LEFT; break; case ATTACK_MOTION.LEFT: this.attack_motion = ATTACK_MOTION.RIGHT; break; } switch (this.attack_motion) { default: case ATTACK_MOTION.RIGHT: this.animator.SetTrigger("attack_r"); break; case ATTACK_MOTION.LEFT: this.animator.SetTrigger("attack_l"); break; } this.attack_voice_audio.PlayOneShot(this.AttackSound[this.attack_sound_index]); this.attack_sound_index = (this.attack_sound_index + 1) % this.AttackSound.Length; this.sword_audio.PlayOneShot(this.SwordSound); } } } }
// 攻撃のコントロール. private void attack_control() { if (!this.is_playable) { return; } if (this.attack_timer > 0.0f) { // 攻撃判定発生中. this.attack_timer -= Time.deltaTime; // 攻撃判定終了チェック. if (this.attack_timer <= 0.0f) { // コライダー(攻撃の当たり判定)の当たり判定を無効にする. // attack_collider.SetPowered(false); } } else { this.attack_disable_timer -= Time.deltaTime; if (this.attack_disable_timer > 0.0f) { // まだ攻撃できない中. } else { this.attack_disable_timer = 0.0f; if (this.is_attack_input()) { // コライダー(攻撃の当たり判定)の当たり判定を有効にする. // attack_collider.SetPowered(true); this.attack_timer = PlayerControl.ATTACK_TIME; this.attack_disable_timer = PlayerControl.ATTACK_DISABLE_TIME; // 攻撃モーションを再生する. Animation animation = this.transform.GetComponentInChildren <Animation>(); // 同じモーションを初めから再生し直したいときは、一度 stop() しないとだめっぽい. //animation.Stop(); // 次に再生するモーションを選ぶ. // // 『おに』の吹き飛ぶ方向を決める時に『直前の攻撃モーション』を知りたいので、 // 再生後ではなく再生前にモーションの選択をする. // switch (this.attack_motion) { default: case ATTACK_MOTION.RIGHT: this.attack_motion = ATTACK_MOTION.LEFT; break; case ATTACK_MOTION.LEFT: this.attack_motion = ATTACK_MOTION.RIGHT; break; } switch (this.attack_motion) { default: case ATTACK_MOTION.RIGHT: animation.CrossFade("P_attack_R", 0.2f); break; case ATTACK_MOTION.LEFT: animation.CrossFade("P_attack_L", 0.2f); break; } // 攻撃モーションが終わったら、走りモーションに戻る. animation.CrossFadeQueued("P_run"); this.attack_voice_audio.PlayOneShot(this.AttackSound[this.attack_sound_index]); this.attack_sound_index = (this.attack_sound_index + 1) % this.AttackSound.Length; this.sword_audio.PlayOneShot(this.SwordSound); } } } }
// 攻撃のコントロール. private void attack_control() { if (!this.is_playable) { return; } if (this.attack_timer > 0.0f) { // 攻撃判定発生中. this.attack_timer -= Time.deltaTime; // 攻撃判定終了チェック. if (this.attack_timer <= 0.0f) { // コライダー(攻撃の当たり判定)の当たり判定を無効にする. // attack_collider.SetPowered(false); } } else { this.attack_disable_timer -= Time.deltaTime; if (this.attack_disable_timer > 0.0f) { // まだ攻撃できない中. } else { this.attack_disable_timer = 0.0f; if (this.is_attack_input()) { // コライダー(攻撃の当たり判定)の当たり判定を有効にする. // attack_collider.SetPowered(true); this.attack_timer = PlayerControl.ATTACK_TIME; this.attack_disable_timer = PlayerControl.ATTACK_DISABLE_TIME; // 攻撃モーションを再生する. // 次に再生するモーションを選ぶ. // // 『おに』の吹き飛ぶ方向を決める時に『直前の攻撃モーション』を知りたいので、 // 再生後ではなく再生前にモーションの選択をする. // switch (this.attack_motion) { default: case ATTACK_MOTION.RIGHT: this.attack_motion = ATTACK_MOTION.LEFT; break; case ATTACK_MOTION.LEFT: this.attack_motion = ATTACK_MOTION.RIGHT; break; } switch (this.attack_motion) { default: case ATTACK_MOTION.RIGHT: this.animator.SetTrigger("attack_r"); break; case ATTACK_MOTION.LEFT: this.animator.SetTrigger("attack_l"); break; } this.attack_voice_audio.PlayOneShot(this.AttackSound[this.attack_sound_index]); this.attack_sound_index = (this.attack_sound_index + 1) % this.AttackSound.Length; this.sword_audio.PlayOneShot(this.SwordSound); } } } }