Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- using System.Collections;
- using UnityEngine;
- public class SolarNrgRecycler : Part
- {
- protected Rect windowPos;
- protected bool soundState;
- protected bool oldState;
- private static string kspDir;
- private static string kspDir2;
- public int aluminium;
- public int water;
- protected override void onFlightStart()
- {
- kspDir2 = UnityEngine.Application.dataPath;
- int lastIndex = kspDir2.LastIndexOf('/');
- if (lastIndex != -1)
- {
- kspDir = kspDir2.Substring(0, lastIndex + 1);
- }
- //urMod_LoadAudioFiles(); //launch the loadsoundfile function from here
- {
- RenderingManager.AddToPostDrawQueue(3, new Callback(drawGUI));//start the GUI
- }
- }
- private void OnCollisionEnter(Collision collisionInfo)
- {
- print("COLLISION!:\t" + collisionInfo.gameObject.name);
- if (collisionInfo.gameObject.name == "rock1(Clone)")
- {
- aluminium++;
- Destroy(collisionInfo.gameObject);
- //do stuff. add to resource etc
- }
- if (collisionInfo.gameObject.name == "rock2(Clone)")
- {
- water++;
- Destroy(collisionInfo.gameObject);
- //do stuff. add to resource etc
- }
- }
- private void WindowGUI(int windowID)
- {
- GUIStyle mySty = new GUIStyle(GUI.skin.button);
- mySty.normal.textColor = mySty.focused.textColor = Color.white;
- mySty.hover.textColor = mySty.active.textColor = Color.yellow;
- mySty.onNormal.textColor = mySty.onFocused.textColor = mySty.onHover.textColor = mySty.onActive.textColor = Color.green;
- GUIStyle yellow = new GUIStyle(GUI.skin.label);
- GUIStyle white = new GUIStyle(GUI.skin.label);
- GUIStyle green = new GUIStyle(GUI.skin.label);
- yellow.normal.textColor = Color.yellow;
- white.normal.textColor = Color.white;
- green.normal.textColor = Color.green;
- //Start building the GUI on screen
- GUILayout.BeginVertical();
- bool oldState = soundState; //Silence switch
- soundState = GUILayout.Toggle(soundState, "Report", mySty, GUILayout.ExpandWidth(false), GUILayout.MinWidth(20));
- if (soundState) //kills all warning Timer sounds when depressed
- {
- print(water);
- print(aluminium);
- }
- aluminium = 0;
- water = 0;
- GUILayout.Label("Aluminium", yellow, GUILayout.ExpandWidth(true));
- GUI.TextField(new Rect(110, 75, 60, 20), aluminium.ToString("F0"));
- GUILayout.Label("Water", yellow, GUILayout.ExpandWidth(true));
- GUI.TextField(new Rect(175, 75, 60, 20), water.ToString("F0"));
- GUILayout.EndVertical();
- GUI.DragWindow(new Rect(0, 0, 10000, 20));
- }
- //Draw the GUI window
- private void drawGUI()
- {
- GUI.skin = HighLogic.Skin;
- windowPos = GUILayout.Window(1403252, windowPos, WindowGUI, "Mining Cargo Inventory", GUILayout.MinWidth(250));
- }
- //Initialize gui when part starts and position
- protected override void onPartStart()
- {
- if ((windowPos.x == 0) && (windowPos.y == 0))//windowPos is used to position the GUI window, lets set it in the center of the screen
- {
- windowPos = new Rect(Screen.width / 6, Screen.height / 3, 10, 10);
- }
- }
- protected override void onPartDestroy()
- {
- RenderingManager.RemoveFromPostDrawQueue(3, new Callback(drawGUI)); //close the GUI
- }
- }
Add Comment
Please, Sign In to add comment