Exemplo n.º 1
0
        public static void LoadLevel(LevelMap levelToLoad)
        {
            toLoad.Enqueue(levelToLoad);
            Thread newThread = new Thread(new ThreadStart(LoaderThread));

            loadingThreads.Add(newThread);
            newThread.Start();
        }
Exemplo n.º 2
0
 public static LevelMap sampleLevelMap()
 {
     LevelMap newMap = new LevelMap();
     newMap.myLoadCommands = new KeyValuePair<string, string>[2];
     newMap.myLoadCommands[0] = new KeyValuePair<string, string>("station", "Model");
     newMap.myLoadCommands[1] = new KeyValuePair<string, string>("simpleAsteroid", "Model");
     newMap.myObjectsWithProperties = new string[1][];
     newMap.myObjectsWithProperties[0] = new string[] { "WorldObject", "simpleAsteroid", "simpleShipTex" };
     return newMap;
 }
Exemplo n.º 3
0
        public static LevelMap sampleLevelMap()
        {
            LevelMap newMap = new LevelMap();

            newMap.myLoadCommands             = new KeyValuePair <string, string> [2];
            newMap.myLoadCommands[0]          = new KeyValuePair <string, string>("station", "Model");
            newMap.myLoadCommands[1]          = new KeyValuePair <string, string>("simpleAsteroid", "Model");
            newMap.myObjectsWithProperties    = new string[1][];
            newMap.myObjectsWithProperties[0] = new string[] { "WorldObject", "simpleAsteroid", "simpleShipTex" };
            return(newMap);
        }
Exemplo n.º 4
0
        public static void LoaderThread()
        {
            if (toLoad.Count == 0)
            {
                loadingThreads.Remove(Thread.CurrentThread);
                return;
            }
            LevelMap levelToLoad = toLoad.Dequeue();

            for (int i = 0; i < levelToLoad.myLoadCommands.Length; i++)
            {
                if (!loadedAssets.ContainsKey(levelToLoad.myLoadCommands[i].Key))
                {
                    KeyValuePair <string, Object> asset = new KeyValuePair <string, object>();
                    bool   assetInitalized = false;
                    Object assetVal;
                    switch (levelToLoad.myLoadCommands[i].Value)
                    {
                    case "Model":
                        assetVal        = myParent.Content.Load <Model>(levelToLoad.myLoadCommands[i].Key);
                        asset           = new KeyValuePair <string, object>("Model", assetVal);
                        assetInitalized = true;
                        break;

                    case "Texture2D":
                        assetVal        = myParent.Content.Load <Texture2D>(levelToLoad.myLoadCommands[i].Key);
                        asset           = new KeyValuePair <string, object>("Texture2D", assetVal);
                        assetInitalized = true;
                        break;
                    }
                    if (assetInitalized)
                    {
                        loadedAssets.Add(levelToLoad.myLoadCommands[i].Key, asset);
                    }
                }
            }
            loadingThreads.Remove(Thread.CurrentThread);
            return;
        }
Exemplo n.º 5
0
 public static void LoadLevel(LevelMap levelToLoad)
 {
     toLoad.Enqueue(levelToLoad);
     Thread newThread = new Thread(new ThreadStart(LoaderThread));
     loadingThreads.Add(newThread);
     newThread.Start();
 }