private void create_oni_group(Vector3 appear_position, float speed, OniGroupControl.TYPE type) { Vector3 position = appear_position; GameObject go = GameObject.Instantiate(this.OniGroupPrefab) as GameObject; OniGroupControl new_group = go.GetComponent <OniGroupControl>(); position.y = OniGroupControl.collision_size / 2.0f; position.z = 0.0f; new_group.transform.position = position; new_group.scene_control = this.scene_control; new_group.main_camera = this.scene_control.main_camera; new_group.player = this.player; new_group.run_speed = speed; new_group.type = type; Vector3 base_position = position; int oni_num = this.oni_appear_num; base_position.x -= (OniGroupControl.collision_size / 2.0f - OniControl.collision_size / 2.0f); base_position.y = OniControl.collision_size / 2.0f; new_group.CreateOnis(oni_num, base_position); }
// OnTriggerEnter はコリジョン同士が接した瞬間しか呼ばれないので、 // 攻撃判定の球が発生したときにオニが球の内側に完全に入っていると、 // うまくひろえない. //void OnTriggerEnter(Collider other) void OnTriggerStay(Collider other) { do { if (!this.is_powered) { break; } if (other.tag != "OniGroup") { break; } OniGroupControl oni = other.GetComponent <OniGroupControl>(); if (oni == null) { break; } // oni.OnAttackedFromPlayer(); // 『攻撃できない中』タイマーをリセットする(すぐに攻撃可にする). this.player.resetAttackDisableTimer(); // 攻撃ヒットエフェクトを再生する. this.player.playHitEffect(oni.transform.position); // 攻撃ヒット音を鳴らす. this.player.playHitSound(); } while(false); }
//OnTriggerEnter只会在和碰撞对象发生接触的瞬间被调用 //如果在产生攻击判断球时完全嵌入怪物的内侧,则会不容易检测 //所以此处使用OnTriggerStay void OnTriggerStay(Collider other) { do { if (!this.is_powered) { break; } if (other.tag != "OniGroup") { break; } OniGroupControl oni = other.GetComponent <OniGroupControl>(); if (oni == null) { break; } //怪物被击飞 oni.OnAttackedFromPlayer(); //重置不能攻击计时器 this.player.ReseAttackDisableTimer(); //播放攻击命中特效 this.player.PlayHitEffect(oni.transform.position); //发出攻击命中音效 this.player.PlayHitSound(); } while (false); }
public void OnCollisionStay(Collision other) { if (other.gameObject.tag == "OniGroup") { do { if (this.attackTimer > 0.0f) { break; } if (this.step == STEP.MISS) { break; } this.next_step = STEP.MISS; this.scene_control.OnPlayerMissed(); OniGroupControl oniGroup = other.gameObject.GetComponent <OniGroupControl>(); oniGroup.OnPlayerHitted(); } while (false); } if (other.gameObject.tag == "Floor") { if (other.relativeVelocity.y >= Physics.gravity.y * Time.deltaTime) { this.is_contact_floor = true; } } }
void OnCollisionStay(Collision other) { //和怪物接触后,减速 if (other.gameObject.tag == "OniGroup") { if (this.step != Step.Miss) { this.next_step = Step.Miss; //玩家和怪物接触时的处理 this.scene_control.OnPlayerMissed(); //记录下怪物组和玩家发生了接触 OniGroupControl oni_group = other.gameObject.GetComponent <OniGroupControl>(); oni_group.OnPlayerHitted(); } } //是否着陆了? if (other.gameObject.tag == "Floor") { is_runnig = true; } }
void OnCollisionStay(Collision other) { // おににぶつかったら、減速する. // if (other.gameObject.tag == "OniGroup") { if (this.step != STEP.MISS) { this.next_step = STEP.MISS; // プレイヤーがおににぶつかったときの処理. this.scene_control.OnPlayerMissed(); // おにグループに、プレイヤーがぶつかったことを覚えておく. OniGroupControl oni_group = other.gameObject.GetComponent <OniGroupControl>(); oni_group.onPlayerHitted(); } } // 着地してる?. if (other.gameObject.tag == "Floor") { this.is_contact_floor = true; } }
private void OnTriggerStay(Collider other) { if (this.is_attacking && other.tag == "OniGroup") { // OniGroupControl 触发被攻击效果 OniGroupControl oni_group = other.GetComponent <OniGroupControl>(); oni_group.OnAttackedFromPlayer(); // TODO player 重置普攻,播放命中特效和音效 } }
void OnCollisionStay(Collision other) { // 和怪物接触后,减速 // if (other.gameObject.tag == "OniGroup") { do { // 攻击判定过程中不可能出现Miss if (this.attack_timer > 0.0f) { break; } if (this.step == STEP.MISS) { break; } // this.next_step = STEP.MISS; // 玩家和怪物接触时的处理 this.scene_control.OnPlayerMissed(); // 记录下怪物小组和玩家发生了接触 OniGroupControl oni_group = other.gameObject.GetComponent <OniGroupControl>(); oni_group.onPlayerHitted(); } while(false); } // 是否着陆了? if (other.gameObject.tag == "Floor") { if (other.relativeVelocity.y >= Physics.gravity.y * Time.deltaTime) { this.is_contact_floor = true; } } }
void OnCollisionStay(Collision other) { // おににぶつかったら、減速する. // if (other.gameObject.tag == "OniGroup") { do { // 攻撃判定発生中はミスにならない. if (this.attack_timer > 0.0f) { break; } if (this.step == STEP.MISS) { break; } // this.next_step = STEP.MISS; // プレイヤーがおににぶつかったときの処理. this.scene_control.OnPlayerMissed(); // おにグループに、プレイヤーがぶつかったことを覚えておく. OniGroupControl oni_group = other.gameObject.GetComponent <OniGroupControl>(); oni_group.onPlayerHitted(); } while(false); } // 着地してる?. if (other.gameObject.tag == "Floor") { if (other.relativeVelocity.y >= Physics.gravity.y * Time.deltaTime) { this.is_contact_floor = true; } } }
// -------------------------------------------------------------------------------- // // オニのグループを発生させる. private void create_oni_group(Vector3 appear_position, float speed, OniGroupControl.TYPE type) { // -------------------------------------------------------- // // グループ全体のコリジョン(当たり判定)を生成する. Vector3 position = appear_position; // OniGroupPrefab のインスタンスを生成します. // "as GameObject" を末尾につけると、生成されたオブジェクトは // GameObject オブジェクトになります. // GameObject go = GameObject.Instantiate(this.OniGroupPrefab) as GameObject; OniGroupControl new_group = go.GetComponent <OniGroupControl>(); // 地面に接する高さ. position.y = OniGroupControl.collision_size / 2.0f; position.z = 0.0f; new_group.transform.position = position; new_group.scene_control = this.scene_control; new_group.main_camera = this.scene_control.main_camera; new_group.player = this.player; new_group.run_speed = speed; new_group.type = type; // -------------------------------------------------------- // // グループに属するオニの集団を生成する. Vector3 base_position = position; int oni_num = this.oni_appear_num; // コリジョンボックスの左端によせる. base_position.x -= (OniGroupControl.collision_size / 2.0f - OniControl.collision_size / 2.0f); // 地面に接する高さ. base_position.y = OniControl.collision_size / 2.0f; // オニを発生させる. new_group.CreateOnis(oni_num, base_position); }
// -------------------------------------------------------------------------------- // // 生成怪物分组 private void create_oni_group(Vector3 appear_position, float speed, OniGroupControl.TYPE type) { // -------------------------------------------------------- // // 生成分组整体的碰撞器(用于碰撞检测) Vector3 position = appear_position; // 生成 OniGroupPrefab 实例 // 加上 "as GameObject" 表示将生成的对象转化为 GameObject // GameObject go = GameObject.Instantiate(this.OniGroupPrefab) as GameObject; OniGroupControl new_group = go.GetComponent <OniGroupControl>(); // 和地面接触的高度 position.y = OniGroupControl.collision_size / 2.0f; position.z = 0.0f; new_group.transform.position = position; new_group.scene_control = this.scene_control; new_group.main_camera = this.scene_control.main_camera; new_group.player = this.player; new_group.run_speed = speed; new_group.type = type; // -------------------------------------------------------- // // 生成分组的怪物集合 Vector3 base_position = position; int oni_num = this.oni_appear_num; // 靠近碰撞盒的左端 base_position.x -= (OniGroupControl.collision_size / 2.0f - OniControl.collision_size / 2.0f); // 和地面接触的高度 base_position.y = OniControl.collision_size / 2.0f; // 生成怪物 new_group.CreateOnis(oni_num, base_position); }
// -------------------------------------------------------------------------------- // // オニのグループを発生させる. private void create_oni_group(Vector3 appear_position, float speed, OniGroupControl.TYPE type) { // -------------------------------------------------------- // // グループ全体のコリジョン(当たり判定)を生成する. Vector3 position = appear_position; // OniGroupPrefab のインスタンスを生成します. // "as GameObject" を末尾につけると、生成されたオブジェクトは // GameObject オブジェクトになります. // GameObject go = GameObject.Instantiate(this.OniGroupPrefab) as GameObject; OniGroupControl new_group = go.GetComponent<OniGroupControl>(); // 地面に接する高さ. position.y = OniGroupControl.collision_size/2.0f; position.z = 0.0f; new_group.transform.position = position; new_group.scene_control = this.scene_control; new_group.main_camera = this.scene_control.main_camera; new_group.player = this.player; new_group.run_speed = speed; new_group.type = type; // -------------------------------------------------------- // // グループに属するオニの集団を生成する. Vector3 base_position = position; int oni_num = this.oni_appear_num; // コリジョンボックスの左端によせる. base_position.x -= (OniGroupControl.collision_size/2.0f - OniControl.collision_size/2.0f); // 地面に接する高さ. base_position.y = OniControl.collision_size/2.0f; // オニを発生させる. new_group.CreateOnis(oni_num, base_position); }