예제 #1
0
    /*
     * void OnCollisionEnter(Collision collision) {
     *      Debug.Log ("PLAYER oncollisionenter");
     *      if (collision.gameObject.tag == "Creeper") {
     *              this.msg = "Creeper collision";
     *              this.collided = true;
     *      }
     * }
     *
     * void OnControllerColliderHit (ControllerColliderHit hit) {
     *
     *
     *      //Debug.Log ("OnControllerColliderHit");
     *
     *      //Debug.Log ("CREEPER MOVEMENT HIT " + hit.gameObject.name);
     *      if (hit.gameObject.tag.Equals("Creeper")) {
     *              Debug.Log ("PLAYER HIT CREEPER!");
     *              //this.msg = "OnControllerColliderHit";
     *              //this.collided = true;
     *              //this.msg = "Creeper collision";
     *              //this.collided = true;
     *      }
     *      //Debug.Log ("OnControllerColliderHit");
     *
     *      //Debug.Log ("HIT " + hit.gameObject.name);
     *      //if (hit.gameObject.tag.Equals("Creeper")) {
     *      //	this.msg = "OnControllerColliderHit";
     *      //	this.collided = true;
     *      //} else {
     *      //	Debug.Log ("wtf did we hit?");
     *      //}
     *
     * }
     */
    void OnGUI()
    {
        /* The "GUIHelper.BeginGroup(Rect)" method can be used now instead of GUI.BeginGroup(Rect) */
        //GUIHelper.BeginGroup (new Rect (Screen.width - 250, Screen.height - 100, 300, 300));
        GUIHelper.BeginGroup(new Rect(0, 0, Screen.width, Screen.height));

        for (int i = 0; i < this.clues.Length; i++)
        {
            /* The "GUIHelper.DrawLine(Vector2, Vector2, Color);"
            *  method will draw a 2D line, with a specified color */
            if (this.clues [i])
            {
                //Debug.Log ("Drawing clue " + i);
                GUIHelper.DrawLine(this.clueLines [i] [0], this.clueLines [i] [1], Color.red);
            }

            //GUIHelper.DrawLine (new Vector2(Screen.width - 200, Screen.height - 200), new Vector2(Screen.width - 250, Screen.height - 300), Color.red);
            //GUIHelper.DrawLine (new Vector2 (Screen.width - 200, Screen.height - 50), new Vector2 (Screen.width - 250, Screen.height - 100), Color.red);
        }
        /* The "GUIHelper.EndGroup()" method will pop the clipping, and disable it. Must be called for every "GUIHelper.BeginGroup(Rect);" */
        GUIHelper.EndGroup();

        if (this.collided)
        {
            GUIStyle style = new GUIStyle();
            style.fontSize = 200;

            if (this.msg.Equals("LOSS"))
            {
                style.normal.textColor = Color.red;
            }
            else
            {
                style.normal.textColor = new Color(0.117f, 0.879f, 0.398f, 1.0f);
            }
            GUI.Label(new Rect(0, 0, Screen.width, Screen.height), this.msg, style);
            //TODO disable player movement
        }
    }
