Example #1
0
    public static Field Create(LevelParameters level, LevelRepository levelRepository, Enemy enemy, Player player)
    {
        var     h_size        = level.H_size;
        var     w_size        = level.W_size;
        Vector3 fieldPosition = Vector3.zero;
        var     field         = Instantiate(Resources.Load("Prefabs/Field") as GameObject, fieldPosition, Quaternion.identity);
        Vector3 scale         = Vector3.one;

        scale.x = h_size;
        scale.y = 0.1f;
        scale.z = w_size;
        field.transform.localScale = scale;

        Vector3 cameraPosition = field.transform.position;

        cameraPosition.x = 6;
        cameraPosition.y = 14;

        Camera.main.transform.position = cameraPosition;
        Camera.main.orthographicSize   = (float)h_size * 0.6f;

        field.gameObject.GetComponent <Field>().CreateEnemie(level, enemy, levelRepository);
        field.gameObject.GetComponent <Field>().CreateChips(level, levelRepository);
        field.gameObject.GetComponent <Field>().CreatePlayer(level, player);

        return(field.gameObject.GetComponent <Field>());
    }
Example #2
0
    // Start is called before the first frame update
    void Awake()
    {
        //enemyLoader.Init();
        //weaponLoader.Init();
        //EverythingLoader.Instance.Init();
        levelLoading = true;
        blind.On();

        virtualController.Init(uiCamera, Move, Stop);
        playerBrain.Init(this, bulletBox);
        //currentLevel = 0;
        //var level = levelList[currentLevel].MakeInstance(bgScrollSprite.transform.gameObject);
        var level = levelLists.levelList[currentLevel].MakeInstance(bgScrollSprite.transform.gameObject);

        level.Init(this);
        level.transform.position = bgScrollSprite.transform.position;
        curLevelPF   = level;
        camStopRight = curLevelPF.camStopRight;
        playerBrain.transform.position = playerStart.position;


        expSlider.value = 0f;
        playerBrain.playerStats.CharacterLevel = 1;
        levelLabel.text = ("Player Lvl." + playerBrain.playerStats.CharacterLevel.ToString());
        AddXP(0);    //For intial setting
        AddValue(0); //For intial setting

        _currentCoroutine = StartCoroutine(ExecuteAfterTime(1f));
        StartCoroutine(ExecuteAfterTime(1f));
        levelLoading = false;
        //AddXP(450);
    }
Example #3
0
    void Start()
    {
        manager      = GameObject.FindObjectOfType <Manager>();
        canvas       = GameObject.FindGameObjectWithTag("Canvas");
        audioManager = GameObject.FindObjectOfType <AudioManager>();
        dictionary   = GameObject.FindObjectOfType <Dictionary>();
        timer        = GameObject.FindObjectOfType <Slider> ();
        scoreManager = GameObject.FindObjectOfType <ScoreManager> ();
        gridLayout   = GetComponent <GridLayoutGroup> ();

        parameters       = LevelParameters.GetParameters(manager.GetCurrentLevel());
        wordParameter    = parameters [0];
        timeParameter    = parameters [1];
        starParameter    = parameters [2];
        tornadoParameter = parameters [3];
        flashParameter   = parameters [4];

        ApplyWordParameter();
        ApplyTimeParameter();

        texts = GetComponentsInChildren <Text>();

        EnlistWords();

        FindSlot(enWords);
        FindSlot(ptWords);

        StartCoroutine(ApplyOtherParameters());

        Messenger.Broadcast(GameEvent.SPAWNED);
    }
Example #4
0
    private void CreatePlayer(LevelParameters level, Player player)
    {
        var     h_size        = level.H_size;
        var     w_size        = level.W_size;
        Vector3 spawnPosition = new Vector3(-h_size / 2, 0.3f, -w_size / 2);

        Player newPlayer = Instantiate(player, spawnPosition, Quaternion.identity) as Player;
    }
Example #5
0
    public void PlayerInit(LevelParameters level)
    {
        int   xHeight = level.XHeight;
        float xOffset = level.XOffset;

        float playerX = xHeight * xOffset / 2;
        var   player  = (GameObject)Instantiate(Resources.Load("Prefabs/Player"), new Vector3(playerX, 0.03f, 3f), Quaternion.identity);

        camera.player = player.transform;
    }
Example #6
0
    private void CreateEnemie(LevelParameters level, Enemy enemy, LevelRepository levelRepository)
    {
        var h_size = level.H_size;
        var w_size = level.W_size;
        var nomber = levelRepository.LevelList[Controller.Instance.Index].enemyNomber * level.IncreaseNomber;

        for (int i = 0; i < nomber; i++)
        {
            Vector3 spawnPosition = new Vector3(Random.Range(-(h_size - 1) / 2, (h_size - 1) / 2), 0.3f, Random.Range(-(w_size - 1) / 2, (w_size - 1) / 2));
            Enemy   newEnemy      = Instantiate(enemy, spawnPosition, Quaternion.identity) as Enemy;
        }
    }
 void Awake()
 {
     GameObject levelParametersObject = GameObject.FindWithTag ("LevelParameters");
     if (levelParametersObject != null)
     {
         levelParameters = levelParametersObject.GetComponent <LevelParameters>();
     }
     if (levelParameters == null)
     {
         Debug.Log ("Cannot find 'LevelParameters' script");
     }
 }
Example #8
0
    public static Map Create(LevelParameters level, Hex hexPrefab)
    {
        Vector3 fieldPosition = Vector3.zero;
        var     mapPrefab     = Resources.Load <Map>("Prefabs/Map");


        var map = Instantiate(mapPrefab, fieldPosition, Quaternion.identity);

        map.Initializie(level, hexPrefab);

        return(map);
    }
Example #9
0
    private void LevelComplete(float x)
    {
        SetGameState(false);
        m_CurrentLevel.SavedParameters.State.SetComplete();
        LevelParameters next = m_AllLevels.GetNextLevelByID(m_CurrentLevel.Preset.ID);

        if (next != null)
        {
            next.SavedParameters.State.SetOpen();
        }
        SaveLevels();
        CommonComponents.ControllerUI.ShowWinScreen.Execute(true);
    }
Example #10
0
 void updateLevelParams(LevelParameters level)
 {
     currentlevel.branchWeights = level.branchWeights;
     currentlevel.idealNumExits = level.idealNumExits;
     currentlevel.mapCol        = level.mapCol;
     currentlevel.mapRows       = level.mapRows;
     currentlevel.maxFloorRatio = level.maxFloorRatio;
     currentlevel.minFloorRatio = level.minFloorRatio;
     currentlevel.numBeacons    = level.numBeacons;
     currentlevel.numEnemies    = level.numEnemies;
     currentlevel.scale         = level.scale;
     currentlevel.tileSize      = level.tileSize;
 }
    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        if (Instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
    }
Example #12
0
    public void InitializeLevel()
    {
        m_level = new LevelParameters(m_currentLevel);

        TokenColors = MakeColor(Level.TokenTypes);

        TokensByTypes = new List <List <Token> >();

        for (int i = 0; i < Level.TokenTypes; i++)
        {
            TokensByTypes.Add(new List <Token>());
        }

        m_field = Field.Create(Level.FieldSize, Level.FreeSpace);
    }
Example #13
0
    public void LoadNextLevel()
    {
        levelComplete = false;

        if (currentLevel >= levelLists.levelList.Count)
        {
            //currentLevel = 0;
            worldComplete = true;
        }

        while (dropContainerList.Count > 0)
        {
            dropContainerList[0].Dissapear();
            dropContainerList.Remove(dropContainerList[0]);
        }
        while (enemiesList.Count > 0)
        {
            enemiesList.Remove(enemiesList[0]);
        }
        if (!worldComplete)
        {
            blind.On();

            StartCoroutine(ExecuteAfterTime(1f));

            curLevelPF.Destruct();
            NGUITools.Destroy(curLevelPF.gameObject);

            var level = levelLists.levelList[currentLevel].MakeInstance(bgScrollSprite.transform.gameObject);
            level.Init(this);
            level.transform.position = bgScrollSprite.transform.position;
            curLevelPF   = level;
            camStopRight = curLevelPF.camStopRight;

            Scroll(new Vector2(720f, 0f), true);

            playerBrain.Reset();
            playerBrain.transform.position = playerStart.position;
            uiCamera.transform.position    = playerBrain.transform.position;

            levelLoading = false;
        }

        if (worldComplete)
        {
            StartCoroutine(WorldComplete());
        }
    }
    // Use this for initialization
    void Start()
    {
        ProceduralWorldCreator worldCreator = GetComponent <ProceduralWorldCreator>();
        CloudSpawner           cloudSpawner = GetComponent <CloudSpawner>();
        MountainSpawner        spawner      = GetComponent <MountainSpawner>();

        LevelParameters level = levels[levelNumber];

        worldCreator.minNumContinents = level.minNumContinents;
        worldCreator.maxNumContinents = level.maxNumContinents;
        cloudSpawner.minCloudCount    = level.minNumClouds;
        cloudSpawner.maxCloudCount    = level.maxNumClouds;
        spawner.minSpawnTime          = level.minMountainSpawnRate;
        spawner.maxSpawnTime          = level.maxMountainSpawnRate;

        numLevels = 3; //levels.Length;
    }
Example #15
0
    public void Setup(LevelManager _lev)
    {
        levMan = _lev;
        string path = "Maps/" + levMan.NAME + "/Steps/";
        string mainPath = "Maps/" + levMan.NAME + "/";

        InitLevelSetup = Instantiate(Resources.Load(mainPath + "Setup")) as LevelParameters;
        LevelSetup = InitLevelSetup;
        LinearSetup = Instantiate(Resources.Load(mainPath + "Linear")) as LinearLevelSetup;
        _listSteps = LinearSetup.LinearSteps;
        untriggerSteps();

        _CURRENTSTEP = _listSteps[0];

        GameEventManager.GameStart += GameStart;
        GameEventManager.Respawn += Respawn;
        GameEventManager.GameOver += GameOver;
    }
Example #16
0
    public void StartLevel()
    {
        CommonComponents.PlayerManager.Reset();
        m_CurrentLevel = m_AllLevels.GetLevelByID(m_SelectedLevel);
        if (m_CurrentLevel == null)
        {
            //error
            return;
        }
        CommonComponents.AsteroidsManager.SetSpawnerParameters(m_CurrentLevel.Preset.AsteroidSpawn);
        CommonComponents.BulletsManager.SetSpawnParameters(m_CurrentLevel.Preset.BulletSpawn);
        CommonComponents.UserInput.SetNewShootTime(m_CurrentLevel.Preset.ShootTime);
        m_AsteroidsPool.ChangePrefab(m_AsteroidPrefabs[m_CurrentLevel.SavedParameters.AsteroidType]);
        NormalizedTimer.Value = 0f;
        m_Timer = 0f;

        CommonComponents.ControllerUI.SetActiveGameUI();
        SetGameState(true);
    }
