コード例 #1
0
    private void LoadRewardImagePreview()
    {
        Debug.Log("Loading reward image preview");
        Texture2D tx = new Texture2D(PIC_WIDTH, PIC_HEIGHT);

        byte[] rewardPic = FileAccessUtil.LoadRewardPic(rewardName);

        //If not a custom reward
        if (rewardPic == null)
        {
            imgPreview.texture = Resources.Load <Texture2D>("RewardPictures/" + rewardName);
        }
        //else is a custom reward
        else
        {
            if (tx.LoadImage(rewardPic))
            {
                tx.LoadImage(rewardPic);
                imgPreview.texture = tx;
            }
            else
            {
                Debug.Log(CLASSNAME + "Loading custom picture failed.");
            }
        }
    }
コード例 #2
0
    public AudioClip ExistingAudioClip(string fileName)
    {
        Debug.Log("MOD getting existing audioclip from file access util with filename: " + fileName);
        AudioClip tempClip;

        tempClip = FileAccessUtil.LoadWordAudio(fileName + ".wav");
        if (tempClip != null)
        {
            return(tempClip);
        }
        else
        {
            Debug.Log("No audioclip found in wordaudio folder. Attempting to load from resources.");
            tempClip = Resources.Load <AudioClip>("Sound/" + fileName);
            if (tempClip != null)
            {
                Debug.Log("Found stock audio clip in resources. returning");
                return(tempClip);
            }
            else
            {
                Debug.Log("ERROR: No stock audioclip found in resource. returning null");
                return(null);
            }
        }
    }
コード例 #3
0
ファイル: VW_GameLoop.cs プロジェクト: lazyninjacat/mylevelup
    /// <summary>
    /// Plays the audio clip corresponding to the string parameter.
    /// </summary>
    /// <param name="word"></param>
    public void PlayAudio(string word)
    {
        AudioClip tempClip = FileAccessUtil.LoadWordAudio(word + ".wav");

        if (tempClip != null)
        {
            audioSource.clip = tempClip;
            audioSource.Play();
        }

        else
        {
            tempClip = Resources.Load <AudioClip>("Sound/" + word);

            if (tempClip != null)
            {
                audioSource.clip = tempClip;
                audioSource.Play();
            }
            else
            {
                Debug.Log("No audioclip found");
            }

            //audioSource.clip = tempClip;
            //audioSource.Play();
        }
    }
コード例 #4
0
    public void DeleteWordImages(List <int> deleteIndices, string word)
    {
        foreach (int idx in deleteIndices)
        {
            Debug.Log("Index number is " + idx);

            if (idx < wordImageNames.Capacity && wordImageNames[idx] != null)
            {
                // Add the file name to the delete names hash set for deletion
                toDelete.Add(wordImageNames[idx]);

                Debug.Log("*****\n wordImageNames entry is: " + wordImageNames[idx] + "");

                // Grab a ref to the texture to be deleted
                imagesForDelete.Add(textureList[idx]);
            }

            Debug.Log("removed from TEXTURELIST");
        }
        if (toDelete.Count > 0)
        {
            for (int x = 0; x < toDelete.Count; x++)
            {
                wordImageNames.Remove(toDelete[x]);
                textureList.Remove(imagesForDelete[x]);
            }

            Debug.Log("to DELETE WAS NOT COUNT ZERO");
            FileAccessUtil.DeleteWordPictures(toDelete, word);

            //Clear the the temporary delete lists
            toDelete.Clear();
            imagesForDelete.Clear();
        }
    }
コード例 #5
0
    private void LoadRewardImagePreview()
    {
        Debug.Log("Loading reward image preview");
        GameObject rewardImagePreview = rewardImagePanel.transform.Find("RewardImagePreview").gameObject;
        RawImage   img = rewardImagePreview.GetComponent <RawImage>();
        Texture2D  tx  = new Texture2D(PIC_WIDTH, PIC_HEIGHT);

        byte[] rewardPic = FileAccessUtil.LoadRewardPic(rewardName);

        //If not a custom reward
        if (rewardPic == null)
        {
            img.texture = Resources.Load <Texture2D>("RewardPictures/" + rewardName);
        }
        //else is a custom reward
        else
        {
            if (tx.LoadImage(rewardPic))
            {
                tx.LoadImage(rewardPic);
                img.texture = tx;
            }
            else
            {
                Debug.Log(CLASSNAME + "Loading custom picture failed.");
            }
        }
    }
