void Start()
 {
     if (!helicopterController)
     {
         helicopterController = GameObject.FindGameObjectWithTag("Player").GetComponent <HelicopterController>();
     }
 }
 void _MakeInstance()
 {
     if (helicopterInstance == null)
     {
         helicopterInstance = this;
     }
 }
Exemple #3
0
 // Use this for initialization
 void Start()
 {
     helicopter             = GetComponentInParent <HelicopterController>();
     initialMiniMapRotation = MiniMapCamera.transform.rotation;
     initialLevelPosition   = LevelBack.transform.localPosition;
     initialLevelRotation   = LevelBack.transform.localRotation.eulerAngles;
 }
Exemple #4
0
    private void Awake()
    {
        // get the heli controller
        HelicopterController = GetComponent <HelicopterController>();

        // Allows to disable camera collisions with cops
        HelicopterController.gameObject.layer = LayerMask.NameToLayer("CameraIgnore");
    }
Exemple #5
0
    /*--- Lifecycle Methods ---*/

    void Start()
    {
        // Set Instance
        instance = this;

        // Get Initial State
        initialPosition = transform.position;
        initialRotation = transform.rotation;
        craftRotationX  = initialRotation.eulerAngles.x;
        craftRotationY  = initialRotation.eulerAngles.y;
        craftRotationZ  = initialRotation.eulerAngles.z;

        // Get Components
        hcRigidbody = GetComponent <Rigidbody>();

        // Move Center of Mass Forward
        hcRigidbody.centerOfMass = new Vector3(0, 0, 2);
    }
Exemple #6
0
    void LoadUpperAirPoints(IntVector4 node, int min, int max)
    {
        GameObject carrier = null;// PlayerFactory.mMainPlayer.Carrier;

        if (carrier == null)
        {
            return;
        }

        HelicopterController hel = carrier.GetComponent <HelicopterController>();

        if (hel == null)
        {
            return;
        }

        /*
         * VCPVtolCockpitFunc vtol = hel.m_Cockpit as VCPVtolCockpitFunc;
         * if (vtol == null)
         * return;
         *
         * if (vtol.FlyingHeight < 50.0f)
         * return;
         * */

        //if (Random.value > AiManager.Manager.upperPoint)
        //    return;

        Vector3 position = node.ToVector3();

        position += new Vector3(Random.Range(0.0f, VoxelTerrainConstants._numVoxelsPerAxis << node.w),
                                0.0f,
                                Random.Range(0.0f, VoxelTerrainConstants._numVoxelsPerAxis << node.w));

        Quaternion rot   = Quaternion.Euler(0.0f, Random.Range(0, 360), 0.0f);
        SPPoint    point = SPPoint.InstantiateSPPoint <SPPoint>(position, rot, nextIndex, transform, 0, 63);

        point.name = "Upper Air : " + point.name;
        RegisterSPPoint(point);
    }
    public void CreateHelicoSimSystem()
    {
        if (heliSimDummy != null)
        {
            return;
        }
        heliSimDummy = new GameObject("helicoCtrl");
        // For debugging with a 3d cube that is visible in the game

        /*heliSimDummy = GameObject.CreatePrimitive(PrimitiveType.Cube);
         * BoxCollider bcoll = heliSimDummy.GetComponent<BoxCollider>();
         * if(bcoll != null)
         * {
         *  DebugMsg("Destroying cube BoxCollider");
         *  Destroy(bcoll);
         * }*/
        DebugMsg("Helico heliSimDummy = " + heliSimDummy.name + " | " + heliSimDummy.GetInstanceID().ToString());
        AudioSource[] audioSources = this.GetComponentsInChildren <AudioSource>();
        foreach (AudioSource audioSrc in audioSources)
        {
            if (audioSrc.clip.name.Contains("RideOffTheValkyries"))
            {
                helicoMusic = audioSrc;
                prefabRoot  = audioSrc.gameObject;
                DebugMsg("Found helico Music Audio Source");
            }
            if (audioSrc.clip.name.Contains("HelicopterRotor"))
            {
                helicoRotorSound = audioSrc;
                DebugMsg("Found helico rotor Audio Source");
            }
        }

        rigidBody                        = heliSimDummy.AddComponent <Rigidbody>();
        rigidBody.useGravity             = false;
        rigidBody.mass                   = 100;
        rigidBody.drag                   = 1;
        rigidBody.angularDrag            = 4;
        rigidBody.interpolation          = RigidbodyInterpolation.None;
        rigidBody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
        rigidBody.constraints            = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
        capColl           = heliSimDummy.AddComponent <CapsuleCollider>();
        capColl.center    = new Vector3(0, 0.125f, 0.3f);
        capColl.radius    = 0.125f;
        capColl.height    = 7f;
        capColl.direction = 2;

        boxcoll        = heliSimDummy.AddComponent <BoxCollider>();
        boxcoll.center = new Vector3(0, 0.125f, 0.3f);
        boxcoll.size   = new Vector3(2.5f, 0.25f, 7f);

        Vector3 newPos = this.transform.position;

        //newPos.y += 1;
        heliSimDummy.transform.position = newPos;
        heliSimDummy.transform.rotation = this.transform.rotation;
        //rigidBody.useGravity = true;

        helicoCtrl = heliSimDummy.AddComponent <HelicopterController>();
        helicoCtrl.HelicopterModel = rigidBody;
        if (helicoRotorSound != null)
        {
            Audio.Manager.AddPlayingAudioSource(helicoRotorSound);
        }
        ctrlPanel = heliSimDummy.AddComponent <HelicoControlPanel>();
        helicoCtrl.ControlPanel = ctrlPanel;
        if (helicoMusic != null)
        {
            Audio.Manager.AddPlayingAudioSource(helicoMusic);
        }

        HeliRotorController rotorCtrl = rotor_joint.gameObject.AddComponent <HeliRotorController>();

        rotorCtrl.RotateAxis           = HeliRotorController.Axis.Z;
        helicoCtrl.MainRotorController = rotorCtrl;

        rotorCtrl                     = back_rotor_joint.gameObject.AddComponent <HeliRotorController>();
        rotorCtrl.RotateAxis          = HeliRotorController.Axis.Z;
        helicoCtrl.SubRotorController = rotorCtrl;

        ctrlPanel.entity = this;
        ctrlPanel.Start();
        helicoCtrl.entity = this;
        helicoCtrl.Start();

        heliSimDummy.SetActive(false);
    }
    private HelicopterController Heli; // the car controller we want to use

    private void Awake()
    {
        // get the car controller
        Heli = GetComponent <HelicopterController>();
    }