Example #17
0
    void SetTitlePanel()
    {
        LevelParameters parameters = Parameters[currentLevel];
        string          title      = "";

        if (parameters.levelNameOn)
        {
            title += parameters.LevelName;
        }
        if (parameters.levelNameOn && parameters.subLevelNameOn)
        {
            title += " - ";
        }
        if (parameters.subLevelNameOn)
        {
            title += parameters.subLevelName;
        }
        if (parameters.subLevelNumberOn)
        {
            title += " " + (currentReaction + 1);
        }

        Game.transform.Find("Panel/Title").GetComponent <Text>().text = title;
        Game.transform.Find("Panel").GetComponent <Image>().color     = LevelColor[currentLevel];

        if (currentReaction == reactions[currentLevel].Length - 1 && currentLevel == reactions.Length - 1)
        {
            Game.transform.Find("Panel/NextLevel").GetComponent <Button>().interactable = false;
        }
        else
        {
            Game.transform.Find("Panel/NextLevel").GetComponent <Button>().interactable = true;
        }

        if (currentReaction == 0 && currentLevel == 0)
        {
            Game.transform.Find("Panel/PreviousLevel").GetComponent <Button>().interactable = false;
        }
        else
        {
            Game.transform.Find("Panel/PreviousLevel").GetComponent <Button>().interactable = true;
        }
    }
Example #18
0
    private void VerticalPoints(LevelParameters level, LevelRepository levelRepository, int sidePosition)
    {
        var     h_size           = level.H_size;
        var     spawnPositions   = new List <Vector3>();
        var     chipfield        = levelRepository.LevelList[Controller.Instance.Index].platforms;
        Vector3 previousPosition = new Vector3(-((h_size - 6) / 2), 0.1f, sidePosition);

        spawnPositions.Add(previousPosition);

        for (int i = 0; i < pointNomber - 1; i++)
        {
            previousPosition = previousPosition + new Vector3(6, 0, 0);

            spawnPositions.Add(previousPosition);
        }
        for (int i = 0; i < pointNomber; i++)
        {
            int       index        = Random.Range(0, chipfield.Length);
            ChipField newChipField = Instantiate(chipfield[index], spawnPositions[i], Quaternion.identity) as ChipField;
        }
    }
Example #19
0
    private void CreateChips(LevelParameters level, LevelRepository levelRepository)
    {
        var h_size = level.H_size;
        var w_size = level.W_size;
        int sidePosition;

        if (((w_size - 1) / 3) % 2 == 0)
        {
            pointNomber  = (((h_size - 1) / 5) * ((w_size - 1) / 3)) / 2;
            sidePosition = (w_size - 5) / 2;

            VerticalPoints(level, levelRepository, sidePosition);
            VerticalPoints(level, levelRepository, -sidePosition);
        }
        else
        {
            pointNomber  = ((h_size - 1) / 5) * ((w_size - 1) / 3);
            sidePosition = 0;
            VerticalPoints(level, levelRepository, sidePosition);
        }
    }
Example #20
0
    void Start()
    {
        GameObject levelParametersObject = GameObject.FindWithTag ("LevelParameters");
        if (levelParametersObject != null)
        {
            levelParameters = levelParametersObject.GetComponent <LevelParameters>();
        }
        if (levelParameters == null)
        {
            Debug.Log ("Cannot find 'LevelParameters' script");
        }

        GameObject networkLoaderObject = GameObject.FindWithTag ("NetworkLoader");
        if (networkLoaderObject != null)
        {
            networkLoader = networkLoaderObject.GetComponent <NetworkLoader>();
        }
        if (networkLoader == null)
        {
            Debug.Log ("Cannot find 'NetworkLoader' script");
        }
    }
Example #21
0
 private void Start()
 {
     levelParameters = gameObject.GetComponentInParent <LevelParameters>();
 }
Example #22
0
 private void Respawn()
 {
     if (this != null)
     {
         untriggerSteps();
         _listSteps = LinearSetup.LinearSteps;
         LevelSetup = InitLevelSetup;
         levMan.tools.disableAllBrick();
         triggerStep(_listSteps[0]);
         InvokeRepeating("checkScore", 0f, 1f);
     }
 }
Example #23
0
    // Use this for initialization
    public void Awake()
    {
        if (GameObject.Find("Frameworks") == null)
        {
            GameObject fmObj = Instantiate(Resources.Load("Presets/Frameworks")) as GameObject;
            fmObj.name = "Frameworks";
        }

        if (GameObject.FindGameObjectWithTag("PlayerData") == null)
        {
            GameObject _dataplayer = Instantiate(Resources.Load("Presets/PlayerData")) as GameObject;
            _profile = _dataplayer.GetComponent<PlayerData>();
            _profile.Launch();
        }
        else
        {
            _profile = GameObject.FindGameObjectWithTag("PlayerData").GetComponent<PlayerData>();
            _profile.Launch();
        }

        if (_profile.SETUP.GameType == GameSetup.versionType.Demo)
        {
        //			Screen.SetResolution(800,600, false);
        //			GameObject.Find("Frameworks/OT/View").GetComponent<OTView>().pixelPerfectResolution = new Vector2(800f,600f);
        //			GameObject.Find("Frameworks/OT/View").GetComponent<OTView>().alwaysPixelPerfect = true;
        //			GameObject.Find("Frameworks/OT/View").GetComponent<OTView>().customSize = 4;
        }

        GAMESTATE = _EditorState;
        _player = GameObject.FindGameObjectWithTag("Player").GetComponent<Player>();
        GlobTuning = Instantiate(Resources.Load("Tuning/Global")) as LPTuning;
        InputMan = Instantiate(Resources.Load("Tuning/InputManager")) as InputManager;
        CurrentLevelInfo = Instantiate(Resources.Load("Tuning/Levels/" + NAME)) as LevelInfo;

        LocalTuning = Instantiate(Resources.Load("Maps/" + NAME + "/Setup")) as LevelParameters;
        LocalTuning.initScript();

        GameObject OutSpw = new GameObject("OuterSpawn");
        OuterSpawn = OutSpw;
        OuterSpawn.transform.parent = FETool.findWithinChildren(this.gameObject, "Enviro").transform;
        OuterSpawn.transform.position = new Vector3(0f, -7.5f, 0f);

        tools = gameObject.AddComponent<LevelTools>();
        tools._levMan = this;
        TranslateAllInScene();

        CollectiblePlaces[] collecPla = FETool.findWithinChildren(this.gameObject, "Enviro/CollectiblePlaces").GetComponentsInChildren<CollectiblePlaces>();
        foreach (CollectiblePlaces cpl in collecPla)
        {
            collecPlaces.Add(cpl);
        }
        Gate = GameObject.FindGameObjectWithTag("SpaceGate").GetComponent<SpaceGate>();
        Gate.Setup(this);

        wpDirector = GetComponentInChildren<WaypointDirector>();
        wpDirector.Setup(this);

        bricksMan = FETool.findWithinChildren(this.gameObject, "LevelBricks/Bricks").GetComponent<BricksManager>();
        bricksMan.Setup();

        if (GAMETYPE != LocalTuning.levelType)
        {
            Debug.Log("Type of LevelMana & Setup scrip arent't the same");
        }
        GAMETYPE = LocalTuning.levelType;
        switch (GAMETYPE)
        {
        case LevelParameters.levelTypeList.Debuggin :
        {
            linearTrigger = gameObject.AddComponent<LinearStepTrigger>();
            linearTrigger.Setup(this);
            break;
        }
        case LevelParameters.levelTypeList.Linear :
        {
            linearTrigger = gameObject.AddComponent<LinearStepTrigger>();
            linearTrigger.Setup(this);
            break;
        }
        case LevelParameters.levelTypeList.Maze :
        {
            break;
        }
        case LevelParameters.levelTypeList.Procedural :
        {
            GameObject gameo = FETool.createGameObject("ProceduralManager", gameObject);
            ProcMana = gameo.AddComponent<Procedural>();
            ProcMana.Setup(this);
            break;
        }
        case LevelParameters.levelTypeList.Vertical :
        {
            GameObject vm = new GameObject("VerticalManager");
            VerticalManager = vm.AddComponent<VerticalScroller>();
            vm.transform.parent = this.transform;
            VerticalManager.Setup(this);
            break;
        }
        }

        wpDirector.affectRelatedBricks(bricksMan.BricksList);

        if (LocalTuning.levelType != LevelParameters.levelTypeList.Debuggin)
        {
            if (GameObject.Find("UI") == null)
            {
                GameObject uiman = Instantiate(Resources.Load("Presets/UI")) as GameObject;
                uiman.name = "UI";
                menuManager = uiman.GetComponent<MainMenu>();
            }
            else
            {
                menuManager = GameObject.Find("UI").GetComponent<MainMenu>();
            }
        }
        if (menuManager != null)
        {
            menuManager.Setup(this);
        }
        managerChecker();
        //		proc.triggerStep(proc._listSteps[0]);
        _player.Setup();
        Setup();
    }
Example #24
0
    public static string instructions(int languageArea,string level,ApplicationID appID)
    {
        LevelParameters given = new LevelParameters(level);
        string instructions = "";

        TextAsset ta = (TextAsset) Resources.Load("Localisation_Files/"+langCode.ToString()+"/Instructions_"+langCode.ToString()+"_"+appID,typeof(TextAsset));
        if(ta!=null){
            string text = ta.text;
            foreach(string line in text.Split('\n')){
                string[] values = line.Split(',');
                int la = 	int.Parse(values[0]);
                //int mode = 	int.Parse(values[1]);

                LevelParameters a = new LevelParameters(values[3]);

                if(la==languageArea)
                if((a.mode==given.mode)){
                    instructions = values[4];
                        if((a.ttsType==given.ttsType)){
                        instructions = values[4];

                            if (values[3].Equals(level))
                                return values[4];

                        }
                }

            }

        }

        return instructions;
    }
