Пример #1
0
    private Song ProcessDirectory(string folder)
    {
        Song tempSong = ScriptableObject.CreateInstance <Song>();

        tempSong.images = new List <Sprite>();
        string[] files = Directory.GetFiles(folder);
        foreach (var file in files)
        {
            Debug.Log(file);
            if (file.EndsWith(".mp3"))
            {
                //tempSong.song = Resources.Load<AudioClip>(file.);
            }
            else if (file.EndsWith(".png"))
            {
                if (file.ToLower().Contains("menuicon"))
                {
                    //tempSong.sprite = IMG2Sprite.LoadNewSprite(file);
                    Texture2D tempTexture2D = IMG2Sprite.LoadTexture(file);

                    tempSong.sprite = IMG2Sprite.ConvertTextureToSprite(tempTexture2D);
                }
                Texture2D tempTexture2DIcon = IMG2Sprite.LoadTexture(file);
                tempSong.images.Add(IMG2Sprite.ConvertTextureToSprite(tempTexture2DIcon));
            }
        }
        return(tempSong);
    }
Пример #2
0
    public static GameObject CreateImageObject(string path)
    {
        Sprite     sprite = IMG2Sprite.LoadNewSprite(path);
        GameObject image  = new GameObject("Image");

        image.AddComponent <Image>().sprite = sprite;
        image.transform.localScale          = new Vector3(1, 1, 1);
        return(image);
    }
 // Start is called before the first frame update
 void Start()
 {
     handIndex = -1;
     //print("front is null");
     i2s = new IMG2Sprite();
     //GameObject.Find("Table").GetComponent<LoadCards>().Decks[deckId].Remove(cardId);
     sideways = false;
     particle = GetComponent <ParticleSystem>();
 }
    void SetCardId(int oldId, int newId)
    {
        print("setting card id: " + newId);
        i2s            = new IMG2Sprite();
        spriteRenderer = transform.GetChild(0).GetComponent <SpriteRenderer>();
        string path = GameObject.Find("Table").GetComponent <LoadCards>().Cards[newId];

        front = i2s.LoadNewSprite(path);
        spriteRenderer.sprite = faceup ? front : back;
    }
Пример #5
0
 void Start()
 {
     iMG2Sprite  = IMG2Sprite.instance;
     texture     = new Texture2D(576, 320, TextureFormat.RGB24, false);
     levelButton = GetComponentInChildren <Button>();
     UpdateStarState();
     UpdateLockState();
     UpdateLevelText();
     UpdateScreenShot();
 }
Пример #6
0
    public void LoadSecrets()
    {
        string filePath = Setting.Secrets_filepath;

        try
        {
            if (File.Exists(filePath))
            {
                string dataAsJson = File.ReadAllText(filePath);
                Dictionary <string, object> data = JsonConvert.DeserializeObject <Dictionary <string, object> >(dataAsJson);
                Debug.Log(dataAsJson);
                foreach (var secret in (JArray)data["secrets"])
                {
                    int    primaryKey   = Convert.ToInt32(secret["primaryKey"]);
                    string problem_path = Path.Combine(Application.dataPath,
                                                       "Resources/Problem_Images/" + Convert.ToString(secret["problem"]));
                    Sprite problem = IMG2Sprite.LoadNewSprite(problem_path);

                    int[]      buttonKeys = new int[12];
                    List <int> answer     = new List <int>();

                    JArray buttonKeysJ = (JArray)secret["buttonKeys"];
                    for (int i = 0; i < 12; i++)
                    {
                        buttonKeys[i] = Convert.ToInt32(buttonKeysJ[i]);
                    }

                    foreach (int answerNum in secret["answer"])
                    {
                        answer.Add(answerNum);
                    }

                    AddSecret(new Secret(primaryKey, problem, buttonKeys, answer.ToArray()));
                }
            }
            else
            {
                throw new FileNotFoundException();
            }
        }
        catch (KeyNotFoundException e)
        {
            Debug.LogError(e.ToString());
        }
        catch (FileNotFoundException e)
        {
            Debug.LogError(e.ToString());
        }
        catch (IndexOutOfRangeException e)
        {
            Debug.LogError(e.ToString());
        }
    }
