Exemplo n.º 1
0
        public void drawOverlay(Rect where, GUIStyle style, bool identified)
        {
            if(tick == null) {
                tick = GameDatabase.Instance.GetAudioClip("Squad/Sounds/sound_click_tick");
            }
            ticking = false;
            int chars = (int)((Time.realtimeSinceStartup - switchTime) * tickRate);
            Rect r = new Rect(0, 0, 200, 20);
            string info = "no structures found";
            if(cons.Count == 1) {
                info = "identified 1 structure";
            } else if(cons.Count > 1) {
                info = "identified " + cons.Count.ToString() + " structures";
            }
            if(!identified) info = "scanning...";
            info = "> " + info;
            if(Math.Round(Time.realtimeSinceStartup) % 2 == 0) info += "_";
            r.x = where.x + 4;
            r.y = where.y + 8;
            GUI.Label(r, left(info, chars), style);
            if(!identified) return;

            r.x = where.x + 4;
            r.y = where.y + where.height - 60;
            string sname = lookat.name;
            Vector3 lookvec = lookat.transform.position;
            if(cons.Count > 0) {
                if(Event.current.type == EventType.ScrollWheel && where.Contains(Event.current.mousePosition)) {
                    activeCon += cons.Count + (Event.current.delta.y > 0 ? 1 : -1);
                    Event.current.Use();
                    switchTime = Time.realtimeSinceStartup;
                }
                activeCon = activeCon % cons.Count;
                lookdetail = cons[activeCon];
                Vector3 pos = cam.WorldToScreenPoint(lookdetail.transform.position);
                lookvec = lookdetail.transform.position;
                sname = lookdetail.objectName;
            }
            if(sname != null) {
                GUI.Label(r, left(sname, chars), style);
                r.y += 30;
                GUI.Label(r, left(distanceString((FlightGlobals.ActiveVessel.transform.position - lookvec).magnitude), chars), style);
            }
            if(ticking) {
                if(Time.realtimeSinceStartup - lastTick > 1f/tickRate) {
                    AudioSource.PlayClipAtPoint(tick, Camera.main.transform.position);
                    lastTick = Time.realtimeSinceStartup;
                }
            }
        }
Exemplo n.º 2
0
        public void setup(int w, int h, GameObject focus)
        {
            if (edgeDetectShader == null)
            {
                // simple colour based edge detection that comes with Unity Pro
                edgeDetectShader   = Shader.Find("Hidden/Edge Detect X");
                edgeDetectMaterial = new Material(edgeDetectShader);
                edgeDetectMaterial.SetFloat("_Threshold", 0.05f);

                // greyscale shader that comes with Unity Pro
                grayscaleShader   = Shader.Find("Hidden/Grayscale Effect");
                grayscaleMaterial = new Material(grayscaleShader);
                Texture2D t = new Texture2D(256, 1, TextureFormat.RGB24, false);
                // ramp texture to render everything in dark shades of Amber,
                // except originally dark lines, which become bright Amber
                for (int i = 0; i < 256; ++i)
                {
                    t.SetPixel(i, 0, Color.Lerp(Color.black, XKCDColors.Amber, i / 1024f));
                }
                for (int i = 0; i < 10; ++i)
                {
                    t.SetPixel(i, 0, XKCDColors.Amber);
                }
                t.Apply();
                grayscaleMaterial.SetTexture("_RampTex", t);
            }
            if (lookat != focus)
            {
                switchTime = Time.realtimeSinceStartup;
                lookdetail = null;
                bounds     = new Bounds();
                foreach (Collider c in focus.GetComponentsInChildren <Collider>())
                {
                    if (c.bounds != null)
                    {
                        bounds.Encapsulate(c.bounds);
                    }
                }
                cons = new List <CrashObjectName>();
                foreach (CrashObjectName con in focus.GetComponentsInChildren <CrashObjectName>())
                {
                    cons.Add(con);
                }
            }
            lookat  = focus;
            width   = w;
            height  = h;
            camRect = new Rect(0, 0, width, height);
        }
