Inheritance: MonoBehaviour
    void ShowMenu(int windowID)
    {
        GameObject   PointCounter = GameObject.Find("Points");
        PointCounter Points       = PointCounter.GetComponent <PointCounter> ();

        GUI.Label(new Rect(20, Screen.height / 8, Screen.width - 40, (Screen.height / 2) - 60), loseText + (Points.point) + loseText2);

        if (GUI.Button(new Rect(20, (Screen.height / 4), (Screen.width / 2) - 30, (Screen.height / 2) - 20), "Main Menu"))
        {
            GlobalVariables.pause();
            showLoseMenu = false;
            LoadLevels.loadMenu("bubble_menu");
            Time.timeScale           = 1;
            GlobalVariables.isPaused = false;
        }
        if (GUI.Button(new Rect((Screen.width / 2), (Screen.height / 4), (Screen.width / 2) - 20, (Screen.height / 2) - 20), "Try Again"))
        {
            //LoadLevels.loadMenu ("OceanGame");
            //GlobalVariables.pause();
            //Application.LoadLevel(Application.loadedLevel);
            //Time.timeScale = 1;
            //GlobalVariables.isPaused = false;
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
            Time.timeScale           = 1;
            GlobalVariables.isPaused = false;
        }
    }
Beispiel #2
0
 void ShowMenu(int windowID)
 {
     if (GUI.Button(new Rect(20, (Screen.height / 4), (Screen.width / 2) - 30, (Screen.height / 2) - 20), "Quit"))
     {
         GlobalVariables.isPaused = false;
         GlobalVariables.resetDifficulty();
         LoadLevels.loadMenu("bubble_menu");
     }
     if (GUI.Button(new Rect((Screen.width / 2), (Screen.height / 4), (Screen.width / 2) - 20, (Screen.height / 2) - 20), "Resume"))
     {
         GlobalVariables.isPaused = false;
         showPauseMenu            = false;
     }
 }
Beispiel #3
0
 void Start()
 {
     _fade       = MainMenuFadeObj.GetComponent <MainMenuFade>();
     _loadLevels = LoadLevelsObj.GetComponent <LoadLevels>();
 }
