Ejemplo n.º 1
0
    //----------------------------------------------------------------------------------------------
    // 更新処理
    //----------------------------------------------------------------------------------------------
    public override void OnUpdate(AutoPilot ap)
    {
        // 攻撃
        int energy = ap.GetEnergy();

        if (energy > 15 && Input.GetMouseButton(0))
        {
            ap.StartAction("ATK1", -1);
        }
        else
        {
            ap.EndAction("ATK1");
        }
        if (energy > 30 && Input.GetMouseButton(1))
        {
            ap.StartAction("ATK3", -1);
        }
        else
        {
            ap.EndAction("ATK3");
        }
        if (!missile && energy > 15 && Input.GetMouseButtonDown(2))
        {
            ap.StartAction("ATK2", -1);
            missile = true;
        }
        else if ((missile && Input.GetMouseButtonDown(2)) || energy < 10)
        {
            ap.EndAction("ATK2");
            missile = false;
        }
    }
Ejemplo n.º 2
0
    //----------------------------------------------------------------------------------------------
    // 更新処理
    //----------------------------------------------------------------------------------------------
    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");
        }
    }
Ejemplo n.º 3
0
    //----------------------------------------------------------------------------------------------
    // 更新処理
    //----------------------------------------------------------------------------------------------
    public override void OnUpdate(AutoPilot ap)
    {
        // 攻撃
        int energy = ap.GetEnergy();

        if (energy > 15 && Input.GetMouseButton(0) && !Input.GetMouseButton(1))
        {
            ap.StartAction("ATK1", -1);
        }
        else
        {
            ap.EndAction("ATK1");
        }
        if (energy > 10 && Input.GetMouseButton(1) && !Input.GetMouseButton(0))
        {
            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");
        }
    }
Ejemplo n.º 4
0
    public override void OnUpdate(AutoPilot ap)//������s
    {
        //trail and menu
        //TrailUpdate(ap);
        CanvasMake(ap);

        //Light ON/OFF Switch
        if (Input.GetKeyDown(KeyCode.H))
        {
            bool flag = !headLightL.activeSelf;
            headLightL.SetActive(flag);
            headLightR.SetActive(flag);
        }
        if (this.HeadLights)
        {
            ap.StartAction("HLights", -1);
        }
        else
        {
            ap.EndAction("HLights");
        }
    }
Ejemplo n.º 5
0
    //----------------------------------------------------------------------------------------------
    // 更新処理
    //----------------------------------------------------------------------------------------------
    public override void OnUpdate(AutoPilot ap)
    {
        // 攻撃
        int energy = ap.GetEnergy();

        //銃
        if (energy > 10 && Input.GetKey(Wep1))
        {
            ap.StartAction("Cannon", -1);
        }
        else
        {
            ap.EndAction("Cannon");
        }

        //エンジン
        if (jetPower > 0)
        {
            if (Input.GetKeyDown(JetDown))
            {
                jetPower--;
            }
        }
        if (jetPower < 4)
        {
            if (Input.GetKeyDown(JetUp))
            {
                jetPower++;
            }
        }

        if (jetPower == 0 && Input.GetKeyDown(JetToggle))
        {
            jetPower = 3;
        }
        else if (jetPower == 1)
        {
            ap.StartAction("Jet1", 1);
            if (Input.GetKeyDown(JetToggle))
            {
                jetPower = 3;
            }
        }
        else if (jetPower == 2)
        {
            ap.StartAction("Jet2", 1);
            if (Input.GetKeyDown(JetToggle))
            {
                jetPower = 3;
            }
        }
        else if (jetPower == 3)
        {
            ap.StartAction("Jet3", 1);
            if (Input.GetKeyDown(JetToggle))
            {
                jetPower = 0;
            }
        }
        else if (jetPower == 4)
        {
            ap.StartAction("Boost", 1);
            jetPower--;
        }
    }
Ejemplo n.º 6
0
    //----------------------------------------------------------------------------------------------
    // Update
    //----------------------------------------------------------------------------------------------
    public override void OnUpdate(AutoPilot ap)
    {
        // Attack
        int energy = ap.GetEnergy();

        if (energy > 20 && Input.GetMouseButton(0))
        {
            ap.StartAction("ATK1", -1);
        }
        else
        {
            ap.EndAction("ATK1");
        }
        if (Input.GetMouseButtonDown(2))
        {
            if (energy > 10 && !sword)
            {
                ap.StartAction("ATK3", -1);
                sword = true;
            }
            else
            {
                ap.EndAction("ATK3");
                sword = false;
            }
        }
        if (energy > 10 && jetStriker)
        {
            ap.StartAction("ATK3", 1);
        }
        if (energy <= 10)
        {
            ap.EndAction("ATK3");
            sword = false;
        }
        if (energy > 10 && Input.GetMouseButtonDown(1) && !missile)
        {
            ap.StartAction("ATK2", -1);
            missile = true;
        }
        else if (Input.GetMouseButtonDown(1) || energy <= 10)
        {
            ap.EndAction("ATK2");
            missile = false;
        }

        //Move
        if (!flightMode)
        {
            //Human Mode
            if (Input.GetKey(KeyCode.W))
            {
                ap.StartAction("w", 1);
            }
            if (Input.GetKey(KeyCode.A))
            {
                ap.StartAction("a", 1);
            }
            if (Input.GetKey(KeyCode.S))
            {
                ap.StartAction("s", 1);
            }
            if (Input.GetKey(KeyCode.D))
            {
                ap.StartAction("d", 1);
            }
            if (Input.GetKey(KeyCode.Space))
            {
                ap.StartAction("up", 1);
            }
            if (Input.GetKey(KeyCode.F))
            {
                ap.StartAction("down", 1);
            }
            if ((Input.GetKeyDown(KeyCode.Alpha1) && aim) || Input.GetKeyDown(KeyCode.Q))
            {
                ap.EndAction("AIM1");
                aim = false;
            }
            else if (Input.GetKeyDown(KeyCode.Alpha1) && !aim || Input.GetKeyUp(KeyCode.Q))
            {
                ap.StartAction("AIM1", -1);
                aim = true;
            }
            if (Input.GetKeyDown(KeyCode.Alpha2))
            {
                ap.StartAction("change", -1);
                ap.EndAction("AIM1");
                flightMode = true;
            }
            if (Input.GetKeyDown(KeyCode.E))
            {
                ap.StartAction("change", -1);
                ap.EndAction("AIM1");
                flightMode = true;
                autoPilot  = true;
                jetStriker = true;
            }
            else
            {
                jetStriker = false;
            }
        }
        else
        {
            //Fighter Mode
            if (jetStriker && Input.GetKeyDown(KeyCode.E))
            {
                jetStriker = false;
                autoPilot  = false;
            }
            else if (!jetStriker && Input.GetKeyDown(KeyCode.E))
            {
                jetStriker = true;
                autoPilot  = true;
                ap.ForgetEnemy();
            }
            if (Input.GetKey(KeyCode.W) || jetStriker)
            {
                ap.StartAction("FMforth", 1);
            }
            if (Input.GetKey(KeyCode.A))
            {
                ap.StartAction("a", 1);
            }
            if (Input.GetKey(KeyCode.S))
            {
                ap.StartAction("FMback", 1);
            }
            if (Input.GetKey(KeyCode.D))
            {
                ap.StartAction("d", 1);
            }
            if (Input.GetKey(KeyCode.Space))
            {
                ap.StartAction("FMup", 1);
            }
            if (Input.GetKey(KeyCode.F))
            {
                ap.StartAction("FMdown", 1);
            }
            if (Input.GetKeyDown(KeyCode.Alpha2))
            {
                ap.EndAction("change");
                flightMode = false;
                ap.StartAction("AIM1", -1);
                aim = true;
            }
        }

        //AutoAim
        float   enemyDistance = ap.GetEnemyDistance();
        float   enemyAngleR   = ap.GetEnemyAngleR();
        float   enemyAngleU   = ap.GetEnemyAngleU();
        Vector3 enemyVelocity = ap.GetEnemyVelocity() - ap.GetVelocity();

        enemyHeight = ap.GetEnemyPosition().y;
        selfHeight  = ap.GetPosition().y;
        //AutoPilot
        if (autoPilot)
        {
            if (!ap.CheckEnemy())
            {
                ap.SearchEnemy();
            }

            aim = true;

            //TargetReset
            if (Input.GetKeyDown(KeyCode.Alpha4))
            {
                ap.ForgetEnemy();
            }
            ap.SelectEnemy(KeyCode.Alpha4);

            if (ap.CheckEnemy())
            {
                newHeight = Mathf.Abs(enemyHeight - selfHeight);
            }
            else
            {
                newHeight = 0;
            }

            if (newHeight > heightSwitch && !Input.GetKey(KeyCode.Q))
            {
                aimMode = 1;
                if (!flightMode)
                {
                    ap.StartAction("AIM1", -1);
                    if (enemyAngleR < -15 && !Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.S) && !Input.GetKey(KeyCode.D))
                    {
                        ap.StartAction("a", 1);
                    }
                    if (enemyAngleR > 15 && !Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.S) && !Input.GetKey(KeyCode.D))
                    {
                        ap.StartAction("d", 1);
                    }
                }
                else
                {
                    if (enemyAngleR < -5 && !Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.S) && !Input.GetKey(KeyCode.D))
                    {
                        ap.StartAction("a", 1);
                    }
                    if (enemyAngleR > 5 && !Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.S) && !Input.GetKey(KeyCode.D))
                    {
                        ap.StartAction("d", 1);
                    }
                    if (enemyHeight - selfHeight > heightSwitch && !Input.GetKey(KeyCode.Space) && !Input.GetKey(KeyCode.F))
                    {
                        ap.StartAction("FMup", 1);
                    }
                    if (enemyHeight - selfHeight < -heightSwitch && !Input.GetKey(KeyCode.Space) && !Input.GetKey(KeyCode.F))
                    {
                        ap.StartAction("FMdown", 1);
                    }
                }
            }
            else if (!Input.GetKey(KeyCode.Q))
            {
                aimMode = 2;
                if (!flightMode)
                {
                    ap.StartAction("AIM1", -1);
                    if (enemyAngleR < -15 && !Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.S) && !Input.GetKey(KeyCode.D))
                    {
                        ap.StartAction("a", 1);
                    }
                    if (enemyAngleR > 15 && !Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.S) && !Input.GetKey(KeyCode.D))
                    {
                        ap.StartAction("d", 1);
                    }
                }
                else
                {
                    if (enemyAngleR < -5 && !Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.S) && !Input.GetKey(KeyCode.D))
                    {
                        ap.StartAction("a", 1);
                    }
                    if (enemyAngleR > 5 && !Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.S) && !Input.GetKey(KeyCode.D))
                    {
                        ap.StartAction("d", 1);
                    }
                    if (enemyHeight - selfHeight < heightSwitch && enemyHeight - selfHeight > -heightSwitch && !Input.GetKey(KeyCode.Space) && !Input.GetKey(KeyCode.F))
                    {
                        if (ap.GetVelocity().y < -10)
                        {
                            ap.StartAction("FMup", 1);
                        }
                        if (ap.GetVelocity().y > 10)
                        {
                            ap.StartAction("FMdown", 1);
                        }
                    }
                }
            }
            else
            {
                aimMode = 0;
                ap.EndAction("AIM1");
            }

            if (Input.GetKeyDown(KeyCode.Alpha3) || (Input.GetKeyDown(KeyCode.Alpha1) && aim))
            {
                ap.ForgetEnemy();
                autoPilot  = false;
                jetStriker = false;
                if (!flightMode)
                {
                    ap.StartAction("AIM1", -1);
                }
            }

            if (aimMode == 1 || aimMode == 2)
            {
                // Aim & Attack
                Vector3 ev = ap.GetEnemyVelocity() - ap.GetVelocity();
                float   ed = enemyDistance * 0.003f;
                Vector3 mv = ap.MulVec(ev, ed);

                //AutoAim
                Vector3 estPos = ap.AddVec(ap.GetEnemyPosition(), mv);
                ap.Aim(estPos);
            }
        }
        else
        {
            aimMode = 0;
            if (Input.GetKeyDown(KeyCode.Alpha3))
            {
                autoPilot = true;
            }
        }

        if (friendFlg)
        {
            if (!ap.CheckFriend())
            {
                ap.SearchFriend("");
            }

            if (!ap.CheckEnemy() && ap.CheckFriend())
            {
                searchAction = "SearchFriend";
                int ang = ap.GetFriendAngleR();
                if (ang > 15)
                {
                    ap.StartAction("d", 1);
                }
                else if (ang < -15)
                {
                    ap.StartAction("a", 1);
                }
                friendCount++;
                if (Input.GetKeyDown(KeyCode.Alpha5) || friendCount > 199)
                {
                    friendFlg   = false;
                    friendCount = 0;
                    ap.ForgetFriend();
                    searchAction = "Standby";
                }
            }
        }
        else
        {
            if (Input.GetKeyDown(KeyCode.Alpha5))
            {
                friendFlg    = true;
                searchAction = "SearchFriend";
            }
        }

        //AGD
        if (flightMode && (ap.GetGroundClearance() > 10 || Input.GetKey(KeyCode.Alpha6)))
        {
            ap.StartAction("AGD", 1);
        }

        //Display Information
        ap.Print(0, "Enemy : " + ap.GetEnemyName());
        ap.Print(1, "Distance : " + enemyDistance);
        ap.Print(2, "AngleR : " + ap.GetEnemyAngleR());
        ap.Print(3, "AimMode : " + aimMode);
        ap.Print(4, "EnemyHeight : " + ap.GetEnemyPosition().y);
        ap.Print(5, "SelfHeight : " + ap.GetPosition().y);
        ap.Print(6, "NewHeight : " + newHeight);
        ap.Print(7, "SearchAction : " + searchAction);
        ap.Print(8, "UpDownVel : " + ap.GetVelocity().y);
    }
