Inheritance: MonoBehaviour
    private void Awake()
    {
        m_LevelInfo = GetComponent <LevelInformation>();

        m_SizeOfPuzzleText      = GetComponentInChildren <Text>();
        m_SizeOfPuzzleText.text = m_Columns + "x" + m_Rows;
    }
示例#2
0
文件: Goal.cs 项目: kknet/kqq
    IEnumerator CompleteCoroutine()
    {
        anim.SetTrigger("Complete");
        yield return(new WaitForSeconds(GoalCompleteAnimationTime));

        //instantiate win scene
        SetWinScene setWinScene = (Instantiate(winScene, Vector2.zero, Quaternion.identity) as GameObject).GetComponent <SetWinScene>();

        if (setWinScene != null)         //last level win scene doesn't have "SetWinScene"
        {
            setWinScene.SetNextLevelToLevelIndex(toIndex);
        }

        //play sound, stop background music
        //GameObject.FindWithTag("Background Music").GetComponent<BackgroundMusicPlayer>().StopMusic();
        Instantiate(winAudio, Vector2.zero, Quaternion.identity);

        //record the score if it breaks the record
        LevelInformation leveInfo          = GameMoniter.Instance.leveInfo;
        float            previousHighScore = GameDataLoaderAndSaver.dataControl.GetHighScore(leveInfo.galaxy, leveInfo.level);

        if (previousHighScore < 0f || GameMoniter.Instance.Score < previousHighScore)
        {
            GameDataLoaderAndSaver.dataControl.SetHighScoreAndSave(leveInfo.galaxy, leveInfo.level, GameMoniter.Instance.Score);
        }
    }
示例#3
0
    void instantiateLevel(int i)
    {
        Debug.Log("create-new-level: " + i);
        string lvl = generateRandomLevel(i);

        // spawn room
        GameObject cube = Instantiate(Resources.Load(lvl)) as GameObject;

        cube.transform.position = new Vector3(0, i * 4, 0);
        // give level number
        cube.name = "level_" + nextNameNumber;

        nextNameNumber++;

        cube.AddComponent <LevelInformation> ();
        LevelInformation info = cube.GetComponent <LevelInformation> () as LevelInformation;

        info.level = i;

        // alternate ladders
        foreach (Transform child in cube.transform)
        {
            if (child.name == "ladder")
            {
                if (i % 2 == 0)
                {
                    child.transform.localPosition = new Vector3(xPosLadder, 1, 0);
                }
            }
        }
    }
示例#4
0
    // Use this for initialization
    void Start()
    {
        cameraObject = GameObject.Find("Main Camera");


        levelProgress = GameObject.Find("Level Information").GetComponent <LevelInformation>();
    }
示例#5
0
        private void OnGUI()
        {
            /* UI Objects */
            GUILayout.Label("Level Data", EditorStyles.boldLabel);
            name  = EditorGUILayout.TextField("Level Name", name);
            sizeX = EditorGUILayout.TextField("Size X", sizeX);
            sizeY = EditorGUILayout.TextField("Size Y", sizeY);

            EditorGUILayout.PrefixLabel("Level Description");
            description = EditorGUILayout.TextArea(description, GUILayout.Height(position.height - 200));

            /* On Generate Level button pushed */
            if (GUI.Button(new Rect(5, position.height - 35, 250, 30),
                           "Generate Level"))
            {
                // Create a new object in the scene, this object will be able to link the editor script to the scene.
                GameObject singular = GameObject.CreatePrimitive(PrimitiveType.Cube);
                singular.transform.position = new Vector3(100000, 100000, 100000);
                singular.name = "TestGenerator";

                // Attach the generation script to the object
                TestGenerator testGenerator = singular.AddComponent <TestGenerator>();

                // Create a level information struct for use in the generator
                LevelInformation information = new LevelInformation(name, description, sizeX, sizeY);

                // Create a level JSON file
                testGenerator.CreateLevelFile(information);

                // cleanup
                DestroyImmediate(singular);
            }
        }
