Exemplo n.º 1
0
        // Use this for initialization
        public void Start()
        {
            //base.OnAwake();

            if(!HighLogic.LoadedSceneIsFlight)
            {
                return;
            }

            if(mk22HUDs == null)
            {
                mk22HUDs = new List<Mk22HUD>();
            }

            mk22HUDs.RemoveAll(h => h == null);
            mk22HUDs.Remove(this);
            mk22HUDs.Add(this);

            part.force_activate();

            Transform ladderMeshTransform = internalProp.FindModelTransform(ladderMeshName);

            ladderUVT = new UVTransformer(ladderMeshTransform.gameObject);
            //ladderTextureSize = new Vector2(ladderUVT.texture.width, ladderUVT.texture.height);

            velRulerUVT = new UVTransformer(internalProp.FindModelTransform(velRulerMeshName).gameObject);

            altRulerUVT = new UVTransformer(internalProp.FindModelTransform(altRulerMeshName).gameObject);

            headingRulerUVT = new UVTransformer(internalProp.FindModelTransform(headingRulerMeshName).gameObject);

            velVectorObject = internalProp.FindModelTransform(velVectorObjectName).gameObject;
            velVectorOrigPos = velVectorObject.transform.localPosition;

            aslObject = internalProp.FindModelTransform(aslMeshName).gameObject;
            rdrObject = internalProp.FindModelTransform(rdrMeshName).gameObject;

            digitReference = internalProp.FindModelTransform(digitReferenceName).gameObject;
            altDigitalTransform = internalProp.FindModelTransform(altDigitalTransformName);
            spdDigitalTransform = internalProp.FindModelTransform(spdDigitalTransformName);
            altNumberField = new HUDNumberField(altDigitalTransform, 5, digitScale, digitReference, digitCharWidth, digitPixelWidth, HUDNumberField.HUDNumberAlign.Right);
            spdNumberField = new HUDNumberField(spdDigitalTransform, 4, digitScale, digitReference, digitCharWidth, digitPixelWidth, HUDNumberField.HUDNumberAlign.Right);
            digitReference.SetActive(false);

            stallObject = internalProp.FindModelTransform(stallMeshName).gameObject;
            slipObject = internalProp.FindModelTransform(slipMeshName).gameObject;

            overlayTransform = internalProp.FindModelTransform(overlayMeshName);
            logoTransform = internalProp.FindModelTransform(logoMeshName);
            subLogoTransform = internalProp.FindModelTransform(subLogoMeshName);
            loadContainerTransform = internalProp.FindModelTransform(loadContainerName);
            loadBarTransform = internalProp.FindModelTransform(loadBarName);

            logoTransform.localScale = new Vector3(1, 1, 0);
            subLogoTransform.localScale = new Vector3(1, 1, 0);
            loadContainerTransform.localScale = new Vector3(1, 1, 0);
            loadBarTransform.localScale = new Vector3(0, 1, 1);

            startLoadSound = GameDatabase.Instance.GetAudioClip(audioFolderPath + "/startLoad");
            loadingSound = GameDatabase.Instance.GetAudioClip(audioFolderPath + "/loading");
            endLoadSound = GameDatabase.Instance.GetAudioClip(audioFolderPath + "/endLoad");
            shutdownSound = GameDatabase.Instance.GetAudioClip(audioFolderPath + "/shutdown");

            if(startLoadSound && loadingSound && endLoadSound && shutdownSound)
            {
                hasAudio = true;
                audioSource = part.gameObject.AddComponent<AudioSource>();
                audioSource.minDistance = 5;
                audioSource.maxDistance = 5;
                audioSource.volume = GameSettings.SHIP_VOLUME;
                audioSource.clip = loadingSound;
                audioSource.loop = true;
                audioSource.dopplerLevel = 0;
                audioSource.Stop();
            }

            SetupHUDMaterials();

            if(ready)
            {
                //PowerOnInstantly();
            }
            else
            {
                hasInitialized = true;
                ShutDown();
            }
        }