Ejemplo n.º 7
0
    //----------------------------------------------------------------------------------------------
    // 更新処理
    //----------------------------------------------------------------------------------------------
    public override void OnUpdate(AutoPilot ap)
    {
        //射撃モード切替
        if (Input.GetKeyDown(KeyCode.LeftControl))
        {
            if (gunMode == 1)
            {
                gunMode = 2;
            }
            else if (gunMode == 2)
            {
                gunMode = 1;
            }
        }

        // 射撃制御
        int energy = ap.GetEnergy();

        if (Input.GetMouseButton(0))
        {
            if (energy > 5 && gunMode == 1)
            {
                ap.StartAction("ATK1-1", 1);
            }
            if (energy > 20 && gunMode == 2)
            {
                ap.StartAction("ATK1-2", 1);
            }
        }
        if (energy > 10 && Input.GetMouseButtonDown(1) && !missile)
        {
            missile = true;
            ap.StartAction("ATK2", -1);
        }
        else if (missile && (Input.GetMouseButtonDown(1) || energy <= 5))
        {
            missile = false;
            ap.EndAction("ATK2");
        }
        if (energy > 50 && Input.GetMouseButtonDown(2) && !shield)
        {
            shield = true;
            ap.StartAction("Shield", -1);
        }
        else if (shield && Input.GetMouseButtonDown(2))
        {
            shield = false;
            ap.EndAction("Shield");
        }

        //カメラモード切替
        if (Input.GetKeyDown(KeyCode.LeftShift))
        {
            if (cameraMode == 1)
            {
                cameraMode = 2;
            }
            else if (cameraMode == 2)
            {
                cameraMode = 3;
            }
            else if (cameraMode == 3)
            {
                cameraMode = 1;
            }
        }

        //カメラ制御
        if (cameraMode == 2)
        {
            ap.StartAction("Camera1", 1);
        }
        else if (cameraMode == 3)
        {
            ap.StartAction("Camera2", 1);
        }
    }
Ejemplo n.º 8
0
    //----------------------------------------------------------------------------------------------
    // 更新処理
    //----------------------------------------------------------------------------------------------
    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;
    }