示例#6
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        m_InformationScript = (LevelInformation)target;
        GUILayout.BeginVertical();

        m_TempID = EditorGUILayout.IntField("ID", m_InformationScript.m_LevelID);

        for (int i = 0; i < m_References.Length; i++)
        {
            if (m_TempID != m_InformationScript.m_LevelID)
            {
                if (m_References[i].m_LevelID == m_TempID)
                {
                    m_TempID = 0;
                    break;
                }
            }
        }

        if (m_TempID > 0)
        {
            m_InformationScript.m_LevelID = m_TempID;
        }
        else
        {
            Debug.LogWarning("This ID is already taken! Please try another value.");
        }

        GUILayout.EndVertical();
    }
示例#7
0
    void Start()
    {
        player         = GameObject.Find("Player").GetComponent <Player>();
        playerMovement = GameObject.Find("Player").GetComponent <FirstPersonDrifter>();
        mainCamera     = GameObject.Find("Main Camera").GetComponent <Camera>();

        allComplete       = false;
        renderer.material = painting;
        //renderer.material.color = Color.grey;
        //textMaterial.color = new Color(0.8f, 0.8f, 0.8f, 1);

        processedWords = new ArrayList();
        finished       = false;
        canType        = false;

        promptText = "Press spacebar to interact";
        hasEntered = false;

        // Particle effects
        // MAX: 2
        particleBlock = 2.0f / maxZen;

        levelProgress      = GameObject.Find("Level Information").GetComponent <LevelInformation>();
        textMaterial.color = new Color(textMaterial.color.r, textMaterial.color.g, textMaterial.color.b, 0);
    }
示例#8
0
 public void DisplayLevel(LevelInformation Info)
 {
     LevelDiscription.text = Info.Description;
     LevelImage.sprite     = Info.Image;
     StartButton.onClick.AddListener(() => StartLevel(Info.RegionName, Info.SceneName));
     gameObject.SetActive(true);
     Canvas.DisableOtherWindows(gameObject);
 }
示例#9
0
    // Use this for initialization
    void Start()
    {
        player        = GameObject.Find("Player");
        playerDrifter = player.GetComponent <FirstPersonDrifter>();
        player.GetComponent <PlayerGUI>().wordsAlpha = 1;

        levelProgress = GameObject.Find("Level Information").GetComponent <LevelInformation>();
    }
示例#10
0
    public void SaveLevelInformation()
    {
        BinaryFormatter  bf   = new BinaryFormatter();
        FileStream       file = File.Create(levelsInfoRute);
        LevelInformation info = new LevelInformation(passedLevels);

        bf.Serialize(file, info);
        file.Close();
    }
示例#11
0
 public void ConfirmationYesButton()
 {
     LevelInformation.ResetSaveData();
     nextLevelIndex = 1;
     if (ConfirmationPanel.activeSelf)
     {
         ConfirmationPanel.SetActive(false);
     }
 }
示例#12
0
 // Update is called once per frame
 void Update()
 {
     if (gameStatus != null)
     {
         LevelInformation info = gameStatus.GetComponent <LevelInformation>();
         textComponentNumberStars.text = info.numberStarsColected.ToString();
         FormatTimeAndDisplay(info);
     }
 }
示例#13
0
    public LevelInformation()
    {
        if (instance != null)
        {
            Debug.LogError("Cannot have two instances of LevelInformation.");
            return;
        }

        instance = this;
    }
示例#14
0
    public LevelInformation()
    {
        if (instance != null)
        {
            Debug.LogError("Cannot have two instances of LevelInformation.");
            return;
        }

        instance = this;
    }