Example #25
0
 public SquareLevelConfigurator()
 {
     _parameters = new LevelParameters();
 }
    public PDLevelConfigGeneratorServer(ActivityServerCommunication para_serverCommunication)
    {
        List<PackagedNextWord> list = null;
        LevelParameters level = new LevelParameters("");

        if(para_serverCommunication!=null){
            list = para_serverCommunication.loadWords();
            level = new LevelParameters(para_serverCommunication.getLevel());
            instruction = LocalisationMang.instructions(para_serverCommunication.getDifficulty()[0],para_serverCommunication.getLevel(),ApplicationID.ENDLESS_RUNNER);

            /*TextAsset ta = (TextAsset) Resources.Load("Localisation_Files/"+para_serverCommunication.language.ToString()+"/Instructions_"+para_serverCommunication.language.ToString(),typeof(TextAsset));
            if(ta != null){

            string text = ta.text;

            foreach(string line in text.Split('\n')){

                string[] values = line.Split(',');

                if(System.Convert.ToInt32(values[0])==(int)ApplicationID.ENDLESS_RUNNER){

                    if(System.Convert.ToInt32(values[1])==level.mode){
                        Debug.Log(line);

                        if((TtsType)System.Enum.Parse(typeof(TtsType), values[2])==level.ttsType){

                            instruction = values[3];
                        }
                    }
                }
            }
            }
            if (instruction==""){
                instruction = "";
            }*/
        }

        if (list==null){
            WorldViewServerCommunication.setError("Did not find words");
            return;
        }else if(list.Count==0){
            WorldViewServerCommunication.setError("List of words is empty");
            return;
        }

        //if (error){
        //	list = WordDBCreator.createListPackagedNextWords("ENDLESS_RUNNER");
        //	level = new LevelParameters(WordDBCreator.getLevel("ENDLESS_RUNNER"));
        //}

        List<PDLevelConfig> hardCodedList = new List<PDLevelConfig>();

        try{

            for (int i=0;i<list.Count;i+=level.accuracy){

                List<string> words = new List<string>();
                List<int> knocks = new List<int>();
                List<int> langArea = new List<int>();
                List<int> diff = new List<int>();

                for(int j=i;j<list.Count;j++){

                    words.Add(list[j].annotatedWord.getWord());
                    langArea.Add(list[j].annotatedWord.getWordProblems()[0].category);
                    diff.Add(list[j].annotatedWord.getWordProblems()[0].index);

                    if(level.mode==0){
                        knocks.Add(list[j].annotatedWord.getSyllables().Length);
                    }else{
                        knocks.Add(list[j].annotatedWord.getGraphemesPhonemes().Count);
                    }

                    if (words.Count==level.accuracy)
                        break;
                }

                hardCodedList.Add( new PDLevelConfig(words.ToArray(),knocks.ToArray(),langArea.ToArray(),diff.ToArray(),words.Count*(4-level.speed)));

            }

            hardCodedArr = hardCodedList.ToArray();
        for(int j=1;j<hardCodedArr.Length;j++){
            int r_j = Random.Range(1,hardCodedArr.Length);
            PDLevelConfig aux = hardCodedArr[r_j];
            hardCodedArr[r_j] = hardCodedArr[j];
            hardCodedArr[j] = aux;
        }

        }catch(System.Exception e){

        WorldViewServerCommunication.setError(e.Message);
        return;
        }

        counter = 0;
    }
    public void setActivityParameters(ApplicationID _appID, int _difficulty, int _languageArea, string _userID, int _evaluation_mode, string _challenge, Mode _mode)
    {
        appID = _appID;

        LevelParameters param = new LevelParameters(_challenge);

        number_words = param.batchSize;
        languageArea = _languageArea;
        difficulty = _difficulty;
        level = _challenge;
        mode = _mode;
        userID = _userID;
        //challenge = _challenge;
        evaluation_mode = _evaluation_mode;

        loading_status = new ConnectionError("Loading of words have to be invoked",RoutineStatus.IDLE);
    }
    public HarvestLevelConfigGeneratorServer(ActivityServerCommunication para_serverCommunication)
    {
        List<PackagedNextWord> list = null;
        LevelParameters level = new LevelParameters("");

        if(para_serverCommunication!=null){
            list = para_serverCommunication.loadWords();
            level = new LevelParameters(para_serverCommunication.getLevel());
            instruction = LocalisationMang.instructions(para_serverCommunication.getDifficulty()[0],para_serverCommunication.getLevel(),ApplicationID.HARVEST);

            /*TextAsset ta = (TextAsset) Resources.Load("Localisation_Files/"+para_serverCommunication.language.ToString()+"/Instructions_"+para_serverCommunication.language.ToString(),typeof(TextAsset));
            if(ta != null){

            string text = ta.text;

            foreach(string line in text.Split('\n')){

                string[] values = line.Split(',');

                if(System.Convert.ToInt32(values[0])==(int)ApplicationID.HARVEST){

                    if(System.Convert.ToInt32(values[1])==level.mode){
                        Debug.Log(line);

                        if((TtsType)System.Enum.Parse(typeof(TtsType), values[2])==level.ttsType){

                            instruction = values[3];
                        }
                    }
                }
            }
            }
            if (instruction==""){
                instruction = "";
            }*/
        }

        if (list==null){
            WorldViewServerCommunication.setError("Did not find words");
            return;
        }else if(list.Count==0){
            WorldViewServerCommunication.setError("List of words is empty");
            return;
        }else{

            foreach(PackagedNextWord w in list){
                if (w.getAnnotatedWord().getWordProblems().Count==0){
                    WorldViewServerCommunication.setError("Word '"+w.getAnnotatedWord().getWord()+"' do not have problems");
                    return;
                }else if(w.getAnnotatedWord().getWordProblems()[0].matched.Length==0){
                    WorldViewServerCommunication.setError("Word '"+w.getAnnotatedWord().getWord()+"' do not have problems");
                    return;
                }
            }
        }

        /*if (error){
            list = WordDBCreator.createListPackagedNextWords("HARVEST");
            level = new LevelParameters(WordDBCreator.getLevel("HARVEST"));
        }*/

        lvlArr = new HarvestLevelConfig[list.Count];

        int idx = 0;

        List<string> patterns = new List<string>();

        try{

        Difficulty[][] profileDifficulties = WorldViewServerCommunication.userProfile.userProblems.getDifficultiesDescription().getDifficulties();

        if (level.mode==0){

            patterns.Add("Open syllable");
            //patterns.Add("Muuuuuu");
            patterns.Add("Closed syllable");
            //patterns.Add("Muuuuuu");

            foreach(PackagedNextWord nw in list){

                List<int> matches = new List<int>();

                string[] cvForm = nw.getAnnotatedWord().getCVForm().Split(new char[] {'-'}, System.StringSplitOptions.RemoveEmptyEntries);
                if (cvForm[0][cvForm[0].Length-1]=='v'){
                    matches.Add(0);
                }else{
                    matches.Add(1);

                }

                /*if(cvForm.Length>1){

                    if (cvForm[1][cvForm[1].Length-1]=='v')
                        matches.Add(2);
                    else
                        matches.Add(3);
                }*/

                lvlArr[idx++] = new HarvestLevelConfig(nw.getAnnotatedWord().getWord(),patterns.ToArray(),matches.ToArray(), nw.getAnnotatedWord().getWordProblems()[0].category,nw.getAnnotatedWord().getWordProblems()[0].index);
            }

        }else if(level.mode==1){

            //int lA = 0;
            foreach(PackagedNextWord nw in list){
                //foreach(WordProblemInfo wp in nw.getAnnotatedWord().getWordProblems()){
                WordProblemInfo wp = nw.getAnnotatedWord().getWordProblems()[0];
                Debug.Log(nw.getAnnotatedWord().getWord()+" "+profileDifficulties[ wp.category ][ wp.index  ].character);

                string problem = profileDifficulties[ wp.category ][ wp.index  ].character;//getDescriptionsToString();
                if(!patterns.Contains(problem)){
                    patterns.Add(problem);
                    //lA = wp.category;
                }
                //}
            }

            /*List<string> candidates = new List<string>();

            for(int i = 0; i < profileDifficulties[lA].Length;i++){

                if (!candidates.Contains(profileDifficulties[lA][i].character)){
                    candidates.Add(profileDifficulties[lA][i].character);
                }
            }

            while((patterns.Count<4)&(candidates.Count>0)){

                int index = Random.Range(0,candidates.Count);
                string candidateCharacter = candidates[index];

                patterns.Add(candidateCharacter);

                candidates.Remove(candidateCharacter);

            }*/

            List<HarvestLevelConfig> array = new List<HarvestLevelConfig>();

            //while(patterns.Count<4)
            //	patterns.Add("Muuuuuu");

            foreach(PackagedNextWord nw in list){

                List<int> matches = new List<int>();

                WordProblemInfo wp = nw.getAnnotatedWord().getWordProblems()[0];
                string problem = profileDifficulties[ wp.category ][ wp.index  ].character;//getDescriptionsToString();

                for(int i = 0;i<patterns.Count;i++){

                    if(patterns[i]==problem){
                        matches.Add(i);
                    }
                }

                if (matches.Count>0)
                    array.Add(new HarvestLevelConfig(nw.getAnnotatedWord().getWord(),patterns.ToArray(),matches.ToArray(),nw.getAnnotatedWord().getWordProblems()[0].category,nw.getAnnotatedWord().getWordProblems()[0].index));

            }

            lvlArr = array.ToArray();

        }else if(level.mode==2){

            foreach(PackagedNextWord nw in list){//confusing lettershapes
                //foreach(WordProblemInfo wp in nw.getAnnotatedWord().getWordProblems()){

                WordProblemInfo wp = nw.getAnnotatedWord().getWordProblems()[0];

                string problem = profileDifficulties[ wp.category ][ wp.index  ].getDescriptionsToString();

                if(!patterns.Contains(problem.Split('/')[0])){
                    patterns.Add(problem.Split('/')[0]);
                }

                if(!patterns.Contains(problem.Split('/')[1])){
                    patterns.Add(problem.Split('/')[1]);
                }
                //}
            }

            while(patterns.Count<4){

                int lA = list[0].getAnnotatedWord().getWordProblems()[0].category;
                int i = Random.Range(0,profileDifficulties[lA].Length);

                string problem = profileDifficulties[ lA ][ i  ].getDescriptionsToString();

                if(!patterns.Contains(problem.Split('/')[0])){
                    patterns.Add(problem.Split('/')[0]);
                }

                if(!patterns.Contains(problem.Split('/')[1])){
                    patterns.Add(problem.Split('/')[1]);
                }
            }

            foreach(PackagedNextWord nw in list){

                List<int> matches = new List<int>();

                for(int i = 0;i<patterns.Count;i++){

                    if(nw.getAnnotatedWord().getWord().IndexOf(patterns[i])>-1){
                        matches.Add(i);
                    }
                }
                lvlArr[idx++] = new HarvestLevelConfig(nw.getAnnotatedWord().getWord(),patterns.ToArray(),matches.ToArray(),nw.getAnnotatedWord().getWordProblems()[0].category,nw.getAnnotatedWord().getWordProblems()[0].index);

            }

        }else if(level.mode==3){//gr//NOT USED

            foreach(PackagedNextWord nw in list){
                //foreach(WordProblemInfo wp in nw.getAnnotatedWord().getWordProblems()){

                string problem =   nw.getAnnotatedWord().getSyllables().Length.ToString();

                if(!patterns.Contains(problem)){
                    patterns.Add(problem);
                }
                if (patterns.Count==4)
                    break;
                //}
            }

            if(patterns.Count<4){
                for (int i=2;i<6;i++){

                    if(!patterns.Contains(i.ToString()))
                        patterns.Add(i.ToString());

                    if (patterns.Count==4)
                            break;

                }
            }

            foreach(PackagedNextWord nw in list){

                List<int> matches = new List<int>();

                string problem = nw.getAnnotatedWord().getSyllables().Length.ToString();

                for(int i = 0;i<patterns.Count;i++){

                    if(patterns[i]==problem){
                        matches.Add(i);
                    }
                }
                if (matches.Count!=0)
                    lvlArr[idx++] = new HarvestLevelConfig(nw.getAnnotatedWord().getWord(),patterns.ToArray(),matches.ToArray(),nw.getAnnotatedWord().getWordProblems()[0].category,nw.getAnnotatedWord().getWordProblems()[0].index);
            }

        }else if(level.mode==4){//Function words

            foreach(PackagedNextWord nw in list){
                //foreach(WordProblemInfo wp in nw.getAnnotatedWord().getWordProblems()){

                string problem =   nw.getAnnotatedWord().getType();

                if(!patterns.Contains(problem)){
                    patterns.Add(problem);
                }
                if (patterns.Count==4)
                    break;
                //}
            }

            //while(patterns.Count<4){

            //			patterns.Add("Muuuuuu");

            //}

            foreach(PackagedNextWord nw in list){

                List<int> matches = new List<int>();

                string problem = nw.getAnnotatedWord().getType();

                for(int i = 0;i<patterns.Count;i++){

                    if(patterns[i]==problem){
                        matches.Add(i);
                    }
                }
                if (matches.Count!=0)
                    lvlArr[idx++] = new HarvestLevelConfig(nw.getAnnotatedWord().getWord(),patterns.ToArray(),matches.ToArray(),nw.getAnnotatedWord().getWordProblems()[0].category,nw.getAnnotatedWord().getWordProblems()[0].index);
            }

        }else if(level.mode==5){

            List<string> problems = new List<string>();
            List<int> wordsCount = new List<int>();

            foreach(PackagedNextWord nw in list){
                foreach(WordProblemInfo wp in nw.getAnnotatedWord().getWordProblems()){

                    string problem = nw.getAnnotatedWord().getWord().Substring(wp.matched[0].start,wp.matched[0].end-wp.matched[0].start);

                    if(!problems.Contains(problem)){
                        //Debug.Log("New! "+nw.getAnnotatedWord().getWord()+" "+problem);
                        problems.Add(problem);
                        wordsCount.Add (1);
                    }else{
                        //Debug.Log("Old! "+nw.getAnnotatedWord().getWord()+" "+problem);

                        next_string_pattern = problem;
                        int i = problems.FindIndex(FindString);
                        wordsCount[i] = wordsCount[i]+1;

                    }
                }

            }

            List<string> validPatterns = new List<string>();
            List<string> needRepresentative = new List<string>();
            List<string> bench = new List<string>();

            for(int i =0;i<problems.Count;i++){

                if( wordsCount[i]>1){
                    validPatterns.Add(problems[i]);
                    needRepresentative.Add(problems[i]);
                }else{

                    bench.Add(problems[i]);
                }
                if (validPatterns.Count==4)
                    break;

            }

            //Debug.Log(validPatterns.Count);

            foreach(string w in bench){
                if(validPatterns.Count<4){
                    validPatterns.Add(w);
                    needRepresentative.Add(w);
                }else
                    break;
            }

            while(validPatterns.Count<4){
                string newPattern = validPatterns[Random.Range(0,validPatterns.Count)];
                validPatterns.Add(newPattern);
                needRepresentative.Add(newPattern);
            }
            //Debug.Log(validPatterns.Count);

            List<PackagedNextWord> words = new List<PackagedNextWord>();

            foreach(PackagedNextWord nw in list){

                bool representative = false;
                foreach(WordProblemInfo wp in nw.getAnnotatedWord().getWordProblems()){

                    string problem = nw.getAnnotatedWord().getWord().Substring(wp.matched[0].start,wp.matched[0].end-wp.matched[0].start);

                    if(needRepresentative.Contains(problem)){
                        patterns.Add(nw.getAnnotatedWord().getWord());
                        needRepresentative.Remove(problem);
                        representative = true;
                        break;
                    }
                }
                if(!representative)
                    words.Add(nw);

            }

            List<HarvestLevelConfig> array = new List<HarvestLevelConfig>();
            //Debug.Log(patterns.Count);

            foreach(PackagedNextWord nw in words){

                List<int> matches = new List<int>();
                for(int i = 0; i<validPatterns.Count;i++){

                    foreach(WordProblemInfo wp in nw.getAnnotatedWord().getWordProblems()){

                        string problem = nw.getAnnotatedWord().getWord().Substring(wp.matched[0].start,wp.matched[0].end-wp.matched[0].start);

                        if (validPatterns[i]==problem){
                            matches.Add(i);
                            //Debug.Log("break?");
                            break;
                        }

                    }
                }
                //Debug.Log(nw.getAnnotatedWord().getWord()+" "+matches.Count);
                if(matches.Count>0){
                    array.Add(new HarvestLevelConfig(nw.getAnnotatedWord().getWord(),patterns.ToArray(),matches.ToArray(),nw.getAnnotatedWord().getWordProblems()[0].category,nw.getAnnotatedWord().getWordProblems()[0].index));
                    if(array.Count==level.batchSize)
                        break;
                }
            }
            lvlArr = array.ToArray();

        }else if(level.mode==6){

            List<int> numberSyllables = new List<int>();
            List<int> wordsCount = new List<int>();

            foreach(PackagedNextWord nw in list){
                //foreach(WordProblemInfo wp in nw.getAnnotatedWord().getWordProblems()){

                int syllables =   nw.getAnnotatedWord().getSyllables().Length;

                if(!numberSyllables.Contains(syllables)){
                    numberSyllables.Add(syllables);
                    wordsCount.Add (1);
                }else{
                    next_int_pattern = syllables;
                    int i = numberSyllables.FindIndex(FindInt);

                    wordsCount[i] = wordsCount[i]+1;

                }

            }

            List<int> validPatterns = new List<int>();
            List<int> bench = new List<int>();
            List<int> needRepresentative = new List<int>();

            for(int i =0;i<numberSyllables.Count;i++){

                if( wordsCount[i]>1){
                    //validPatterns.Add(numberSyllables[i]);
                    needRepresentative.Add(numberSyllables[i]);
                }else{

                    bench.Add(numberSyllables[i]);

                }

                if (needRepresentative.Count==4)
                        break;

            }

                //Debug.Log(validPatterns.Count);

                foreach(int w in bench){
                    if(needRepresentative.Count<4){
                        //validPatterns.Add(w);
                        needRepresentative.Add(w);
                    }else
                        break;
                }

            while(needRepresentative.Count<4){
                int newPattern = needRepresentative[Random.Range(0,needRepresentative.Count)];
                //validPatterns.Add(newPattern);
                needRepresentative.Add(newPattern);
            }

            List<PackagedNextWord> words = new List<PackagedNextWord>();

            //string[] patternsArray = new string[needRepresentative.Count];

            foreach(PackagedNextWord nw in list){
                //foreach(WordProblemInfo wp in nw.getAnnotatedWord().getWordProblems()){

                int syllables = nw.getAnnotatedWord().getSyllables().Length;

                if(needRepresentative.Contains(syllables)){
                    validPatterns.Add(syllables);
                    patterns.Add(nw.getAnnotatedWord().getWord());
                    needRepresentative.Remove(syllables);
                }else if(validPatterns.Contains(syllables)){
                    words.Add(nw);
                    //Debug.Log("WORD "+nw.getAnnotatedWord().getWord());
                }

            }

            List<HarvestLevelConfig> array = new List<HarvestLevelConfig>();
            foreach(PackagedNextWord nw in words){

                List<int> matches = new List<int>();
                int syllables = nw.getAnnotatedWord().getSyllables().Length;

                for(int i = 0; i<validPatterns.Count;i++)
                    if (validPatterns[i]==syllables)
                        matches.Add(i);

                if(matches.Count>0){
                    array.Add(new HarvestLevelConfig(nw.getAnnotatedWord().getWord(),patterns.ToArray(),matches.ToArray(),nw.getAnnotatedWord().getWordProblems()[0].category,nw.getAnnotatedWord().getWordProblems()[0].index));
                    if(array.Count==level.batchSize)
                        break;
                }

            }

            lvlArr = array.ToArray();

        }

        for(int i= 1;i<lvlArr.Length;i++){

            int j = Random.Range(1,lvlArr.Length);

            HarvestLevelConfig a = lvlArr[i];
            lvlArr[i] = lvlArr[j];
            lvlArr[j] = a;

        }

        }catch(System.Exception e){

        WorldViewServerCommunication.setError(e.Message);
        return;
        }

        counter = 0;
    }
    // Note: Assumes that server communication object was previously polled by the activity script to check when it has RoutineStatus.READY.
    //       the script has confirmed that the generator can go ahead.
    public TDLevelConfigGeneratorServer(ActivityServerCommunication para_serverCommunication)
    {
        List<PackagedNextWord> list = null;
        LevelParameters level = new LevelParameters("");

        if(para_serverCommunication!=null){
            list = para_serverCommunication.loadWords();
            level = new LevelParameters(para_serverCommunication.getLevel());
            instruction = LocalisationMang.instructions(para_serverCommunication.getDifficulty()[0],para_serverCommunication.getLevel(),ApplicationID.TRAIN_DISPATCHER);

        }

        if (list==null){
            WorldViewServerCommunication.setError("Did not find words");
            return;
        }else if(list.Count==0){
            WorldViewServerCommunication.setError("List of words is empty");
            return;
        }else{

            foreach(PackagedNextWord w in list){
                if (w.getAnnotatedWord().getWordProblems().Count==0){
                    WorldViewServerCommunication.setError("Word '"+w.getAnnotatedWord().getWord()+"' do not have problems");
                    return;
                }else if(w.getAnnotatedWord().getWordProblems()[0].matched.Length==0){
                    WorldViewServerCommunication.setError("Word '"+w.getAnnotatedWord().getWord()+"' do not have problems");
                    return;
                }
            }
        }

        List<TDLevelConfig> reqList = new List<TDLevelConfig>();

        try{

        for(int i=0; i<list.Count; i++)
        {
            AnnotatedWord tmpAWord = list[i].annotatedWord;
            string[] syllables;

            if(level.mode==0){//Syllables

                syllables = tmpAWord.getSyllables();

            }else if(level.mode==1){//Suffix
                syllables = new string[2];

                syllables[0] = tmpAWord.getWord().Substring(0,tmpAWord.getWordProblems()[0].matched[0].start);
                syllables[1] = tmpAWord.getWord().Substring(tmpAWord.getWordProblems()[0].matched[0].start,tmpAWord.getWordProblems()[0].matched[0].end-tmpAWord.getWordProblems()[0].matched[0].start);

            }else if(level.mode==2){//Prefix
                syllables = new string[2];

                syllables[0] = tmpAWord.getWord().Substring(0,tmpAWord.getWordProblems()[0].matched[0].end);
                syllables[1] = tmpAWord.getWord().Substring(tmpAWord.getWordProblems()[0].matched[0].end,tmpAWord.getWord().Length-tmpAWord.getWordProblems()[0].matched[0].end);

            }else{//Graphemes

                syllables = new string[tmpAWord.getGraphemesPhonemes().Count];

                for(int j=0;j<syllables.Length;j++){

                    syllables[j] = tmpAWord.getGraphemesPhonemes()[j].grapheme;

                }

            }

            reqList.Add(new TDLevelConfig(tmpAWord.getWord(),syllables, tmpAWord.getWordProblems()[0].category,tmpAWord.getWordProblems()[0].index ,level.speed));

        }

        hardCodedArr = reqList.ToArray();

        for(int j=1;j<hardCodedArr.Length;j++){
            int r_j = Random.Range(1,hardCodedArr.Length);
            TDLevelConfig aux = hardCodedArr[r_j];
            hardCodedArr[r_j] = hardCodedArr[j];
            hardCodedArr[j] = aux;
        }
        }catch(System.Exception e){

        WorldViewServerCommunication.setError(e.Message);
        return;
        }
        counter = 0;
    }