Ejemplo n.º 9
0
    //----------------------------------------------------------------------------------------------
    // 更新処理
    //----------------------------------------------------------------------------------------------
    public override void OnUpdate(AutoPilot ap)
    {
        if (ap.CheckEnemy() == false && (aimMode == 3 || aimMode == 4))
        {
            ap.SearchEnemy();
        }

        enemyHeight = ap.GetEnemyPosition().y;
        selfHeight  = ap.GetPosition().y;

        if (ap.CheckEnemy() == true)
        {
            friendFlg = false;
            newHeight = Mathf.Abs(enemyHeight - selfHeight);
        }

        //カウント
        if (count < 3000)
        {
            count = count + 1;
        }
        else
        {
            count = 0;
        }

        if (count % 20 == 0)
        {
            random = Random.Range(0, 1000);
        }

        //ターゲットリセット
        ap.SearchThreat(MASK_ALL, 1000f);
        if (count % 600 == 0)
        {
            ap.SetCounterSearch(500);
        }

        float   enemyDistance = ap.GetEnemyDistance();
        float   enemyAngleR   = ap.GetEnemyAngleR();
        float   enemyAngleU   = ap.GetEnemyAngleU();
        Vector3 enemyVelocity = ap.GetEnemyVelocity() - ap.GetVelocity();

        //味方との連携
        int friendDistance = ap.GetFriendDistance();

        if (!ap.CheckFriend() && friendFlg)
        {
            ap.SearchFriend("");
        }

        if (friendDistance < 200 || !ap.CheckFriend() || ap.CheckEnemy() || !friendFlg)
        {
            moveStart = false;
            sampleDis = 0;
            checker   = 0;
        }

        //壁検知
        int wallZ  = ap.MeasureClearanceToWall(0, -5, 100, 25);
        int wallXL = ap.MeasureClearanceToWall(100, -5, 0, 10);
        int wallXR = ap.MeasureClearanceToWall(-100, -5, 0, 10);

        if (wallZ < 25 || wallXL < 10 || wallXR < 10)
        {
            wallCheck = true;
        }
        else
        {
            wallCheck = false;
        }

        // 移動による探索
        int random2 = random / 10;

        if (!ap.CheckEnemy() && !moveStart && !wallCheck)
        {
            //ランダム探索
            searchAction = "Random";
            if (random2 < 20)
            {
                ap.StartAction("s", 1);
            }
            else if (random2 < 25)
            {
                ap.StartAction("a", 1);
            }
            else if (random2 < 30)
            {
                ap.StartAction("d", 1);
            }
            else
            {
                ap.StartAction("w", 1);
            }
        }
        else if (!ap.CheckEnemy() && friendDistance >= 50 && ap.CheckFriend() && friendFlg && !wallCheck)
        {
            searchAction = "MoveToFriend";
            //味方と合流
            int ang = ap.GetFriendAngleR();
            if (ang > 30)
            {
                ap.StartAction("d", 1);
            }
            else if (ang < -30)
            {
                ap.StartAction("a", 1);
            }
            else
            {
                ap.StartAction("w", 1);
            }
        }
        else if (ap.CheckEnemy() && enemyDistance <= 50 && !wallCheck)
        {
            //回避機動
            searchAction = "Back";
            if (random2 < 70)
            {
                ap.StartAction("w", 1);
            }
            else if (random2 > 65)
            {
                ap.StartAction("a", 1);
            }
            else if (random2 > 60)
            {
                ap.StartAction("d", 1);
            }
            else
            {
                ap.StartAction("s", 1);
            }
        }
        else if (wallCheck)
        {
            //壁回避機動
            searchAction = "AvoidWall";
            if (random2 < 20 || wallXR < 10)
            {
                ap.StartAction("d", 1);
            }
            else if (random2 < 40 || wallXL < 10)
            {
                ap.StartAction("a", 1);
            }
            else if (random2 < 60)
            {
                ap.StartAction("d", 1);
            }
            else if (random2 < 80)
            {
                ap.StartAction("a", 1);
            }
            else
            {
                ap.StartAction("w", 1);
            }
        }
        else
        {
            //通常交戦機動
            searchAction = "Battle";
            if (random2 < 20)
            {
                ap.StartAction("s", 1);
            }
            else if (random2 < 25)
            {
                ap.StartAction("a", 1);
            }
            else if (random2 > 60)
            {
                ap.StartAction("w", 1);
            }
            else if (random2 > 55)
            {
                ap.StartAction("d", 1);
            }
        }

        //ランダムジャンプ
        if (count % 20 == 0 && random % 10 == 0)
        {
            ap.StartAction("上昇", 10);
        }

        //AI操縦
        if (autoPilot && ap.CheckEnemy())
        {
            //武装選択
            if (enemyDistance < 100 && random % 3 == 0)
            {
                attackAction = "Beamer";
            }
            else if (enemyDistance < 100 && random % 3 == 1)
            {
                attackAction = "Cannon";
            }
            else if (enemyDistance < 100 && random % 3 == 2)
            {
                attackAction = "Escape";
            }
            else if (enemyDistance < 200 && random % 3 == 0)
            {
                attackAction = "Escape";
            }
            else if (enemyDistance < 200 && random % 3 != 0)
            {
                attackAction = "Cannon";
            }
            else if (random % 3 == 0)
            {
                attackAction = "Escape";
            }
            else if (random % 3 == 1)
            {
                attackAction = "Cannon";
            }
            else if (random % 3 == 2)
            {
                attackAction = "Missile";
            }
            else
            {
                attackAction = "Cannon";
            }
        }
        else
        {
            attackAction = "Escape";
        }

        //対地対空機銃自動エイミングモード
        if (count % 100 == 10)
        {
            autoAim = true;
            if (newHeight > heightSwitch)
            {
                aimMode = 4;
                ap.StartAction("AIM1", -1);
                ap.EndAction("AIM2");
            }
            else
            {
                aimMode = 3;
                ap.StartAction("AIM2", -1);
                ap.EndAction("AIM1");
            }
        }

        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");
        }

        // 攻撃
        int energy = ap.GetEnergy();

        if (energy > 10 && (attackAction == "Cannon"))
        {
            ap.StartAction("ATK1", -1);
        }
        else
        {
            ap.EndAction("ATK1");
        }
        if (energy > 15 && (attackAction == "Beamer"))
        {
            ap.StartAction("ATK2", -1);
        }
        else
        {
            ap.EndAction("ATK2");
        }
        if (energy > 5 && (attackAction == "Missile"))
        {
            ap.StartAction("ATK3", -1);
            chargeCount++;
        }
        else if (energy > 5 && chargeCount > 0 && chargeCount < 2000)
        {
            chargeCount++;
        }
        else
        {
            chargeCount = 0;
            ap.EndAction("ATK3");
        }

        //情報表示
        ap.Print(0, "Enemy : " + ap.GetEnemyName());
        ap.Print(1, "Distance : " + enemyDistance);
        ap.Print(2, "AngleR : " + ap.GetEnemyAngleR());
        ap.Print(3, "AimMode : " + aimMode);
        ap.Print(4, "EnemyHeight : " + ap.GetEnemyPosition().y);
        ap.Print(5, "SelfHeight : " + ap.GetPosition().y);
        ap.Print(6, "Count : " + count);
        ap.Print(7, "Weapon : " + attackAction);
        ap.Print(8, "Search : " + searchAction);
        ap.Print(9, "WallCheck : " + wallCheck);

        // エイム
        float   ed = enemyDistance * 0.003f;
        Vector3 mv = ap.MulVec(enemyVelocity, ed);

        if (aimMode == 3 || aimMode == 4)
        {
            //機銃オートエイム
            Vector3 estPos = ap.AddVec(ap.GetEnemyPosition(), mv);
            ap.Aim(estPos);
        }

        oldHeight = newHeight;
    }
Ejemplo n.º 10
0
    //----------------------------------------------------------------------------------------------
    // 更新処理
    //----------------------------------------------------------------------------------------------
    public override void OnUpdate(AutoPilot ap)
    {
        //索敵(前方優先で近い敵を選択)
        if (ap.CheckEnemy() == false && aimMode == 2)
        {
            ap.SearchEnemy();
        }
        int enemyDistance = ap.GetEnemyDistance();

        // 攻撃
        int energy = ap.GetEnergy();

        if (energy > 15 && Input.GetMouseButton(0) && !Input.GetMouseButton(1))
        {
            ap.StartAction("ATK1", -1);
        }
        else
        {
            ap.EndAction("ATK1");
        }
        if (energy > 10 && Input.GetMouseButton(1) && !Input.GetMouseButton(0))
        {
            ap.StartAction("ATK2", -1);
        }
        else
        {
            ap.EndAction("ATK2");
        }

        //サイドブースト
        if (energy > 25 && Input.GetKey(KeyCode.Q))
        {
            ap.StartAction("Ldash", -1);
        }
        else if (energy < 10 || !Input.GetKey(KeyCode.Q))
        {
            ap.EndAction("Ldash");
        }
        if (energy > 25 && Input.GetKey(KeyCode.E))
        {
            ap.StartAction("Rdash", -1);
        }
        else if (energy < 10 || !Input.GetKey(KeyCode.E))
        {
            ap.EndAction("Rdash");
        }

        //サイコスキャニングモード
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            aimMode = 1;
            ap.StartAction("AIM1", -1);
            ap.EndAction("AIM2");
        }
        else if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            aimMode = 2;
            ap.StartAction("AIM1", -1);
            ap.StartAction("AIM2", -1);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            aimMode = 0;
            ap.EndAction("AIM1");
            ap.EndAction("AIM2");
        }

        //ターゲットリセット
        ap.SelectEnemy(KeyCode.Alpha2);

        //情報表示
        ap.Print(0, "Enemy : " + ap.GetEnemyName());
        ap.Print(1, "Distance : " + enemyDistance);
        ap.Print(2, "AngleR : " + ap.GetEnemyAngleR());
        ap.Print(3, "AimMode : " + aimMode);

        // エイム & 攻撃(敵の速度と距離を考慮して目標座標を補正)
        Vector3 ev = ap.GetEnemyVelocity();
        float   ed = enemyDistance * 0.002f;
        Vector3 mv = ap.MulVec(ev, ed);

        if (aimMode == 2)
        {
            Vector3 estPos = ap.AddVec(ap.GetEnemyPosition(), mv);
            ap.Aim(estPos);
        }
    }
