// View Initialization
    void Start()
    {
        Debug.Log(CLASSNAME + "creating view");
        MAS_PlayList master = (MAS_PlayList)COM_Director.GetMaster("MAS_PlayList");

        if (master != null)
        {
            controller = (CON_PlayList)master.GetController("CON_PlayList");

            if (controller != null)
            {
                //Start setting up scene
                //Request Rewards from controller
                RequestData();
            }

            if (controller.CheckIfNewEntry())
            {
                Debug.Log("New Entry");
            }
            else
            {
                chooseRewardObj = JsonUtility.FromJson <DO_ChooseReward>(controller.GetJsonByIndex(controller.GetActiveContextIndex()));
                ToggleAllToggles();
            }
        }
    }
Beispiel #2
0
    void Restart()
    {
        // Grab the play list object for this game
        playlistObj = gameLoop.GetCurrentPlay();

        // Grab the choose reward object
        chooseRewardObject = JsonUtility.FromJson <DO_ChooseReward>(playlistObj.json);

        // Start the dataservice
        ds = StartupScript.ds;

        //create the already loaded lists
        alreadyLoadedImageList = new List <string>();

        // Creat the reward buttons
        CreateRewardButtons();

        //Create the webview
        CreateWebview();

        // Clear the already loaded list
        alreadyLoadedImageList.Clear();

        // deactivate the round counter bar so the countdown bar will be visable
        RoundCounterProgressBar.SetActive(false);
    }
    public void SaveRewardToPlayList()
    {
        // Get the duration from the timer input field
        int duration = Convert.ToInt32(durationInput.text);

        Debug.Log("Current Duration: " + duration.ToString());

        // Save this choose reward to the playlist through the controller
        Debug.Log(CLASSNAME + "Sending request to Controller to save reward to playlist...");

        DO_ChooseReward tempReward = new DO_ChooseReward(CreateRewardIdsList(), duration);

        // Success feedback
        if (controller.AddOrEditEntry(TYPESTR, duration, tempReward))
        {
            successModal.SetActive(true);
        }
        else
        {
            errorModal.SetActive(true);
            // TODO: Log an error
        }
    }
Beispiel #4
0
    private void CreateAutoPlaylistEntries(int part)
    {
        // Create a choose reward playlist entry, with pre-set reward time (rewardTime) and types (rewardInts)
        List <int> rewardInts = new List <int>();

        rewardInts.Add(1);
        DO_ChooseReward       tempChooseReward           = new DO_ChooseReward(CreateRewardIdsList(), rewardTime);
        Dictionary <int, int> OrderedFilteredWordIdsDict = CreateOrderedWordIDList();


        if (part == maxParts)
        {
            int tempint = 0;


            for (int i = ((wordsPerReward * part)); i <= filteredWordIDListCount; i++)
            {
                foreach (var entry in OrderedFilteredWordIdsDict)
                {
                    if (entry.Key == i)
                    {
                        Debug.Log("sending " + i + " to CreateWordLists");
                        CreateWordLists(entry.Value);
                    }
                }

                tempint++;
            }

            int remainderInt = wordsPerReward - tempint;

            for (int i = 1; i <= remainderInt; i++)
            {
                foreach (var entry in OrderedFilteredWordIdsDict)
                {
                    if (entry.Key == i)
                    {
                        Debug.Log("sending " + i + " to CreateWordLists");

                        CreateWordLists(entry.Value);
                    }
                }

                tempint++;
            }
        }
        else if (part == 0 && part != maxParts)
        {
            //////////////////////////////////////////////////////// TESTING NEW CODE HERE
            for (int i = 1; i <= (wordsPerReward); i++) //TEST CODE
            {
                foreach (var entry in OrderedFilteredWordIdsDict)
                {
                    if (entry.Key == i)
                    {
                        Debug.Log("sending " + i + " to CreateWordLists");

                        CreateWordLists(entry.Value);
                    }
                }
            }
        }
        else
        {
            for (int i = ((wordsPerReward * part) + 1); i <= (wordsPerReward * (part + 1)); i++)
            {
                foreach (var entry in OrderedFilteredWordIdsDict)
                {
                    if (entry.Key == i)
                    {
                        Debug.Log("sending " + i + " to CreateWordLists");

                        CreateWordLists(entry.Value);
                    }
                }
            }
        }

        controller.CreatingNew();
        controller.AddOrEditEntry("Choose Reward", rewardTime, tempChooseReward);
    }