Example #30
0
    public void SelectThisLevel(LevelParameters newParameters)
    {
        levelSelected = newParameters;

        SceneManager.LoadScene(2);
    }
Example #31
0
    private void Initializie(LevelParameters level, Hex hexPrefab)
    {
        var hexHeightDistance = (hexLength * 2);
        var hexWidthDistance  = Mathf.Sqrt(3) * hexLength;
        var rowlengthAddition = 0;

        //size = new Vector2Int(level.ZWidth, level.XHeight);

        var gridStart = new Vector3(0, 0, 0);

        //float z = 0;
        //float x = 0;

        //for (int r = 0; r < (gridSize * 2) + 1 - Mathf.Abs(gridSize - r); r++)
        //{
        //    for (int q = 0; q < gridSize - r; q++)
        //    {
        //        var position = new Vector3(r, 0, q + z);
        //        var hex_go = Instantiate(hexPrefab, position, Quaternion.identity);


        //        hex_go.name = "Hex_" + q + "_" + r;
        //    }

        //    //if (r >= gridSize - 1)
        //    //{

        //    //    y += hexWidthDistance / 2 ;
        //    //   x += (hexHeightDistance * 0.75f) / 2 ;
        //    //}
        //    //else
        //    //{
        //    x += hexWidthDistance / 2;
        //    z += (hexHeightDistance * 0.75f) / 2 / 1.7f;
        //    //}
        //}

        for (int q = -gridSize; q <= gridSize; q++)
        {
            int r1 = Mathf.Max(-gridSize, -q - gridSize);
            int r2 = Mathf.Min(gridSize, -q + gridSize);
            for (int r = r1; r <= r2; r++)
            {
                Vector3Int cube   = new Vector3Int(q, r, -q - r);
                Vector2Int n      = new Vector2Int(q, r);
                var        hex_go = Instantiate(hexPrefab);
                hex_go.transform.SetParent(transform);


                hex_go.transform.localPosition = Hexagonal.Cube.HexToPixel(
                    cube,
                    Vector2.one * hexLength / 2f);;

                hex_go.index      = Hexagonal.Offset.QFromCube(cube);
                hex_go.name       = "Hex_" + q + "_" + r;
                hex_go.cube_coord = cube;

                hexes.Add(hex_go);

                //Debug.Log($"{cube}");
                //Debug.Log($"{n}");
                //Debug.Log($"{hex_go.index}");
            }
        }

        var target = hexes
                     .Where(h => h.cube_coord == new Vector3Int(0, 0, 0))
                     .First();

        var stopIndexes = GetNeighbour(target.cube_coord);

        RenderColor(target);
        target.end = false;

        var targetNeighbours = new List <Hex>();

        foreach (var item in hexes)
        {
            if (stopIndexes.Contains(item.cube_coord))
            {
                RenderColor(item);
                item.end        = false;
                item.permission = false;
                targetNeighbours.Add(item);
            }
        }

        var zonesCenters = new List <Hex>();

        foreach (var item in hexes)
        {
            if (zones(gridSize).Contains(item.cube_coord))
            {
                RenderColor(item);
                item.permission = false;
                zonesCenters.Add(item);
            }
        }

        GetZoneNeighbour(zonesCenters, targetNeighbours);


        //foreach (var item in hexes)
        //{
        //    foreach (var index in GetZoneNeighbour(zonesCenters))
        //    {

        //        if (item.cube_coord == index)
        //        {
        //            RenderColor(item);
        //            item.permission = false;
        //            zonesCenters.Add(item);
        //        }
        //    }
        //}



        return;

        for (int r = 0; r < (gridSize * 2) - 1; r++)
        {
            for (int q = 0; q < gridSize + rowlengthAddition; q++)
            {
                var position = gridStart;

                var hex_go = Instantiate(hexPrefab, position, Quaternion.identity);


                hex_go.transform.position = new Vector3(position.z, 0, (position.x += (hexWidthDistance / 2 * q)));
                hex_go.index      = new Vector2Int(q, r);
                hex_go.name       = "Hex_" + q + "_" + r;
                hex_go.cube_coord = Hexagonal.Offset.RToCube(hex_go.index);

                //hex_go.neihbours = GetNeighbour(hex_go.cube_coord);
                //Debug.Log($"{hex_go.neihbours.ToArray()[1]}");

                hex_go.transform.SetParent(transform);
                hexes.Add(hex_go);
            }

            if (r >= gridSize - 1)
            {
                rowlengthAddition -= 1;
                gridStart.z       += hexWidthDistance / 2 / 1.15f;
                gridStart.x       += (hexHeightDistance * 0.75f) / 2 / 1.7f;
            }
            else
            {
                rowlengthAddition += 1;
                gridStart.z       += hexWidthDistance / 2 / 1.15f;
                gridStart.x       -= (hexHeightDistance * 0.75f) / 2 / 1.7f;
            }
        }



        //var rend = target.GetComponent<Renderer>();
        //rend.materials = new[] { null, redMaterial, redMaterial };
        //target.end = false;
    }
    // Note: Assumes that server communication object was previously polled by the activity script to check when it has RoutineStatus.READY.
    //       the script has confirmed that the generator can go ahead.
    public BBLevelConfigGeneratorServer(ActivityServerCommunication para_serverCommunication)
    {
        List<PackagedNextWord> list = null;
        LevelParameters level = new LevelParameters("");

        if(para_serverCommunication!=null){
            list = para_serverCommunication.loadWords();
            level = new LevelParameters(para_serverCommunication.getLevel());

            instruction = LocalisationMang.instructions(para_serverCommunication.getDifficulty()[0],para_serverCommunication.getLevel(),ApplicationID.EYE_EXAM);

        }

        if (list==null){
            WorldViewServerCommunication.setError("Did not find words");
            return;
        }else if(list.Count==0){
            WorldViewServerCommunication.setError("List of words is empty");
            return;
        }else{
            if ((level.mode!=0))//Words must have a difficulty unless we are only using syllables

            foreach(PackagedNextWord w in list){
                if (w.getAnnotatedWord().getWordProblems().Count==0){
                    WorldViewServerCommunication.setError("Word '"+w.getAnnotatedWord().getWord()+"' do not have problems");
                    return;
                }else if(w.getAnnotatedWord().getWordProblems()[0].matched.Length==0){
                    WorldViewServerCommunication.setError("Word '"+w.getAnnotatedWord().getWord()+"' do not have problems");
                    return;
                }
            }
        }

        List<BBLevelConfig> reqList = new List<BBLevelConfig>();

        try{

        for(int i=0; i<list.Count; i++)
        {
            AnnotatedWord tmpAWord = list[i].annotatedWord;
            string bridgeWord = tmpAWord.getWord();

            if(level.mode==0){//(deprecated for EN) GR syllable division

                List<int> wordSylls = tmpAWord.getSyllSplitPositions();

                int syllableIndex = UnityEngine.Random.Range(0,wordSylls.Count);

                if(syllableIndex==0){

                    HighlightDesc hd= new HighlightDesc(0,wordSylls[0]);

                    if(WorldViewServerCommunication.userProfile.language=="EN")
                            reqList.Add(new BBLevelConfig(bridgeWord,new List<HighlightDesc>() {hd},"First syllable",TtsType.WRITTEN2WRITTEN, tmpAWord.getWordProblems()[0].category,tmpAWord.getWordProblems()[0].index));
                    else
                            reqList.Add(new BBLevelConfig(bridgeWord,new List<HighlightDesc>() {hd},"πρώτη συλλαβή",TtsType.WRITTEN2WRITTEN, tmpAWord.getWordProblems()[0].category,tmpAWord.getWordProblems()[0].index));

                }else if(syllableIndex==wordSylls.Count-1){

                    HighlightDesc hd= new HighlightDesc(wordSylls[wordSylls.Count-1]+1,bridgeWord.Length-1);
                    if(WorldViewServerCommunication.userProfile.language=="EN")

                            reqList.Add(new BBLevelConfig(bridgeWord,new List<HighlightDesc>() {hd},"Last syllable",TtsType.WRITTEN2WRITTEN, tmpAWord.getWordProblems()[0].category,tmpAWord.getWordProblems()[0].index));

                    else
                            reqList.Add(new BBLevelConfig(bridgeWord,new List<HighlightDesc>() {hd},"Τελευταία συλλαβή",TtsType.WRITTEN2WRITTEN, tmpAWord.getWordProblems()[0].category,tmpAWord.getWordProblems()[0].index));

                }else{

                    HighlightDesc hd= new HighlightDesc(wordSylls[syllableIndex-1]+1,wordSylls[syllableIndex]-1);
                    string position = "";

                    if(WorldViewServerCommunication.userProfile.language=="EN"){

                        switch(syllableIndex){

                        case 1: position = "Second";break;
                        case 2: position = "Third";break;
                        case 3: position = "Fourth";break;
                        case 4: position = "Fifth";break;
                        case 5: position = "Sixth";break;
                        }
                            reqList.Add(new BBLevelConfig(bridgeWord,new List<HighlightDesc>() {hd},position+" syllable",TtsType.WRITTEN2WRITTEN, tmpAWord.getWordProblems()[0].category,tmpAWord.getWordProblems()[0].index));
                    }else{

                        switch(syllableIndex){
                        case 1: position = "δεύτερη";break;
                        case 2: position = "τρίτη";break;
                        case 3: position = "τέταρτη";break;

                        }
                            reqList.Add(new BBLevelConfig(bridgeWord,new List<HighlightDesc>() {hd},position+" συλλαβή",TtsType.WRITTEN2WRITTEN, tmpAWord.getWordProblems()[0].category,tmpAWord.getWordProblems()[0].index));

                    }
                }

            }else if(level.mode==6){//GR inflexional and prefixes and letter similarity

                MatchedData[] matches = tmpAWord.getWordProblems()[0].matched;

                List<HighlightDesc> listMatches = new List<HighlightDesc>();
                string pattern = tmpAWord.getWord().Substring(matches[0].start,matches[0].end-matches[0].start);
                foreach (MatchedData match in matches)
                    if(tmpAWord.getWord().Substring(match.start,match.end-match.start)==pattern)
                        listMatches.Add( new HighlightDesc(match.start,match.end-1) );

                reqList.Add(new BBLevelConfig(bridgeWord,listMatches,pattern,level.ttsType, tmpAWord.getWordProblems()[0].category,tmpAWord.getWordProblems()[0].index));

            }else{//EN

                int languageArea = tmpAWord.getWordProblems()[0].category;
                int difficulty = tmpAWord.getWordProblems()[0].index;
                MatchedData[] matches = tmpAWord.getWordProblems()[0].matched;

                string description = WorldViewServerCommunication.userProfile.userProblems.getDifficultiesDescription().getDifficulties()[languageArea][difficulty].getDescriptionsToString();

                if(level.mode==4){//vowel or consonants, TTS

                    string phoneme = "";

                    foreach(string pattern in description.Split (',')){
                        if (pattern.Contains("-")){
                            if (phoneme=="")
                                phoneme += pattern.Split('-')[1];
                            else
                                phoneme += " / "+pattern.Split('-')[1];
                        }
                    }

                    List<HighlightDesc> highlights = new List<HighlightDesc>();

                    foreach(MatchedData match in matches){
                        highlights.Add(new HighlightDesc(match.start,match.end-1));
                    }

                    string pattern2 = "";
                    if(level.ttsType==TtsType.WRITTEN2WRITTEN){
                            GhostbookManagerLight gbMang = GhostbookManagerLight.getInstance();
                            pattern2 = gbMang.createExplanation(languageArea,difficulty);//Human readable description
                    }else{
                        if(phoneme==""){
                                level.ttsType=TtsType.WRITTEN2WRITTEN;
                                GhostbookManagerLight gbMang = GhostbookManagerLight.getInstance();
                                pattern2 = gbMang.createExplanation(languageArea,difficulty);//Human readable description
                        }else{
                                pattern2 = "/"+phoneme+"/";
                                if(!WorldViewServerCommunication.tts.test(pattern2)){//Phonemes are prerecorded
                                    level.ttsType=TtsType.WRITTEN2WRITTEN;
                                    GhostbookManagerLight gbMang = GhostbookManagerLight.getInstance();
                                    pattern2 = gbMang.createExplanation(languageArea,difficulty);//Human readable description
                                }
                        }
                    }

                    reqList.Add(new BBLevelConfig(bridgeWord,highlights ,pattern2,level.ttsType, tmpAWord.getWordProblems()[0].category,tmpAWord.getWordProblems()[0].index));

                }else if(level.mode==1){//EN suffix

                    List<HighlightDesc> listMatches = new List<HighlightDesc>();

                    foreach (MatchedData match in matches)
                        listMatches.Add( new HighlightDesc(match.start,match.end-1) );

                        reqList.Add(new BBLevelConfig(bridgeWord,listMatches,"-"+description,level.ttsType, tmpAWord.getWordProblems()[0].category,tmpAWord.getWordProblems()[0].index));

                }else if(level.mode==2){//EN prefix

                    List<HighlightDesc> listMatches = new List<HighlightDesc>();

                    foreach (MatchedData match in matches)
                        listMatches.Add( new HighlightDesc(match.start,match.end-1) );

                    reqList.Add(new BBLevelConfig(bridgeWord,listMatches,description+"-",level.ttsType, tmpAWord.getWordProblems()[0].category,tmpAWord.getWordProblems()[0].index));

                }else{//5, EN confusing letters

                    List<HighlightDesc> listMatches = new List<HighlightDesc>();

                    description = bridgeWord.Substring(matches[0].start,matches[0].end-matches[0].start);

                    foreach (MatchedData match in matches){
                        if(bridgeWord.Substring(match.start,match.end-match.start).Equals(description))
                               listMatches.Add( new HighlightDesc(match.start,match.end-1) );
                    }
                    reqList.Add(new BBLevelConfig(bridgeWord,listMatches,description,level.ttsType, tmpAWord.getWordProblems()[0].category,tmpAWord.getWordProblems()[0].index));

                }
            }
        }

        hardCodedArr = reqList.ToArray();

        for(int j=1;j<hardCodedArr.Length;j++){
            int r_j = Random.Range(1,hardCodedArr.Length);
            BBLevelConfig aux = hardCodedArr[r_j];
            hardCodedArr[r_j] = hardCodedArr[j];
            hardCodedArr[j] = aux;
        }

        }catch(System.Exception e){

        WorldViewServerCommunication.setError(e.Message);
        return;
        }

        counter = 0;
    }
    public MSLevelConfigGeneratorServer(ActivityServerCommunication para_serverCommunication)
    {
        List<PackagedNextWord> list = null;
        LevelParameters level = new LevelParameters("");

        if(para_serverCommunication!=null){
            list = para_serverCommunication.loadWords();
            level = new LevelParameters(para_serverCommunication.getLevel());
            instruction = LocalisationMang.instructions(para_serverCommunication.getDifficulty()[0],para_serverCommunication.getLevel(),ApplicationID.MAIL_SORTER);

        }

        if (list==null){
            WorldViewServerCommunication.setError("Did not find words");
            return;

        }else if(list.Count==0){

            WorldViewServerCommunication.setError("List of words is empty");
            return;

        }else{

            foreach(PackagedNextWord w in list){
                if (w.getAnnotatedWord().getWordProblems().Count==0){
                    WorldViewServerCommunication.setError("Word '"+w.getAnnotatedWord().getWord()+"' do not have problems");
                    return;
                }else if(w.getAnnotatedWord().getWordProblems()[0].matched.Length==0){
                    WorldViewServerCommunication.setError("Word '"+w.getAnnotatedWord().getWord()+"' do not have problems");
                    return;
                }
            }
        }

        if(WorldViewServerCommunication.tts==null){
            level.ttsType = TtsType.WRITTEN2WRITTEN;

        }

        List<MSLevelConfig> lvlList = new List<MSLevelConfig>();
        int idx = 0;
        try{

            while(idx<list.Count){

            string[] deckA = new string[level.accuracy+1];
            string[] deckB = new string[level.accuracy+1];

            int[] languageAreas = new int[level.accuracy+1];
            int[] difficulties = new int[level.accuracy+1];

            for (int j =0;j<deckA.Length;j++){

                int languageArea = list[idx+j].getAnnotatedWord().getWordProblems()[0].category;
                int  difficulty = list[idx+j].getAnnotatedWord().getWordProblems()[0].index;

                string description = WorldViewServerCommunication.userProfile.userProblems.getDifficultiesDescription().getDifficulties()[languageArea][difficulty].getDescriptionsToString();

                languageAreas[j] = languageArea;
                difficulties[j] = difficulty;

                if(level.mode==0){//EN consonants & vowels
                    deckB[j] = list[idx+j].getAnnotatedWord().getWord();

                    string phoneme = "";

                    foreach(string desc in description.Split (',')){
                        if (desc.Contains("-")){
                            if (phoneme=="")
                                phoneme += desc.Split('-')[1];
                            else
                                phoneme += " / "+desc.Split('-')[1];
                        }
                    }

                        if(level.ttsType==TtsType.WRITTEN2WRITTEN){
                            GhostbookManagerLight gbMang = GhostbookManagerLight.getInstance();
                            deckA[j] = gbMang.createExplanation(languageAreas[j],difficulties[j]);//Human readable description

                        }else{

                    if(phoneme==""){
                            level.ttsType = TtsType.WRITTEN2WRITTEN;

                            GhostbookManagerLight gbMang = GhostbookManagerLight.getInstance();
                            deckA[j] = gbMang.createExplanation(languageAreas[j],difficulties[j]);//Human readable description

                    }else{
                            if(!WorldViewServerCommunication.tts.test("/"+phoneme+"/")){//Phonemes are prerecorded
                                level.ttsType = TtsType.WRITTEN2WRITTEN;
                                GhostbookManagerLight gbMang = GhostbookManagerLight.getInstance();
                                deckA[j] = gbMang.createExplanation(languageAreas[j],difficulties[j]);//Human readable description
                            }else{

                                deckA[j] = "/"+phoneme+"/";
                            }

                    }

                        }

                }else if(level.mode==1){//Suffix
                    deckB[j] = list[idx+j].getAnnotatedWord().getWord();

                    //deckB[j] = "-"+list[idx+j].getAnnotatedWord().getSuffix();//getSyllables()[list[idx+j].getAnnotatedWord().getSyllables().Length-1];
                    if(para_serverCommunication.language==LanguageCode.EN)
                        deckA[j] = "-"+WorldViewServerCommunication.userProfile.userProblems.getDifficultiesDescription().getDifficulties()[languageArea][difficulty].descriptions[0].Split('-')[0];
                    else{

                            int start = list[idx+j].getAnnotatedWord().getWordProblems()[0].matched[0].start;
                            int end = list[idx+j].getAnnotatedWord().getWordProblems()[0].matched[0].end;

                            //Debug.Log(list[idx+j].getAnnotatedWord().getWord());
                            deckA[j] = "-"+list[idx+j].getAnnotatedWord().getWord().Substring(start,end-start);
                    }

                }else if(level.mode==2){//Prefix
                    deckB[j] = list[idx+j].getAnnotatedWord().getWord();
                    deckA[j] = WorldViewServerCommunication.userProfile.userProblems.getDifficultiesDescription().getDifficulties()[languageArea][difficulty].descriptions[0].Split('-')[0]+"-";
                }else if(level.mode==3){//GR GP or EN blends

                    deckB[j] = list[idx+j].getAnnotatedWord().getWord();

                    //Grapheme
                    deckA[j] = list[idx+j].getAnnotatedWord().getWord().Substring(list[idx+j].getAnnotatedWord().getWordProblems()[0].matched[0].start,list[idx+j].getAnnotatedWord().getWordProblems()[0].matched[0].end-list[idx+j].getAnnotatedWord().getWordProblems()[0].matched[0].start);

                    //TODO: blends should use recorded sounds

                    if(level.ttsType==TtsType.WRITTEN2SPOKEN){//GR
                        if(WorldViewServerCommunication.tts!=null){
                                bool correct = true;
                                foreach(string s in deckA){
                                    if(!WorldViewServerCommunication.tts.test(s)){
                                        correct = false;
                                        break;
                                    }
                                }
                                if(!correct){
                                    level.ttsType=TtsType.WRITTEN2WRITTEN;
                                }
                        }else{
                                level.ttsType=TtsType.WRITTEN2WRITTEN;

                        }
                    }
                }
            }

            idx += deckA.Length;

            for(int i =0;i<deckA.Length;i++){
                int j = Random.Range(0,deckA.Length);

                string a = deckA[i];
                deckA[i] =deckA[j];
                deckA[j] = a;

                a = deckB[i];
                deckB[i] =deckB[j];
                deckB[j] = a;

                int la = languageAreas[i];
                languageAreas[i] = languageAreas[j];

                languageAreas[j] = la;

                int d = difficulties[i];
                difficulties[i] = difficulties[j];
                difficulties[j] = d;

            }

            lvlList.Add(new MSLevelConfig(deckB,deckA,level.ttsType,level.speed,languageAreas,difficulties));

        }
        }catch(System.Exception e){

            WorldViewServerCommunication.setError(e.Message);
            return;
        }
        lvlArr = lvlList.ToArray();
        counter = 0;
    }
    public WAMLevelConfigGeneratorServer(ActivityServerCommunication para_serverCommunication)
    {
        //Debug.LogWarning( "More than one pattern per game?" );

        List<PackagedNextWord> list = null;
        LevelParameters level = new LevelParameters("");

        if(para_serverCommunication!=null){
            list = para_serverCommunication.loadWords();
            level = new LevelParameters(para_serverCommunication.getLevel());
            instruction = LocalisationMang.instructions(para_serverCommunication.getDifficulty()[0],para_serverCommunication.getLevel(),ApplicationID.WHAK_A_MOLE);
        }

        if (list==null){
            WorldViewServerCommunication.setError("Did not find words");
            return;
        }else if(list.Count==0){
            WorldViewServerCommunication.setError("List of words is empty");
            return;
        }else{

            foreach(PackagedNextWord w in list){
                if (w.getAnnotatedWord().getWordProblems().Count==0){
                    WorldViewServerCommunication.setError("Word '"+w.getAnnotatedWord().getWord()+"' do not have problems");
                    return;
                }else if(w.getAnnotatedWord().getWordProblems()[0].matched.Length==0){
                    WorldViewServerCommunication.setError("Word '"+w.getAnnotatedWord().getWord()+"' do not have problems");
                    return;
                }
            }
        }

        //List<WAMLevelConfig> list_levels = new List<WAMLevelConfig>();

        try{

            bool patternSound = (level.ttsType==TtsType.SPOKEN2WRITTEN);

            if(WorldViewServerCommunication.tts==null){
                patternSound = false;
            }

            List<PackagedNextWord> words = new List<PackagedNextWord>();
            List<PackagedNextWord> fillers = new List<PackagedNextWord>();

            foreach( PackagedNextWord nw in list){

                if(nw.getFiller()){ fillers.Add(nw);
                }else{ words.Add(nw); }
            }

            string[] deckA = new string[words.Count];
            string[] deckB = new string[fillers.Count];

            string pattern = "";
            if(words.Count==0){
                WorldViewServerCommunication.setError("Correct words not available for difficulty ("+para_serverCommunication.getDifficulty()[0]+","+para_serverCommunication.getDifficulty()[1]);
                return;
            }

            int languageArea = words[0].getAnnotatedWord().getWordProblems()[0].category;
            int difficulty = words[0].getAnnotatedWord().getWordProblems()[0].index;
            string description = WorldViewServerCommunication.userProfile.userProblems.getDifficultiesDescription().getDifficulties()[languageArea][difficulty].getDescriptionsToString();

            if(level.mode==0){//DEPRECATED

                string phoneme = "";

                foreach(string desc in description.Split (',')){
                    if (desc.Contains("-")){
                        if (phoneme=="")
                            phoneme += desc.Split('-')[1];
                        else
                            phoneme += " / "+desc.Split('-')[1];
                    }
                }

                if(phoneme==""){
                    patternSound = false;
                    pattern = description;
                }else
                    pattern = "/"+phoneme+"/";

                for (int i=0;i<deckA.Length;i++){

                    deckA[i] = WorldViewServerCommunication.userProfile.userProblems.getDifficultiesDescription().getDifficulties()[languageArea][difficulty].descriptions[0].Split('-')[0];
                }

                for (int i=0;i<deckB.Length;i++){

                    int fillerLanguageArea = fillers[i].getAnnotatedWord().getWordProblems()[0].category;
                    int fillerDifficulty = fillers[i].getAnnotatedWord().getWordProblems()[0].index;

                    deckB[i] = WorldViewServerCommunication.userProfile.userProblems.getDifficultiesDescription().getDifficulties()[fillerLanguageArea][fillerDifficulty].descriptions[0].Split('-')[0];

                }

            }else if (level.mode==1){//EN, vowels & consonants, monkeys with words, phoneme on the pattern

                string phoneme = "";

                foreach(string desc in description.Split (',')){
                    if (desc.Contains("-")){
                        if (phoneme=="")
                            phoneme += desc.Split('-')[1];
                        else
                            phoneme += " / "+desc.Split('-')[1];
                    }
                }

                if(!patternSound){
                    GhostbookManagerLight gbMang = GhostbookManagerLight.getInstance();
                    pattern = gbMang.createExplanation(languageArea,difficulty);//Human readable description
                }else{
                    if(phoneme==""){
                        patternSound = false;
                        GhostbookManagerLight gbMang = GhostbookManagerLight.getInstance();
                        pattern = gbMang.createExplanation(languageArea,difficulty);//Human readable description
                    }else{
                        pattern = "/"+phoneme+"/";
                        if(!WorldViewServerCommunication.tts.test(pattern)){//Phonemes are prerecorded
                            patternSound = false;
                            GhostbookManagerLight gbMang = GhostbookManagerLight.getInstance();
                            pattern = gbMang.createExplanation(languageArea,difficulty);//Human readable description
                        }
                    }
                }
                for (int i=0;i<deckA.Length;i++){
                    deckA[i] = words[i].getAnnotatedWord().getWord();
                }

                for (int i=0;i<deckB.Length;i++){
                    deckB[i] = fillers[i].getAnnotatedWord().getWord();
                }

            }else if(level.mode==2){//Suffix, EN, pattern is the suffix

                //pattern = "-"+WorldViewServerCommunication.userProfile.userProblems.getDifficultiesDescription().getDifficulties()[languageArea][difficulty].descriptions[0].Split('-')[0];

                for (int i=0;i<deckA.Length;i++){
                    deckA[i] = words[i].getAnnotatedWord().getWord();
                }

                for (int i=0;i<deckB.Length;i++){
                    deckB[i] = fillers[i].getAnnotatedWord().getWord();
                }

                MatchedData problem = words[0].getAnnotatedWord().getWordProblems()[0].matched[0];
                pattern = "-"+words[0].getAnnotatedWord().getWord().Substring(problem.start,problem.end-problem.start);

            }else if(level.mode==3){//Prefix, EN, use

                //pattern = WorldViewServerCommunication.userProfile.userProblems.getDifficultiesDescription().getDifficulties()[languageArea][difficulty].descriptions[0].Split('-')[0]+"-";

                for (int i=0;i<deckA.Length;i++){
                    deckA[i] = words[i].getAnnotatedWord().getWord();
                }

                for (int i=0;i<deckB.Length;i++){
                    deckB[i] = fillers[i].getAnnotatedWord().getWord();
                }

                MatchedData problem = words[0].getAnnotatedWord().getWordProblems()[0].matched[0];
                pattern = words[0].getAnnotatedWord().getWord().Substring(problem.start,problem.end-problem.start)+"-";

            }else if (level.mode==4){//COnfusing letters (EN) and letter similarity (GR); letter to letter

                int size =level.batchSize/2;

                deckA = new string[size];

                if(para_serverCommunication.language==LanguageCode.EN){//get the pair of confusing letters from the difficulty description, e.g. b/d
                    deckB = new string[1];

                    deckA[0] = WorldViewServerCommunication.userProfile.userProblems.getDifficultiesDescription().getDifficulties()[languageArea][difficulty].descriptions[0].Split('/')[0];
                    deckB[0] = WorldViewServerCommunication.userProfile.userProblems.getDifficultiesDescription().getDifficulties()[languageArea][difficulty].descriptions[0].Split('/')[1];

                    for(int k=1;k<deckA.Length;k++){

                        deckA[k] = deckA[0];
                    }
                }else{

                    int letter = Random.Range(0,description.Split(',').Length);//The description are the letters separated by commas a,A,e

                    deckB = new string[description.Split(',').Length-1];

                    int i = 0;
                    for(int ii = 0;ii<description.Split(',').Length;ii++){
                        if (ii == letter){
                            deckA[0] = description.Split(',')[letter];
                        }else{
                            deckB[i++] = description.Split(',')[ii];
                        }
                    }
                }

                pattern = deckA[0];

            }else if (level.mode==5){//GR, prefixes and derivational; pattern is a word

                pattern = words[0].getAnnotatedWord().getWord();

                deckA = new string[deckA.Length-1];
                for (int i=0;i<deckA.Length;i++){
                    deckA[i] = words[i+1].getAnnotatedWord().getWord();
                }

                for (int i=0;i<deckB.Length;i++){
                    deckB[i] = fillers[i].getAnnotatedWord().getWord();
                }

            }else if (level.mode==6){//GR, letter similarity; pattern is a the first letter of correct words

                for (int i=0;i<deckA.Length;i++){
                    deckA[i] = words[i].getAnnotatedWord().getWord();
                }

                for (int i=0;i<deckB.Length;i++){
                    deckB[i] = fillers[i].getAnnotatedWord().getWord();
                }

                if(patternSound){
                    //TODO: record Greek phonemes
                    pattern = words[0].getAnnotatedWord().getWord().Substring(0,1);
                    //pattern ="/"+ words[0].getAnnotatedWord().getGraphemesPhonemes()[0].phoneme+"/";
                    if(! WorldViewServerCommunication.tts.test(pattern)){
                        patternSound = false;
                        pattern = words[0].getAnnotatedWord().getWord().Substring(0,1);//first letter
                    }
                }else{
                    pattern = words[0].getAnnotatedWord().getWord().Substring(0,1);//first letter
                }

            }else if(level.mode==7){//EN with confusing and GR with GP correspondence, pattern is the grapheme/phoneme of the correct words

                MatchedData problem = words[0].getAnnotatedWord().getWordProblems()[0].matched[0];
                pattern = words[0].getAnnotatedWord().getWord().Substring(problem.start,problem.end-problem.start);//grapheme

                for (int i=0;i<deckA.Length;i++){
                    deckA[i] = words[i].getAnnotatedWord().getWord();
                }

                for (int i=0;i<deckB.Length;i++){
                    deckB[i] = fillers[i].getAnnotatedWord().getWord();
                }
            }

            if(patternSound){//This should be handled above, additional precaution
                if(WorldViewServerCommunication.tts!=null){
                    if(!WorldViewServerCommunication.tts.test(pattern))
                        patternSound = false;
                }
            }

            lvlArr = new WAMLevelConfig[1]{ new WAMLevelConfig(pattern ,deckA,deckB ,patternSound,level.speed,languageArea,difficulty)};

        }catch(System.Exception e){

            WorldViewServerCommunication.setError(e.Message);
            return;
        }

        counter = 0;
    }
