Exemple #1
0
    IEnumerator CatchMinigame(Fish fish)
    {
        catchStarted = true;
        float startTime = Time.time;
        float bobTime   = Random.Range(fish.minBobTime, fish.maxBobTime);
        float catchTime = Random.Range(fish.minCatchTime, fish.maxCatchTime);

        catchTime = bobTime + catchTime;
        WaterPhysics water      = FindObjectOfType <WaterPhysics>();
        float        startLevel = water.waterLevel;

        while (Time.time - startTime < bobTime)
        {
            water.waterLevel -= 0.1f;
            yield return(new WaitForSeconds(Random.Range(0.2f, 0.4f)));

            water.waterLevel += 0.1f;
            yield return(new WaitForSeconds(Random.Range(0.2f, 0.4f)));
        }
        while (Time.time - startTime < catchTime)
        {
            water.waterLevel = startLevel - 0.2f;
            canCatch         = true;
            caughtFish       = fish;
            yield return(new WaitForEndOfFrame());
        }
        canCatch = false;
        if (!reelStarted)
        {
            caughtFish = null;
        }
        catchStarted     = false;
        water.waterLevel = startLevel;
    }
Exemple #2
0
 void Start()
 {
     waterPhysics = gameObject.GetComponent <WaterPhysics>();
     parentPos    = transform;
     initArray();
     cubeArrayPre = cubeArray;
     //fillArray();
     arrayChange();
     positionCubes();
 }
        public static void Postfix(MFDPTacticalSituationDisplay __instance, Actor a)
        {
            Vector3 position  = __instance.tsc.weaponManager.actor.position;
            Vector3 position2 = a.position;
            int     num       = Mathf.RoundToInt(VectorUtils.Bearing(position, position2));
            int     num2      = Mathf.RoundToInt(__instance.measurements.ConvertedDistance(Vector3.Distance(position, position2)));

            if (__instance.measurements.distanceMode == MeasurementManager.DistanceModes.Feet || __instance.measurements.distanceMode == MeasurementManager.DistanceModes.Meters)
            {
                num2 /= 1000;
            }
            float num3 = Mathf.RoundToInt(__instance.measurements.ConvertedAltitude(WaterPhysics.GetAltitude(position2)) / 100f) / 10f;

            __instance.braNumsText.text = string.Format("{0}\n{1}\n{2}", num, num2, num3);
        }
Exemple #4
0
    // Use this for initialization
    void Start()
    {
        uiController = GameObject.FindGameObjectWithTag ("UI").GetComponent<UIController> ();
        player = GameObject.FindGameObjectWithTag ("Player");
        seatPos = GameObject.FindGameObjectWithTag ("Seat").GetComponent<Transform> ();
        camSeatPos = GameObject.FindGameObjectWithTag ("SeatCamPos").GetComponent<Transform> ();
        boatUse = transform.root.GetComponent<WaterPhysics> ();

        player.transform.position = seatPos.position;
        player.transform.parent = seatPos.parent;
        player.gameObject.GetComponent<Character_Movement> ().enabled = false;
        player.gameObject.GetComponent<CharacterController> ().enabled = false;
        Camera.main.GetComponent<CamaraFollow>().distance = 4.1f;
        Camera.main.transform.position = camSeatPos.position;
        Camera.main.transform.rotation = camSeatPos.rotation;
        inICUse = true;
    }
Exemple #5
0
    // Use this for initialization
    void Start()
    {
        objectCollider = GetComponent <BoxCollider>();
        Vector3[] corners      = new Vector3[4];
        Vector3[] points       = new Vector3[xPointCount * zPointCount];
        Vector3   colliderSize = objectCollider.bounds.size;

        objectRB = GetComponent <Rigidbody>();

        corners[0] = objectCollider.bounds.min;
        for (int z = 1, i = 0; z <= zPointCount; z++)
        {
            for (int x = 1; x <= xPointCount; x++, i++)
            {
                points[i] = corners[0] +
                            new Vector3(colliderSize.x / xPointCount * x, 0, colliderSize.z / zPointCount * z);
            }
        }

        joints = new GameObject("joints");
        //joints.transform.SetParent(transform);
        joints.transform.position = transform.position + jointPosOffset;
        MoveJoints mj = joints.AddComponent <MoveJoints>();

        mj.effectedObjectTransform = transform;

        foreach (var point in points)
        {
            Vector3 preStartPos    = point + jointPosOffset;
            float   yPhysicsOffset = WaterPhysics.CalculateTrianglePointHeight(preStartPos);
            preStartPos.y += yPhysicsOffset;

            GameObject joint = Instantiate(jointPrefab, preStartPos, Quaternion.identity);

            SpringJoint sj = joint.GetComponent <SpringJoint>();
            sj.connectedAnchor = transform.InverseTransformPoint(point);
            sj.connectedBody   = objectRB;
            sj.maxDistance     = Vector3.Distance(point, joint.transform.position);
            joint.transform.SetParent(joints.transform);
        }

        objectRB.maxAngularVelocity = 2f;
    }
