Ejemplo n.º 1
0
    private void LoadDeckPaddDecks(string DeckFile)
    {
        //this.Decks = new List<Deck>();
        Deck item = new Deck();
        DownloadFileHandler fh = GameObject.Find("FileHandler").GetComponent <DownloadFileHandler>();

        item.GUID = System.Guid.NewGuid().ToString();
        string deckType;

        System.IO.StreamReader sr = new System.IO.StreamReader(DeckFile);
        while (!sr.EndOfStream)
        {
            string          line     = sr.ReadLine();
            string[]        data     = line.Split('\t');
            List <string[]> cardData = CardBase.GetDataByField(CardBase.CardCollection, "Name", data[1], false);
            deckType = CardBase.FieldValue(cardData[0], "Type");
            int  cardIndex = CardBase.GetIndex(data[1]);
            Card card      = new Card();
            card.ParentGUID = item.GUID;
            card.Active     = true;
            card.CardIndex  = cardIndex;
            fh.GetFileFromURL(cardIndex);
            card.PlayerIndex = Global.CurrentPlayer;
            switch (deckType)
            {
            case "Mission": GetDeck(DeckEnum.Mission).Cards.Add(card); break;

            case "Dilemma": GetDeck(DeckEnum.Dilemma).Cards.Add(card); break;

            default: GetDeck(DeckEnum.Draw).Cards.Add(card); break;
            }
        }
    }
Ejemplo n.º 2
0
    private bool LoadFromURL(string URL, string Path)
    {
        if (File.Exists(Path))
        {
            return(true);
        }
        GameObject          goFH = GameObject.Find("FileHandler");
        DownloadFileHandler dfh  = goFH.GetComponent <DownloadFileHandler>();

        dfh.GetFileFromURL(URL, Path);
        FileStream fs;
        bool       unlock = false;

        while (!unlock)
        {
            try
            {
                fs     = File.Open(Path, FileMode.Open);
                unlock = true;
                fs.Close();
            }
            catch (IOException ex)
            {
                Debug.Log(ex.Message);
                unlock = true;
            }
        }
        return(true);
    }
Ejemplo n.º 3
0
    public Sprite LoadNewSprite(int cardIndex, float PixelsPerUnit = 100.0f, SpriteMeshType spriteType = SpriteMeshType.Tight)
    {
        FileStream fs;

        string[] card;
        string   ImageFile;
        string   filePath;

        bool unlock = false;

        if (cardIndex != -1)
        {
            card      = CardBase.CardCollection[cardIndex];
            ImageFile = CardBase.FieldValue(card, Global.ImageHeader);
        }
        else
        {
            ImageFile = "cardback";
        }
        filePath = Global.ImageDir + @"\" + ImageFile + ".jpg";
        if (_fh.GetFileFromURL(cardIndex))
        {
            if (File.Exists(filePath))
            {
                while (!unlock)
                {
                    try
                    {
                        fs     = File.Open(filePath, FileMode.Open);
                        unlock = true;
                        fs.Close();
                    }
                    catch (IOException ex)
                    {
                        unlock = false;
                        Debug.Log(ex.Message);
                    }
                }
            }
            else
            {
                filePath = Global.ImageDir + @"\CardMissing.jpg";
            }
        }
        else
        {
            filePath = Global.ImageDir + @"\CardMissing.jpg";
        }
        Texture2D SpriteTexture = LoadTexture(filePath);
        Sprite    NewSprite     = Sprite.Create(SpriteTexture, new Rect(0, 0, SpriteTexture.width, SpriteTexture.height), new Vector2(0.5f, 0.5f), PixelsPerUnit, 0, spriteType);

        return(NewSprite);
    }
Ejemplo n.º 4
0
    private void LoadLackeyDecks(string DeckFile)
    {
        //this.Decks = new List<Deck>();
        DownloadFileHandler fh = GameObject.Find("FileHandler").GetComponent <DownloadFileHandler>();
        Deck item = GetDeck(DeckEnum.Draw);

        item.GUID = System.Guid.NewGuid().ToString();
        item.Cards.Clear();
        string deckType = "";

        System.IO.StreamReader sr = new System.IO.StreamReader(DeckFile);
        while (!sr.EndOfStream)
        {
            string line = sr.ReadLine();
            if (line != "")
            {
                string[] data = line.Split('\t');
                if (data.Length == 1)
                {
                    deckType = data[0];
                }
                else
                {
                    if (data[1].Trim() != "")
                    {
                        int qty       = System.Int32.Parse(data[0]);
                        int cardIndex = CardBase.GetIndex(data[1]);
                        fh.GetFileFromURL(cardIndex);
                        Card card = new Card();
                        card.ParentGUID  = item.GUID;
                        card.Active      = true;
                        card.CardIndex   = cardIndex;
                        card.PlayerIndex = Global.CurrentPlayer;
                        for (int i = 0; i < qty; i++)
                        {
                            switch (deckType)
                            {
                            case "Missions:": GetDeck(DeckEnum.Mission).Cards.Add(card); break;

                            case "Dilemmas:": GetDeck(DeckEnum.Dilemma).Cards.Add(card); break;

                            default: GetDeck(DeckEnum.Draw).Cards.Add(card); break;
                            }
                        }
                    }
                    else
                    {
                        deckType = data[0];
                    }
                }
            }
        }
    }