コード例 #6
0
        public String RecognizeFromOcto(int[] pixels, int size)
        {
            Logger.WriteMessage("Recognizing OCto");
            var imgFace = ImagesProcessing.DetectAndTrimFace(pixels, size, fixedFaceSize);

            if (imgFace == null)
            {
                return("No face detected on the image");
                //imgFace.Save(@"e:\data\phototest\trimed.jpg");
            }
            Logger.WriteMessage("Face detected");
            var equalized = ImagesProcessing.EqualizeHist(imgFace);

            Logger.WriteMessage("Face equalized");
            var folder = FileAccessUtil.GetFolder();

            Logger.WriteMessage("Folder obtained");
            var recognizer = ImagesProcessing.CreateRecognizerFromFotosInFolder(folder, "_" + fixedFaceSize, 0.001, 3000);

            Logger.WriteMessage("Recognizer created");
            String label = recognizer.Recognize(equalized);

            if (!String.IsNullOrEmpty(label))
            {
                return(label);
            }

            return("Could not recognize");
        }
コード例 #7
0
    public bool SaveDLCAudio(byte[] audioFile, string wordName)
    {
        bool audioSuccess = false;

        audioSuccess = FileAccessUtil.SaveDLCWordAudio(audioFile, wordName);

        if (audioSuccess)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
コード例 #8
0
    private void RequestData()
    {
        Debug.Log(CLASSNAME + "Sending data request to the controller...");
        Dictionary <int, string> dict = controller.RequestRewards();

        //Debug.Log(CLASSNAME + "Available Rewards: ");
        foreach (var reward in dict)
        {
            //Create a panel
            GameObject panel = GameObject.Instantiate(rewardPanel, viewportContent.transform, false);
            panel.name = reward.Key.ToString();
            GameObject label = panel.transform.Find("Label").gameObject;
            label.GetComponent <Text>().text = reward.Value;
            label.name = reward.Value.ToString();

            Toggle t = panel.GetComponent <Toggle>();
            t.onValueChanged.AddListener(delegate {
                OnToggleChange(t);
            });

            panel.SetActive(true);

            GameObject panelImage = panel.transform.Find("Image").gameObject;
            RawImage   img        = panelImage.GetComponent <RawImage>();
            Texture2D  tx         = new Texture2D(PIC_WIDTH, PIC_HEIGHT);
            byte[]     rewardPic  = FileAccessUtil.LoadRewardPic(reward.Value);
            //If not a custom reward
            if (rewardPic == null)
            {
                img.texture = Resources.Load <Texture2D>("RewardPictures/" + reward.Value);
            }
            //else is a custom reward
            else
            {
                if (tx.LoadImage(rewardPic))
                {
                    img.texture = tx;
                }
                else
                {
                    Debug.Log(CLASSNAME + "Loading custom picture failed.");
                }
            }
        }
    }
コード例 #9
0
    //public bool ImageDeleteCleanup(string word) { return FileAccessUtil.WordImageDirRepair(word); }

    /// <summary>
    /// Deletes a word entry from the data base and removes it from the word list dictionary.
    /// Additionally, it deletes any .wav or .png files associated with the word too.
    /// Returns true if the entry is successfully deleted from the data base.
    /// </summary>
    /// <param name="key"></param>
    /// <returns>bool</returns>
    public bool RemoveWordListEntry(string key)
    {
        bool success = false;

        wordList.Clear();
        LoadWordList();

        if (dataService.DeleteFromWords(wordList[key].IdNum) > 0)
        {
            success = !success;
            wordList.Remove(key);
            FileAccessUtil.DeleteWordAudio(key);
            List <string> existingPicsFiles = new List <string>();
            string[]      temparr           = Directory.GetFiles(Application.persistentDataPath + "/WordPictures/" + key);

            foreach (string path in temparr)
            {
                existingPicsFiles.Add(path);
            }

            Debug.Log("existingPicsFiles array length = " + existingPicsFiles.Count);

            foreach (string path in existingPicsFiles)
            {
                Debug.Log("existingPicsFiles array element recorded as: " + path);
                File.Delete(path);
            }

            Debug.Log("Done deleting pics for " + key);
            Directory.Delete(Application.persistentDataPath + "/WordPictures/" + key);
            Debug.Log("Done deleting directory for " + key);
            temparr = null;
            existingPicsFiles.Clear();
        }
        else
        {
            Debug.Log("Error trying to delete " + key);
        }

        dataService.RebaseAllWordIDs();

        return(success);
    }
コード例 #10
0
    public int SaveTextures(string word)
    {
        int x = 0;


        string[] isolatedName;

        foreach (string fileName in FileAccessUtil.SaveWordPics(textureList, word))
        {
            if (!wordImageNames.Contains(fileName))
            {
                isolatedName = Regex.Split(fileName, PNG_PATTERN);
                Debug.Log("Saving textures, isolated file name is " + isolatedName[1]);
                wordImageNames.Add(isolatedName[1]);
                x += 1;
            }
        }

        return(x);
    }
コード例 #11
0
    private void AddRewardItem(int id, string name)
    {
        GameObject panel = GameObject.Instantiate(itemPanel, viewportContent.transform, false);

        panel.name = name;
        panel.transform.Find("Text").GetComponent <Text>().text = name;

        GameObject panelImage = panel.transform.Find("RewardIcon").gameObject;
        RawImage   img        = panelImage.GetComponent <RawImage>();
        Texture2D  tx         = new Texture2D(PIC_WIDTH, PIC_HEIGHT);

        byte[] rewardPic = FileAccessUtil.LoadRewardPic(name);

        //If custom reward with custom pic
        if (rewardPic != null)
        {
            if (tx.LoadImage(rewardPic))
            {
                img.texture = tx;
            }
            else
            {
                Debug.Log(CLASSNAME + "Loading custom picture failed.");
            }
        }
        //else is a stock reward
        else
        {
            img.texture = Resources.Load <Texture2D>("RewardPictures/" + name);
        }

        if (id <= NUM_OF_STATIC_REWARDS)
        {
            //panel.transform.Find("Edit").GetComponent<Button>().interactable = false;
            panel.transform.Find("Delete").GetComponent <Button>().interactable = false;
        }
        panel.SetActive(true);
        currentEntries++;
    }
コード例 #12
0
 public void DeleteWordImage(string word)
 {
     FileAccessUtil.DeleteWordPic(word);
 }
コード例 #13
0
    private void SetRewardButtonImage(GameObject rb, GameObject rp, RawImage ri, Text rt, Text label)
    {
        rb.SetActive(true);

        var rewards = ds.GetRewardsTable();

        Debug.Log("SetRewardButtonImage method starting, with rb = " + rb.name + ", rp = " + rp.name + ", ri = " + ri.name + ", rt = " + rt.name);

        RawImage   img             = rb.GetComponent <RawImage>();
        RawImage   customPanelImg  = ri.GetComponent <RawImage>();
        Text       customPanelText = rt.GetComponent <Text>();
        GameObject customPanel     = rp;

        foreach (var row in rewards)
        {
            if (chooseRewardObject.rewardIdsList.Contains(row.reward_id) && !alreadyLoadedImageList.Contains(row.reward_name))
            {
                Debug.Log("Reward Loading. name = " + row.reward_name + ", type = " + row.reward_type + ", url = " + row.reward_url);

                customPanel.name = row.reward_name;
                label.text       = row.reward_name;

                Texture2D tx        = new Texture2D(75, 75);
                byte[]    rewardPic = FileAccessUtil.LoadRewardPic(row.reward_name);

                // If it is stock reward pic:
                if (rewardPic == null)
                {
                    Debug.Log("It's a stock pic");
                    img.texture = Resources.Load <Texture2D>("RewardPictures/" + row.reward_name);
                    alreadyLoadedImageList.Add(row.reward_name);

                    if (row.reward_url != "" || row.reward_url != null)
                    {
                        Debug.Log("Setting button name to reward url");
                        rb.name = row.reward_url;
                    }

                    return;
                }
                // Else it is a custom reward pic:
                else
                {
                    tx.LoadImage(rewardPic);
                    img.texture            = tx;
                    customPanelImg.texture = tx;
                    customPanelText.text   = rp.name;

                    if (row.reward_type == "website")
                    {
                        rb.name = row.reward_url;
                    }
                    else
                    {
                        rb.name = row.reward_name;
                        rp.name = row.reward_name;
                        rt.text = row.reward_name;
                        Debug.Log("itsa custom");
                    }

                    alreadyLoadedImageList.Add(row.reward_name);

                    return;
                }
            }
        }
    }
コード例 #14
0
 ///<summary>
 /// Calls on the FileAccessUtil to check whether a photo exists with the file name passed.
 ///</summary>
 ///<param name="fileName">A string representing the file name you wish to check for.</param>
 ///<returns>Returns a bool signalling whether the photo exists or not.</returns>
 public bool DoesRewardPhotoExist(string fileName)
 {
     return(FileAccessUtil.DoesRewardPicExist(fileName));
 }
コード例 #15
0
ファイル: VW_GameLoop.cs プロジェクト: lazyninjacat/mylevelup
    /// <summary>
    /// This function takes the name of an image (usually the word itself), a RawImage Game Object,
    /// and some optional XY dimensions. The imageName is used to recover a byte array and load
    /// a png from it for display. Otherwise, it will attempt to load from assets. The optional
    /// dimensions are for the resizing of the image.
    /// </summary>
    /// <param name="imageName3"></param>
    /// <param name="obj3"></param>
    /// <param name="xDelta"></param>
    /// <param name="yDelta"></param>
    public void SetImage3(string imageName3, GameObject obj3 /*, int xDelta = XY_DIMENSION, int yDelta = XY_DIMENSION*/)
    {
        Debug.Log("IMG 2: IMAGE NAME IS " + imageName3);
        //int xVect = xDelta, yVect = yDelta;
        System.Random rand = new System.Random();

        //TEMP CODE
        bool isRandom = true;

        //REMOVE LATER

        //bool success = true;
        byte[] bytes3 = null;

        // Check if load random option is checked
        if (isRandom)
        {
            // Choose randomly whether stock image will be used or not. Weight it towards non stock
            if (rand.Next(RAND_LOWER_BOUND, RAND_UPPER_BOUND) == 1)
            {
                Debug.Log("IMG: RANDO WAS 1 grabbing from assets");

                // Grab a stock texture
                Texture2D tempTex = Resources.Load <Texture2D>("WordPictures/" + imageName3 + "/" + imageName3 + UnityEngine.Random.Range(1, 6));

                // If the stock texture is not null use it else grab a random user image
                if (tempTex != null)
                {
                    Debug.Log("IMG: ASSET RESOURCE WAS GOOD! appyling");
                    obj3.GetComponent <RawImage>().texture = tempTex;
                }
                else
                {
                    Debug.Log("IMG: COULD NOT LOAD FROM assets! Grabbing random image");
                    SetRandomImage3(bytes3, obj3, imageName3);
                }
            }
            else
            {
                // Grab a random user image
                SetRandomImage3(bytes3, obj3, imageName3);
            }
        }
        else
        {
            if (activeTypeId == 1)
            {
                Debug.Log("IMG: ACTIVE TYPE WAS REWARD");
                bytes3 = FileAccessUtil.LoadRewardPic(imageName3);
            }
            else
            {
                bytes3 = FileAccessUtil.LoadWordPic(imageName3);
            }

            if (bytes3 != null)
            {
                Debug.Log("IMG: bYTES ARE GOOD!");

                if (customTexture3.LoadImage(bytes3))
                {
                    obj3.GetComponent <RawImage>().texture = customTexture3;
                }
                else
                {
                    Debug.Log("Error: could not load image");
                    return;
                }
            }
            else
            {
                Debug.Log("IMG: BYTES WERE NULL");
                obj3.GetComponent <RawImage>().texture = Resources.Load <Texture2D>("WordPictures/" + imageName3 + "/" + imageName3 + UnityEngine.Random.Range(1, 6));
                //customTexture = Resources.Load<Texture2D>("WordPictures/" + imageName);
            }
        }

        //obj.GetComponent<RawImage>().texture = customTexture;
        RectTransform rt = obj3.GetComponent <RectTransform>();
        //rt.sizeDelta = new Vector2(xVect, yVect);
    }
コード例 #16
0
 public bool SaveAudioClip()
 {
     return(FileAccessUtil.SaveWordAudio(CurrentClip, WordName));
 }
コード例 #17
0
 private bool SaveTexture()
 {
     return(FileAccessUtil.SaveWordPic(CurrentTexture, WordName));
 }
コード例 #18
0
 ///<summary>
 /// Calls on the FileAccessUtil to save a photo with the file name and Texture2D object passed.
 ///</summary>
 ///<param name="photo">A Texture2D object representing the photo you are wishing to save.</param>
 ///<param name="fileName">A string representing the file name you wish to save the photo under.</param>
 ///<returns>Returns a bool signalling whether the photo was successfully saved or not.</returns>
 public bool SavePhoto(Texture2D photo, string fileName)
 {
     return(FileAccessUtil.SaveRewardPic(photo, fileName));
 }
コード例 #19
0
    /// <summary>
    /// Takes a word string and retrieves all of the png images associated with it.
    /// </summary>
    /// <param name="word"></param>///
    /// <returns>bool</returns>
    public bool RetrieveSavedPics(string word)
    {
        Debug.Log("MOD: trying to retirieve pictures for word " + word);
        int x = 1;

        List <byte[]> tempList = FileAccessUtil.RetrieveWordPics(word);

        /****************************************************************/
        // THIS IS USED TO DISPLAY MULTIPLE STOCK IMAGES
        // Grab any stock textures from assets

        if (stockTextureList.Count == 0)
        {
            Texture2D stockChecker = Resources.Load <Texture2D>("WordPictures/" + word + "/" + word + "1");

            if (stockChecker != null)
            {
                Debug.Log("Stock images exist for: " + word);
                Texture2D stockTexture1 = Resources.Load <Texture2D>("WordPictures/" + word + "/" + word + "1");
                Texture2D stockTexture2 = Resources.Load <Texture2D>("WordPictures/" + word + "/" + word + "2");
                Texture2D stockTexture3 = Resources.Load <Texture2D>("WordPictures/" + word + "/" + word + "3");
                Texture2D stockTexture4 = Resources.Load <Texture2D>("WordPictures/" + word + "/" + word + "4");
                Texture2D stockTexture5 = Resources.Load <Texture2D>("WordPictures/" + word + "/" + word + "5");

                stockTextureList.Add(stockTexture1);
                stockTextureList.Add(stockTexture2);
                stockTextureList.Add(stockTexture3);
                stockTextureList.Add(stockTexture4);
                stockTextureList.Add(stockTexture5);
            }
            else
            {
                Debug.Log("no stock images exist for " + word);
            }
        }


        if (tempList != null && tempList.Count > 0)
        {
            foreach (byte[] bytes in tempList)
            {
                if (bytes == null || bytes.Length <= 0)
                {
                    Debug.Log("MOD: BYTES ARE NO GOOOOOOD");
                }

                Debug.Log("MOD: IN FOR EACH x IS " + x.ToString());

                Texture2D tempTex = new Texture2D(SAVED_PIC_XY, SAVED_PIC_XY);
                tempTex.LoadImage(bytes);
                textureList.Add(tempTex);
                x += 1;
            }
        }
        else
        {
            return(false);
        }

        string[] isolatedName;

        foreach (string fileName in FileAccessUtil.GetWordImagePaths(word))
        {
            isolatedName = Regex.Split(fileName, PNG_PATTERN);
            Debug.Log("REGEX: isolated name is " + isolatedName[1]);
            if (!wordImageNames.Contains(isolatedName[1]))
            {
                wordImageNames.Add(isolatedName[1]);
            }
        }

        foreach (string fileName in wordImageNames)
        {
            Debug.Log("Next word image name is " + fileName);
        }



        Debug.Log("MOD: TEX LIST COUNT IS " + textureList.Count.ToString());
        return(true);
    }
コード例 #20
0
 ///<summary>
 /// Calls on the FileAccessUtil to delete a reward picture with the file name passed.
 ///</summary>
 ///<param name="fileName">A string representing the file name of the photo you wish to delete.</param>
 public void DeletePhoto(string fileName)
 {
     FileAccessUtil.DeleteRewardPic(fileName);
 }
コード例 #21
0
    /// <summary>
    /// Creates a new word list entry and saves it to the database and the word list dictionary.
    /// Additionally, it saves any new audio or picture files.
    /// Returns true if saving data to the data base is successful.
    /// </summary>
    /// <param name="word"></param>
    /// <returns>bool</returns>
    public bool CreateNewDbEntry(string word, string wordTags)
    {
        string img;
        string sound;
        string tags;
        int    rowsInserted;
        bool   audioSuccess = true;
        bool   photoSuccess = true;

        // Check if the audio file path and photo file paths are active
        if (CurrentClip != null)
        {
            //TODO: Fix false positive when overwriting existing files
            // Maybe a check between the files date metadata and the current time?
            audioSuccess = FileAccessUtil.SaveWordAudio(CurrentClip, word);

            if (!audioSuccess)
            {
                //TODO: add error checking
            }
        }

        if (CurrentTexture != null)
        {
            //TODO: Fix false positive when overwriting existing files
            // Maybe a check between the files date metadata and the current time?

            /*
             * photoSuccess = FileAccessUtil.SaveWordPic(CurrentTexture, word);
             *
             * if (!photoSuccess)
             * {
             *  //TODO: add error checking
             * }
             */

            SaveTextures(word);
        }

        //Save word to DB
        string category = "custom";

        //int diff = (int)Math.Round(difficultySlider.value);

        //Preset Image and sound entries - This will need to be changed when adding features for an image/audio path
        img   = word + ".png";
        sound = word + ".wav";
        tags  = wordTags;

        if (audioSuccess && photoSuccess)
        {
            //Call to DB to insert the word
            rowsInserted = dataService.CreateWord(word, category, tags, sound, img);

            if (rowsInserted == 1)
            {
                // Get the newly created id of the word entry from the data base
                IEnumerable <Words> rows = dataService.GetLastById();
                int    id    = 0;
                string check = "";

                foreach (var row in rows)
                {
                    id    = row.word_id;
                    check = row.word_name;
                }

                if (check.Equals(word))
                {
                    // Create a new word data object and add a new entry into the static word/WordDO dictionary
                    WordDO dataObject = new WordDO(id, word, category, tags, sound, img);
                    wordList[word] = dataObject;
                    return(true);
                }
                else
                {
                    //TODO: THROW AN ERROR
                }
            }
        }

        return(false);
    }
コード例 #22
0
    ///<summary>System event called when dragging an object ends</summary>
    ///<param name="eventData">the data collected about the event by Unity</param>
    public virtual void OnEndDrag(PointerEventData eventData)
    {
        string word;



        word = ImageBeingDragged.name;

        Debug.Log("Image dropped is " + word);


        //Unload ImageBeingDragged
        ImageBeingDragged = null;

        //Re-enables raycasting to the image
        //GetComponent<CanvasGroup>().blocksRaycasts = true;

        //Check if this object's parent is the starting slot _or_ the canvas
        if (transform.parent == startParent)
        {
            //Sets the object's position back to the starting slot
            transform.position = startPosition;
            if (word == helper.word1)
            {
                helper.word1Errors++;
            }
            else if (word == helper.word2)
            {
                helper.word2Errors++;
            }
            else if (word == helper.word3)
            {
                helper.word3Errors++;
            }
            else
            {
                Debug.Log("Error. word dropped does not match word1, word2 or word3");
            }
        }

        else
        {
            AudioClip tempClip = FileAccessUtil.LoadWordAudio(word + ".wav");

            if (tempClip != null)
            {
                audioSource.clip = tempClip;
                Debug.Log("Playing word sound");

                audioSource.Play();
            }
            else
            {
                tempClip = Resources.Load <AudioClip>("Sound/" + word);


                if (tempClip != null)
                {
                    audioSource.clip = tempClip;
                    Debug.Log("Playing word sound");
                    audioSource.Play();
                }
                else
                {
                    Debug.Log("No Sound available to play");
                }

                //audioSource.clip = tempClip;
                //Debug.Log("Playing word sound");
                //audioSource.Play();
            }

            helper.IterateSolvedPairs();
        }
        Debug.Log("End OnDrag");
    }
コード例 #23
0
ファイル: VW_Settings.cs プロジェクト: lazyninjacat/mylevelup
    public void Reset()
    {
        CloseConfirmResetModal();
        OpenPleaseWaitModal();
        // Clear playlist table and reset auto increment to 0
        dataService.DeleteAllPlaylist();
        dataService.ReseedTable("playlist", 0);

        // Delete all non stock words
        foreach (var row in wordList)
        {
            if (row.Value.StockCustom == "custom")
            {
                Debug.Log("Adding to wordlist to delete: " + row.Value.Word_name);
                wordIDsForDelete.Add(row.Value.IdNum);
                FileAccessUtil.DeleteWordAudio(row.Value.Word_name);

                List <string> existingPicsFiles = new List <string>();
                string[]      temparr           = System.IO.Directory.GetFiles(Application.persistentDataPath + "/WordPictures/" + row.Value.Word_name);

                foreach (string path in temparr)
                {
                    existingPicsFiles.Add(path);
                }

                Debug.Log("existingPicsFiles array length = " + existingPicsFiles.Count);


                foreach (string path in existingPicsFiles)
                {
                    Debug.Log("existingPicsFiles array element recorded as: " + path);
                    System.IO.File.Delete(path);
                }
                Debug.Log("Done deleting pics for " + row.Value.Word_name);
                System.IO.Directory.Delete(Application.persistentDataPath + "/WordPictures/" + row.Value.Word_name);
                Debug.Log("Done deleting directory for " + row.Value.Word_name);
                temparr = null;
                existingPicsFiles.Clear();
            }
        }
        foreach (int id in wordIDsForDelete)
        {
            Debug.Log(" deleting word ID: " + id);
            dataService.DeleteFromWords(id);
        }
        dataService.ReseedTable("Words", 10);
        wordList.Clear();
        wordIDsForDelete.Clear();


        // Clear existing mastery database records
        dataService.DeleteAllMastery();


        // Reset all Playerprefs
        PlayerPrefs.SetInt("isFirstKey", 0);
        PlayerPrefs.SetInt("AutoPlaylistOnOffKey", 0);
        PlayerPrefs.SetInt("isTutorial", 0);
        PlayerPrefs.SetString("ChildNameKey", "");

        // TODO: reset rewards stuff
        // Reset all rewards

        ClosePleaseWaitModal();
        OpenResetCompleteModal();
    }
コード例 #24
0
 /// <summary>
 /// Takes a file name (a word) and recovers randomly selected byte array belonging to that word.
 /// </summary>
 /// <param name="fileName"></param>
 /// <returns>byte array</returns>
 public byte[] LoadRandomWordPic(string fileName)
 {
     return(FileAccessUtil.LoadRandomWordPic(fileName));
 }
コード例 #25
0
ファイル: DragHandler.cs プロジェクト: lazyninjacat/mylevelup
    ///<summary>System event called when dragging an object ends</summary>
    ///<param name="eventData">the data collected about the event by Unity</param>
    public virtual void OnEndDrag(PointerEventData eventData)
    {
        string letter;



        letter = letterBeingDragged.name.Replace("_", " ").Replace("(Clone)", "");

        Debug.Log("Letter dropped is " + letter);


        //Unload letterBeingDragged
        letterBeingDragged = null;
        //Re-enables raycasting to the letter
        GetComponent <CanvasGroup>().blocksRaycasts = true;

        //Check if this object's parent is the starting slot _or_ the canvas
        //if (transform.parent == startParent || transform.parent == transform.root) {
        if (transform.parent == startParent)
        {
            //Sets the object's position back to the starting slot
            transform.position = startPosition;
            //Sets the object's parent back to the starting slot
            //transform.SetParent (startParent);
            ExecuteEvents.ExecuteHierarchy <IPostAnError>(gameObject, null, (x, y) => x.PostAnError());
            print("posting an error");
        }

        else
        {
            //Play soundclip

            //audioSource.Play();



            AudioClip tempClip = FileAccessUtil.LoadWordAudio(letter + ".wav");

            if (tempClip != null)
            {
                audioSource.clip = tempClip;
                audioSource.Play();
            }
            else
            {
                tempClip = Resources.Load <AudioClip>("Sound/" + letter);


                if (tempClip != null)
                {
                    audioSource.clip = tempClip;
                    audioSource.Play();
                }
                else
                {
                    //Do nothing
                }

                audioSource.clip = tempClip;
                audioSource.Play();
            }


            //Play animation
            animation.Play();
        }
    }
コード例 #26
0
    /////////////////////////////// Choose Reward Stuff vvvvvvvvvvvvvvvvvvvvv

    private void RequestData()
    {
        Dictionary <int, string> rewardDict = controller.RequestRewards();
        List <string>            listTags   = controller.GetWordTagsList();
        Dictionary <int, string> tagsDict   = controller.GetIdToWordTagsDict();

        foreach (var reward in rewardDict)
        {
            //Create a panel
            GameObject panel = GameObject.Instantiate(rewardPanel, RewardsViewportContent.transform, false);
            panel.name = reward.Key.ToString();
            GameObject label = panel.transform.Find("Label").gameObject;
            label.GetComponent <Text>().text = reward.Value;
            label.name = reward.Value.ToString();
            Toggle t = panel.GetComponent <Toggle>();

            t.onValueChanged.AddListener(delegate
            {
                OnToggleChange(t);
            });

            panel.SetActive(true);
            GameObject panelImage = panel.transform.Find("Image").gameObject;
            RawImage   img        = panelImage.GetComponent <RawImage>();
            Texture2D  tx         = new Texture2D(PIC_WIDTH, PIC_HEIGHT);
            byte[]     rewardPic  = FileAccessUtil.LoadRewardPic(reward.Value);

            //If not a custom reward
            if (rewardPic == null)
            {
                img.texture = Resources.Load <Texture2D>("RewardPictures/" + reward.Value);
            }
            //else is a custom reward
            else
            {
                if (tx.LoadImage(rewardPic))
                {
                    img.texture = tx;
                }
                else
                {
                    // TODO: log an error
                    Debug.Log("VW_Playlist Loading custom picture failed.");
                }
            }
        }

        foreach (string entry in listTags)
        {
            //Create a panel
            GameObject tPanel = GameObject.Instantiate(tagCopyPanel, tagsViewportContent.transform, false);
            tPanel.name = entry;
            GameObject tagLabel = tPanel.transform.Find("Label").gameObject;
            tagLabel.GetComponent <Text>().text = entry;
            tagLabel.name = entry;
            Toggle toggleTag = tPanel.GetComponent <Toggle>();

            toggleTag.onValueChanged.AddListener(delegate
            {
                OnTagToggleChange(toggleTag);
            });

            tPanel.SetActive(true);
        }

        foreach (string entry in controller.GetTypeStrings())
        {
            // TODO: Remove negative ref to memory cards once it has been debugged.
            if (entry != "Choose_Reward" && entry != "Memory_Cards")
            {
                //Create a panel
                GameObject sgPanel = GameObject.Instantiate(gameCopyPanel, setGamesContent.transform, false);
                sgPanel.name = entry;
                GameObject gameLabel = sgPanel.transform.Find("Label").gameObject;
                gameLabel.GetComponent <Text>().text = entry;
                gameLabel.name = entry;
                Toggle toggleGame = sgPanel.GetComponent <Toggle>();

                toggleGame.onValueChanged.AddListener(delegate
                {
                    OnGameToggleChange(toggleGame);
                });

                sgPanel.SetActive(true);
            }
        }
    }