void Update() { // Debug.Log(EnemyAttackPower.GetEnemyBHitGet()); if (!once) { FirstHP = FPSCon.GetComponent <MyStatus>().GetHp(); NowHP = FPSCon.GetComponent <MyStatus>().GetHp(); once = true; } //HPを持ってくる if (EnemyAttackPower.GetEnemyBHitGet()) { // Debug.Log("FirstHp" + FirstHP); NowHP = FPSCon.GetComponent <MyStatus>().GetHp(); // Debug.Log("NowHp" + NowHP); } if (NowHP <= 0) { GameOverEnter(); if (alpha >= 1) { Invoke("GameOver", 1.0f); } } //ここのif文に当たった処理を! if (NowHP > 0) { if (EnemyAttackPower.GetEnemyBHitGet()) { AudioManager.Instance.PlaySE("damage1"); this.img.color = new Color(0.5f, 0f, 0f, 0.5f); FirstHP = NowHP; } else { this.img.color = Color.Lerp(this.img.color, Color.clear, Time.deltaTime); } } }
void Update() { //if(!PauseScript.pause()){ //if(!SkillManagement.GetTimeStop()){ // ======== // アニメーション // ======== //あらかじめ設定していたintパラメーター「trans」の値を取り出す. trans = animator.GetInteger("trans"); // 発見フラグ条件判定 if (foundflg == false) { // 敵が正面を向いていて知覚できる範囲内なら if ((transform.position - player.gameObject.transform.position).magnitude < 15 && trans == 0) { foundflg = true; fireflg = true; trans = 0; //intパラメーターの値を設定する. animator.SetInteger("trans", trans); } // プレイヤーとの距離が範囲内なら if ((transform.position - player.gameObject.transform.position).magnitude < 5) { foundflg = true; fireflg = true; trans = 0; //intパラメーターの値を設定する. animator.SetInteger("trans", trans); } // プレイヤーから攻撃を受けたら } // 発見フラグがONなら if (foundflg == true) { // 正面を向き trans = 0; animator.SetInteger("trans", trans); //targetに向かって進む transform.position += transform.forward * ep.speed * 0.1f; } // 発見フラグがOFFなら else if (foundflg == false) { // 角度計算 rot = GetAim(new Vector2(transform.position.x, transform.position.z), new Vector2(player.gameObject.transform.position.x, player.gameObject.transform.position.z)); rot = rot + ep.startrot; // 角度計算 // 正面 if (rot >= -45.0f && rot <= 45.0f) { trans = 0; } // 右面 else if (rot >= 45.0f && rot <= 135.0f) { trans = 1; } // 左面 else if (rot >= -135 && rot <= -45) { trans = 3; } // 後面 else { trans = 2; } //intパラメーターの値を設定する animator.SetInteger("trans", trans); } // デバッグ表示 // Debug.Log("GhostFoundFlg"); // Debug.Log(foundflg); // 敵の体力が0になったら if (ep.hp == 0) { // 死亡時の爆発エフェクトを再生 GameObject de = Instantiate(deadeffect) as GameObject; de.transform.position = this.gameObject.transform.position; de.transform.position = new Vector3(de.transform.position.x, de.transform.position.y, de.transform.position.z); // 死んだときにアイテムポップ if (PopObject) { GameObject po = Instantiate(PopObject) as GameObject; po.transform.position = this.gameObject.transform.position; } // 解放処理 Destroy(de, 2.0f); Destroy(this.gameObject); } // // 弾発射 // // z キーが押された時 // if (Input.GetKeyDown(KeyCode.Z)) // { // if(fireflg == true) // { // fireflg = false; // } // else // { // fireflg = true; // ftime = 0; // } // } // 敵の体力が0になったら if (ep.hp == 0) { // 死亡時の爆発エフェクトを再生 GameObject de = Instantiate(deadeffect) as GameObject; de.transform.position = this.gameObject.transform.position; de.transform.position = new Vector3(de.transform.position.x, de.transform.position.y - 1.2f, de.transform.position.z); // 死んだときにアイテムポップ if (PopObject) { GameObject po = Instantiate(PopObject) as GameObject; po.transform.position = this.gameObject.transform.position; } // 解放処理 Destroy(de, 2.0f); Destroy(this.gameObject); } // // Xを押したら // if (Input.GetKey(KeyCode.X)) // { // GameObject go = Instantiate(this.gameObject) as GameObject; // go.transform.position = new Vector3(this.transform.position.x, this.transform.position.y, this.transform.position.z + 5); // } // 発射フラグがONなら if (fireflg == true) { if (ftime == 0) { // 弾丸の複製 GameObject bullets = Instantiate(bullet) as GameObject; // 攻撃力の挿入 eap = bullets.GetComponent <EnemyAttackPower>(); eap.SetAtkPower(ep.atk); // 向き方向の取得 Vector3 aim = player.gameObject.transform.position - this.transform.position; // Rigidbodyに力を加えて発射 bullets.GetComponent <Rigidbody>().AddForce(aim, ForceMode.Impulse); // 弾丸の位置を調整 bullets.transform.position = this.gameObject.transform.position; // 三秒後に削除 Destroy(bullets, 3.0f); } ftime++; if (AILevel == 1) { if (ftime > 80) { ftime = 0; } } else if (AILevel == 2) { if (ftime > 70) { ftime = 0; } } else if (AILevel == 3) { if (ftime > 60) { ftime = 0; } } } //} }
void Update() { //if(!PauseScript.pause()){ //if(!SkillManagement.GetTimeStop()){ // ======== // アニメーション // ======== //あらかじめ設定していたintパラメーター「trans」の値を取り出す. trans = animator.GetInteger("trans"); // 発見フラグ条件判定 if (foundflg == false) { // 敵が正面を向いていて知覚できる範囲内なら if ((transform.position - player.gameObject.transform.position).magnitude < 15 && trans == 0) { foundflg = true; trans = 0; //intパラメーターの値を設定する. animator.SetInteger("trans", trans); } // プレイヤーとの距離が範囲内なら if ((transform.position - player.gameObject.transform.position).magnitude < 5) { foundflg = true; trans = 0; //intパラメーターの値を設定する. animator.SetInteger("trans", trans); } // プレイヤーから攻撃を受けたら } // 発見フラグがONなら if (foundflg == true) { if (!AttackFlg) { // // 体力を元に戻す // ep.hp = 120; // 正面を向き trans = 0; animator.SetInteger("trans", trans); // HPbar再生 if (Hpbar) { Hpbar.SetActive(true); } } if (AILevel == 2) { material.SetFloat(propID_h, 0.45f); //material.SetFloat(propID_s, 1.0f); //material.SetFloat(propID_c, 0.7f); //ep.hp = 10; ep.atk = 20; ep.def = 10; ActionTime = 60; AILevel = 0; //plight.color = new Color(1.0f,0.5f,0.5f,1.0f); } } // 発見フラグがOFFなら else if (foundflg == false) { // 角度計算 rot = GetAim(new Vector2(transform.position.x, transform.position.z), new Vector2(player.gameObject.transform.position.x, player.gameObject.transform.position.z)); rot = rot + ep.startrot; // 角度計算 // 正面 if (rot >= -45.0f && rot <= 45.0f) { trans = 0; } // 右面 else if (rot >= 45.0f && rot <= 135.0f) { trans = 1; } // 左面 else if (rot >= -135 && rot <= -45) { trans = 3; } // 後面 else { trans = 2; } //intパラメーターの値を設定する animator.SetInteger("trans", trans); } // 行動パターン ============================================= if (foundflg && !deadflg) { // 待機モーション if (ActionFlg == 0) { ActionCnt++; if (ActionCnt > 60) { ActionCnt = 0; ActionFlg = Random.Range(0, 4); } } // 攻撃1モーション else if (ActionFlg == 1) { if (ActionCnt == 0) { fireflg = true; } ActionCnt++; if (ActionCnt > ActionTime) { ActionCnt = 0; // 待機モーションへ戻る ActionFlg = 0; } } // 攻撃2モーション else if (ActionFlg == 2) { if (ActionCnt == 0) { GameObject ps1 = Instantiate(PopSmoke) as GameObject; ps1.transform.position = new Vector3(this.transform.position.x + 2, this.transform.position.y - 3, this.transform.position.z + 3); Destroy(ps1, 2.0f); GameObject go1 = Instantiate(MiniSquid) as GameObject; go1.transform.position = new Vector3(this.transform.position.x + 2, this.transform.position.y - 3, this.transform.position.z + 3); GameObject ps2 = Instantiate(PopSmoke) as GameObject; ps2.transform.position = new Vector3(this.transform.position.x + 2, this.transform.position.y - 3, this.transform.position.z - 3); Destroy(ps2, 2.0f); GameObject go2 = Instantiate(MiniSquid) as GameObject; go2.transform.position = new Vector3(this.transform.position.x + 2, this.transform.position.y - 3, this.transform.position.z - 3); } ActionCnt++; if (ActionCnt > ActionTime) { ActionCnt = 0; // 待機モーションへ戻る ActionFlg = 0; } } // 攻撃3モーション else if (ActionFlg == 3) { if (ActionCnt == 0) { AttackFlg = true; trans = 4; } ActionCnt++; if (ActionCnt > 60) { ActionCnt = 0; // 待機モーションへ戻る ActionFlg = 0; } } // 攻撃1処理 if (fireflg) { if (ftime == 0) { GameObject fe = Instantiate(FireEffect) as GameObject; fe.transform.position = new Vector3( this.gameObject.transform.position.x + 1, this.gameObject.transform.position.y, this.gameObject.transform.position.z ); Destroy(fe, 1.0f); } if (ftime == 60) { // 弾丸の複製 GameObject bullets = Instantiate(Bullet) as GameObject; // 攻撃力の挿入 eap = bullets.GetComponent <EnemyAttackPower>(); eap.SetAtkPower(ep.atk); // 向き方向の取得 Vector3 aim = player.gameObject.transform.position - this.transform.position; // Rigidbodyに力を加えて発射 bullets.GetComponent <Rigidbody>().AddForce(aim * 1.5f, ForceMode.Impulse); // 弾丸の位置を調整 bullets.transform.position = this.gameObject.transform.position; // 三秒後に削除 Destroy(bullets, 3.0f); } ftime++; // if (AILevel == 1) // { if (ftime > 60) { ftime = 0; fireflg = false; } //} // if (AILevel == 0) // { // if (ftime > 45) { // ftime = 0; // fireflg = false; // } // } } // 攻撃3処理 if (AttackFlg == true) { if (trans == 4) { if (AttackCnt > 30) { trans = 5; AttackCnt = 0; } } if (trans == 5) { if (AttackCnt == 0) { GameObject ds1 = Instantiate(DustSmoke) as GameObject; ds1.transform.position = new Vector3(this.transform.position.x, this.transform.position.y - 2, this.transform.position.z); Destroy(ds1, 4.0f); } if (AttackCnt == 40) { SavePlayerPos = new Vector3(player.transform.position.x, 0, player.transform.position.z); } if (AttackCnt == 50) { GameObject tentacle = Instantiate(Tentacle) as GameObject; tentacle.transform.position = SavePlayerPos; } if (AttackCnt > 180) { trans = 6; AttackCnt = 0; } } if (trans == 6) { if (AttackCnt > 30) { trans = 0; AttackCnt = 0; AttackFlg = false; } } AttackCnt++; animator.SetInteger("trans", trans); } } // 敵の体力が0になったら if (deadflg == false) { if (ep.hp == 0) { deadflg = true; a = 0.5f; animator.enabled = false; // // 解放処理 Destroy(this.gameObject, 5.5f); Destroy(Hpbar.gameObject, 5.5f); } } if (deadflg) { mvalue = Random.Range(-2.0f, 2.0f); if (decnt == 0) { GameObject de = Instantiate(deadeffect) as GameObject; de.transform.position = new Vector3(this.transform.position.x + mvalue, this.transform.position.y + mvalue, this.transform.position.z + mvalue); Destroy(de, 2.0f); } decnt++; if (decnt > 10) { decnt = 0; } a -= 0.01f; material.SetFloat(propID_s, a); if (a < 0) { a = 0; } mvalue = Random.Range(-0.1f, 0.1f); this.gameObject.transform.position = new Vector3( this.gameObject.transform.position.x + mvalue, this.gameObject.transform.position.y - 0.025f, this.gameObject.transform.position.z + mvalue ); } // デバッグ表示 //Debug.Log("SquidHp"); //Debug.Log(ep.hp); }