Ejemplo n.º 11
0
    //----------------------------------------------------------------------------------------------
    // 更新処理
    //----------------------------------------------------------------------------------------------
    public override void OnUpdate(AutoPilot ap)
    {
        // 待機
        if (wait > 0)
        {
            --wait;
            ap.Log("wait=" + wait);
            return;
        }

        // 自爆演出(右回転+上昇→自爆)
        if (suicideWait > 0)
        {
            ap.TurnMover(ap.GetPosition() + ap.GetRight());
            ap.SetMoverAltitude(100);
            if (--suicideWait == 0)
            {
                ap.Suicide();
            }
            return;
        }

        // 索敵(ヘルスが満タンでなかったら前方優先で近い敵を選択,攻撃を検出したら捕捉対象を変更)
        if (!ap.CheckEnemy() && ap.GetHealth() < 100)
        {
            ap.SearchEnemy();
        }
        if (count % 600 == 0)
        {
            ap.SetCounterSearch(500);
        }

        float   enemyDistance = ap.GetEnemyDistance();
        float   enemyAngleR   = ap.GetEnemyAngleR();
        float   enemyAngleU   = ap.GetEnemyAngleU();
        Vector3 enemyVelocity = ap.GetEnemyVelocity();

        // 情報表示
        ap.Print(0, "Enemy : " + ap.GetEnemyName());
        ap.Print(1, "Distance : " + enemyDistance);
        ap.Print(2, "AngleR : " + enemyAngleR);
        ap.Print(3, "AngleU : " + enemyAngleU);
        ap.Print(4, "Speed(m/s) : " + Mathf.RoundToInt(Vector3.Magnitude(enemyVelocity)));
        if (Time.frameCount % 60 == 0)
        {
            ap.Print(8, "Random : " + Random.Range(0, 99));
        }

        if (ap.CheckEnemy())
        {
            var relVel = ap.GetEnemyVelocity() - ap.GetVelocity(); // 相対速度
            var estPos = ap.GetEnemyPosition() + relVel * 0.2f;    // 着弾予測座標
            ap.TurnMover(estPos);                                  // 旋回(Mover専用)
            ap.Aim(estPos);                                        // エイム
        }

        // 武器選択&通知
        var prevAttackAction = attackAction;
        int attackAngle      = 10;
        int attackEnergy     = 50;

        if (enemyDistance < 20)
        {
            attackAction = "Sword";
            attackAngle  = 60;
            attackEnergy = 20;
        }
        else if (chargeCount > 0)
        {
            attackAction = "Beamer";
        }
        else if (enemyDistance > 40 && enemyDistance < 250)
        {
            attackAction = "Cannon";
        }
        else if (enemyDistance > 300)
        {
            attackAction = "Beamer";
        }

        // 武器破損チェック(代替武器に変更,代替武器も破損していたら自爆開始)
        if (ap.GetSurvivalRate(attackAction) < 50)
        {
            attackAction = attackAction == "Cannon" ? "Beamer" : "Cannon";
        }
        if (ap.GetSurvivalRate(attackAction) < 50)
        {
            suicideWait = 180;
        }

        // 武器変更通知(ログ出力)
        bool isWeaponChanged = attackAction != prevAttackAction;

        if (isWeaponChanged)
        {
            ap.Log(attackAction + " is selected.");
        }

        // 攻撃中止
        int energy = ap.GetEnergy();

        if (Mathf.Abs(enemyAngleR) > attackAngle * 2 || energy < 10 || isWeaponChanged || !ap.CheckEnemy())
        {
            ap.EndAction("Sword");
            ap.EndAction("Cannon");
            ap.EndAction("Beamer");
        }

        // 攻撃開始(ダメージを受けた後ENに余裕があったら選択中の武器で攻撃,下方に敵がいたらグレネード)
        if (ap.GetHealth() < 100 && ap.CheckEnemy())
        {
            if (enemyAngleU < -70)
            {
                ap.StartAction("Grenade", 1);
            }
            else if (Mathf.Abs(enemyAngleR) < attackAngle && energy > attackEnergy)
            {
                ap.StartAction(attackAction, -1);
            }
        }

        // ランチャーチャージ開始(ダメージを受けた後ENに余裕があったら実行)
        if (chargeCount == 0 && energy > 60 && ap.GetHealth() < 100 && ap.CheckEnemy())
        {
            ap.StartAction("Launcher", -1);
        }

        // ランチャー発射(一定時間チャージした後ロックオン中またはEN切れなら実行)
        if (ap.CheckAction("Launcher"))
        {
            ++chargeCount;
            if (chargeCount > 200)
            {
                if (ap.CheckLockOn() || energy < 5 || chargeCount > 800)
                {
                    ap.EndAction("Launcher");
                    chargeCount = 0;
                }
            }
        }

        // 水平移動(脅威を回避してターゲットとの距離を保つ,至近距離なら近づく,暇なら開始座標に戻る)
        ap.SearchThreat(MASK_ALL, 100);
        if (ap.CheckThreat())
        {
            ap.StartAction(ap.GetThreatAngleR() < 0 ? "HoverR" : "HoverL", 10);
        }
        else if (ap.CheckEnemy())
        {
            if (energy < 30)
            {
                ap.StartAction("HoverB", 10);
            }
            else if (Mathf.Abs(enemyAngleR) < 45)
            {
                if (enemyDistance > 10 && enemyDistance < 50)
                {
                    ap.StartAction("HoverF", 10);
                }
                else if (enemyDistance < 100)
                {
                    ap.StartAction("HoverB", 10);
                }
                else if (enemyDistance > 500)
                {
                    ap.StartAction("HoverF", 10);
                }
            }
        }
        else if (Vector3.Distance(ap.GetPosition(), startPosition) > 50)
        {
            ap.TurnMover(startPosition);
            ap.SetMoverAltitude(10);
            ap.StartAction("HoverF", 10);
        }

        // 垂直移動(敵を少し見上げる)
        if (chargeCount > 0)
        {
            ap.SetMoverAltitude(100);
        }
        else if (ap.CheckEnemy())
        {
            if (enemyAngleU < 5)
            {
                ap.StartAction("HoverD", 10);
            }
            else if (enemyAngleU > 15)
            {
                ap.StartAction("HoverU", 10);
            }
        }

        // 転覆から復帰
        if (ap.GetTilt() > 60)
        {
            ap.Recover();
        }

        ++count;
    }
Ejemplo n.º 12
0
    //----------------------------------------------------------------------------------------------
    // 更新処理
    //----------------------------------------------------------------------------------------------
    public override void OnUpdate(AutoPilot ap)
    {
        // 攻撃
        int energy = ap.GetEnergy();

        //銃
        if (energy > 10 && Input.GetKey(Wep1))
        {
            ap.StartAction("ATK1", -1);
        }
        else
        {
            ap.EndAction("ATK1");
        }

        //ソード
        if (energy > 30 && (Input.GetKeyDown(SwordOn) || Input.GetKeyDown(SwordSlash)) && !sword)
        {
            sword = true;
        }
        else if (Input.GetKeyDown(SwordOn) && sword)
        {
            sword = false;
        }
        if (sword && energy > 10 && !spin)
        {
            ap.StartAction("ATK3BF", 1);
        }

        if (energy > 30 && !spin && Input.GetKeyDown(SwordSpin))
        {
            ap.StartAction("spin", -1);
            sword = false;
            spin  = true;
        }
        else if (spin && (energy < 10 || sword || Input.GetKeyDown(SwordSpin)))
        {
            ap.EndAction("spin");
            spin = false;
        }

        //ミサイル
        if (!missile && Input.GetKeyDown(Wep2))
        {
            ap.StartAction("ATK2", -1);
            if (missileMode == 1)
            {
                ap.StartAction("ATK2-1", -1);
            }
            else if (missileMode == 2)
            {
                ap.StartAction("ATK2-2", -1);
            }
            missile = true;
        }
        else if ((missile && Input.GetKeyDown(Wep2)) || energy < 10)
        {
            ap.EndAction("ATK2");
            ap.EndAction("ATK2-1");
            ap.EndAction("ATK2-2");
            missile = false;
        }

        //ミサイル切り替え
        if (Input.GetKeyDown(MissileChange) && missileMode == 1 && !missile)
        {
            missileMode = 2;
        }
        else if (Input.GetKeyDown(MissileChange) && missileMode == 2 && !missile)
        {
            missileMode = 1;
        }

        //ジャンプ
        if (energy > 40 && Input.GetKey(Jump))
        {
            ap.StartAction("Jump", -1);
        }
        else if (!Input.GetKey(Jump) || energy < 10)
        {
            ap.EndAction("Jump");
        }
    }
