Пример #1
0
    private Texture2D GetMemeSprite(Meme.MemeType type)
    {
        int returnCode = 0;

        switch (type)
        {
        case Meme.MemeType.Alone:
            returnCode = 0;
            break;

        case Meme.MemeType.Brave:
            returnCode = 1;
            break;

        case Meme.MemeType.Cereal:
            returnCode = 2;
            break;

        case Meme.MemeType.Derpina:
            returnCode = 3;
            break;

        case Meme.MemeType.Fap:
            returnCode = 4;
            break;

        case Meme.MemeType.Gusta:
            returnCode = 5;
            break;

        case Meme.MemeType.Indiferent:
            returnCode = 6;
            break;

        case Meme.MemeType.Lol:
            returnCode = 7;
            break;

        case Meme.MemeType.Rage:
            returnCode = 8;
            break;

        case Meme.MemeType.Troll:
            returnCode = 9;
            break;

        case Meme.MemeType.Creep:
            returnCode = 10;
            break;

        case Meme.MemeType.Poker:
            returnCode = 11;
            break;
        }
        return(memeSprites[returnCode]);
    }
Пример #2
0
    /// <summary>
    /// Fills the global meme gallery with memes from Resources/MemeFiles/MemeData.txt
    /// </summary>
    private static void FillGlobalGallery()
    {
        TextAsset textFile = (TextAsset)Resources.Load("MemeFiles/MemeData");

        // For each line in MemeData.txt...
        string[] lines = textFile.text.Split("\n"[0]);
        for (int i = 0; i < lines.Length; i++)
        {
            // If the line has the correct number of arguments...
            string[] memeData = lines[i].Split(","[0]);
            if (memeData.Length == 4)
            {
                // Parse the comma-separated line
                string title     = memeData[0].Trim();
                string creator   = memeData[1].Trim();
                string type      = memeData[2].Trim();
                string imageFile = memeData[3].Trim();

                // Select the appropriate type
                Meme.MemeType memeType  = Meme.MemeType.Max;
                bool          validMeme = true;
                if (type == "DeepFried")
                {
                    memeType = Meme.MemeType.DeepFried;
                }
                else if (type == "Text")
                {
                    memeType = Meme.MemeType.Text;
                }
                else if (type == "Reaction")
                {
                    memeType = Meme.MemeType.Reaction;
                }
                else
                {
                    validMeme = false;
                }

                // Find the image
                Sprite imageSprite = Resources.Load <Sprite>("MemeFiles/" + imageFile);

                if (validMeme)
                {
                    Meme newMeme = new Meme(title, creator, memeType, imageSprite);
                    globalGallery.Add(newMeme);
                }
            }
        }
    }