Exemplo n.º 2
0
        // Use this for initialization
        public void Start()
        {
            //base.OnAwake();

            if (!HighLogic.LoadedSceneIsFlight)
            {
                return;
            }

            if (mk22HUDs == null)
            {
                mk22HUDs = new List <Mk22HUD>();
            }

            mk22HUDs.RemoveAll(h => h == null);
            mk22HUDs.Remove(this);
            mk22HUDs.Add(this);

            part.force_activate();

            Transform ladderMeshTransform = internalProp.FindModelTransform(ladderMeshName);

            ladderUVT = new UVTransformer(ladderMeshTransform.gameObject);
            //ladderTextureSize = new Vector2(ladderUVT.texture.width, ladderUVT.texture.height);

            velRulerUVT = new UVTransformer(internalProp.FindModelTransform(velRulerMeshName).gameObject);

            altRulerUVT = new UVTransformer(internalProp.FindModelTransform(altRulerMeshName).gameObject);

            headingRulerUVT = new UVTransformer(internalProp.FindModelTransform(headingRulerMeshName).gameObject);

            velVectorObject  = internalProp.FindModelTransform(velVectorObjectName).gameObject;
            velVectorOrigPos = velVectorObject.transform.localPosition;

            aslObject = internalProp.FindModelTransform(aslMeshName).gameObject;
            rdrObject = internalProp.FindModelTransform(rdrMeshName).gameObject;

            digitReference      = internalProp.FindModelTransform(digitReferenceName).gameObject;
            altDigitalTransform = internalProp.FindModelTransform(altDigitalTransformName);
            spdDigitalTransform = internalProp.FindModelTransform(spdDigitalTransformName);
            altNumberField      = new HUDNumberField(altDigitalTransform, 5, digitScale, digitReference, digitCharWidth, digitPixelWidth, HUDNumberField.HUDNumberAlign.Right);
            spdNumberField      = new HUDNumberField(spdDigitalTransform, 4, digitScale, digitReference, digitCharWidth, digitPixelWidth, HUDNumberField.HUDNumberAlign.Right);
            digitReference.SetActive(false);

            stallObject = internalProp.FindModelTransform(stallMeshName).gameObject;
            slipObject  = internalProp.FindModelTransform(slipMeshName).gameObject;

            overlayTransform       = internalProp.FindModelTransform(overlayMeshName);
            logoTransform          = internalProp.FindModelTransform(logoMeshName);
            subLogoTransform       = internalProp.FindModelTransform(subLogoMeshName);
            loadContainerTransform = internalProp.FindModelTransform(loadContainerName);
            loadBarTransform       = internalProp.FindModelTransform(loadBarName);

            logoTransform.localScale          = new Vector3(1, 1, 0);
            subLogoTransform.localScale       = new Vector3(1, 1, 0);
            loadContainerTransform.localScale = new Vector3(1, 1, 0);
            loadBarTransform.localScale       = new Vector3(0, 1, 1);

            startLoadSound = GameDatabase.Instance.GetAudioClip(audioFolderPath + "/startLoad");
            loadingSound   = GameDatabase.Instance.GetAudioClip(audioFolderPath + "/loading");
            endLoadSound   = GameDatabase.Instance.GetAudioClip(audioFolderPath + "/endLoad");
            shutdownSound  = GameDatabase.Instance.GetAudioClip(audioFolderPath + "/shutdown");

            if (startLoadSound && loadingSound && endLoadSound && shutdownSound)
            {
                hasAudio                 = true;
                audioSource              = part.gameObject.AddComponent <AudioSource>();
                audioSource.minDistance  = 5;
                audioSource.maxDistance  = 5;
                audioSource.volume       = GameSettings.SHIP_VOLUME;
                audioSource.clip         = loadingSound;
                audioSource.loop         = true;
                audioSource.dopplerLevel = 0;
                audioSource.Stop();
            }

            SetupHUDMaterials();


            if (ready)
            {
                //PowerOnInstantly();
            }
            else
            {
                hasInitialized = true;
                ShutDown();
            }
        }