Beispiel #4
0
    // create objects based on data within level.
    private void CreateFromFile()
    {
        players  = new GameObject("Players");
        units    = GameObject.Find("Units");
        cellGrid = GameObject.Find("CellGrid");
        mCamera  = Camera.main;
        var cameraObject = new GameObject("Main Camera");

        cameraObject.tag = "MainCamera";
        mCamera          = cameraObject.AddComponent <Camera>();

        cellGrid.GetComponent <CellGrid>().PlayersParent = players.transform;

        for (int i = 0; i < 2; i++)
        {
            var player = new GameObject(string.Format("Player_{0}", players.transform.childCount));
            player.AddComponent <HumanPlayer>();
            player.GetComponent <Player>().PlayerNumber = players.transform.childCount;
            player.transform.parent = players.transform;
        }

        EditorObject p = players.AddComponent <EditorObject>();

        p.data.pos        = players.transform.position;
        p.data.rot        = players.transform.rotation;
        p.data.objectType = EditorObject.ObjectType.Player;



        GameObject LoadLevels;
        var        ret = new List <Cell>();


        for (int i = 0; i < level.editorObjects.Count; i++)
        {
            if (level.editorObjects[i].objectType == EditorObject.ObjectType.Unit)
            {
                LoadLevels = Instantiate(itemsToPickFrom[0]);
                LoadLevels.transform.position = level.editorObjects[i].pos; // set position from data in level
                LoadLevels.transform.rotation = level.editorObjects[i].rot; // set rotation from data in level.
                LoadLevels.layer = 9;                                       // assign to SpawnedObjects layer.

                LoadLevels.GetComponent <Unit>().PlayerNumber = 0;
                units = GameObject.Find("Units");

                LoadLevels.transform.SetParent(units.transform);

                //Add editor object component and feed data.
                EditorObject eo = LoadLevels.AddComponent <EditorObject>();
                eo.data.pos        = LoadLevels.transform.position;
                eo.data.rot        = LoadLevels.transform.rotation;
                eo.data.objectType = EditorObject.ObjectType.Unit;
            }

            else if (level.editorObjects[i].objectType == EditorObject.ObjectType.Unit2) // if a cylinder object
            {
                LoadLevels = Instantiate(itemsToPickFrom[1]);
                LoadLevels.transform.position = level.editorObjects[i].pos; // set position from data in level
                LoadLevels.transform.rotation = level.editorObjects[i].rot; // set rotation from data in level.
                LoadLevels.layer = 9;                                       // assign to SpawnedObjects layer.

                LoadLevels.GetComponent <Unit>().PlayerNumber = 1;
                units = GameObject.Find("Units");

                LoadLevels.transform.SetParent(units.transform);

                //Add editor object component and feed data.
                EditorObject eo = LoadLevels.AddComponent <EditorObject>();
                eo.data.pos        = LoadLevels.transform.position;
                eo.data.rot        = LoadLevels.transform.rotation;
                eo.data.objectType = EditorObject.ObjectType.Unit2;
            }

            /*else if (level.editorObjects[i].objectType == EditorObject.ObjectType.Obstacle)
             * {
             *  LoadLevels = Instantiate(itemsToPickFrom[2]);
             *  LoadLevels.transform.position = level.editorObjects[i].pos; // set position from data in level
             *  LoadLevels.transform.rotation = level.editorObjects[i].rot; // set rotation from data in level.
             *  LoadLevels.layer = 9; // assign to SpawnedObjects layer.
             *
             *  //Add editor object component and feed data.
             *  EditorObject eo = LoadLevels.AddComponent<EditorObject>();
             *  eo.data.pos = LoadLevels.transform.position;
             *  eo.data.rot = LoadLevels.transform.rotation;
             *  eo.data.objectType = EditorObject.ObjectType.Obstacle;
             * }*/

            else if (level.editorObjects[i].objectType == EditorObject.ObjectType.Obstacle)
            {
                LoadLevels = Instantiate(itemsToPickFrom[2]);
                LoadLevels.transform.position = level.editorObjects[i].pos; // set position from data in level
                LoadLevels.transform.rotation = level.editorObjects[i].rot; // set rotation from data in level.
                LoadLevels.layer = 9;                                       // assign to SpawnedObjects layer.

                LoadLevels.GetComponent <Unit>().PlayerNumber = 2;
                units = GameObject.Find("Units");

                LoadLevels.transform.SetParent(units.transform);

                //Add editor object component and feed data.
                EditorObject eo = LoadLevels.AddComponent <EditorObject>();
                eo.data.pos        = LoadLevels.transform.position;
                eo.data.rot        = LoadLevels.transform.rotation;
                eo.data.objectType = EditorObject.ObjectType.Unit2;
            }

            else if (level.editorObjects[i].objectType == EditorObject.ObjectType.Cell)
            {
                Debug.Log("loading grid");
                var LoadLevelss = Instantiate(itemsToPickFrom[3]);
                if (level.editorObjects[i].isTaken == true)
                {
                    LoadLevelss.GetComponent <Cell>().IsTaken = true;
                }
                LoadLevelss.transform.position = level.editorObjects[i].pos; // set position from data in level
                LoadLevelss.transform.rotation = level.editorObjects[i].rot; // set rotation from data in level.
                LoadLevelss.GetComponent <Cell>().OffsetCoord  = level.editorObjects[i].coord;
                LoadLevelss.GetComponent <Cell>().MovementCost = 1;
                cellGrid = GameObject.Find("CellGrid");
                LoadLevelss.transform.SetParent(cellGrid.transform);


                Debug.Log(LoadLevelss.GetComponent <Cell>().OffsetCoord);
                EditorObject eo = LoadLevelss.AddComponent <EditorObject>();
                eo.data.pos        = LoadLevelss.transform.position;
                eo.data.rot        = LoadLevelss.transform.rotation;
                eo.data.objectType = EditorObject.ObjectType.Cell;
            }
            else if (level.editorObjects[i].objectType == EditorObject.ObjectType.Camera)
            {
                mCamera.transform.position = level.editorObjects[i].pos; // set position from data in level
                mCamera.transform.rotation = level.editorObjects[i].rot; // set rotation from data in level.
                mCamera.fieldOfView        = 35.3f;

                EditorObject eo = cameraObject.AddComponent <EditorObject>();
                eo.data.pos        = cameraObject.transform.position;
                eo.data.rot        = cameraObject.transform.rotation;
                eo.data.objectType = EditorObject.ObjectType.Camera;
            }
        }
    }
Beispiel #5
0
 // Use this for initialization
 void Start()
 {
     // _loadlevel = LoadLevelObj.GetComponent<LoadLevel>();
     _loadlevels = LoadLevelsObj.GetComponent <LoadLevels>();
 }