Esempio n. 1
0
    private void drawLevelSelection(Rect drawingRect)
    {
        int        oldFontSize   = GUI.skin.label.fontSize;
        TextAnchor oldAlignment  = GUI.skin.label.alignment;
        int        titleFontSize = 24;

        GUI.skin.label.fontSize = titleFontSize;
        //print ("Draw Level Selection at " + drawingRect.ToString ());
        string prefix = "< ";
        string suffix = " >";

        if (selectedLevel == 0)
        {
            prefix = "";
        }
        else if (selectedLevel == availableLevels.Count - 1)
        {
            suffix = "";
        }
        print(selectedLevel);
        string selectedLevelName = availableLevels [selectedLevel];
        string contentTitle      = prefix + selectedLevelName + suffix;

        GUI.BeginGroup(drawingRect);
        GUI.Label(new Rect(0, 0, drawingRect.width, 50), contentTitle);
        // TODO LevelStats anzeigen
        if (TheBrain.GetInstance().LoadedSaveGame())
        {
            int[] scoreList          = TheBrain.GetInstance().GetScoreListForLevel(selectedLevelName);
            float scoreLabelHeight   = 20;
            int   scoreLabelFontSize = 16;
            GUI.skin.label.fontSize = scoreLabelFontSize;
            //GUI.skin.label.alignment = TextAnchor.UpperLeft;
            //string scoreListString = "";
            for (int i = 0; i < scoreList.Length; i++)
            {
                int score = scoreList [i];
                //print(score);
                string scoreRow = (i + 1).ToString() + ". " + (score.ToString());
                //print(scoreRow);
                GUI.Label(new Rect(5, 50 + (i * 20), drawingRect.width / 2, 30), scoreRow);
            }
        }
        else
        {
            print("not ready");
        }
        GUI.EndGroup();
        GUI.skin.label.alignment = oldAlignment;
        GUI.skin.label.fontSize  = oldFontSize;
        //print (scoreListString);
    }
Esempio n. 2
0
    private IEnumerator EndLevel()
    {
        this.currentLevelScore += (int)((finishScore + timeToBeat + Lander.GetInstance().GetFuel()) + 0.5f);
        //this.currentLevelScore += (int)( + 0.5f);
        TheBrain.GetInstance().ApplyCurrentScore(currentLevelScore);

        SetMessageLabelText("Well done ...", 48, 3);

        yield return(new WaitForSeconds(3));

        // TODO vernünftiges Verhalten für das Beenden eines Levels
        SetGameOver();
    }
Esempio n. 3
0
    // Use this for initialization
    void Start()
    {
        // should initialize TheBrain
        receiver = WiimoteReceiver.Instance;
        receiver.connect();
        //if(TheBrain.GetInstance().LoadedSaveGame()){
        TheBrain.GetInstance().LoadSaveGame(selectedSaveGame);

        /*} else {
         *      print("already loaded");
         * }*/
        this.availableLevels = TheBrain.GetInstance().GetAvailableLevels();
        if (audio == null)
        {
            gameObject.AddComponent(typeof(AudioSource));
        }
    }
Esempio n. 4
0
 void Start()
 {
     //currentLandingPad = 0;
     Debug.Log("Fake load level in LandingPadGroup");
     instance         = this;
     elapsedTime      = 0;
     this.landingPads = gameObject.GetComponentsInChildren <LandingPlatform> ();
     TheBrain.GetInstance().StartNewLevel(Application.loadedLevelName);
     this.currentLevelScore       = 0;
     Physics.gravity              = new Vector3(0, -gravityForce, 0);
     this.messageLabelDisplayTime = 4;
     this.messageLabelfontSize    = 48;
     print("Finished Fake load");
     Time.timeScale = 1;
     if (gameObject.audio == null)
     {
         gameObject.AddComponent(typeof(AudioSource));
     }
 }
Esempio n. 5
0
    void OnGUI()
    {
        // Set up gui skin
        //GUI.skin = guiSkin;

        // Our GUI is laid out for a 1920 x 1200 pixel display (16:10 aspect). The next line makes sure it rescales nicely to other resolutions.
        //GUI.matrix = Matrix4x4.TRS (new Vector3 (0, 0, 0), Quaternion.identity, new Vector3 (Screen.height / nativeVerticalResolution, Screen.height / nativeVerticalResolution, 1));

        if (isPaused || gameOver)
        {
            currentButtons = isPaused ? pauseMenuButtonNames : endMenuButtonNames;

            // TODO wrap with GUI.Box
            //print ("center: " + (Screen.width / 2).ToString ());
            float width        = 100;
            float heigthButton = 50;
            float x            = (Screen.width / 2) - (width / 2);
            float yPadding     = 10;
            float y            = (Screen.height / 2) - (heigthButton * 2);

            if (WiimoteReceiver.Instance.wiimotes.ContainsKey(1))
            {
                //print ("Got WiiMote in Menu");
                Wiimote wiimote = WiimoteReceiver.Instance.wiimotes [1];
                if (wiimote.BUTTON_A > 0)
                {
                    //GUI.b
                    string focusedControl = GUI.GetNameOfFocusedControl();
                    if (focusedControl.Length > 0)
                    {
                        if (isPaused && activeMenuButton == 0)
                        {
                            print("Continue");
                            Time.timeScale = 1;
                            isPaused       = false;
                        }
                        else if (currentButtons [currentButtons.Length - 2].Equals(focusedControl))
                        {
                            print("Restart");
                            Application.LoadLevel(TheBrain.GetInstance().GetCurrentLevelName());
                        }
                        else if (currentButtons [currentButtons.Length - 1].Equals(focusedControl))
                        {
                            print("Main Menu!");
                            Application.LoadLevel(0);
                        }
                    }
                }
            }
            //activeMenuButton = GUI.SelectionGrid (new Rect (x, y, width, height*4), activeMenuButton, selectionStrings, 1);
            GUI.skin = NormalSkin;
            string menuTitle = isPaused ? "Pause" : "Game Over";
            float  heightb   = (heigthButton * currentButtons.Length) + (yPadding * (currentButtons.Length - 1));
            GUI.Box(new Rect(x - 20, y - 30, width + 40, heightb + 40), menuTitle);
            GUI.FocusControl(currentButtons [activeMenuButton]);

            for (int i = 0; i < currentButtons.Length; i++)
            {
                GUI.SetNextControlName(currentButtons [i]);
                GUI.Button(new Rect(x, y + (i * (heigthButton + yPadding)), width, heigthButton), currentButtons [i]);
            }
            //GUI.F
        }
        else
        {
            if (messageLabelText != null)
            {
                if (messageLabelDisplayTime > 0)
                {
                    GUI.skin = NormalSkin;
                    NormalSkin.label.fontSize = messageLabelfontSize;
                    float width  = 300;
                    float height = 150;
                    float x      = (Screen.width / 2) - (width / 2);
                    float y      = (Screen.height / 2) - (height / 2);
                    GUI.Label(new Rect(x, y, width, height), messageLabelText, "label");
                    //messageLabelDisplayTime -= Time.smoothDeltaTime;
                }
                else
                {
                    messageLabelText = null;
                }
            }
        }
    }