Exemple #6
0
 public void DisablePhysics()
 {
     lock( physicsLock ) {
         sandPhysics = null;
         snowPhysics = null;
         plantPhysics = null;
         waterPhysics = null;
         lavaPhysics = null;
         tickQueue.Clear();
         physicsEnabled = false;
     }
     Logger.Log( "Map: Physics disabled." );
 }
Exemple #7
0
 public void EnablePhysics()
 {
     Stopwatch sw = Stopwatch.StartNew();
     lock( physicsLock ) {
         sandPhysics = new SandPhysics( this );
         snowPhysics = new SnowPhysics( this );
         plantPhysics = new PlantPhysics( this );
         waterPhysics = new WaterPhysics( this );
         lavaPhysics = new LavaPhysics( this );
         physicsEnabled = true;
     }
     sw.Stop();
     Logger.Log( "Map: Physics enabled in {0}ms", sw.ElapsedMilliseconds );
 }
Exemple #8
0
 // Use this for initialization
 void Start()
 {
     waterPhys = GetComponent<WaterPhysics> ();
     windPower = GameObject.FindGameObjectWithTag ("GameController").GetComponent<WindController>();
 }
 // Start is called before the first frame update
 void Start()
 {
     generateCubes = gameObject.GetComponent <GenerateCubes>();
     waterPhysics  = gameObject.GetComponent <WaterPhysics>();
     chunk         = gameObject.GetComponent <Chunk>();
 }
Exemple #10
0
 // Use this for initialization
 void Start()
 {
     waterPhysicsScript = GetComponent <WaterPhysics>();
     theAM           = FindObjectOfType <AudioManager>();
     bossMusicScript = FindObjectOfType <BossMusicSwitch>();
 }