Example #35
0
 void Start()
 {
     selectedIndex = 0;
     guiEnter = false;
     firstLoop = true;
     GameObject levelParametersObject = GameObject.FindWithTag ("LevelParameters");
     if (levelParametersObject != null)
     {
         levelParameters = levelParametersObject.GetComponent <LevelParameters>();
     }
     if (levelParameters == null)
     {
         Debug.Log ("Cannot find 'LevelParameters' script");
     }
 }
Example #36
0
 public void InitializeLevel(int koeff)
 {
     level = new LevelParameters(koeff);
 }
    // Note: Assumes that server communication object was previously polled by the activity script to check when it has RoutineStatus.READY.
    //       the script has confirmed that the generator can go ahead.
    public SHLevelConfigGeneratorServer(ActivityServerCommunication para_serverCommunication)
    {
        List<PackagedNextWord> list = null;
        LevelParameters level = new LevelParameters("");

        if(para_serverCommunication!=null){
            list = para_serverCommunication.loadSentences();
        //			list = para_serverCommunication.loadWords();
            level = new LevelParameters(para_serverCommunication.getLevel());

            instruction = LocalisationMang.instructions(para_serverCommunication.getDifficulty()[0],para_serverCommunication.getLevel(),ApplicationID.SERENADE_HERO);

            /*TextAsset ta = (TextAsset) Resources.Load("Localisation_Files/"+para_serverCommunication.language.ToString()+"/Instructions_"+para_serverCommunication.language.ToString(),typeof(TextAsset));
            if(ta != null){

            string text = ta.text;

            foreach(string line in text.Split('\n')){

                string[] values = line.Split(',');

                if(System.Convert.ToInt32(values[0])==(int)ApplicationID.SERENADE_HERO){

                    if(System.Convert.ToInt32(values[1])==level.mode){
                        Debug.Log(line);

                        if((TtsType)System.Enum.Parse(typeof(TtsType), values[2])==level.ttsType){

                            instruction = values[3];
                        }
                    }
                }
            }
            }
            if (instruction==""){
                instruction = "Instructions not available";
            }*/
        }

        int speed = level.speed;

        if (list==null){
            WorldViewServerCommunication.setError("Did not find words");
            return;
        }else if(list.Count==0){
            WorldViewServerCommunication.setError("List of words is empty");
            return;
        }

        if (error){
            list = WordDBCreator.createListPackagedNextWords("SERENADE_HERO");
            level = new LevelParameters(WordDBCreator.getLevel("SERENADE_HERO"));
        }

        lvlArr = new SHeroLevelConfig[list.Count];

        try{

        for(int i=0; i<list.Count; i++)
        {

            AnnotatedSentence sentence = list[i].getAnnotatedSentence();

            bool isWord = false;
            string[] text;
            List<int> indexes = new List<int>();

            isWord = true;
            text = sentence.theSentence.Split(new char[] { '{', '}' }, System.StringSplitOptions.RemoveEmptyEntries);

            List<int> positions = new List<int>();
            int j = -1;

                Debug.Log(sentence.theSentence);
            while ((j = sentence.theSentence.IndexOf('{', j+1)) != -1)
                {
                    positions.Add(j);
                    //Debug.Log(j);
                }

            int total_length = 0;

            for( j = 0;j<text.Length;j++){
                    if (positions.Contains(total_length)){
                        indexes.Add(j);
                        total_length +=2; //Opening and closing brakets
                    }

                    total_length += text[j].Length;
            }

                Debug.Log(sentence.theSentence+" "+indexes.Count+" "+sentence.fillerWords.Count);
                for(int jj =0;jj<sentence.fillerWords.Count;jj++){

                    Debug.Log(sentence.fillerWords[jj]);

                }

                if(sentence.fillerWords.Count>4){
                    List<string> needHaveFillers = new List<string>();//The last fillers are the correct syllables

                    for(int jj=0;jj<indexes.Count;jj++){
                        needHaveFillers.Add(sentence.fillerWords[sentence.fillerWords.Count-1]);
                        sentence.fillerWords.Remove(needHaveFillers[jj]);
                    }

                    while((sentence.fillerWords.Count+indexes.Count)>4){
                        sentence.fillerWords.RemoveAt(Random.Range(0,sentence.fillerWords.Count));
                        Debug.Log("Remove! "+sentence.fillerWords.Count);
                    }

                    foreach(string needFiller in needHaveFillers)
                        sentence.fillerWords.Add(needFiller);

                }

            for(int jj =0;jj<sentence.fillerWords.Count;jj++){

                int k = Random.Range(0,sentence.fillerWords.Count);
                sentence.fillerWords.Add(sentence.fillerWords[k]);
                sentence.fillerWords.Remove(sentence.fillerWords[k]);

            }

            Debug.Log(text+" "+list[i].getAnnotatedSentence().languageArea+" "+list[i].getAnnotatedSentence().difficulty);

            lvlArr[i] = new SHeroLevelConfig(text,indexes.ToArray(),sentence.fillerWords.ToArray(),isWord,speed, list[i].getAnnotatedSentence().languageArea,list[i].getAnnotatedSentence().difficulty  );
        }

        for(int j=1;j<lvlArr.Length;j++){
            int r_j = Random.Range(1,lvlArr.Length);
            SHeroLevelConfig aux = lvlArr[r_j];
            lvlArr[r_j] = lvlArr[j];
            lvlArr[j] = aux;
        }
        }catch(System.Exception e){

        WorldViewServerCommunication.setError(e.Message);
        return;
        }
    }
