public void EndEnemyCommonWork() { // 액션 한계 시간 검사 float time = Time.fixedTime - aiActionTImeStart; if (time > aiActionTimeLength) { aiState = ENEMYAISTS.ACTIONSELECT; } }
public override void SetCombatAIState(ENEMYAISTS sts) { base.SetCombatAIState(sts); switch (aiState) { case ENEMYAISTS.ACTIONSELECT: break; case ENEMYAISTS.WAIT: aiActionL = Random.Range(0.0f, 1.0f); break; case ENEMYAISTS.RUNTOPLAYER: aiActionL = 3.0f; break; case ENEMYAISTS.JUMPTOPLAYER: aiActionL = 1.0f; break; case ENEMYAISTS.ESCAPE: aiActionL = Random.Range(2.0f, 5.0f); break; case ENEMYAISTS.RETRUNTODGPILE: aiActionL = 3.0f; break; } }
// AI가 일정 시간마다 주기적으로 다음 행동을 생각한다 public void EndEnemyCommonWork() { float time = Time.fixedTime - aiActionTimeStart; if (time > aiActionTimeLength) { aiState = ENEMYAISTS.ACTIONSELECT; } }
// === コード(基本AI動作処理) ============================= public bool BeginEnemyCommonWork() { // 生きているか? if (enemyCtrl.hp <= 0) { return(false); } // アクティブゾーンに入っているか? if (inActiveZoneSwitch) { inActiveZone = false; Vector3 vecA = player.transform.position + playerCtrl.enemyActiveZonePointA; Vector3 vecB = player.transform.position + playerCtrl.enemyActiveZonePointB; if (transform.position.x > vecA.x && transform.position.x < vecB.x && transform.position.y > vecA.y && transform.position.y < vecB.y) { inActiveZone = true; } } // 空中は強制実行(空中設置敵・エリアル対応) if (enemyCtrl.grounded) { // カメラ内に入っているか? if (cameraSwitch && !cameraEnabled && !inActiveZone) { // カメラに映っていない enemyCtrl.ActionMove(0.0f); enemyCtrl.cameraRendered = false; enemyCtrl.animator.enabled = false; rigidbody2D.Sleep(); return(false); } } enemyCtrl.animator.enabled = true; enemyCtrl.cameraRendered = true; // 状態チェック if (!CheckAction()) { return(false); } // ドッグパイル if (dogPile != null) { if (GetDistaneDogPile() > dogPileReturnLength) { aiState = ENEMYAISTS.RETURNTODOGPILE; } } return(true); }
// === AI พื้นฐาน ============================= public bool BeginEnemyCommonWork() { // ยังมีชีวิตอยู่หรือไม่ if (enemyCtrl.hp <= 0) { return(false); } // เข้ามาใน active zone แล้วหรือยัง if (inActiveZoneSwitch) { inActiveZone = false; Vector3 vecA = player.transform.position + playerCtrl.enemyActiveZonePointA; Vector3 vecB = player.transform.position + playerCtrl.enemyActiveZonePointB; if (transform.position.x > vecA.x && transform.position.x < vecB.x && transform.position.y > vecA.y && transform.position.y < vecB.y) { inActiveZone = true; } } if (enemyCtrl.grounded) { // เข้ามาอยู่หน้ากล้องแล้วหรือยัง if (cameraSwitch && !cameraEnabled && !inActiveZone) { // ถ้าไม่อยู่หน้ากล้อง (มองไม่เห็น) ให้กำหนดค่าต่างๆ ตามนี้ enemyCtrl.ActionMove(0.0f); enemyCtrl.cameraRendered = false; enemyCtrl.animator.enabled = false; GetComponent <Rigidbody2D>().Sleep(); return(false); } } enemyCtrl.animator.enabled = true; enemyCtrl.cameraRendered = true; // เช็คสถานะ if (!CheckAction()) { return(false); } // เช็ค dogPile if (dogPile != null) { if (GetDistaneDogPile() > dogPileReturnLength) { aiState = ENEMYAISTS.RETURNTODOGPILE; } } return(true); }
public void EndEnemyCommonWork() { // เกินเวลาที่กำหนดไว้แล้วหรือยัง ถ้าเกินให้หยุดแล้วเลือกสถานะใหม่ float time = Time.fixedTime - aiActionTImeStart; if (time > aiActionTimeLength) { aiState = ENEMYAISTS.ACTIONSELECT; } }
// === コード(COMBAT AI対応処理) ========================== public override void SetCombatAIState(ENEMYAISTS sts) { base.SetCombatAIState (sts); switch (aiState) { case ENEMYAISTS.ACTIONSELECT : break; case ENEMYAISTS.WAIT : aiActionTimeLength = 1.0f + Random.Range(0.0f,1.0f); break; case ENEMYAISTS.RUNTOPLAYER : aiActionTimeLength = 3.0f; break; case ENEMYAISTS.JUMPTOPLAYER : aiActionTimeLength = 1.0f; break; case ENEMYAISTS.ESCAPE : aiActionTimeLength = Random.Range(2.0f,5.0f); break; case ENEMYAISTS.RETURNTODOGPILE : aiActionTimeLength = 3.0f; break; } }
/* AI가 생각해도 되는지를 검사 * hp가 없거나 당하거나 죽거나 공격하면 false 아니면 true */ public bool BeginEnemyCommonWork() { if (enemyCtrl.hp <= 0) { return(false); } if (inActiveZoneSwitch) { inActiveZone = false; Vector3 vecA = player.transform.position + playerCtrl.enemyActiveZonePointA; Vector3 vecB = player.transform.position + playerCtrl.enemyActiveZonePointB; if (transform.position.x > vecA.x && transform.position.x < vecB.x && transform.position.y > vecA.y && transform.position.y < vecB.y) { inActiveZone = true; } } if (enemyCtrl.grounded) { if (cameraSwitch && !cameraEnabled && !inActiveZoneSwitch) { enemyCtrl.ActionMove(0.0f); enemyCtrl.cameraRendered = false; enemyCtrl.animator.enabled = false; GetComponent <Rigidbody2D>().Sleep(); return(false); } } enemyCtrl.animator.enabled = true; enemyCtrl.cameraRendered = true; //공격하거나 당할 때 if (!CheckAction()) { return(false); } if (dogPile != null) { if (GetDistanceDogPile() > dogPileReturnLength) { aiState = ENEMYAISTS.RETURNTODOGPILE; } } return(true); }
public virtual void SetCombatAIState(ENEMYAISTS sts) { aiState = sts; aiActionTImeStart = Time.fixedTime; enemyCtrl.ActionMove(0.0f); }
public void SetAIState(ENEMYAISTS sts, float t) { aiState = sts; aiActionTImeStart = Time.fixedTime; aiActionTimeLength = t; }
public virtual void SetCombatAIState(ENEMYAISTS sts) { aiState = sts; aiActionTImeStart = Time.fixedTime; enemyCtrl.ActionMove (0.0f); }
public void SetAIState(ENEMYAISTS sts,float t) { aiState = sts; aiActionTImeStart = Time.fixedTime; aiActionTimeLength = t; }
// === 코드(기본 AI 동작 처리) ============================= public bool BeginEnemyCommonWork () { // 살아 있는지 확인 if (enemyCtrl.hp <= 0) { return false; } // 활성 영역에 들어와 있는지 확인 if (inActiveZoneSwitch) { inActiveZone = false; Vector3 vecA = player.transform.position + playerCtrl.enemyActiveZonePointA; Vector3 vecB = player.transform.position + playerCtrl.enemyActiveZonePointB; if (transform.position.x > vecA.x && transform.position.x < vecB.x && transform.position.y > vecA.y && transform.position.y < vecB.y) { inActiveZone = true; } } // 공중에서는 강제 실행(공중 설치 적·광범위 대응) if (enemyCtrl.grounded) { // 카메라 안에 들어와 있는지 확인 if (cameraSwitch && !cameraEnabled && !inActiveZone) { // 카메라에 비쳐지고 있지 않다 enemyCtrl.ActionMove (0.0f); enemyCtrl.cameraRendered = false; enemyCtrl.animator.enabled = false; rigidbody2D.Sleep (); return false; } } enemyCtrl.animator.enabled = true; enemyCtrl.cameraRendered = true; // 상태 검사 if (!CheckAction ()) { return false; } #if xxx // 본래는 이 처리가 필요하지만 비스듬한 방향으로 점프할 수 없으므로 DMG_B 애니메이션 길이로 조정 if (!enemyCtrl.grounded) { enemyCtrl.ActionMove (0.0f); return false; } #endif // 도그 파일 if (dogPile != null) { if (GetDistaneDogPile() > dogPileReturnLength) { aiState = ENEMYAISTS.RETURNTODOGPILE; } } return true; }
// === コード(基本AI動作処理) ============================= public bool BeginEnemyCommonWork() { // 生きているか? if (enemyCtrl.hp <= 0) { return false; } // アクティブゾーンに入っているか? if (inActiveZoneSwitch) { inActiveZone = false; Vector3 vecA = player.transform.position + playerCtrl.enemyActiveZonePointA; Vector3 vecB = player.transform.position + playerCtrl.enemyActiveZonePointB; if (transform.position.x > vecA.x && transform.position.x < vecB.x && transform.position.y > vecA.y && transform.position.y < vecB.y) { inActiveZone = true; } } // 空中は強制実行(空中設置敵・エリアル対応) if (enemyCtrl.grounded) { // カメラ内に入っているか? if (cameraSwitch && !cameraEnabled && !inActiveZone) { // カメラに映っていない enemyCtrl.ActionMove (0.0f); enemyCtrl.cameraRendered = false; enemyCtrl.animator.enabled = false; rigidbody2D.Sleep (); return false; } } enemyCtrl.animator.enabled = true; enemyCtrl.cameraRendered = true; // 状態チェック if (!CheckAction ()) { return false; } #if xxx // 本当は、この処理が必要だが、斜めジャンプができなくなるので、DMG_Bのアニメーションの長さで調整 if (!enemyCtrl.grounded) { enemyCtrl.ActionMove (0.0f); return false; } #endif // ドッグパイル if (dogPile != null) { if (GetDistaneDogPile() > dogPileReturnLength) { aiState = ENEMYAISTS.RETURNTODOGPILE; } } return true; }
public virtual void SetCombatAIState(ENEMYAISTS sts) { aiState = sts; aiActionTimeStart = Time.fixedTime; // enemyBirdCtrl.ActionMove(0f,0f); }
public bool BeginEnemyCommonWork() { if(enemyCtrl.hp<=0){ return false; } if(inActiveZoneSwitch){ inActiveZone = false; Vector3 vecA = player.transform.position + playerCtrl.enemyActiveZonePointA; Vector3 vecB = player.transform.position + playerCtrl.enemyActiveZonePointB; if(transform.position.x > vecA.x && transform.position.x <vecB.x && transform.position.y > vecA.y && transform.position.y <vecB.y){ inActiveZone = true; } } if(enemyCtrl.grounded){ if(cameraSwitch && !cameraEnabled && !inActiveZone){ enemyCtrl.ActionMove(0.0f); enemyCtrl.cameraRendered = false; enemyCtrl.animator.enabled = false; rigidbody2D.Sleep(); return false; } } enemyCtrl.animator.enabled = true; enemyCtrl.cameraRendered = true; if(!CheckAction()){ return false; } if(dogPile != null){ if(GetDistanceDogPile() > dogPileReturnLength){ aiState = ENEMYAISTS.RETURNTODOGPILE; } } return true; }