示例#15
0
    /*
     *
     * Metodo onde ira checar os subniveis e atribuir seus valores de cenas e se esta disponiveis, passando como parametro o componente levelInformation
     *
     *
     */
    public void check(LevelInformation level)
    {
        subStage.SetActive(true);

        text.loadMenuLevelTexts(level.getLevelId());

        int[] _valueLevel = level.getLevel();                                // vetor de inteiro onde recebe os subniveis que estavao armazenados no LevelInformation passa no parametro

        GameObject[] phases = GameObject.FindGameObjectsWithTag("SubLevel"); // Vetor de gameObjects onde fica os objeto encontrado com o nome de "SubLevel"

        int blockedLevels = LevelManager.getBlockedLevels();                 // inteiro que recebe ate qual nivel esta desbloqueado

        // repete um grupo de instruções inseridos para cada elemento de uma matriz ou uma coleção do objeto
        foreach (GameObject phase in phases)
        {
            SubLevelInformation _subLevelInformation = phase.GetComponent <SubLevelInformation>(); // Cria componente que recebe o componente criado do objeto dentro do forech

            switch (phase.name)                                                                    // Faz uma checagem nos nomes

            {
            case "SubFase1": {                                                             // Caso nome seja igual ao do "case"
                _subLevelInformation.setLevel(_valueLevel[0]);                             // informa que este subnivel tem um seu reespectivo valor de cena

                _subLevelInformation.setTextLevel((level.getLevelId().ToString() + "-1")); // informa  que o text que sera escrito recebe o numero do levelID mais seu subnivel

                break;
            }

            case "SubFase2": {
                _subLevelInformation.setLevel(_valueLevel[1]);

                _subLevelInformation.setTextLevel((level.getLevelId().ToString() + "-2"));

                break;
            }

            case "SubFase3": {
                _subLevelInformation.setLevel(_valueLevel[2]);

                _subLevelInformation.setTextLevel((level.getLevelId().ToString() + "-3"));

                break;
            }
            }

            if (_subLevelInformation.getLevel() >= blockedLevels)
            {
                _subLevelInformation.checkLevelState(LevelState.locked);
            }
            else
            {
                _subLevelInformation.checkLevelState(LevelState.normal);
            }
        }
    }
示例#16
0
    private void FinishLevel()
    {
        levelComplete = true;

        if (LevelInformation.GetLevel(level + 1) == null)
        {
            ui.WinGame();
            return;
        }

        ui.CompleteLevel();
    }
示例#17
0
    void Start()
    {
        Screen.lockCursor = true;
        Screen.showCursor = false;

        wordsInventory = GetComponent <Player>().currentWords;
        playerDrifter  = GetComponent <FirstPersonDrifter>();
        zen            = GetComponent <Player>().zen;
        words          = GetComponent <Player>().words;

        levelProgress = GameObject.Find("Level Information").GetComponent <LevelInformation>();
    }
    private void SetUp()
    {
        _currentLevel     = _levelsInformation[_level];
        _numberEnemies    = _levelsInformation[_level]._numberOfEnemies;
        _enemiesLeft.text = "x " + _numberEnemies.ToString();

        _gameover     = false;
        _enemySpawner = GetComponent <Spawner>();
        _enemySpawner._onDeathCall      = OnEnemyDeath;
        _enemySpawner._levelInformation = _levelsInformation[_level];
        _enemySpawner.SetNumberOfEnemies();
        StartCoroutine(_enemySpawner.SpawnEnemies());
    }
        public void CanExtractWhenNoData()
        {
            var gameFiles = new GamesFiles();
            var dir       = gameFiles.GetCurrentDirectory();
            var textMap   = new string[0];

            GetFileWithLevel(textMap, 5);
            var levelInf = new LevelFiles(dir, 5);
            var level    = new LevelInformation(levelInf);

            Assert.IsEmpty(level.Platforms);
            System.IO.File.Delete(dir + @"\Leveles\5.txt");
        }
