//---------------------------------------------------------------------------------------------- // 更新処理 //---------------------------------------------------------------------------------------------- public override void OnUpdate(AutoPilot ap) { //位置取得 ap.Print(0, "Position : " + ap.GetPosition()); ap.Print(1, "Pitch : " + ap.GetPitch()); ap.Print(2, "Direction : " + ap.GetDirection()); ap.Print(3, "Back : " + ap.GetBank()); // 攻撃 int energy = ap.GetEnergy(); if (energy > 15 && Input.GetMouseButton(0)) { ap.StartAction("ATK1", -1); } else { ap.EndAction("ATK1"); } if (energy > 10 && Input.GetMouseButton(1)) { ap.StartAction("ATK2", -1); } else { ap.EndAction("ATK2"); } //サイドブースト if (energy > 40 && Input.GetKey(KeyCode.Q)) { ap.StartAction("Ldash", -1); } else if (energy < 10 || !Input.GetKey(KeyCode.Q)) { ap.EndAction("Ldash"); } if (energy > 40 && Input.GetKey(KeyCode.E)) { ap.StartAction("Rdash", -1); } else if (energy < 10 || !Input.GetKey(KeyCode.E)) { ap.EndAction("Rdash"); } }
//---------------------------------------------------------------------------------------------- // 更新処理 //---------------------------------------------------------------------------------------------- public override void OnUpdate(AutoPilot ap) { //索敵(前方優先で近い敵を選択) if (ap.CheckEnemy() == false && (aimMode == 2 || aimMode == 3 || aimMode == 4)) { ap.SearchEnemy(); } int enemyDistance = ap.GetEnemyDistance(); enemyHeight = ap.GetEnemyPosition().y; selfHeight = ap.GetPosition().y; if (ap.CheckEnemy() == true) { newHeight = (enemyHeight - selfHeight) * 2; } //対地対空機銃自動エイミングモード if (Input.GetKeyDown(KeyCode.Alpha3)) { autoAim = true; if (newHeight > heightSwitch) { aimMode = 4; ap.StartAction("AIM1", -1); ap.EndAction("AIM2"); } else { aimMode = 3; ap.StartAction("AIM2", -1); ap.EndAction("AIM1"); } } newHeight = (enemyHeight - selfHeight) * 2; if (newHeight > heightSwitch && oldHeight <= heightSwitch && autoAim) { aimMode = 4; ap.StartAction("AIM1", -1); ap.EndAction("AIM2"); } if (newHeight < heightSwitch && oldHeight >= heightSwitch && autoAim) { aimMode = 3; ap.StartAction("AIM2", -1); ap.EndAction("AIM1"); } //ターゲットリセット if (Input.GetKeyDown(KeyCode.Alpha2) || Input.GetKeyDown(KeyCode.Alpha3)) { ap.ForgetEnemy(); } ap.SelectEnemy(KeyCode.Alpha2); ap.SelectEnemy(KeyCode.Alpha3); // 攻撃 int energy = ap.GetEnergy(); if (energy > 10 && Input.GetMouseButton(0)) { ap.StartAction("ATK1", -1); } else { ap.EndAction("ATK1"); } if (energy > 40 && Input.GetMouseButton(1)) { ap.StartAction("ATK2", -1); } else { ap.EndAction("ATK2"); } if (energy > 5 && Input.GetMouseButton(2)) { ap.StartAction("ATK3", -1); } else { ap.EndAction("ATK3"); } //エイムモード if (Input.GetKeyDown(KeyCode.Alpha1)) { aimMode = 1; //手動モード ap.StartAction("AIM1", -1); ap.EndAction("AIM2"); autoAim = false; } else if (Input.GetKeyDown(KeyCode.Alpha2)) { aimMode = 2; //榴弾モード ap.StartAction("AIM2", -1); ap.EndAction("AIM1"); autoAim = false; } else if (aimChange == 3) { aimMode = 3; //対地モード ap.StartAction("AIM2", -1); ap.EndAction("AIM1"); } else if (aimChange == 4) { aimMode = 4; //対空モード ap.StartAction("AIM1", -1); ap.EndAction("AIM2"); } else if (Input.GetKeyDown(KeyCode.Alpha4)) { aimMode = 0; //休止モード ap.EndAction("AIM1"); ap.EndAction("AIM2"); autoAim = false; } //情報表示 ap.Print(0, "Position : " + ap.GetPosition()); ap.Print(1, "Pitch : " + ap.GetPitch()); ap.Print(2, "Direction : " + ap.GetDirection()); ap.Print(3, "Back : " + ap.GetBank()); // エイム & 攻撃(敵の速度と距離を考慮して目標座標を補正) Vector3 ev = ap.GetEnemyVelocity() - ap.GetVelocity(); float ed = enemyDistance * 0.003f; Vector3 mv = ap.MulVec(ev, ed); if (aimMode == 2) { //榴弾オートエイム Vector3 estPos = ap.AddVec(ap.GetEnemyPosition(), mv); Vector3 mv2 = ap.MulVec(ap.GetGravity(), enemyDistance * enemyDistance * 0.006f); ap.Aim(ap.SubVec(estPos, mv2)); } if (aimMode == 3 || aimMode == 4) { //機銃オートエイム Vector3 estPos = ap.AddVec(ap.GetEnemyPosition(), mv); ap.Aim(estPos); } oldHeight = newHeight; }