Example #38
0
 void Start()
 {
     window = gameObject.AddComponent<HelpWindow>() as HelpWindow;
     levelWindow = gameObject.AddComponent<LevelWindow>() as LevelWindow;
     aboutWindow = gameObject.AddComponent<AboutWindow>() as AboutWindow;
     selectedIndex = 0;
     selectedIndex = 0;
     guiEnter = false;
     Time.timeScale = 1.0f;
     GameObject levelParametersObject = GameObject.FindWithTag ("LevelParameters");
     if (levelParametersObject != null)
     {
         levelParameters = levelParametersObject.GetComponent <LevelParameters>();
     }
     if (levelParameters == null)
     {
         Debug.Log ("Cannot find 'LevelParameters' script");
     }
 }
Example #39
0
    private bool checkLevelCorrectness(string challenge,ApplicationID reqAcID,int languageArea)
    {
        TextAsset ta = (TextAsset) Resources.Load("Localisation_Files/"+LocalisationMang.langCode+"/Instructions_"+LocalisationMang.langCode+"_"+reqAcID,typeof(TextAsset));
        string text = ta.text;
        string[] lineArr = text.Split('\n');

        string initialChallenge = "";

        bool found = false;

        LevelParameters given = new LevelParameters(challenge);

        foreach(string line in lineArr){

            string[] values = line.Split(',');

            if(System.Convert.ToInt32(values[0])==languageArea){

                if(initialChallenge.Equals(""))
                    initialChallenge = values[3];

                LevelParameters a = new LevelParameters(values[3]);

                if((a.mode==given.mode)){
                    initialChallenge = values[3];
                    if((a.ttsType==given.ttsType)){
                        initialChallenge = values[3];

                        if((a.accuracy == given.accuracy)&(a.amountDistractors == given.amountDistractors)&(a.speed==given.speed)){

                            found = true;
                            break;
                        }

                    }

                }

            }
            //}
        }

        return found;
    }
Example #40
0
    public void InitializeLevel()
    {
        level = new LevelParameters(currentLevel);

        field = Field.Create(Level, LevelRepository, Enemy, Player);
    }