Beispiel #1
0
 void OnCollisionEnter(Collision thing)
 {
     if (thing.gameObject.transform.parent != null && thing.gameObject.transform.parent.name == "Tank")
     {
         if (remainingItems == 1)
         {
             Application.LoadLevel(Application.loadedLevel);
         }
         else if (Time.time - timeImmuned > immuneLength)
         {
             timeImmuned  = Time.time;
             timeStunned  = Time.time;
             currentState = States.STUNNED;
             animLeftBird.SetBool("Flying", false);
             animMiddleBird.SetBool("Flying", false);
             animRightBird.SetBool("Flying", false);
             animVine.SetBool("Flying", false);
             remainingItems--;
             GetComponent <Rigidbody>().velocity.Set(0f, 0f, 0f);
             GameObject[] allTanks;
             allTanks = GameObject.FindGameObjectsWithTag("tank");
             foreach (GameObject tank in allTanks)
             {
                 //reset all tank layers to 0
                 tank.transform.GetChild(0).gameObject.layer = 0;
             }
         }
     }
     else if (thing.gameObject.name == "Goal")
     {
         if (DT != null)
         {
             if (DT.getHighScore() <= (remainingItems * points))
             {
                 DT.setHighscore(remainingItems * points);
             }
         }
         Application.LoadLevel(1);
     }
 }
Beispiel #2
0
    void OnGUI()
    {
        if (DT == null)
        {
            DT = GameObject.Find("DataTracker").GetComponent <DataTracker>();
        }

        Rect highScore = new Rect(Screen.width - 50f, 50f, highscoreBoxX, highscoreBoxY);

        GUI.Box(highScore, "Highscore: " + DT.getHighScore(), highscoreStyle);

        GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));
        GUILayout.BeginVertical();
        Rect suppliesRect = new Rect(Screen.width / 2, Screen.height / 2 * .7f, 10f, 10f);

        GUI.Box(suppliesRect, "Select a supplies container to deliver!", SelectionGUIStyle);
        GUILayout.BeginHorizontal();
        Rect item1Rect = new Rect((Screen.width / 2) * .85f, Screen.height / 2 * .7f, 10f, 10f);

        GUI.Box(item1Rect, "Faster Speed!", ItemSelect1Style);
        Rect item2Rect = new Rect(Screen.width / 2, Screen.height / 2 * .7f, 10f, 10f);

        GUI.Box(item2Rect, "Better Turn!", ItemSelect2Style);
        Rect item3Rect = new Rect(Screen.width / 2 * 1.15f, Screen.height / 2 * .7f, 10f, 10f);

        GUI.Box(item3Rect, "More Resources!", ItemSelect3Style);
        GUILayout.EndHorizontal();
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();
        Rect buttonAreaRect = new Rect(Screen.width * .2f, Screen.height * .4f, Screen.width * .6f, Screen.height * .3f);

        GUILayout.BeginArea(buttonAreaRect, buttonAreaStyle);
        GUILayout.BeginHorizontal();
        item1focus = GUILayout.Button("", ItemSelect1ButtonStyle);
        if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
        {
            GameObject.Find("Item1").GetComponent <Pedestal>().rotationSpeed = 100;
        }
        else
        {
            GameObject.Find("Item1").GetComponent <Pedestal>().rotationSpeed = 10;
        }
        item2focus = GUILayout.Button("", ItemSelect2ButtonStyle);
        if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
        {
            GameObject.Find("Item2").GetComponent <Pedestal>().rotationSpeed = 100;
        }
        else
        {
            GameObject.Find("Item2").GetComponent <Pedestal>().rotationSpeed = 10;
        }
        item3focus = GUILayout.Button("", ItemSelect3ButtonStyle);
        if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
        {
            GameObject.Find("Item3").GetComponent <Pedestal>().rotationSpeed = 100;
        }
        else
        {
            GameObject.Find("Item3").GetComponent <Pedestal>().rotationSpeed = 10;
        }
        GUILayout.EndHorizontal();
        GUILayout.EndArea();
    }