Ejemplo n.º 13
0
    public override void OnUpdate(AutoPilot ap)
    {
        /*
         * if(Counter == 0f){
         *      armoriserHUD.StartHUD(ap);
         * }else{
         *      armoriserHUD.StartUpHUD(ap, Counter);
         * }
         * Counter += 2f;
         * if(Counter > 361f){
         *      armoriserHUD.ContinueRend(ap);
         * }
         * armoriserHUD.SearchObject(ap);
         */

        /*
         * ap.Print(0,ap.GetFlightTime());
         * ap.Print(1,ap.GetVelocity().y);
         * ap.Print(2,Mathf.Floor(ap.GetSpeed()) * 3800 / 1000);
         * ap.Print(3,Counter);
         */

        //データロード
        if (Input.GetKey(KeyCode.F7) && Input.GetKey(KeyCode.LeftAlt))
        {
            if (PushedTab == false)
            {
                ReadAssignFile(ap);
                PushedTab = true;
            }
        }
        else
        {
            PushedTab = false;
        }



        if (Input.GetKey(AimAssist))
        {
            if (IsPushedAlpha2 == false && isAiming == false)
            {
                isAiming       = true;
                IsPushedAlpha2 = true;
            }
            else if (IsPushedAlpha2 == false && isAiming == true)
            {
                isAiming       = false;
                IsPushedAlpha2 = true;
            }
        }
        else
        {
            IsPushedAlpha2 = false;
        }
        if (Input.GetKey(BoostKey))
        {
            if (IsPushedF == false)
            {
                if (IsboostMode == false)
                {
                    IsboostMode = true;
                }
                else if (IsboostMode == true)
                {
                    IsboostMode = false;
                }
                IsPushedF = true;
            }
        }
        else
        {
            IsPushedF = false;
        }
        if (Input.GetKey(ChangeOptKey))
        {
            if (IsPushedKeyPad5 == false)
            {
                if (RancherMode == false)
                {
                    RancherMode = true;
                }
                else if (RancherMode == true)
                {
                    RancherMode = false;
                }
                if (AimingOpt == false)
                {
                    AimingOpt = true;
                }
                else if (AimingOpt == true)
                {
                    AimingOpt = false;
                }
                IsPushedKeyPad5 = true;
            }
        }
        else
        {
            IsPushedKeyPad5 = false;
        }
        if (Input.GetKey(AimKey))
        {
            if (IsPushedT == false)
            {
                if (Aiming == false)
                {
                    Aiming = true;
                }
                else if (Aiming == true)
                {
                    Aiming = false;
                }
                IsPushedT = true;
            }
        }
        else
        {
            IsPushedT = false;
        }
        if (Input.GetKey(LauncherKey))
        {
            if (IsPushedKeypad4 == false)
            {
                if (IsSGMode == false)
                {
                    IsSGMode = true;
                }
                else if (IsSGMode == true)
                {
                    IsSGMode = false;
                }
                IsPushedKeypad4 = true;
            }
        }
        else
        {
            IsPushedKeypad4 = false;
        }


        if (AimingOpt == false)
        {
            if (Input.GetKey(Wep1))
            {
                if (IsSGMode == false)
                {
                    ap.StartAction("Main", 1);
                }
                else if (IsSGMode == true)
                {
                    ap.StartAction("SG", 1);
                }
            }
            if (Input.GetKey(Wep2) && Input.GetKey(Wep3))
            {
                ap.StartAction("Sub2", 1);
            }
            else
            {
                if (Input.GetKey(Wep2))
                {
                    ap.StartAction("Sword", 1);
                }
                if (Input.GetKey(Wep3))
                {
                    ap.StartAction("Sub", 1);
                }
            }
        }
        else
        {
            if (Input.GetKey(Wep1))
            {
                if (IsSGMode == false)
                {
                    ap.StartAction("OptWepF1", 2);
                }
                else
                {
                    ap.StartAction("OptWepF5", 2);
                }
            }
            if (Input.GetKey(Wep2) && Input.GetKey(Wep3))
            {
                ap.StartAction("OptWepF4", 2);
            }
            else
            {
                if (Input.GetKey(Wep2))
                {
                    ap.StartAction("OptWepF2", 2);
                }
                if (Input.GetKey(Wep3))
                {
                    ap.StartAction("OptWepF3", 2);
                }
            }
        }


        if (ChangeAim == true)
        {
            if (Aiming == true && AimingOpt == false)
            {
                if (isChengedAiming == false)
                {
                    ap.StartAction("Aim", -1);
                    ap.EndAction("OptWep");
                    isChengedAiming    = true;
                    isChengedAimingOpt = false;
                }
            }
            else if (Aiming == true && AimingOpt == true)
            {
                if (isChengedAimingOpt == false)
                {
                    ap.StartAction("OptWep", -1);
                    ap.EndAction("Aim");
                    isChengedAiming    = false;
                    isChengedAimingOpt = true;
                }
            }
            else
            {
                ap.EndAction("OptWep");
                ap.EndAction("Aim");
                isChengedAiming    = false;
                isChengedAimingOpt = false;
            }
        }
        else
        {
            if (Aiming == true && AimingOpt == false)
            {
                if (isChengedAiming == false)
                {
                    ap.StartAction("Aim", -1);
                    ap.EndAction("OptWep");
                    isChengedAiming    = true;
                    isChengedAimingOpt = false;
                }
            }
            else if (Aiming == true && AimingOpt == true)
            {
                if (isChengedAimingOpt == false)
                {
                    ap.StartAction("OptWep", -1);
                    isChengedAiming    = false;
                    isChengedAimingOpt = true;
                }
            }
            else
            {
                ap.EndAction("OptWep");
                ap.EndAction("Aim");
                isChengedAiming    = false;
                isChengedAimingOpt = false;
            }
        }

        if (RancherMode == true)
        {
            if (Input.GetKey(Missile))
            {
                ap.StartAction("Launcher", 1);
            }
        }
        else
        {
            if (Input.GetKey(Missile))
            {
                ap.StartAction("Missile2", 1);
            }
        }


        if (ap.GetFlightTime() <= 0.5f)
        {
            if (Input.GetKey(MoveF) || Input.GetKey(MoveB) || Input.GetKey(MoveL) || Input.GetKey(KeyCode.E))
            {
                ap.StartAction("AnyAssig", 1);
            }

            if (Input.GetKey(MoveB) == false)
            {
                if (Input.GetKey(MoveF) == false)
                {
                    if (Input.GetKey(MoveL))
                    {
                        ap.StartAction("ThrustF", 1);
                        ap.StartAction("MoveL", 1);
                        ap.StartAction("WalkF", 1);
                    }
                    if (Input.GetKey(KeyCode.E))
                    {
                        ap.StartAction("ThrustF", 1);
                        ap.StartAction("MoveR", 1);
                        ap.StartAction("WalkF", 1);
                    }
                }
                else
                {
                    if (Input.GetKey(MoveL) || Input.GetKey(KeyCode.E))
                    {
                        if (Input.GetKey(MoveL))
                        {
                            ap.StartAction("ThrustF", 1);
                            ap.StartAction("MoveF", 1);
                            ap.StartAction("MoveL", 1);
                            ap.StartAction("WalkF", 1);
                        }
                        if (Input.GetKey(KeyCode.E))
                        {
                            ap.StartAction("ThrustF", 1);
                            ap.StartAction("MoveF", 1);
                            ap.StartAction("MoveR", 1);
                            ap.StartAction("WalkF", 1);
                        }
                    }
                    else
                    {
                        ap.StartAction("ThrustF", 1);
                        ap.StartAction("MoveF", 1);
                        ap.StartAction("WalkF", 1);
                    }
                }
            }
            else
            {
                if (Input.GetKey(MoveL) || Input.GetKey(KeyCode.E))
                {
                    if (Input.GetKey(MoveL))
                    {
                        ap.StartAction("ThrustB", 1);
                        ap.StartAction("MoveR", 1);
                        ap.StartAction("MoveB", 1);
                        ap.StartAction("WalkF", 1);
                    }
                    if (Input.GetKey(KeyCode.E))
                    {
                        ap.StartAction("ThrustB", 1);
                        ap.StartAction("MoveL", 1);
                        ap.StartAction("MoveB", 1);
                        ap.StartAction("WalkF", 1);
                    }
                }
                else
                {
                    ap.StartAction("ThrustB", 1);
                    ap.StartAction("MoveB", 1);
                    ap.StartAction("WalkF", 1);
                }
            }

            if (IsboostMode == true)
            {
                ap.EndAction("ThrustF");
                ap.EndAction("ThrustB");
                if (Input.GetKey(MoveF))
                {
                    ap.StartAction("SlideF", 20);
                    ap.EndAction("MoveF");
                }
                if (Input.GetKey(MoveB))
                {
                    ap.StartAction("SlideB", 1);
                    ap.EndAction("MoveB");
                }
                if (Input.GetKey(MoveL))
                {
                    ap.StartAction("SlideF", 20);
                    ap.StartAction("MoveL", 1);
                }
                if (Input.GetKey(KeyCode.E))
                {
                    ap.StartAction("SlideF", 20);
                    ap.StartAction("MoveR", 1);
                }
                if (Input.GetKey(MoveU))
                {
                    ap.StartAction("SlideU", 1);
                    ap.StartAction("SlideF", 20);
                    ap.EndAction("MoveU");
                }
                else if (ap.GetVelocity().y < 0)
                {
                    ap.StartAction("SlideU", 1);
                    ap.StartAction("SlideF", 20);
                    ap.EndAction("MoveU");
                }
                if (Input.GetKey(MoveD))
                {
                    //ap.StartAction("SlideD", 1);
                    //ap.EndAction("MoveD");
                }
            }
            else
            {
                if (ap.CheckAction("ThrustF"))
                {
                    if (Input.GetKey(MoveU))
                    {
                        ap.StartAction("MoveU", 1);
                        ap.StartAction("ThrustF", 1);
                    }
                    else if (Input.GetKey(MoveD))
                    {
                        ap.StartAction("MoveD", 1);
                        ap.StartAction("ThrustF", 1);
                    }
                }
                else if (ap.CheckAction("ThrustB"))
                {
                    if (Input.GetKey(MoveU))
                    {
                        ap.StartAction("MoveD", 1);
                        ap.StartAction("ThrustB", 1);
                    }
                    else if (Input.GetKey(MoveD))
                    {
                        ap.StartAction("MoveU", 1);
                        ap.StartAction("ThrustB", 1);
                    }
                }
                else
                {
                    if (Input.GetKey(MoveU))
                    {
                        ap.StartAction("MoveU", 1);
                        ap.StartAction("ThrustF", 1);
                    }
                    else if (Input.GetKey(MoveD))
                    {
                        ap.StartAction("MoveD", 1);
                        ap.StartAction("ThrustF", 1);
                    }
                }
            }
        }
        else
        {
            if (ap.GetGroundClearance() > 3)
            {
                ap.StartAction("FryMode", 1);
            }

            if (Input.GetKey(MoveF) || Input.GetKey(MoveB) || Input.GetKey(MoveL) || Input.GetKey(KeyCode.E))
            {
                ap.StartAction("AnyAssig", 1);
            }

            if (Input.GetKey(MoveB) == false)
            {
                if (Input.GetKey(MoveF) == false)
                {
                    if (Input.GetKey(MoveL))
                    {
                        ap.StartAction("ThrustF", 1);
                        ap.StartAction("MoveUL", 1);
                    }
                    if (Input.GetKey(KeyCode.E))
                    {
                        ap.StartAction("ThrustF", 1);
                        ap.StartAction("MoveUR", 1);
                    }
                }
                else
                {
                    if (Input.GetKey(MoveL) || Input.GetKey(KeyCode.E))
                    {
                        if (Input.GetKey(MoveL))
                        {
                            ap.StartAction("ThrustF", 1);
                            ap.StartAction("MoveUF", 1);
                            ap.StartAction("MoveUL", 1);
                        }
                        if (Input.GetKey(KeyCode.E))
                        {
                            ap.StartAction("ThrustF", 1);
                            ap.StartAction("MoveUF", 1);
                            ap.StartAction("MoveUR", 1);
                        }
                    }
                    else
                    {
                        ap.StartAction("ThrustF", 1);
                        ap.StartAction("MoveUF", 1);
                    }
                }
            }
            else
            {
                if (Input.GetKey(MoveL) || Input.GetKey(KeyCode.E))
                {
                    if (Input.GetKey(MoveL))
                    {
                        ap.StartAction("ThrustB", 1);
                        ap.StartAction("MoveULB", 1);
                        ap.StartAction("MoveUB", 1);
                    }
                    if (Input.GetKey(KeyCode.E))
                    {
                        ap.StartAction("ThrustB", 1);
                        ap.StartAction("MoveURB", 1);
                        ap.StartAction("MoveUB", 1);
                    }
                }
                else
                {
                    ap.StartAction("ThrustB", 1);
                    ap.StartAction("MoveUB", 1);
                }
            }



            if (IsboostMode == true)
            {
                ap.EndAction("ThrustF");
                ap.EndAction("ThrustB");
                if (Input.GetKey(MoveF))
                {
                    ap.StartAction("SlideF", 20);
                    ap.EndAction("MoveUF");
                }
                if (Input.GetKey(MoveB))
                {
                    ap.StartAction("SlideB", 1);
                    ap.EndAction("MoveB");
                }
                if (Input.GetKey(MoveL))
                {
                    ap.StartAction("SlideF", 20);
                    ap.EndAction("MoveL");
                }
                if (Input.GetKey(KeyCode.E))
                {
                    ap.StartAction("SlideF", 20);
                    ap.EndAction("MoveR");
                }
                if (ap.CheckAction("SlideF"))
                {
                    if (Input.GetKey(MoveU))
                    {
                        ap.StartAction("MoveU", 1);
                        ap.StartAction("SlideF", 20);
                    }
                    else if (Input.GetKey(MoveD))
                    {
                        ap.StartAction("MoveD", 1);
                        ap.StartAction("SlideF", 20);
                    }
                }
                else if (ap.CheckAction("SlideB"))
                {
                    if (Input.GetKey(MoveU))
                    {
                        ap.StartAction("MoveD", 1);
                        ap.StartAction("SlideB", 1);
                    }
                    else if (Input.GetKey(MoveD))
                    {
                        ap.StartAction("MoveU", 1);
                        ap.StartAction("SlideB", 1);
                    }
                }
                else
                {
                    if (Input.GetKey(MoveU))
                    {
                        ap.StartAction("MoveU", 1);
                        ap.StartAction("SlideF", 20);
                    }
                    else if (Input.GetKey(MoveD))
                    {
                        ap.StartAction("MoveD", 1);
                        ap.StartAction("SlideF", 20);
                    }
                }
            }
            else
            {
                if (ap.CheckAction("ThrustF"))
                {
                    if (Input.GetKey(MoveU))
                    {
                        ap.StartAction("MoveU", 1);
                        ap.StartAction("ThrustF", 1);
                    }
                    else if (Input.GetKey(MoveD))
                    {
                        ap.StartAction("MoveD", 1);
                        ap.StartAction("ThrustF", 1);
                    }
                }
                else if (ap.CheckAction("ThrustB"))
                {
                    if (Input.GetKey(MoveU))
                    {
                        ap.StartAction("MoveD", 1);
                        ap.StartAction("ThrustB", 1);
                    }
                    else if (Input.GetKey(MoveD))
                    {
                        ap.StartAction("MoveU", 1);
                        ap.StartAction("ThrustB", 1);
                    }
                }
                else
                {
                    if (Input.GetKey(MoveU))
                    {
                        ap.StartAction("MoveU", 1);
                        ap.StartAction("ThrustF", 1);
                    }
                    else if (Input.GetKey(MoveD))
                    {
                        ap.StartAction("MoveD", 1);
                        ap.StartAction("ThrustF", 1);
                    }
                }
            }
        }


        if (isAiming)
        {
            SavedVelocity  = new Vector3(Mathf.Lerp(SavedVelocity.x, ap.GetVelocity().normalized.x, 0.5f), Mathf.Lerp(SavedVelocity.y, ap.GetVelocity().normalized.y, 0.5f), Mathf.Lerp(SavedVelocity.z, ap.GetVelocity().normalized.z, 0.5f));
            ray            = new Ray(ap.AddVec(ap.GetPosition(), ap.MulVec(ap.GetCameraForward(), 10f)), ap.AddVec(ap.GetCameraForward(), ap.MulVec(SavedVelocity, 0.1f)));
            targetPosition = ray.GetPoint(1000f);
            ap.DrawLine3D(Color.yellow, ray.origin, targetPosition);
            if (Physics.Raycast(ray.origin, ray.direction, out hit, 1000f))
            {
                ap.Print(4, hit.transform.name);
                if (ap.MeasureClearance((int)(ap.AddVec(ap.GetCameraForward(), ap.MulVec(SavedVelocity, 0.05f)).x * 1000), (int)(ap.AddVec(ap.GetCameraForward(), ap.MulVec(SavedVelocity, 0.05f)).y * 1000), (int)(ap.AddVec(ap.GetCameraForward(), ap.MulVec(SavedVelocity, 0.05f)).z * 1000), (int)hit.distance + 50) != 9999)
                {
                    ap.DrawLine3D(Color.red, ap.GetPosition(), targetPosition);
                }
                else
                {
                    ap.DrawLine3D(Color.green, ap.GetPosition(), targetPosition);
                }
            }
            else
            {
                ap.DrawLine3D(Color.red, ap.GetPosition(), targetPosition);
            }
        }

        Vector2 MachineForward       = new Vector2(ap.GetForward().x, ap.GetForward().z);
        Vector2 CameraForward        = new Vector2(ap.GetCameraForward().x, ap.GetCameraForward().z);
        float   DotVariable          = Vector2.Dot(MachineForward.normalized, CameraForward.normalized);
        int     CalcAngleRWithCamera = ap.CalcAngleR(ap.GetCameraPosition());

        ap.Log(DotVariable);
        if (DotVariable < 0.6f)
        {
            if (CalcAngleRWithCamera < 0)
            {
                ap.StartAction("TurnR", 1);
            }
            else
            {
                ap.StartAction("TurnL", 1);
            }
        }
        else if (DotVariable < 0.8f)
        {
            if (CalcAngleRWithCamera < 0)
            {
                ap.StartAction("TurnR2", 1);
            }
            else
            {
                ap.StartAction("TurnL2", 1);
            }
        }
        else if (DotVariable < 0.98f)
        {
            if (CalcAngleRWithCamera < 0)
            {
                ap.StartAction("TurnR3", 1);
            }
            else
            {
                ap.StartAction("TurnL3", 1);
            }
        }

        /*
         * int DotVariable = ap.CalcAngleR(ap.GetCameraPosition());
         * ap.Log(DotVariable);
         * if(DotVariable > -90 && DotVariable < 90){
         *      if(ap.CalcAngleR(ap.GetCameraPosition()) < 0){
         *              ap.StartAction("TurnR", 2);
         *      }else{
         *              ap.StartAction("TurnL", 2);
         *      }
         * }else if(DotVariable > -170 && DotVariable < 170){
         *      if(ap.CalcAngleR(ap.GetCameraPosition()) < 0){
         *              ap.StartAction("TurnR2", 2);
         *      }else{
         *              ap.StartAction("TurnL2", 2);
         *      }
         * }else if(DotVariable > -175 && DotVariable < 175){
         *      if(ap.CalcAngleR(ap.GetCameraPosition()) < 0){
         *              ap.StartAction("TurnR3", 2);
         *      }else{
         *              ap.StartAction("TurnL3", 2);
         *      }
         * }
         */
    }