Пример #7
0
    public void LoadPosts()
    {
        string filePath = Setting.Post_filepath;

        try
        {
            if (File.Exists(filePath))
            {
                string dataAsJson = File.ReadAllText(filePath);
                Dictionary <string, object> data = JsonConvert.DeserializeObject <Dictionary <string, object> >(dataAsJson);

                foreach (var post in (JArray)data["posts"])
                {
                    int      userID    = Convert.ToInt32(post["userID"]);
                    string   text      = Convert.ToString(post["text"]);
                    DateTime timestamp =
                        DateTime.ParseExact(Convert.ToString(post["timestamp"]), "yyyy-MM-dd HH:mm tt", null);
                    int      primaryKey  = Convert.ToInt32(post["primaryKey"]);
                    JArray   photos_path = (JArray)post["photos"];
                    Sprite[] photos      = new Sprite[photos_path.Count];

                    for (int i = 0; i < photos.Length; i++)
                    {
                        string photoPath = Path.Combine(Application.dataPath, "Resources/Post_Images/" + photos_path[i]);
                        if (File.Exists(photoPath))
                        {
                            photos[i] = IMG2Sprite.LoadNewSprite(photoPath);
                        }
                        else
                        {
                            Debug.LogError("Post photos doesnt exist." + photoPath);
                        }
                    }
                    AddPost(new Post(userID, text, timestamp, primaryKey, photos));
                }
            }
            else
            {
                throw new FileNotFoundException();
            }
        }
        catch (KeyNotFoundException e)
        {
            Debug.LogError(e.ToString());
        }
        catch (FileNotFoundException e)
        {
            Debug.LogError(e.ToString());
        }
    }
Пример #8
0
    public void LoadUsers()
    {
        string filePath = Setting.User_filepath;

        try
        {
            if (File.Exists(filePath))
            {
                string dataAsJson = File.ReadAllText(filePath);
                Dictionary <string, object> data = JsonConvert.DeserializeObject <Dictionary <string, object> >(dataAsJson);

                foreach (var user in (JArray)data["users"])
                {
                    int    primaryKey  = Convert.ToInt32(user["primaryKey"]);
                    string name        = Convert.ToString(user["name"]);
                    string avatar_path = Path.Combine(Application.dataPath,
                                                      "Resources/User_Images/" + Convert.ToString(user["avatar"]));
                    Sprite        avatar            = IMG2Sprite.LoadNewSprite(avatar_path);
                    JArray        informations_json = (JArray)user["informations"];
                    Information[] informations      = new Information[Setting.InformationMaxCount];
                    for (int i = 0; i < informations_json.Count; i++)
                    {
                        informations[i] = new Information((InformationType)Enum.Parse(typeof(InformationType), informations_json[i]["type"].ToString()), informations_json[i]["text"].ToString());
                    }

                    //Default Unknown
                    for (int i = informations_json.Count; i < Setting.InformationMaxCount; i++)
                    {
                        informations[i] = new Information(InformationType.Default, "Unknown");
                    }

                    AddUser(new User(name, avatar, informations, primaryKey));
                }
            }
            else
            {
                throw new FileNotFoundException();
            }
        }
        catch (KeyNotFoundException e)
        {
            Debug.LogError(e.ToString());
        }
        catch (FileNotFoundException e)
        {
            Debug.LogError(e.ToString());
        }
    }
