Ejemplo n.º 1
0
 void getPlayers(out Player A, out Player B, out GameData gameData)
 {
     gameData = CardsLoader.LoadFromAssembly(root.StdCardset);
     GameInstance.CreateFromData(gameData).CreateOnly(out A, out B);
 }
Ejemplo n.º 2
0
        private void LoadSelectedLesson()
        {
            CodeProfiler.Start("LoadLesson");
            Debug.WriteLine("Loading lesson: " + SelectedLesson);
            KillImageLoader();

            string lessonPath = LessonBasePath + SelectedLesson;

            string[] files = Directory.GetFiles(lessonPath);
            Array.Sort(files);

            //Clean up old cards. Dispose Audio object.
            foreach (FlashCardItem ptrItem in Cards)
            {
                ptrItem.Dispose();
            }
            Cards.Clear();
            FlashCardItem newItem;

            //Load and sort cards.
            CodeProfiler.Start("Generate Items");
            string CardName;
            string CardText;
            string CardImageType;

            foreach (string ptrFile in files)
            {
                //Card Format
                //[CardIndex]#<Card Name>.<Image type>
                CardImageType = Path.GetExtension(ptrFile).ToLower();
                if (!IsImageTypeSupported(CardImageType))
                {
                    continue;
                }

                CardName = CardText = Path.GetFileNameWithoutExtension(ptrFile);
                if (CardName.Contains("#"))
                {
                    CardText = CardName.Substring(CardName.IndexOf("#") + 1);
                }
                newItem = new FlashCardItem(CardName, CardText, ptrFile);
                Debug.WriteLine("> " + newItem.Text);
                Cards.Add(newItem);
            }
            CodeProfiler.Stop("Generate Items");

            //Load card contents.
            if (UseThread)
            {
                //Use threading to load images.
                CardsLoader = new Thread(LoadCardsData);
                CardsLoader.Start();
                CodeProfiler.Start("LoadCard1");
                Cards[0].Load(); //Make sure first image is loaded
                CodeProfiler.Stop("LoadCard1");
            }
            else
            {
                //Single thread operation (Slower) - Keep for debugging purpose
                foreach (FlashCardItem ptrItem in Cards)
                {
                    CodeProfiler.Start("Load Card " + ptrItem.Name);
                    ptrItem.Load();
                    CodeProfiler.Stop("Load Card " + ptrItem.Name);
                }
            }

            Cards.ResetIndex();
            CardsLoader.Join();
            OnLessonLoaded();
            Debug.WriteLine("Lesson loaded.");
            CodeProfiler.Stop("LoadLesson");
        }
Ejemplo n.º 3
0
 public visualRandom(string cardSetPath, string serializerName)
     : this(CardsLoader.LoadFromAssembly(cardSetPath), serializerName)
 {
 }
Ejemplo n.º 4
0
 public visualNN(string cardSetPath, string serializerName, string nnfile)
     : this(CardsLoader.LoadFromAssembly(cardSetPath), serializerName, nnfile)
 {
 }
Ejemplo n.º 5
0
 public static void GAll(string cardSetPath, string serializerName, out GameData data, out GameInstance gi, out StdSerializers.ISerializer ser)
 {
     data = CardsLoader.LoadFromAssembly(cardSetPath);
     gi   = GameInstance.CreateFromData(data);
     ser  = StdSerializers.Util.CreateFromName(serializerName, data);
 }