Ejemplo n.º 14
0
    //----------------------------------------------------------------------------------------------
    // 更新処理
    //----------------------------------------------------------------------------------------------
    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())
        {
            newHeight = Mathf.Abs(enemyHeight - selfHeight);
        }
        else
        {
            newHeight = 0f;
        }

        //対地対空機銃自動エイミングモード
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            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 > 15 && Input.GetMouseButton(1))
        {
            ap.StartAction("ATK2", -1);
        }
        else
        {
            ap.EndAction("ATK2");
        }
        if (!missile && energy > 5 && Input.GetMouseButtonDown(2))
        {
            ap.StartAction("ATK3", -1);
            missile = true;
        }
        else if (missile && (Input.GetMouseButtonDown(2) || energy < 5))
        {
            ap.EndAction("ATK3");
            missile = false;
        }

        //エイムモード
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            aimMode = 1; //手動モード
            ap.StartAction("AIM1", -1);
            ap.EndAction("AIM2");
            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, "Enemy : " + ap.GetEnemyName());
        ap.Print(1, "Distance : " + enemyDistance);
        ap.Print(2, "AngleR : " + ap.GetEnemyAngleR());
        ap.Print(3, "AimMode : " + aimMode);
        ap.Print(4, "EnemyHeight : " + ap.GetEnemyPosition().y);
        ap.Print(5, "SelfHeight : " + ap.GetPosition().y);

        // エイム & 攻撃(敵の速度と距離を考慮して目標座標を補正)
        Vector3 ev = ap.GetEnemyVelocity() - ap.GetVelocity();
        float   ed = enemyDistance * 0.003f;
        Vector3 mv = ap.MulVec(ev, ed);

        if (aimMode == 3 || aimMode == 4)
        {
            //機銃オートエイム
            Vector3 estPos = ap.AddVec(ap.GetEnemyPosition(), mv);
            ap.Aim(estPos);
        }

        oldHeight = newHeight;
    }
