Esempio n. 1
0
    public static void DrawLines(AutoPilot ap)
    {
        var pos1 = ap.GetPosition();

        for (int i = 0; i < 5000; ++i)
        {
            var pos2 = new Vector3(Random.Range(-100f, 100f), 10f, Random.Range(-100f, 100f));
            var col  = new Color(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f));
            ap.DrawLine3D(col, pos1, pos2);
        }
    }
Esempio n. 2
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);
         *      }
         * }
         */
    }
Esempio n. 3
0
    public void LockOn(Vector3 botPos, Vector3 botVel, GameObject LockBot)
    {
        Vector3 LockBotPos = LockBot.transform.position;
        //Aim Estimator
        Vector3 velocity = ((LockBotPos - posPrev) / Time.deltaTime);
        Vector3 relVel   = (velocity);
        float   dist     = Vector3.Distance(botPos, LockBotPos);

        //Random Maker
        Vector3 Randomizer = new Vector3(UnityEngine.Random.Range(-randomMax, randomMax), UnityEngine.Random.Range(-randomMax, randomMax), UnityEngine.Random.Range(-randomMax, randomMax));
        //Offset Maker
        Vector3 OffsetValue = LockBot.transform.TransformPoint(new Vector3(xOffset, yOffset, zOffset)) - LockBotPos;

        Vector3 estPosW = Util.PosEstimate(botPos, LockBotPos, botVel, velocity, UnityEngine.Random.Range(380, 420));
        Vector3 estPos  = estPosW;

        posPrev = LockBotPos;

        //Orbit Maker
        float   xCircle     = Mathf.Sin(Mathf.PI * (Time.time / orbitSpeed)) * orbitRadius;
        float   zCircle     = Mathf.Cos(Mathf.PI * (Time.time / orbitSpeed)) * orbitRadius;
        Vector3 orbitCircle = new Vector3(xCircle, orbitHeight, zCircle);

        //Draw Line Stuff
        if (drawLines)
        {
            // ap.DrawLine3D(Color.red,botPos,LockBotPos);
            ap.DrawLine3D(Color.green, LockBotPos, LockBotPos + orbitCircle);
            ap.DrawLine3D(Color.blue, LockBotPos + (LockBot.transform.right * 10), LockBotPos + (LockBot.transform.forward * 10));
            ap.DrawLine3D(Color.blue, LockBotPos + (LockBot.transform.right * -10), LockBotPos + (LockBot.transform.forward * 10));
            ap.DrawLine3D(Color.magenta, LockBotPos, LockBotPos + OffsetValue);
            ap.DrawLine3D(Color.yellow, LockBotPos + OffsetValue, OffsetValue + estPos);

            // ap.DrawLine3D(Color.black,ap.GetCameraPosition(),hitPos);
        }
        //Lock On Toggle System
        if (lockOnStat)
        {
            ap.SetAimPosition(1, Randomizer + OffsetValue + estPos);
            // ap.SetAimPosition(5,LockBotPos + Randomizer+OffsetValue+estPos);
            // ap.SetAimPosition(5,LockBot.transform.position+orbitCircle);
        }
        else
        {
            ap.SetAimPosition(1, new Vector3(0, 0, 0));
            // ap.SetAimPosition(5,new Vector3(0,0,0));
            // ap.SetAimPosition(6,new Vector3(0,0,0));
        }

        //Debug text
        switch (selectMode)
        {
        case 1:
            modeText = "X Offset";
            break;

        case 2:
            modeText = "Y Offset";
            break;

        case 3:
            modeText = "Z Offset";
            break;

        case 4:
            modeText = "Random";
            break;

        case 5:
            modeText = "Orbit Radius";
            break;

        case 6:
            modeText = "Orbit Height";
            break;

        case 7:
            modeText = "Orbit Speed";
            break;
        }

        // ap.Print(0, LockBot.name);
        // ap.Print(1, "range  : " + dist );
        // ap.Print(2, "Mode : " + modeText );
        // ap.Print(3, "Rng : " + randomMax );
        // ap.Print(4, "Offset : " + new Vector3(xOffset,yOffset,zOffset) );
        // ap.Print(5, "Orbit : " + new Vector3(orbitRadius,orbitHeight,orbitSpeed) );
    }