Exemplo n.º 3
0
		public void setup ( int w , int h , GameObject focus ) {
			if (edgeDetectShader == null) {
				// simple colour based edge detection that comes with Unity Pro
				edgeDetectShader = Shader.Find ("Hidden/Edge Detect X");
				edgeDetectMaterial = new Material (edgeDetectShader);
				edgeDetectMaterial.SetFloat ("_Threshold" , 0.05f);

				// greyscale shader that comes with Unity Pro
				grayscaleShader = Shader.Find ("Hidden/Grayscale Effect");
				grayscaleMaterial = new Material (grayscaleShader);
				Texture2D t = new Texture2D (256 , 1 , TextureFormat.RGB24 , false);
				// ramp texture to render everything in dark shades of Amber,
				// except originally dark lines, which become bright Amber
				for (int i=0; i<256; ++i)
					t.SetPixel (i , 0 , palette.lerp (palette.black , palette.xkcd_Amber , i / 1024f));
				for (int i=0; i<10; ++i)
					t.SetPixel (i , 0 , palette.xkcd_Amber);
				t.Apply ();
				grayscaleMaterial.SetTexture ("_RampTex" , t);
			}
			if (lookat != focus) {
				switchTime = Time.realtimeSinceStartup;
				lookdetail = null;
				bounds = new Bounds ();
				foreach (Collider c in focus.GetComponentsInChildren<Collider>())
						bounds.Encapsulate (c.bounds);
				cons = new List<CrashObjectName> ();
				foreach (CrashObjectName con in focus.GetComponentsInChildren<CrashObjectName>()) {
					cons.Add (con);
				}
			}
			lookat = focus;
			width = w;
			height = h;
			/* FIXME: unused */ //camRect = new Rect (0 , 0 , width , height);
		}
Exemplo n.º 4
0
        public void drawOverlay(Rect where, GUIStyle style, bool identified)
        {
            if (tick == null)
            {
                tick = GameDatabase.Instance.GetAudioClip("Squad/Sounds/sound_click_tick");
            }
            ticking = false;
            int    chars = (int)((Time.realtimeSinceStartup - switchTime) * tickRate);
            Rect   r     = new Rect(0, 0, 200, 20);
            string info  = "no structures found";

            if (cons.Count == 1)
            {
                info = "identified 1 structure";
            }
            else if (cons.Count > 1)
            {
                info = "identified " + cons.Count.ToString() + " structures";
            }
            if (!identified)
            {
                info = "scanning...";
            }
            info = "> " + info;
            if (Math.Round(Time.realtimeSinceStartup) % 2 == 0)
            {
                info += "_";
            }
            r.x = where.x + 4;
            r.y = where.y + 8;
            GUI.Label(r, left(info, chars), style);
            if (!identified)
            {
                return;
            }

            r.x = where.x + 4;
            r.y = where.y + where.height - 60;
            string  sname   = lookat.name;
            Vector3 lookvec = lookat.transform.position;

            if (cons.Count > 0)
            {
                if (Event.current.type == EventType.ScrollWheel && where.Contains(Event.current.mousePosition))
                {
                    activeCon += cons.Count + (Event.current.delta.y > 0 ? 1 : -1);
                    Event.current.Use();
                    switchTime = Time.realtimeSinceStartup;
                }
                activeCon  = activeCon % cons.Count;
                lookdetail = cons [activeCon];
                /* FIXME: unused */                 //Vector3 pos = cam.WorldToScreenPoint (lookdetail.transform.position);
                lookvec = lookdetail.transform.position;
                sname   = lookdetail.objectName;
            }
            if (sname != null)
            {
                GUI.Label(r, left(sname, chars), style);
                r.y += 30;
                GUI.Label(r, left(distanceString((FlightGlobals.ActiveVessel.transform.position - lookvec).magnitude), chars), style);
            }
            if (ticking)
            {
                if (Time.realtimeSinceStartup - lastTick > 1f / tickRate)
                {
                    AudioSource.PlayClipAtPoint(tick, Camera.main.transform.position);
                    lastTick = Time.realtimeSinceStartup;
                }
            }
        }