示例#20
0
        /// <summary>
        /// Use to be able to pull all level data from a level and store that data in a
        /// JSON format.
        /// </summary>
        /// <param name="levelInformation"></param>
        public void CreateLevelFile(LevelInformation levelInformation)
        {
            GameObject singular = GameObject.CreatePrimitive(PrimitiveType.Cube);

            singular.transform.position = new Vector3(100000, 100000, 100000);

            singular.name = "SceneLooker";

            GameObject[] objects = singular.scene.GetRootGameObjects();

            foreach (GameObject o in objects)
            {
                if (o.name == "Level")
                {
                    GameObject levelData = o.transform.Find("LevelData").gameObject;
                    CreateLevelData(levelData);
                }

                if (o.CompareTag("Enemy"))
                {
                    CreateEnemyData(o);
                }

                if (o.CompareTag("InteractableObject"))
                {
                    CreateInteractableObjects(o);
                }

                if (o.CompareTag("MissionTrigger"))
                {
                    CreateMissionTriggers(o);
                }

                if (o.CompareTag("Player"))
                {
                    playerPosition = new ObjectPosition(o.transform.position);
                }
            }

            ObjectData objectData = new ObjectData(_walls.ToArray(), _enemies.ToArray(), _interactableObjects.ToArray(), _missionTriggers.ToArray(), playerPosition);

            var       oj              = JsonConvert.SerializeObject(objectData);
            SceneData sceneData       = new SceneData(objectData);
            LevelFile levelFileStruct = new LevelFile(levelInformation, sceneData);
            var       json            = JsonConvert.SerializeObject(levelFileStruct);

            WriteLevelDataToFile(json, levelInformation.title.ToLower());

            DestroyImmediate(singular);
        }
示例#21
0
    public void OnSaveDraftButtonClick()
    {
        LevelInformation thisLevel = LevelCreatorManager.SerializeLevelIntoScriptObj(GameManager.theTempLevel);

        _draftLevelInfo.tagList = thisLevel.tagList;
        _draftLevelInfo.tagGameObjectListJSON = thisLevel.tagGameObjectListJSON;
        _draftLevelInfo.switcherControlJSON   = thisLevel.switcherControlJSON;
        _draftLevelInfo.playerStartPosition   = thisLevel.playerStartPosition;

#if UNITY_EDITOR
        EditorUtility.SetDirty(_draftLevelInfo);
        AssetDatabase.SaveAssets();
#endif
    }
示例#22
0
    public static void SaveLevel(LevelInformation info)
    {
        BinaryFormatter formatter = new BinaryFormatter();

        string     path   = Application.persistentDataPath + "/" + SaveName + ".bin";
        FileStream stream = new FileStream(path, FileMode.Create);

        LevelData levelData = new LevelData(info);


        saveData.AddLevel(levelData);

        formatter.Serialize(stream, saveData);
        stream.Close();
    }
示例#23
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);

        lvlInfo = new LevelInformation();
    }
示例#24
0
 public void ChargeLevelsInfo()
 {
     if (File.Exists(levelsInfoRute))
     {
         BinaryFormatter  bf   = new BinaryFormatter();
         FileStream       file = File.Open(levelsInfoRute, FileMode.Open);
         LevelInformation info = (LevelInformation)bf.Deserialize(file);
         passedLevels = info.passedLevels;
         file.Close();
     }
     else
     {
         passedLevels = new int[0];
     }
 }
示例#25
0
    /*** Finish About Audio Effect Button ***/

    #region Rotinas da escolha de Fases
    public static IEnumerator playLevel(RaycastHit _obj, AudioClip sound)
    {
        Director.sharedDirector().playEffect(sound);

        _obj.transform.localScale = new Vector3(1.1f, 1.1f, 1.0f);

        yield return(new WaitForSeconds(0.2f));

        _obj.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);

        yield return(new WaitForSeconds(0.1f));

        LevelInformation _level = _obj.collider.GetComponent <LevelInformation>();

        _level.buttonClickEnter(_level);
    }
        public void CanNotExtractLevelWithIncorrectData()
        {
            var gameFiles             = new GamesFiles();
            var dir                   = gameFiles.GetCurrentDirectory();
            var textMapWithWrongValue = new[]
            {
                "PLAT 0 0 5 5",
                "PLER 0 0",
            };

            GetFileWithLevel(textMapWithWrongValue, 3);
            var levelInf = new LevelFiles(dir, 3);
            var level    = new LevelInformation(levelInf);

            Assert.Throws <Exception>(() => level.Extractor.ExtractLevelFromFile());
            System.IO.File.Delete(dir + @"\Leveles\3.txt");
        }