Ejemplo n.º 15
0
    //----------------------------------------------------------------------------------------------
    // 更新処理
    //----------------------------------------------------------------------------------------------
    public override void OnUpdate(AutoPilot ap)
    {
        // 攻撃
        int energy = ap.GetEnergy();

        if ((Input.GetKeyDown(BodyFix) && fixFlg) || Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.S) ||
            Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.D))
        {
            fixFlg    = false;
            fireCount = FIRE_COUNT_MAX;
        }
        else if ((Input.GetKeyDown(BodyFix) && !fixFlg) || Input.GetKeyDown(Wep1))
        {
            fixFlg = true;
        }

        if (fixFlg)
        {
            if (fireCount > 0)
            {
                fireCount = fireCount - 1;
            }
            ap.StartAction("FIX", 1);
        }

        //銃
        if (energy > 30 && fireCount == 0 && Input.GetKey(Wep1) && fixFlg && !Input.GetKeyDown(KeyCode.W) && !Input.GetKeyDown(KeyCode.S) &&
            !Input.GetKeyDown(KeyCode.A) && !Input.GetKeyDown(KeyCode.D))
        {
            ap.StartAction("ATK1", 1);
        }

        //ミサイル
        if (!missile && Input.GetKeyDown(Wep2))
        {
            ap.StartAction("ATK2", -1);
            if (missileMode == 1)
            {
                ap.StartAction("ATK2-1", -1);
            }
            else if (missileMode == 2)
            {
                ap.StartAction("ATK2-2", -1);
            }
            missile = true;
        }
        else if ((missile && Input.GetKeyDown(Wep2)) || energy < 10)
        {
            ap.EndAction("ATK2");
            ap.EndAction("ATK2-1");
            ap.EndAction("ATK2-2");
            missile = false;
        }

        //ミサイル切り替え
        if (Input.GetKeyDown(MissileChange) && missileMode == 1 && !missile)
        {
            missileMode = 2;
        }
        else if (Input.GetKeyDown(MissileChange) && missileMode == 2 && !missile)
        {
            missileMode = 1;
        }

        //ジャンプ
        if (energy > 65 && Input.GetKey(Jump))
        {
            ap.StartAction("Jump", -1);
            fixFlg    = false;
            fireCount = FIRE_COUNT_MAX;
        }
        else if (!Input.GetKey(Jump) || energy < 10)
        {
            ap.EndAction("Jump");
        }

        if (Input.GetKeyDown(CamChange) && camCount < 2)
        {
            camCount = camCount + 1;
        }
        else if (Input.GetKeyDown(CamChange) && camCount >= 2)
        {
            camCount = 0;
        }

        if (camCount == 1)
        {
            ap.StartAction("Camera", 1);
        }
        else if (camCount == 2)
        {
            ap.StartAction("CamPlus", 1);
        }
    }