Exemple #11
0
    public IEnumerator main()
    {
        Vector3 PitchYawRoll = new Vector3();
        bool    tiltC        = false;

        while (VTMapManager.fetch == null || !VTMapManager.fetch.scenarioReady)
        {
            yield return(null);
        }
        foreach (var thing in FindObjectsOfType <AIPilot>())
        {
            Stuff += thing.gameObject.name + " ";
        }
        goOn = true;
        while (GoOn == false)
        {
            Stuff = "";
            foreach (var thing in FindObjectsOfType <AIPilot>())
            {
                Stuff += thing.gameObject.name + " ";
            }
            yield return(null);
        }
        AIPilot toControl = new AIPilot();
        bool    found     = false;

        AIPilot[] wut = FindObjectsOfType <AIPilot>();
        for (int i = 0; i < wut.Length; i++)
        {
            if (wut[i].gameObject.name.Contains(toEdit))
            {
                toControl = wut[i];
                found     = true;
                break;
            }
        }
        if (!found)
        {
            Debug.LogError("Couldn't find AIPilot, defaulting to 0.");
            toControl = wut[0];
        }
        toControl.commandState = AIPilot.CommandStates.Override;
        foreach (var thing in FindObjectsOfType <AIPilot>())
        {
            Debug.Log(thing);
        }
        GameObject targetVehicle = toControl.gameObject;

        if (targetVehicle != null)
        {
            Debug.Log("GOT THE TARGET VEHICLE!!!");
        }
        TiltController TC = targetVehicle.GetComponent <TiltController>();

        if (TC != null)
        {
            tiltC = true;
        }
        Transform             transform = FlightSceneManager.instance.playerActor.transform;
        FloatingOriginShifter playerfos = transform.GetComponent <FloatingOriginShifter>();

        if (playerfos)
        {
            playerfos.enabled = false;
        }
        GameObject empty       = new GameObject();
        GameObject Cammy       = Instantiate(empty, transform.position, Quaternion.identity);
        Actor      targetActor = targetVehicle.GetComponent <Actor>();
        //  targetActor.team = Teams.Allied;
        Camera         CammyCam = Cammy.AddComponent <Camera>();
        CameraFollowMe cam      = Cammy.AddComponent <CameraFollowMe>();

        cam.targets = new List <Transform>();
        Debug.Log("Target list created.");
        cam.AddTarget(targetActor.transform);
        Debug.Log("Added our actor to the target.");
        if (targetActor.transform == null)
        {
            Debug.LogError("Actor transform is null.");
        }
        if (cam.gameObject == null)
        {
            Debug.LogError("cam gameObject is null.");
        }
        cam.cam = CammyCam;
        cam.gameObject.SetActive(true);
        cam.AddTarget(FlightSceneManager.instance.playerActor.transform);
        GameSettings.SetGameSettingValue("HIDE_HELMET", true, true);
        Debug.Log("Cam should be set.");
        VehicleInputManager control = targetVehicle.AddComponent <VehicleInputManager>();
        AutoPilot           AP      = targetVehicle.GetComponent <AutoPilot>();

        control.pyrOutputs = AP.outputs;
        AP.steerMode       = AutoPilot.SteerModes.Aim;
        List <ModuleEngine> Engines = AP.engines;

        AP.enabled = false;
        control.wheelSteerOutputs = targetVehicle.GetComponents <WheelsController>();
        GearAnimator gear = toControl.gearAnimator;

        targetVehicle.GetComponent <AIPilot>().enabled = false;
        Radar        targetRadar  = toControl.detectionRadar;
        LockingRadar lTargetRadar = new LockingRadar();

        if (targetRadar != null)
        {
            targetRadar.teamsToDetect = Radar.DetectionTeams.Both;
            lTargetRadar = toControl.lockingRadar;
            radarActive  = true;
        }
        if (lTargetRadar != null)
        {
            lockingRadar = true;
        }
        foreach (var thing in targetVehicle.GetComponents(typeof(Component)))
        {
            Debug.Log(thing);
        }
        WeaponManager wm = targetVehicle.GetComponent <WeaponManager>();

        if (wm != null)
        {
            hasWM = true;
            wm.SetMasterArmed(true);
            foreach (var internalBays in wm.internalWeaponBays)
            {
                internalBays.openOnAnyWeaponMatch = true;
            }
        }
        MissileDetector    rwr = toControl.rwr;
        MeasurementManager MM  = MeasurementManager.instance;
        float            t     = 0f;
        float            v     = 0f;
        CameraScreenshot CS    = new CameraScreenshot();

        PitchYawRoll = new Vector3(0f, 0f, 0f);
        FlightInfo FI = targetActor.flightInfo;
        // RefuelPlane rPlane = targetVehicle.GetComponent<RefuelPlane>();
        float x          = 0f;
        float y          = 0f;
        float z          = 0f;
        float flaps      = 0f;
        float brakes     = 0f;
        int   idx        = -1;
        int   p          = 2;
        float headingNum = 0;
        bool  locked     = false;
        bool  tDep       = false;
        bool  hDep       = false;

        if (toControl.tailHook != null)
        {
            tDep = toControl.tailHook.isDeployed;
        }
        if (toControl.catHook != null)
        {
            hDep = toControl.catHook.deployed;
        }
        infAmmo iA = targetVehicle.AddComponent <infAmmo>();

        iA.wepMan  = wm;
        iA.enabled = false;
        Actor lockSelection = new Actor();

        Debug.Log("Controlling " + targetVehicle);
        while (true)
        {
            // Pitch Yaw Roll controls
            if (Input.GetKey(KeyCode.S))
            {
                x = -1f;
            }
            else if (Input.GetKey(KeyCode.W))
            {
                x = 1f;
            }
            else
            {
                x = 0f;
            }
            if (Input.GetKey(KeyCode.A))
            {
                y = -1f;
            }
            else if (Input.GetKey(KeyCode.D))
            {
                y = 1f;
            }
            else
            {
                y = 0f;
            }
            if (Input.GetKey(KeyCode.E))
            {
                z = -1f;
            }
            else if (Input.GetKey(KeyCode.Q))
            {
                z = 1f;
            }
            else
            {
                z = 0f;
            }

            // Tilt Controller
            if (Input.GetKey(KeyCode.Z))
            {
                if (v >= 90)
                {
                }
                else
                {
                    if (TC)
                    {
                        v += 1;
                        TC.SetTiltImmediate(v);
                    }
                }
            }
            if (Input.GetKey(KeyCode.X))
            {
                if (v <= 0)
                {
                }
                else
                {
                    if (tiltC)
                    {
                        v -= 1;
                        TC.SetTiltImmediate(v);
                    }
                }
            }

            // Screen Shot
            if (Input.GetKeyDown(KeyCode.L))
            {
                try
                {
                    if (CS.cam == null)
                    {
                        CS.cam = CameraFollowMe.instance.cam;
                        Debug.Log("NULL in assigning cam to CS");
                    }
                    CS.Screenshot();
                }
                catch (NullReferenceException)
                {
                    Debug.Log("This dude really tried screenshotting without having the debug cam on, LOSER!");
                }
            }

            // WeaponManager code
            if (wm != null)
            {
                if (Input.GetKeyDown(KeyCode.R))
                {
                    wm.CycleActiveWeapons();
                }
                if (iA.enabled)
                {
                    if (Input.GetKey(KeyCode.Space))
                    {
                        if (wm.currentEquip is HPEquipIRML || wm.currentEquip is HPEquipRadarML)
                        {
                            wm.SingleFire();
                        }
                        else
                        {
                            wm.StartFire();
                        }
                    }
                    if (Input.GetKeyUp(KeyCode.Space))
                    {
                        if (!(wm.currentEquip is HPEquipIRML || wm.currentEquip is HPEquipRadarML))
                        {
                            wm.EndFire();
                        }
                    }
                }
                else
                {
                    if (Input.GetKeyDown(KeyCode.Space))
                    {
                        if (wm.currentEquip is HPEquipIRML || wm.currentEquip is HPEquipRadarML)
                        {
                            wm.SingleFire();
                        }
                        else
                        {
                            wm.StartFire();
                        }
                    }
                    if (Input.GetKeyUp(KeyCode.Space))
                    {
                        if (!(wm.currentEquip is HPEquipIRML || wm.currentEquip is HPEquipRadarML))
                        {
                            wm.EndFire();
                        }
                    }
                }
                Weapon = wm.currentEquip.name;
                Ammo   = wm.currentEquip.GetCount().ToString();
            }

            // Gear Toggle
            if (Input.GetKeyDown(KeyCode.G))
            {
                if (gear != null)
                {
                    gear.Toggle();
                }
            }

            // Thrrottle code
            if (Input.GetKey(KeyCode.LeftControl)) // Increase
            {
                if (t > 0)
                {
                    t -= 0.0125f;
                }
            }
            if (Input.GetKey(KeyCode.LeftShift)) // Decrease
            {
                if (t < 1)
                {
                    t += 0.0125f;
                }
            }

            // CMS dispenser
            if (Input.GetKey(KeyCode.C))
            {
                toControl.FireFlares();
                toControl.FireChaff();
            }

            // Radar code
            if (targetRadar != null)
            {
                if (lTargetRadar != null)
                {
                    if (Input.GetKeyDown(KeyCode.M)) // Move right in the array
                    {
                        idx += 1;
                        if (idx > targetRadar.detectedUnits.Count - 1)
                        {
                            idx = targetRadar.detectedUnits.Count - 1;
                        }
                        if (targetRadar.detectedUnits.Count > 0)
                        {
                            lockSelection = targetRadar.detectedUnits[idx];
                            sRadarTargets = lockSelection.actorName;
                        }
                    }
                    if (Input.GetKeyDown(KeyCode.N)) // Move left in the array
                    {
                        idx -= 1;
                        if (idx < 0)
                        {
                            idx = 0;
                        }
                        if (targetRadar.detectedUnits.Count > 0)
                        {
                            lockSelection = targetRadar.detectedUnits[idx];
                            sRadarTargets = lockSelection.actorName;
                        }
                    }
                    if (Input.GetKeyDown(KeyCode.J)) // Lock
                    {
                        if (!locked)
                        {
                            if (targetRadar.detectedUnits.Count > 0)
                            {
                                if (idx >= 0)
                                {
                                    if (lTargetRadar.GetLock(lockSelection))
                                    {
                                        lRadarTargets = lockSelection.ToString();
                                        locked        = !locked;
                                    }
                                }
                            }
                        }
                        else
                        {
                            lTargetRadar.Unlock();
                            lRadarTargets = "No lock";
                            locked        = !locked;
                        }
                    }
                    if (!lTargetRadar.IsLocked())
                    {
                        lRadarTargets = "Lock Dropped";
                        if (locked)
                        {
                            locked = !locked;
                        }
                    }
                }
                radarTargets = "";
                foreach (var thing in targetRadar.detectedUnits)
                {
                    headingNum = Mathf.Round(VectorUtils.SignedAngle(Vector3.forward, thing.transform.forward, Vector3.right));
                    if (headingNum < 0)
                    {
                        headingNum += 360;
                    }
                    radarTargets += thing + " " + headingNum.ToString() + " " + MM.ConvertedDistance(Mathf.Round((targetRadar.transform.position - thing.position).magnitude)).ToString() + " " + DistanceLabel() + " " + MM.ConvertedAltitude(Mathf.Round((WaterPhysics.GetAltitude(thing.position)))).ToString() + " " + AltitudeLabel() + "\n";
                }
            }

            // RWR code
            if (rwr != null)
            {
                Missiles = "";
                if (rwr.missileDetected)
                {
                    MissileDetected = true;
                    foreach (var Missile in rwr.detectedMissiles)
                    {
                        headingNum = Mathf.Round(VectorUtils.SignedAngle(Vector3.forward, Missile.transform.forward, Vector3.right));
                        if (headingNum < 0)
                        {
                            headingNum += 360;
                        }
                        Missiles += Missile.ToString() + " " + headingNum.ToString() + " " + MM.ConvertedDistance(Mathf.Round((rwr.transform.position - Missile.transform.position).magnitude)).ToString() + " " + DistanceLabel() + " " + MM.ConvertedAltitude(Mathf.Round((WaterPhysics.GetAltitude(Missile.transform.position)))).ToString() + " " + AltitudeLabel() + "\n";
                    }
                }
            }

            // Flaps
            if (Input.GetKeyDown(KeyCode.F))
            {
                if (flaps == 0f)
                {
                    flaps = .5f;
                }
                else if (flaps == .5f)
                {
                    flaps = 1f;
                }
                else
                {
                    flaps = 0f;
                }
                foreach (var thing in toControl.autoPilot.outputs)
                {
                    thing.SetFlaps(flaps);
                }
            }

            // Brakes
            if (Input.GetKeyDown(KeyCode.B))
            {
                if (brakes == 0f)
                {
                    brakes = 1f;
                }
                else
                {
                    brakes = 0f;
                }
                foreach (var thing in toControl.autoPilot.outputs)
                {
                    thing.SetBrakes(brakes);
                }
            }

            // Wing Folding
            if (Input.GetKeyDown(KeyCode.K))
            {
                if (toControl.wingRotator != null)
                {
                    if (toControl.wingRotator.deployed)
                    {
                        toControl.wingRotator.SetDefault();
                    }
                    else
                    {
                        toControl.wingRotator.SetDeployed();
                    }
                }
            }

            // Tail Hook
            if (Input.GetKeyDown(KeyCode.H))
            {
                if (toControl.tailHook != null)
                {
                    if (tDep)
                    {
                        toControl.tailHook.RetractHook();
                        tDep = !tDep;
                    }
                    else
                    {
                        toControl.tailHook.ExtendHook();
                        tDep = !tDep;
                    }
                }
            }

            //  Launch Bar
            if (Input.GetKeyDown(KeyCode.T))
            {
                if (toControl.catHook != null)
                {
                    if (hDep)
                    {
                        toControl.catHook.Retract();
                        hDep = !hDep;
                    }
                    else
                    {
                        toControl.catHook.Extend();
                        hDep = !hDep;
                    }
                }
            }

            // Debug
            if (Input.GetKeyDown(KeyCode.O))
            {
                iA.enabled = !iA.enabled;
            }

            // Misc Stuff
            PitchYawRoll.Set(x, y, z);
            control.SetJoystickPYR(PitchYawRoll);
            foreach (ModuleEngine Engine in Engines)
            {
                Engine.SetThrottle(t);
            }
            headingNum = VectorUtils.SignedAngle(Vector3.forward, targetActor.transform.forward, Vector3.right);
            if (headingNum < 0f)
            {
                headingNum += 360f;
            }
            heading  = FI.heading.ToString();
            altitude = MM.ConvertedAltitude(FI.altitudeASL).ToString() + " " + AltitudeLabel();
            speed    = MM.ConvertedSpeed(FI.surfaceSpeed).ToString() + " " + SpeedLabel();
            yield return(null);
        }
    }