Beispiel #5
0
    public string CreateActivityListString(int index, int typeId)
    {
        StringBuilder builder = new StringBuilder();

        int max;

        switch (typeId)
        {
        case 0:
            DO_WordScramble scramble = JsonUtility.FromJson <DO_WordScramble>(model.GetJsonData(index));

            max = scramble.wordIdList.Count;

            for (int idx = 0; idx < max; idx++)
            {
                if (idx == (max - 1))
                {
                    builder.AppendFormat("{0}", TidyCase(model.wordDict[scramble.wordIdList[idx]]));
                }
                else
                {
                    builder.AppendFormat("{0}{1}", (TidyCase(model.wordDict[scramble.wordIdList[idx]])), ", ");
                }
            }

            break;

        case 1:
            DO_ChooseReward reward = JsonUtility.FromJson <DO_ChooseReward>(model.GetJsonData(index));

            max = reward.rewardIdsList.Count;

            break;

        case 2:
            DO_FlashCard flash = JsonUtility.FromJson <DO_FlashCard>(model.GetJsonData(index));

            max = flash.wordIdList.Count;

            for (int idx = 0; idx < max; idx++)
            {
                if (idx == (max - 1))
                {
                    builder.AppendFormat("{0}", TidyCase(model.wordDict[flash.wordIdList[idx]]));
                }
                else
                {
                    builder.AppendFormat("{0}{1}", (TidyCase(model.wordDict[flash.wordIdList[idx]])), ", ");
                }
            }

            break;

        case 3:
            DO_CountingGame counting = JsonUtility.FromJson <DO_CountingGame>(model.GetJsonData(index));

            max = counting.wordIds.Count;

            for (int idx = 0; idx < max; idx++)
            {
                if (idx == (max - 1))
                {
                    builder.AppendFormat("{0}", TidyCase(model.wordDict[counting.wordIds[idx]]));
                }
                else
                {
                    builder.AppendFormat("{0}{1}", (TidyCase(model.wordDict[counting.wordIds[idx]])), ", ");
                }
            }

            break;

        case 4:
            DO_KeyboardGame keyboard = JsonUtility.FromJson <DO_KeyboardGame>(model.GetJsonData(index));

            max = keyboard.wordIdList.Count;

            for (int idx = 0; idx < max; idx++)
            {
                if (idx == (max - 1))
                {
                    builder.AppendFormat("{0}", TidyCase(model.wordDict[keyboard.wordIdList[idx]]));
                }
                else
                {
                    builder.AppendFormat("{0}{1}", (TidyCase(model.wordDict[keyboard.wordIdList[idx]])), ", ");
                }
            }

            break;

        case 5:
            DO_MemoryCards memory = JsonUtility.FromJson <DO_MemoryCards>(model.GetJsonData(index));

            max = memory.wordIdList.Count;

            for (int idx = 0; idx < max; idx++)
            {
                if (idx == (max - 1))
                {
                    builder.AppendFormat("{0}", TidyCase(model.wordDict[memory.wordIdList[idx]]));
                }
                else
                {
                    builder.AppendFormat("{0}{1}", (TidyCase(model.wordDict[memory.wordIdList[idx]])), ", ");
                }
            }

            break;

        case 6:
            DO_MatchingGame matching = JsonUtility.FromJson <DO_MatchingGame>(model.GetJsonData(index));

            max = matching.wordIdList.Count;

            for (int idx = 0; idx < max; idx++)
            {
                if (idx == (max - 1))
                {
                    builder.AppendFormat("{0}", TidyCase(model.wordDict[matching.wordIdList[idx]]));
                }
                else
                {
                    builder.AppendFormat("{0}{1}", (TidyCase(model.wordDict[matching.wordIdList[idx]])), ", ");
                }
            }

            break;

        default:
            // TODO: log an error
            return(null);
        }

        return(builder.ToString());

        //case 7:
        //    break;
        //case 8:
        //    break;
        //case 10:
        //    break;
        //case 11:
    }