Ejemplo n.º 16
0
    //----------------------------------------------------------------------------------------------
    // 更新処理
    //----------------------------------------------------------------------------------------------
    public override void OnUpdate(AutoPilot ap)
    {
        //グリズリーのAIをやっつけで自動化したので余計な変数が多々あります よって解説付き

        //敵を捕捉していないときに索敵します
        if (ap.CheckEnemy() == false)
        {
            ap.SearchEnemy();
        }

        //敵と味方の高さ(Y軸)を記録
        enemyHeight = ap.GetEnemyPosition().y;
        selfHeight  = ap.GetPosition().y;

        //敵がいるときは友軍との合流をあきらめ(1行目)、自機と敵機の高さの差を測ります(2行目)
        if (ap.CheckEnemy() == true)
        {
            friendFlg = false;
            newHeight = Mathf.Abs(enemyHeight - selfHeight);
        }

        //カウント(一定時間ごとの周期的な動作に利用します)
        if (count < 3000)
        {
            count = count + 1;
        }
        else
        {
            count = 0;
        }

        //20フレームごとに乱数を更新します
        if (count % 20 == 0)
        {
            random = Random.Range(0, 1000);
        }

        //ターゲットリセット
        ap.SearchThreat(MASK_ALL, 1000f);
        if (count % 600 == 0)
        {
            ap.SetCounterSearch(500);
        }

        //敵の方向・距離・相対的な移動速度を取得
        float   enemyDistance = ap.GetEnemyDistance();
        float   enemyAngleR   = ap.GetEnemyAngleR();
        float   enemyAngleU   = ap.GetEnemyAngleU();
        Vector3 enemyVelocity = ap.GetEnemyVelocity() - ap.GetVelocity();

        //味方との連携用
        int friendDistance = ap.GetFriendDistance();

        if (!ap.CheckFriend() && friendFlg)
        {
            ap.SearchFriend("");
            moveStart = true;
        }

        if (friendDistance < 200 || !ap.CheckFriend() || ap.CheckEnemy() || !friendFlg)
        {
            moveStart = false;
        }

        //壁検知
        int wallZ  = ap.MeasureClearanceToWall(0, -5, 100, 25);
        int wallXL = ap.MeasureClearanceToWall(100, -5, 0, 10);
        int wallXR = ap.MeasureClearanceToWall(-100, -5, 0, 10);

        if (wallZ < 25 || wallXL < 10 || wallXR < 10)
        {
            wallCheck = true;
        }
        else
        {
            wallCheck = false;
        }

        // 移動方法
        int random2 = random / 10;

        if (!ap.CheckEnemy() && !moveStart && !wallCheck)
        {
            //ランダム探索
            searchAction = "Random";
            if (random2 < 20)
            {
                ap.StartAction("s", 1);
            }
            else if (random2 < 25)
            {
                ap.StartAction("a", 1);
            }
            else if (random2 < 30)
            {
                ap.StartAction("d", 1);
            }
            else
            {
                ap.StartAction("w", 1);
            }
        }
        else if (!ap.CheckEnemy() && friendDistance >= 50 && ap.CheckFriend() && friendFlg && !wallCheck)
        {
            searchAction = "MoveToFriend";
            //味方と合流
            int ang = ap.GetFriendAngleR();
            if (ang > 30)
            {
                ap.StartAction("d", 1);
            }
            else if (ang < -30)
            {
                ap.StartAction("a", 1);
            }
            else
            {
                ap.StartAction("w", 1);
            }
        }
        else if (ap.CheckEnemy() && enemyDistance <= 50 && !wallCheck)
        {
            //回避機動
            searchAction = "Back";
            if (random2 < 70)
            {
                ap.StartAction("w", 1);
            }
            else if (random2 > 65)
            {
                ap.StartAction("a", 1);
            }
            else if (random2 > 60)
            {
                ap.StartAction("d", 1);
            }
            else
            {
                ap.StartAction("s", 1);
            }
        }
        else if (wallCheck)
        {
            //壁回避機動
            searchAction = "AvoidWall";
            if (random2 < 20 || wallXR < 10)
            {
                ap.StartAction("d", 1);
            }
            else if (random2 < 40 || wallXL < 10)
            {
                ap.StartAction("a", 1);
            }
            else if (random2 < 60)
            {
                ap.StartAction("d", 1);
            }
            else if (random2 < 80)
            {
                ap.StartAction("a", 1);
            }
            else
            {
                ap.StartAction("w", 1);
            }
        }
        else
        {
            //通常交戦機動
            searchAction = "Battle";
            if (random2 < 20)
            {
                ap.StartAction("s", 1);
            }
            else if (random2 < 25)
            {
                ap.StartAction("a", 1);
            }
            else if (random2 > 60)
            {
                ap.StartAction("w", 1);
            }
            else if (random2 > 55)
            {
                ap.StartAction("d", 1);
            }
        }

        //ランダムにジャンプ
        if (count % 20 == 0 && random % 10 == 0)
        {
            ap.StartAction("上昇", 10);
        }

        //AI操縦時の武装選択
        if (autoPilot && ap.CheckEnemy())
        {
            if (enemyDistance < 100 && random % 3 == 0)
            {
                attackAction = "Beamer";
            }
            else if (enemyDistance < 100 && random % 3 == 1)
            {
                attackAction = "Cannon";
            }
            else if (enemyDistance < 100 && random % 3 == 2)
            {
                attackAction = "Escape";
            }
            else if (enemyDistance < 200 && random % 3 == 0)
            {
                attackAction = "Escape";
            }
            else if (enemyDistance < 200 && random % 3 != 0)
            {
                attackAction = "Cannon";
            }
            else if (random % 3 == 0)
            {
                attackAction = "Escape";
            }
            else if (random % 3 == 1)
            {
                attackAction = "Cannon";
            }
            else if (random % 3 == 2)
            {
                attackAction = "Missile";
            }
            else
            {
                attackAction = "Cannon";
            }
        }
        else
        {
            attackAction = "Escape";
        }

        //対地・対空エイミングモード自動切替
        if (newHeight > heightSwitch && autoAim)
        {
            aimMode = 4;
            ap.StartAction("AIM1", 1);
            ap.EndAction("AIM2");
        }
        if (newHeight <= heightSwitch && autoAim)
        {
            aimMode = 3;
            ap.StartAction("AIM2", 1);
            ap.EndAction("AIM1");
        }

        //自動攻撃(エネルギー切れ防止機構付き)
        int energy = ap.GetEnergy();

        if (energy > 10 && (attackAction == "Cannon"))
        {
            ap.StartAction("ATK1", -1);
        }
        else
        {
            ap.EndAction("ATK1");
        }
        if (energy > 15 && (attackAction == "Beamer"))
        {
            ap.StartAction("ATK2", -1);
        }
        else
        {
            ap.EndAction("ATK2");
        }
        if (energy > 5 && (attackAction == "Missile"))
        {
            ap.StartAction("ATK3", -1);
            chargeCount++;
        }
        else if (energy > 5 && chargeCount > 0 && chargeCount < 2000)
        {
            chargeCount++;
        }
        else
        {
            chargeCount = 0;
            ap.EndAction("ATK3");
        }

        //情報表示
        ap.Print(0, "Enemy : " + ap.GetEnemyName());
        ap.Print(1, "Distance : " + enemyDistance);
        ap.Print(2, "AngleR : " + ap.GetEnemyAngleR());
        ap.Print(3, "AimMode : " + aimMode);
        ap.Print(4, "EnemyHeight : " + ap.GetEnemyPosition().y);
        ap.Print(5, "SelfHeight : " + ap.GetPosition().y);
        ap.Print(6, "Count : " + count);
        ap.Print(7, "Weapon : " + attackAction);
        ap.Print(8, "Search : " + searchAction);
        ap.Print(9, "WallCheck : " + wallCheck);

        //エイム用データ取得
        float   ed     = enemyDistance * 0.003f;
        Vector3 mv     = ap.MulVec(enemyVelocity, ed);
        Vector3 estPos = ap.AddVec(ap.GetEnemyPosition(), mv);

        ap.Aim(estPos);
    }
Ejemplo n.º 17
0
    //----------------------------------------------------------------------------------------------
    // 更新処理
    //----------------------------------------------------------------------------------------------
    public override void OnUpdate(AutoPilot ap)
    {
        //移動
        if (Input.GetKey(KeyCode.W))
        {
            ap.StartAction("foot", 1);
            ap.StartAction("Rforth", 1);
        }
        else if (Input.GetKey(KeyCode.S))
        {
            ap.StartAction("foot2", 1);
            ap.StartAction("Rforth", 1);
        }
        else if (Input.GetKey(KeyCode.A))
        {
            ap.StartAction("foot", 1);
            ap.StartAction("Rback", 1);
        }
        else if (Input.GetKey(KeyCode.D))
        {
            ap.StartAction("foot2", 1);
            ap.StartAction("Rback", 1);
        }

        // 攻撃
        //銃・キャノン
        if (gunMode == 1 && Input.GetKeyDown(KeyCode.Q))
        {
            gunMode = 2;
        }
        else if (gunMode == 2 && Input.GetKeyDown(KeyCode.Q))
        {
            gunMode = 1;
        }
        int energy = ap.GetEnergy();

        if (energy > 10 && Input.GetMouseButton(0) && gunMode == 1)
        {
            ap.StartAction("ATK1", 1);
        }
        else if (energy > 50 && Input.GetMouseButton(0) && gunMode == 2)
        {
            ap.StartAction("ATK4", 1);
        }

        //ミサイル
        if (!missile && energy > 15 && Input.GetMouseButtonDown(1))
        {
            ap.StartAction("ATK2", -1);
            missile = true;
        }
        else if ((missile && Input.GetMouseButtonDown(1)) || energy < 10)
        {
            ap.EndAction("ATK2");
            missile = false;
        }

        //ソード
        if (energy > 15 && Input.GetMouseButtonDown(2) && !sword)
        {
            ap.StartAction("ATK3", -1);
            sword = true;
        }
        else if ((Input.GetMouseButtonDown(2) || energy < 10) && sword)
        {
            ap.EndAction("ATK3");
            sword = false;
        }

        //カメラ
        if (Input.GetKeyDown(KeyCode.LeftShift) && !camera)
        {
            camera = true;
        }
        else if (Input.GetKeyDown(KeyCode.LeftShift) && camera)
        {
            camera = false;
        }

        if (camera && cameraZoom == 1)
        {
            ap.StartAction("Camera", 1);
            if (Input.GetKeyDown(KeyCode.E))
            {
                cameraZoom = 2;
            }
        }
        else if (camera && cameraZoom == 2)
        {
            ap.StartAction("Camera2", 1);
            if (Input.GetKeyDown(KeyCode.E))
            {
                cameraZoom = 1;
            }
        }
    }
Ejemplo n.º 18
0
    //----------------------------------------------------------------------------------------------
    // 更新処理
    //----------------------------------------------------------------------------------------------
    public override void OnUpdate(AutoPilot ap)
    {
        // 攻撃
        int energy = ap.GetEnergy();

        if (Input.GetMouseButton(0))
        {
            if (energy > 15 && gunMode == 1)
            {
                ap.StartAction("ATK1-1", 1);
            }
            if (energy > 15 && gunMode == 2)
            {
                ap.StartAction("ATK1-2", 1);
            }
            if (gunMode == 3 && energy > 30)
            {
                ap.StartAction("ATK1-3", 1);
            }
        }
        if (energy > 10 && Input.GetMouseButtonDown(1) && !missile)
        {
            missile = true;
            ap.StartAction("ATK2", -1);
        }
        else if (missile && (Input.GetMouseButtonDown(1) || energy <= 10))
        {
            missile = false;
            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");
        }

        //射撃モード切替
        if (Input.GetKeyDown(KeyCode.LeftControl))
        {
            if (gunMode == 1)
            {
                gunMode = 2;
            }
            else if (gunMode == 2)
            {
                gunMode = 3;
            }
            else if (gunMode == 3)
            {
                gunMode = 1;
            }
        }
    }