예제 #2
0
    void OnGUI()
    {
        if (UItype == UIType.IPad || UItype == UIType.Mouse_Key)
        {
            bigButton      = new GUIStyle(GUI.skin.button);
            bigButton.font = defaultStyle.font;
        }
        else
        {
            bigButton           = new GUIStyle(defaultStyle);
            bigButton.alignment = TextAnchor.LowerCenter;
        }

        GUIStyle fadedBigButton = new GUIStyle(bigButton);

        fadedBigButton.normal.textColor = new Color(1, 1, 1, .5f);

        GUIStyle currentBigButton = new GUIStyle(bigButton);

        currentBigButton.normal.textColor = new Color(1, 1, 1, .75f);

        //Get Axis bounds
        Camera    c          = Camera.main;
        Transform t          = city.transform;
        Vector2   origin     = c.WorldToScreenPoint(t.position);
        Vector2   top        = c.WorldToScreenPoint(t.position + Vector3.up * t.localScale.y);
        Vector2   right      = c.WorldToScreenPoint(t.position + Vector3.right * t.localScale.x);
        bool      inGraph    = (UItype == UIType.IPad || UItype == UIType.Mouse_Key) && new Rect(origin.x, origin.y, Screen.width, top.y).Contains(Input.mousePosition);
        Vector2   poa        = new Vector2(origin.x, Screen.height - Input.mousePosition.y); //Point On Axis
        int       lineheight = 10;

        //Normalize because its dumb
        origin.y = Screen.height - origin.y;
        top.y    = Screen.height - top.y;
        right.y  = Screen.height - right.y;

        float labelHeight = 28f;
        float labelWidth  = 100f;
        float keysOffset  = 27f;
        float offset;
        Color faded = new Color(1, 1, 1, 0.5f);

        GUIStyle yValueStyle = new GUIStyle(defaultStyle);

        yValueStyle.alignment = TextAnchor.UpperRight;

        GUIStyle plStyle = new GUIStyle(defaultStyle);

        plStyle.alignment        = TextAnchor.UpperRight;
        plStyle.normal.textColor = new Color(1, 1, 1, 0.05f);
        plStyle.fontSize         = 300;

        //Draw Projects Loaded
        //GUI.Label(new Rect(Screen.width - 250, 0, 250, 150), "Projects Loaded:\n" + ProjectCount, yValueStyle);
        GUI.Label(new Rect(0, 0, Screen.width, Screen.height), ProjectCount.ToString(), plStyle);

        GUIHelper.BeginGroup(new Rect(0, 0, Screen.width, Screen.height));
        //Draw Axis Numbers
        if (yAxisVisible)
        {
            KSMetric yMetric = KSMetric.List[yLabel];

            //New Draw Axis
            GUIHelper.DrawLine(top, origin, faded);
            GUIHelper.DrawLine(origin, right, faded);

            if (inGraph)
            {
                GUIHelper.DrawLine(
                    new Vector2(origin.x - lineheight / 2, Screen.height - Input.mousePosition.y),
                    new Vector2(origin.x + lineheight / 2, Screen.height - Input.mousePosition.y),
                    Color.white
                    );

                GUIStyle ypValueStyle = new GUIStyle(defaultStyle);
                ypValueStyle.alignment = TextAnchor.MiddleRight;
                GUI.Label(
                    new Rect(poa.x - 150, poa.y - 50, 150 - lineheight / 2 - 20, 100),
                    string.Format(yMetric.Format,
                                  yMetric.Zoom * zoom * 10 * (poa.y - origin.y) / (top.y - origin.y)),
                    ypValueStyle
                    );
            }

            //Draw tick value
            GUILayout.BeginArea(new Rect(top.x - labelWidth, top.y, labelWidth, 100));
            {
                GUILayout.BeginVertical();
                {
                    GUILayout.Label(
                        string.Format(yMetric.Format, yMetric.Zoom * zoom * 10),
                        yValueStyle,
                        GUILayout.Height(labelHeight)
                        );


                    if (GUILayout.Button(yMetric.Name.ToUpper(), yValueStyle))
                    {
                        xAxisClicked = false;
                        zoomClicked  = false;
                        yAxisClicked = !yAxisClicked;
                    }
                    if (UItype == UIType.Rockband)
                    {
                        Rect temp = GUILayoutUtility.GetLastRect();
                        drawKeys(new Vector2(temp.x, temp.y + keysOffset), 0, yAxisClicked);
                    }
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndArea();
            //actual tick
            GUIHelper.DrawLine(top - Vector2.right * lineheight, top, faded);

            if (yAxisClicked)
            {
                string[] labels = KSMetric.ListNames;
                for (int i = 0; i < labels.Length; i++)
                {
                    if (UItype == UIType.IPad)
                    {
                        offset = labelHeight * (i + 1);
                    }
                    else
                    {
                        offset = labelHeight * (i + 1 - yLabelNew);
                    }

                    if (GUI.Button(
                            new Rect(top.x - labelWidth * 2, top.y + offset, labelWidth, labelHeight),
                            labels[i].ToUpper(),
                            yValueStyle
                            ))
                    {
                        yAxisClicked = false;
                        yLabelNew    = i;
                        city.GetComponent <City>().RotateY();
                    }
                }
            }
        }

        if (xAxisVisible)
        {
            KSMetric xMetric = KSMetric.List[xLabel];

            //Metric name and tick value
            GUILayout.BeginArea(new Rect(right.x - labelWidth, right.y + 10, labelWidth, 100));
            {
                GUILayout.BeginVertical();
                {
                    GUILayout.Label(
                        string.Format(xMetric.Format, xMetric.Zoom * zoom * 10),
                        yValueStyle,
                        GUILayout.Height(labelHeight)
                        );

                    if (GUILayout.Button(xMetric.Name.ToUpper(), yValueStyle))
                    {
                        yAxisClicked = false;
                        zoomClicked  = false;
                        xAxisClicked = !xAxisClicked;
                    }
                    if (UItype == UIType.Rockband)
                    {
                        Rect temp = GUILayoutUtility.GetLastRect();
                        drawKeys(new Vector2(temp.x, temp.y + keysOffset), 1, xAxisClicked);
                    }
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndArea();
            //actual tick
            GUIHelper.DrawLine(right, right + Vector2.up * lineheight, faded);
            if (!yAxisVisible)
            {
                GUI.Label(new Rect(origin.x - 100, origin.y, 100, 100), string.Format(xMetric.Format, "0"), yValueStyle);
                GUIHelper.DrawLine(origin, origin + Vector2.up * lineheight, faded);
            }
            //Draw precise numbers
            if (inGraph)
            {
                GUIStyle xpValueStyle = new GUIStyle(defaultStyle);
                xpValueStyle.alignment = TextAnchor.UpperCenter;
                poa = new Vector2(Input.mousePosition.x, origin.y);
                GUI.Label(
                    new Rect(poa.x - 100, poa.y + lineheight / 2 + 2, 200, 50),
                    string.Format(xMetric.Format,
                                  xMetric.Zoom * zoom * 10 * (poa.x - origin.x) / (right.x - origin.x)),
                    xpValueStyle
                    );

                GUIHelper.DrawLine(
                    new Vector2(Input.mousePosition.x, origin.y - lineheight / 2),
                    new Vector2(Input.mousePosition.x, origin.y + lineheight / 2),
                    Color.white
                    );
            }


            //draw new metrics list
            if (xAxisClicked)
            {
                string[] labels = KSMetric.ListNames;
                for (int i = 0; i < labels.Length; i++)
                {
                    if (UItype == UIType.IPad)
                    {
                        offset = labelHeight * (i + 2 - labels.Length);
                    }
                    else
                    {
                        offset = labelHeight * (i + 1 - xLabelNew);
                    }

                    if (GUI.Button(
                            new Rect(right.x, right.y + 10 + offset, labelWidth, labelHeight),
                            labels[i].ToUpper(),
                            defaultStyle
                            ))
                    {
                        xAxisClicked = false;
                        xLabelNew    = i;
                        city.GetComponent <City>().RotateX();
                    }
                }
            }
        }

        GUIHelper.EndGroup();

        Vector2 zoomOffset, catsOffset;

        zoomOffset = catsOffset = Vector2.zero;

        //draw options
        GUILayout.BeginArea(new Rect(20, 0, Screen.width - 40, Screen.height - 20));
        {
            GUILayout.BeginHorizontal();
            {
                //draw categories
                if (catsVisible)
                {
                    GUILayout.BeginVertical(GUILayout.Width(100));
                    {
                        GUILayout.FlexibleSpace();
                        if (catsClicked)
                        {
                            for (int i = 0; i < legendTitles.Length; i++)
                            {
                                if (UItype == UIType.Mouse_Key || UItype == UIType.IPad)
                                {
                                    if (GUILayout.Button(legendTitles[i], bigButton))
                                    {
                                        city.GetComponent <City>().HighlightCategory(legendTitles[i]);
                                        selectedLegend = i;
                                    }
                                }
                                else
                                {
                                    if (i == selectedLegend)
                                    {
                                        GUILayout.Label(legendTitles[i], bigButton);
                                    }
                                    else if (i == newLegend)
                                    {
                                        GUILayout.Label(legendTitles[i], currentBigButton);
                                    }
                                    else
                                    {
                                        GUILayout.Label(legendTitles[i], fadedBigButton);
                                    }
                                }
                            }
                        }
                        if (GUILayout.Button("CATEGORIES", defaultStyle))
                        {
                            catsClicked = !catsClicked;
                        }

                        Rect temp = GUILayoutUtility.GetLastRect();
                        catsOffset = new Vector2(temp.x, temp.y + 25);
                    }
                    GUILayout.EndVertical();
                }
                if (UItype == UIType.Rockband)
                {
                    GUILayout.FlexibleSpace();
                }

                //draw zoom
                if (zoomVisible)
                {
                    GUILayout.BeginVertical(GUILayout.Width(75));
                    {
                        GUILayout.FlexibleSpace();

                        if ((UItype == UIType.IPad || UItype == UIType.Mouse_Key) && zoomClicked)
                        {
                            if (GUILayout.RepeatButton("+++", bigButton))
                            {
                                city.GetComponent <City>().ZoomInstant(1 - Time.deltaTime * 1.5f);
                            }
                            if (GUILayout.RepeatButton("+", bigButton))
                            {
                                city.GetComponent <City>().ZoomInstant(1 - Time.deltaTime * .3f);
                            }
                            if (GUILayout.RepeatButton("-", bigButton))
                            {
                                city.GetComponent <City>().ZoomInstant(1 + Time.deltaTime * .3f);
                            }
                            if (GUILayout.RepeatButton("---", bigButton))
                            {
                                city.GetComponent <City>().ZoomInstant(1 + Time.deltaTime * 1.5f);
                            }
                        }
                        if (GUILayout.Button("ZOOM", defaultStyle))
                        {
                            zoomClicked = !zoomClicked;
                        }

                        Rect temp = GUILayoutUtility.GetLastRect();
                        zoomOffset = new Vector2(temp.x, temp.y + 25);
                    }
                    GUILayout.EndVertical();
                }
                if (UItype != UIType.Rockband)
                {
                    GUILayout.FlexibleSpace();
                }
            }
            GUILayout.EndHorizontal();
        }
        GUILayout.EndArea();

        if (UItype == UIType.Rockband)
        {
            if (catsVisible)
            {
                drawKeys(catsOffset, 4, catsClicked);
            }
            if (zoomVisible)
            {
                drawKeys(zoomOffset, 2, zoomClicked);
            }
        }


//		GUI.Label(
//			new Rect(right.x - 150, right.y + 10, 150, 100),
//			string.Format(xMetric.Format, xMetric.Zoom * zoom * 10) + "\n" + xMetric.Name.ToUpper(),
//			yValueStyle
//		);

        //Draw Precise numbers

        /*
         * //Draw Scrubbers
         * float xRot = GUI.VerticalSlider(
         *      new Rect(top.x - 20, top.y, 20, origin.y - top.y),
         *      city.transform.localEulerAngles.x - 360,
         *      0f,-90f
         * );
         *
         * float yRot = GUI.HorizontalSlider(
         *      new Rect(origin.x + 10, origin.y, right.x - origin.x, 20),
         *      city.transform.localEulerAngles.y,
         *      0f,90f
         * );
         *
         *
         * city.transform.eulerAngles = new Vector3(xRot, yRot, 0);
         */

        //string label = "X: " + axisNames[xLabel] + "\nY: " + axisNames[yLabel];

        /*
         * GUILayout.BeginArea(new Rect(0,0,Screen.width, Screen.height));
         * {
         *      GUILayout.BeginVertical();
         *      {
         *              //GUILayout.Label(label);
         *
         *              GUILayout.FlexibleSpace();
         *              GUILayout.BeginHorizontal();
         *              {
         *                      GUILayout.BeginVertical();
         *                      {
         *                              GUILayout.Label("Zoom");
         *                              GUILayout.BeginHorizontal();
         *                              {
         *                                      if(GUILayout.Button("+"))
         *                                              city.GetComponent<City>().ZoomIn();
         *
         *                                      if(GUILayout.Button("-"))
         *                                              city.GetComponent<City>().ZoomOut();
         *                              }
         *                              GUILayout.EndHorizontal();
         *                              GUILayout.BeginHorizontal();
         *                              {
         *                                      if(GUILayout.Button("++"))
         *                                              city.GetComponent<City>().ZoomInIn();
         *
         *                                      if(GUILayout.Button("--"))
         *                                              city.GetComponent<City>().ZoomOutOut();
         *                              }
         *                              GUILayout.EndHorizontal();
         *
         *                              GUILayout.Label("\n\nHorizontal Axis");
         *                              int newValue = GUILayout.SelectionGrid(xLabel, KSMetric.ListNames, 2);
         *                              if(newValue != xLabel)
         *                              {
         *                                      xLabelNew = newValue;
         *                                      city.GetComponent<City>().RotateX();
         *                              }
         *                              GUILayout.Label("\nVertical Axis");
         *                              newValue = GUILayout.SelectionGrid(yLabel, KSMetric.ListNames, 2);
         *                              if(newValue != yLabel)
         *                              {
         *                                      yLabelNew = newValue;
         *                                      city.GetComponent<City>().RotateY();
         *                              }
         *
         *                              GUILayout.Label("\n\nGeo Bounds");
         *                              newValue = GUILayout.SelectionGrid(Geographic, GeoBounds.ListNames, 2);
         *                              if(newValue != Geographic)
         *                              {
         *                                      Geographic = newValue;
         *                                      city.GetComponent<City>().ZoomNone();
         *
         *                              }
         *
         *                              GUILayout.Label("\n\nHighlight Category");
         *                              newValue = GUILayout.SelectionGrid(selectedLegend, legendTitles, 2);
         *                              if(newValue != selectedLegend)
         *                              {
         *                                      city.GetComponent<City>().HighlightCategory(legendTitles[newValue]);
         *                                      selectedLegend = newValue;
         *                              }
         *                      }
         *                      GUILayout.EndVertical();
         *                      GUILayout.FlexibleSpace();
         *
         *              }
         *              GUILayout.EndHorizontal();
         *              GUILayout.FlexibleSpace();
         *      }
         *      GUILayout.EndVertical();
         * }
         * GUILayout.EndArea();*/
    }