public HUDNumberField(Transform transform, int digitCount, float scale, GameObject digitReference, float charWidth, float charPixelWidth, HUDNumberAlign alignment) { this.transform = transform; this.charWidth = charWidth; this.charPixelWidth = charPixelWidth; this.alignment = alignment; digCount = digitCount; digitObjects = new GameObject[digitCount]; UVTs = new UVTransformer[digitCount]; digits = new int[digitCount]; for (int i = 0; i < digitCount; i++) { GameObject digitObject = (GameObject)GameObject.Instantiate(digitReference); digitObjects[i] = digitObject; digitObject.transform.parent = transform; digitObject.transform.localScale = Vector3.one; digitObject.transform.localPosition = Vector3.zero; digitObject.transform.localRotation = Quaternion.identity; digitObject.SetActive(true); if (alignment == HUDNumberAlign.Right) { digitObject.transform.localPosition -= (charWidth * digitCount) * Vector3.right; } digitObject.transform.localPosition += (charWidth * i) * Vector3.right; UVTs[i] = new UVTransformer(digitObject); transform.localScale = scale * Vector3.one; digits[i] = -1; } char[] maxValChars = new char[digitCount]; for (int i = 0; i < digitCount; i++) { maxValChars[i] = '9'; } string maxValString = new string(maxValChars); maxValue = int.Parse(maxValString); }
public HUDNumberField(Transform transform, int digitCount, float scale, GameObject digitReference, float charWidth, float charPixelWidth, HUDNumberAlign alignment) { this.transform = transform; this.charWidth = charWidth; this.charPixelWidth = charPixelWidth; this.alignment = alignment; digCount = digitCount; digitObjects = new GameObject[digitCount]; UVTs = new UVTransformer[digitCount]; digits = new int[digitCount]; for(int i = 0; i < digitCount; i++) { GameObject digitObject = (GameObject)GameObject.Instantiate(digitReference); digitObjects[i] = digitObject; digitObject.transform.parent = transform; digitObject.transform.localScale = Vector3.one; digitObject.transform.localPosition = Vector3.zero; digitObject.transform.localRotation = Quaternion.identity; digitObject.SetActive(true); if(alignment == HUDNumberAlign.Right) { digitObject.transform.localPosition -= (charWidth * digitCount) * Vector3.right; } digitObject.transform.localPosition += (charWidth * i) * Vector3.right; UVTs[i] = new UVTransformer(digitObject); transform.localScale = scale*Vector3.one; digits[i] = -1; } char[] maxValChars = new char[digitCount]; for(int i = 0; i < digitCount; i++) { maxValChars[i] = '9'; } string maxValString = new string(maxValChars); maxValue = int.Parse(maxValString); }
// 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(); } }
// 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(); } }