Пример #9
0
    //////////////////////////////////////////////////
    /// Manipulating the visual part

    //turn 2D images to "paintings"
    private GameObject MakeImagesPaintings(string filePath)
    {
        IMG2Sprite imgToSprite = GetComponent <IMG2Sprite>(); //this script is also attached to PocketInventoryManagger
        //make empty parent object
        //GameObject paintingItem = new GameObject(Path.GetFileNameWithoutExtension(filePath));


        //make canvasBase (acts as parent object)
        GameObject canvasBase = GameObject.CreatePrimitive(PrimitiveType.Cube);

        canvasBase.transform.position = new Vector3(0, 1, 0);
        canvasBase.gameObject.name    = Path.GetFileNameWithoutExtension(filePath);
        canvasBase.gameObject.tag     = "WallArt";
        canvasBase.gameObject.layer   = LayerMask.NameToLayer("Artwork");

        //make painting
        GameObject     go       = new GameObject(Path.GetFileNameWithoutExtension(filePath));
        SpriteRenderer renderer = go.AddComponent <SpriteRenderer>();
        Sprite         canvas   = imgToSprite.LoadNewSprite(filePath);

        renderer.sprite           = canvas;
        renderer.transform.parent = canvasBase.transform;

        var bounds  = canvas.bounds;
        var factory = 1 / bounds.size.y;
        var factorx = 1 / bounds.size.x;

        renderer.transform.localScale = new Vector2(factorx, factory);

        canvasBase.transform.localScale = new Vector3(canvas.texture.width / 1000.0f, canvas.texture.height / 1000.0f, 0.055f) * 1.5f;
        renderer.transform.position     = new Vector3(canvasBase.transform.position.x - (canvasBase.transform.localScale.x / 2), canvasBase.transform.position.y - (0.5f * canvasBase.transform.position.y), canvasBase.transform.position.z - (canvasBase.transform.localScale.z));

        //canvasBase.AddComponent<BoxCollider>();
        canvasBase.GetComponent <MeshRenderer>().enabled = false;
        canvasBase.transform.Rotate(0.0f, 180.0f, 0.0f);
        canvasBase.AddComponent <ColliderDetector>();
        canvasBase.AddComponent <Rigidbody>();
        canvasBase.GetComponent <Rigidbody>().useGravity  = false;
        canvasBase.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;

        return(canvasBase);
    }
    // Carga la configuración de niveles desde archivo "levels.xml".
    List <LevelData> GetLevelData()
    {
        List <LevelData> output = new List <LevelData>();

        string path = @"Levels/Levels.xml";

        if (File.Exists(path))
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(path);
            XmlNode root = doc.FirstChild;

            if (root.HasChildNodes)
            {
                for (int i = 0; i < root.ChildNodes.Count; i++)
                {
                    XmlElement level = (XmlElement)root.ChildNodes[i];
                    LevelData  levelData;
                    levelData.name          = level["name"].InnerText;
                    levelData.description   = level["description"].InnerText;
                    levelData.image         = IMG2Sprite.LoadNewSprite("Levels/" + level["image"].InnerText);
                    levelData.fruitsA       = Convert.ToUInt32(level["fruitsA"].InnerText);
                    levelData.fruitsB       = Convert.ToUInt32(level["fruitsB"].InnerText);
                    levelData.speedA        = Convert.ToUInt32(level["speedA"].InnerText);
                    levelData.speedB        = Convert.ToUInt32(level["speedB"].InnerText);
                    levelData.enableLock    = Convert.ToBoolean(level["enableLock"].InnerText);
                    levelData.commonCounter = Convert.ToBoolean(level["commonCounter"].InnerText);
                    levelData.endGameButton = Convert.ToBoolean(level["endGameButton"].InnerText);
                    output.Add(levelData);
                }
            }
        }
        else
        {
            Debug.LogError("Levels.xml not found");
        }

        return(output);
    }
Пример #11
0
    // Start is called before the first frame update
    void Start()
    {
        i2s    = new IMG2Sprite();
        Stacks = new List <StackConfig>();
        Decks  = new List <List <int> >();
        string folder = Directory.GetCurrentDirectory() + "\\Cards";

        string[] paths = Directory.GetFiles(folder, "*.json");
        foreach (string path in paths)
        {
            StreamReader reader = new StreamReader(path);
            string       config = reader.ReadToEnd();
            StackConfig  stack  = JsonUtility.FromJson <StackConfig>(config);
            Stacks.Add(stack);
            Decks.Add(new List <int>());
        }
        Cards = new List <string>();
        string[] pics = Directory.GetFiles(folder, "card_*.jpg");
        foreach (string pic in pics)
        {
            Match match = Regex.Match(pic, "[0-9]+");
            int   index = int.Parse(match.Groups[0].Value.ToString());
            Cards.Add(pic);
            for (int i = 0; i < Stacks.Count; i++)
            {
                StackConfig stack = Stacks[i];
                if (index >= stack.min && index <= stack.max)
                {
                    Decks[i].Add(Cards.Count - 1);
                }
            }
        }
        Backsides = new List <Sprite>();
        for (int i = 0; i < Stacks.Count; i++)
        {
            Backsides.Add(i2s.LoadNewSprite(folder + "\\" + Stacks[i].backside));
        }
    }