示例#27
0
    public void RestartLevel()
    {
        levelComplete = false;
        ui.SetLevel(level);

        grid = LevelInformation.GetLevel(level);

        for (int i = 0; i < objGrid.GetLength(0); i++)
        {
            for (int j = 0; j < objGrid.GetLength(1); j++)
            {
                Destroy(objGrid[i, j]);
            }
        }

        CreateGrid();
    }
示例#28
0
    void FormatTimeAndDisplay(LevelInformation info)
    {
        int hours        = (int)(info.timeLevel / 3600f);
        int minutes      = (int)(info.timeLevel / 60f);
        int seconds      = (int)(info.timeLevel % 60f);
        int milliseconds = (int)(((info.timeLevel % 60f) * 1000f) % 1000); //Time.timeSinceLevelLoad * 6f

        string time = "";

        if (!string.Equals(hours.ToString("00"), "00"))
        {
            time += hours.ToString("00") + ":";
        }

        time += minutes.ToString("00") + ":" + seconds.ToString("00");
        textComponentTimer.text             = time;
        textComponentTimerMilliSeconds.text = milliseconds.ToString("000");
    }
示例#29
0
    //singleton
    private void Awake()
    {
        if (levelInfo == null)
        {
            levelInfo = this;
        }
        else if (levelInfo != this)
        {
            Destroy(this);
        }

        if (useRandomSeed)
        {
            rng = new System.Random();
        }
        else
        {
            rng = new System.Random(customSeed);
        }
    }
示例#30
0
    /*
     * Metodo responsavel por chamar o diretor ou a message para carregar o nivel desejado, passando como parametro o componente LevelInformation onde contem informaçao das cenas dos subniveis.
     */
    public void buttonClickEnter(LevelInformation other)
    {
        switch (this.levelState)
        {
        // quando clicar e o statos do level for igual a normal faça as operaçoes dentro desse case
        case LevelState.normal: {
            SubLevelCheckPhases subLevel = GameObject.Find("menuFases.CheckPhase").GetComponent <SubLevelCheckPhases>();                    // Procura o objeto menufases>checkPhases  e recupera seu componente SubLevelCheckPhase
            //para poder checar o Subnivel e atribuir seus valor (se esta diponivel , e o valor da Cena que ele carrega)

            subLevel.check(other);                     // acessa o metodo Check do componente subnivel psaando como parametro o componente LevelInformation onde tem a informaçao dos subniveis, que antes armazenada nos niveis.

            break;
        }

        // Caso o level esteja trancado chama Mensage para poder ativar uma mensagem que nao sera possivel acessar a fase
        case  LevelState.locked: {
            // quando clicar e o statos do level for igual a locked faça as operaçoes dentro desse case
            break;
        }
        }
    }
示例#31
0
    private void Start()
    {
        ui = GameObject.Find("Canvas").GetComponent <UI>();

        cableSpriteDict = new Dictionary <CableType, Sprite> {
            { CableType.STRAIGHT, straight },
            { CableType.T, t },
            { CableType.CROSS, cross },
            { CableType.CORNER, corner },
            { CableType.GENERATOR, generator },
            { CableType.TARGET, target }
        };

        level = 1;
        ui.SetLevel(level);

        grid = LevelInformation.GetLevel(level);
        CreateGrid();

        UpdateConnections();
    }