Пример #12
0
    public static void CreateButtonSearchSprite()
    {
        if (GUILayout.Button("Search Sprite"))
        {
            spriteFolderList  = new List <Sprite>();
            textureFolderList = new List <Texture>();
            imagePathList     = ToolGetSpriteInFolder.takeSpriteToFolder(ToolGeneric.pathFolderSprite);

            foreach (string _filePath in imagePathList)
            {
                Sprite newSprite;
                newSprite      = IMG2Sprite.LoadNewSprite(_filePath);
                newSprite.name = Path.GetFileNameWithoutExtension(_filePath);
                spriteFolderList.Add(newSprite);

                Texture newTexture;
                newTexture = newSprite.texture;
                textureFolderList.Add(newTexture);
            }
            spriteFolderArray   = spriteFolderList.ToArray();
            textureFolderArray  = textureFolderList.ToArray();
            selectionSpriteDraw = 0;
        }
    }
Пример #13
0
    private void LoadImage(string path)
    {
        if (path == null)
        {
            return;
        }

        if (postData.imageNames == null)
        {
            postData.imageNames = new List <string>();
        }

        postData.imageNames.Add(path);

        GameObject cropImage_obj = Instantiate(cropImage_prefab, imgBoard, false);

        cropImage_obj.GetComponent <RectTransform>().sizeDelta = new Vector2(imgBoard.gameObject.GetComponent <RectTransform>().sizeDelta.y, imgBoard.gameObject.GetComponent <RectTransform>().sizeDelta.y);

        CropImage cropImage = cropImage_obj.GetComponent <CropImage>();

        cropImage.image.sprite = IMG2Sprite.LoadNewSprite(path);

        cropImage.GetComponent <CropImage>().FitCanvas();
    }
Пример #14
0
    // Update is called once per frame
    void Update()
    {
        //First Panel
        if (firstDone == false)
        {
            if (Time.time - startTime >= 3.0f)
            {
                if (imageColor.a > 0.0f)
                {
                    imageColor.a -= 0.008f;
                    black.color   = imageColor;
                }
                if (markColor.a < 1.0f)
                {
                    markColor.a    += 0.01f;
                    watermark.color = markColor;
                }
                if (textColor.a > 0.0f)
                {
                    textColor.a     -= 0.01f;
                    authorText.color = textColor;
                    appIcon.color    = textColor;
                }
                else if (imageColor.a < 0.02f)
                {
                    authorText.enabled = false;
                    black.enabled      = false;
                    firstDone          = true;
                    firstToSecond      = true;
                }
            }
        }
        else if (firstDone == true && firstToSecond == true)
        {
            //Second Panel
            SecondPanel.SetActive(true);
            if (firstTimeToSecond)
            {
                cancelIcon.SetActive(false);
                firstTimeToSecond = false;
            }
            else
            {
                cancelIcon.SetActive(true);
            }
            FirstPanel.SetActive(false);
            countdownObj.SetActive(false);
            firstToSecond = false;
        }
        else if (secondDone == true && secondToThird == true)
        {
            //Load photo as texture
            if (ScreenRecorder.reloadTexture == true)
            {
                Debug.Log("PATH:" + ScreenRecorder.nowUserPhotoFilePath);
                Texture2D newTexture = IMG2Sprite.LoadTexture(ScreenRecorder.nowUserPhotoFilePath);
                photo.GetComponent <Renderer>().sharedMaterial.mainTexture = newTexture;
                ScreenRecorder.reloadTexture = false;
            }

            noticeText.SetActive(true);
            secondCorrection.SetActive(true);
            secondSwitch.SetActive(true);
            cancelIcon.SetActive(true);
            userColor.a = 0.8f;
            user.color  = userColor;
            SecondPanel.SetActive(false);
            ThirdPanel.SetActive(true);
            ARModeIcons.SetActive(true);
            secondToThird = false;
        }

        if (countdownThread == true)
        {
            if (clickStartTime == -1)
            {
                clickStartTime = Time.time;
            }
            if (userColor.a > 0.0f)
            {
                userColor.a -= 0.0051f;
                user.color   = userColor;
            }
            if (Time.time - clickStartTime < 3.0f)
            {
                noticeText.SetActive(false);
                secondCorrection.SetActive(false);
                secondSwitch.SetActive(false);
                cancelIcon.SetActive(false);
                int countdown = 3 - (int)(Time.time - clickStartTime);
                countdownText.text = countdown.ToString();
            }
            else
            {
                if (shotted == false)
                {
                    SecondPanel.SetActive(false);
                    ScreenRecorder.captureScreenshot = true;
                    shotted = true;
                }
                //if (Time.time - clickStartTime < 4.8f)
                //{
                //    if (ScreenRecorder.done == true)
                //    {
                //        SecondPanel.SetActive(true);
                //        countdownText.fontSize = 150;
                //        countdownText.text = "OK!";
                //    }
                //}
                //else
                if (Time.time - clickStartTime > 4.2f)
                {
                    countdownObj.SetActive(false);
                    countdownText.fontSize = 300;
                    countdownText.text     = "";
                    countdownThread        = false;
                    clickStartTime         = -1;
                    secondDone             = true;
                    secondToThird          = true;
                    shotted             = false;
                    ScreenRecorder.done = false;
                    //cameraText.text = "";
                }
            }
        }
    }
Пример #15
0
 // Use this for initialization
 void Start()
 {
     img2Sprite = IMG2Sprite.instance;
     LoadInventoryAndDataBase();
 }
Пример #16
0
    //void SetEmotion(string emotion)
    //{
    //  StartCoroutine(SetEmotionInternal(emotion));
    //}

    void SetEmotion(string emotion)
    {
        if (emotion == "cry")
        {
            cryingRoboy = !cryingRoboy;
        }
        anim.SetBool("cryingRoboy", cryingRoboy);
        //anim.SetBool("cryingRoboy", true);
        // pause 2 sec
        //yield return new WaitForSeconds(6);
        //anim.SetBool("cryingRoboy", false);
        // trigger to idle

        if (emotion == "tongue")
        {
            anim.SetTrigger("tongue_out");
        }
        if (emotion == "lucky")
        {
            anim.SetTrigger("happy2");
        }
        if (emotion == "angry")
        {
            anim.SetTrigger("angey_new");
        }
        if (emotion == "teeth")
        {
            anim.SetTrigger("happy");
        }
        if (emotion == "annoyed")
        {
            anim.SetTrigger("angry");
        }
        if (emotion == "hypno")
        {
            anim.SetTrigger("hypno_eyes");
        }
        if (emotion == "rolling")
        {
            anim.SetTrigger("rolling");
        }


        if (emotion == "moustache")
        {
            moustache = !moustache;
        }
        anim.SetBool("moustache", moustache);

        if (emotion == "pirate")
        {
            pirate = !pirate;
        }
        anim.SetBool("pirate", pirate);

        if (emotion == "pissed")
        {
            anim.SetTrigger("pissed");
        }
        if (emotion == "sunglasses_on")
        {
            sunglasses_on = !sunglasses_on;
        }
        anim.SetBool("sunglasses_on", sunglasses_on);

        if (emotion == "suprised")
        {
            anim.SetTrigger("surprise_mit_augen");
        }
        if (emotion == "hypno_color")
        {
            anim.SetTrigger("hypno_color");
        }

        if (emotion == "toggleblack")
        {
            black.enabled = !black.enabled;
        }
        if (emotion == "glasseson")
        {
            glasses.color = Color.white;
        }
        else if (emotion == "glassesoff")
        {
            glasses.color = new Color(1, 1, 1, 0);
        }
        else if (emotion == "hearts")
        {
            emotion = "img:Heart";
        }
        else if (emotion.Contains("img:"))
        {
            string emoji = emotion.Substring(4);
            foreach (Sprite s in icons)
            {
                if (s.name == emoji)
                {
                    emojiLeft.sprite  = s;
                    emojiRight.sprite = s;
                    anim.SetTrigger("hearts");
                    break;
                }
            }
        }
        else if (emotion.Contains("url:"))
        {
            string emoji = emotion.Substring(4);
            emojiLeft.sprite  = IMG2Sprite.LoadNewSprite(emoji);
            emojiRight.sprite = IMG2Sprite.LoadNewSprite(emoji);
            anim.SetTrigger("hearts");
        }
        else
        {
            anim.SetTrigger(emotion);
        }
    }