Esempio n. 1
0
        public static async Task<string> GetRealVideoAddress(string url, Action<Error> onFail = null)
        {
            string address = string.Empty;

            DataLoader loader = new DataLoader();
            await loader.LoadDataAsync(url, response => {
                RealVideoAddressData data = JsonSerializer.Deserialize<RealVideoAddressData>(response, true);
                if(data.Status.Equals("ok", StringComparison.OrdinalIgnoreCase))
                {
                    address = data.Info;
                }
                else
                {
                    if(onFail != null)
                    {
                        onFail.Invoke(new Error() { Message = data.Info });
                    }
                }
            }, error => {
                if(onFail != null)
                {
                    onFail.Invoke(error);
                }
            });

            return address;
        }
Esempio n. 2
0
		private void Awake()
		{
			if (Instance == null)
			{
				Instance = this;
				DontDestroyOnLoad(gameObject);

				LogManager.IsEnabled = true;

				// Setup the Unity Logger!
				//LogManager.AttachLogTarget(new UnityTarget(Logger.Level.Trace, Logger.Level.Error, true));

				StartupTime = DateTime.Now;

				Loader = new DataLoader();
				Loader.DataLoadPath = Application.dataPath;
				Loader.LoadAll();

				// This will pull the player data, after we have instantiated all available cards
				PlayerProfile profile = new PlayerProfile();

				// Losd the Board Scene into the world!
				Application.LoadLevelAdditive("UI");
				Application.LoadLevelAdditive("BoardScene");

				InitializeControllers();

                _eventManager = new EventManager();
                Events = _eventManager; 

				_currentGameState = GameState.Invalid;
			}
		}
Esempio n. 3
0
        public void CanPatchVanillaUI()
        {
            throw new NotImplementedException("need to be reworked for new backup foirmat");
            var subject = new PatchDataLoader();
            var dllLoader = new DataLoader();

            var uiDataLoader = new UIDataLoader();

            var patchPath = Path.Combine(Directory.GetCurrentDirectory(), "TestData", "CorePatches.xml");
            var uiPath = Path.Combine(Directory.GetCurrentDirectory(), "TestData", "skin1.xml");

            var loaded = subject.LoadData(patchPath);

            foreach (var definition in loaded.Definitions)
            {
                foreach (var uiPatch in definition.UIPatches)
                {
                    Assert.IsTrue(uiPatch.FilePath.EndsWith("xml")); //need to extend tests for other files

                    var doc = uiDataLoader.FixAndLoadXml(uiPath);

                    var nodeToPatch = doc.XPathSelectElement(uiPatch.XPath);

                    Assert.IsTrue(nodeToPatch != null);

                    var nr = new XmlNodeReader(uiPatch.Data);

                    var patchedNode = XElement.Load(nr).Descendants().FirstOrDefault();
                    //patchedNode = patchedNode.Descendants().FirstOrDefault();

                    if (uiPatch.PatchMode == UIPatchMode.Replace)
                    {
                        var parent = nodeToPatch.Parent;
                        var prevNode = nodeToPatch.PreviousNode;

                        var backup = new XComment(string.Format("__sotsos_backup__|{0}|__sotsos_backup__", nodeToPatch.ToString()));
                        patchedNode.Add(backup);
                        nodeToPatch.Remove();

                        if (prevNode != null)
                        {
                            prevNode.AddAfterSelf(patchedNode);
                        }
                        else
                        {
                            parent.Add(patchedNode);
                        }
                    }

                    var wr = doc.CreateWriter();

                    using (var writer = XmlWriter.Create(uiPath))
                    {
                        doc.WriteTo(writer);
                    }

                }
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Initialize a new server
 /// </summary>
 public Server()
 {
     this.Initialized = false;
     this.Running = false;
     this.ListenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     this.Clients = new List<Client>();
     Loader = new DataLoader();
     Maps = new MapManager();
 }
Esempio n. 5
0
        public void DataLoaderInitializeTest()
        {
            DataLoader a = new DataLoader();

            Assert.AreEqual(LoadingState.None, a.LoadingState);

            Assert.IsFalse(a.IsBusy);
            Assert.IsFalse(a.IsFinished);
            Assert.IsFalse(a.IsError);

        }
Esempio n. 6
0
        private void Start()
        {
            //Creating a new instance of the data loader
            dataLoader = new DataLoader();

            LoadPlayerData();
            if(currentPlayerData == null)
            {
                CreateNewPlayerData();
                SavePlayerData();
            }
            LoadPlayerData();
            UpdatePlayerAttributes();
        }
Esempio n. 7
0
        public async Task DataLoaderLoadTest()
        {
            DataLoader a = new DataLoader();

            var task = a.LoadAsync(() => LongRunningOperation());

            Assert.AreEqual(LoadingState.Loading, a.LoadingState);

            Assert.IsTrue(a.IsBusy);
            Assert.IsFalse(a.IsFinished);
            Assert.IsFalse(a.IsError);

            Assert.AreEqual("result", await task);

            Assert.IsFalse(a.IsBusy);
            Assert.IsTrue(a.IsFinished);
            Assert.IsFalse(a.IsError);
        }
Esempio n. 8
0
        public async Task DataLoaderLoadErrorSwallowTest()
        {
            //Swallow exceptions by default
            DataLoader a = new DataLoader();

            var task = a.LoadAsync(() => LongRunningOperationThrowsError());

            Assert.AreEqual(LoadingState.Loading, a.LoadingState);

            Assert.IsTrue(a.IsBusy);
            Assert.IsFalse(a.IsFinished);
            Assert.IsFalse(a.IsError);

            //Exception is swallowed
            Assert.AreEqual(null, await task);

            Assert.IsFalse(a.IsBusy);
            Assert.IsFalse(a.IsFinished);
            Assert.IsTrue(a.IsError);
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            if (args.Length >= 1)
            {
                if (string.Equals(args[0], "gentestdat", StringComparison.OrdinalIgnoreCase))
                {
                    UnitTests.GenerateTestData();
                }
                if (args.Length == 2 && string.Equals(args[0], "profile", StringComparison.OrdinalIgnoreCase))
                {
                    int count = 0;
                    if (!int.TryParse(args[1], out count))
                    {
                        return;
                    }
                    var stopwatch = new Stopwatch();
                    var loader = new DataLoader();
                    for (int i = 0; i < count; i++)
                    {
                        foreach (var name in loader.AssetNames)
                        {
                            var pset = loader.GetAsset(name).Polygons;

                            foreach (WindingRule winding in Enum.GetValues(typeof(WindingRule)))
                            {
                                var tess = new Tess();
                                PolyConvert.ToTess(pset, tess);
                                stopwatch.Start();
                                tess.Tessellate(winding, ElementType.Polygons, 3);
                                stopwatch.Stop();
                            }
                        }
                    }
                    Console.WriteLine("{0:F3}ms", stopwatch.Elapsed.TotalMilliseconds);
                }
                return;
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }
Esempio n. 10
0
        public async Task DataLoaderLoadErrorTest()
        {
            //false indicates: Do not swallow exception!
            DataLoader a = new DataLoader(false);

            var task = a.LoadAsync(() => LongRunningOperationThrowsError());

            Assert.AreEqual(LoadingState.Loading, a.LoadingState);

            Assert.IsTrue(a.IsBusy);
            Assert.IsFalse(a.IsFinished);
            Assert.IsFalse(a.IsError);

            try
            {
                Assert.AreEqual("result", await task);
            }
            catch { }

            Assert.IsFalse(a.IsBusy);
            Assert.IsFalse(a.IsFinished);
            Assert.IsTrue(a.IsError);
        }
Esempio n. 11
0
 public CartController(DataLoader loader)
 {
     _loader = loader;
 }
    /// <summary>
    /// For decoding RLE encoded critter animations.
    /// </summary>
    /// <param name="FileIn">File in.</param>
    /// <param name="pixels">Pixels.</param>
    /// <param name="bits">Bits.</param>
    /// <param name="datalen">Datalen.</param>
    /// <param name="maxpix">Maxpix.</param>
    /// <param name="addr_ptr">Address ptr.</param>
    /// <param name="auxpal">Auxpal.</param>
    public static void ua_image_decode_rle(char[] FileIn, char[] pixels, int bits, int datalen, int maxpix, int addr_ptr, char[] auxpal)
    {
        //Code lifted from Underworld adventures.
        // bit extraction variables
        int bits_avail = 0;
        int rawbits    = 0;
        int bitmask    = ((1 << bits) - 1) << (8 - bits);
        int nibble;

        // rle decoding vars
        int pixcount    = 0;
        int stage       = 0; // we start in stage 0
        int count       = 0;
        int record      = 0; // we start with record 0=repeat (3=run)
        int repeatcount = 0;

        while (datalen > 0 && pixcount < maxpix)
        {
            // get new bits
            if (bits_avail < bits)
            {
                // not enough bits available
                if (bits_avail > 0)
                {
                    nibble   = ((rawbits & bitmask) >> (8 - bits_avail));
                    nibble <<= (bits - bits_avail);
                }
                else
                {
                    nibble = 0;
                }

                //rawbits = ( int)fgetc(fd);
                rawbits = (int)DataLoader.getValAtAddress(FileIn, addr_ptr, 8);
                addr_ptr++;
                if ((int)rawbits == -1)  //EOF
                {
                    return;
                }

                //         fprintf(LOGFILE,"fgetc: %02x\n",rawbits);

                int shiftval = 8 - (bits - bits_avail);

                nibble |= (rawbits >> shiftval);

                rawbits = (rawbits << (8 - shiftval)) & 0xFF;

                bits_avail = shiftval;
            }
            else
            {
                // we still have enough bits
                nibble      = (rawbits & bitmask) >> (8 - bits);
                bits_avail -= bits;
                rawbits   <<= bits;
            }

            //      fprintf(LOGFILE,"nibble: %02x\n",nibble);

            // now that we have a nibble
            datalen--;

            switch (stage)
            {
            case 0:     // we retrieve a new count
                if (nibble == 0)
                {
                    stage++;
                }
                else
                {
                    count = nibble;
                    stage = 6;
                }
                break;

            case 1:
                count = nibble;
                stage++;
                break;

            case 2:
                count = (count << 4) | nibble;
                if (count == 0)
                {
                    stage++;
                }
                else
                {
                    stage = 6;
                }
                break;

            case 3:
            case 4:
            case 5:
                count = (count << 4) | nibble;
                stage++;
                break;
            }

            if (stage < 6)
            {
                continue;
            }

            switch (record)
            {
            case 0:
                // repeat record stage 1
                //         fprintf(LOGFILE,"repeat: new count: %x\n",count);

                if (count == 1)
                {
                    record = 3;     // skip this record; a run follows
                    break;
                }

                if (count == 2)
                {
                    record = 2;     // multiple run records
                    break;
                }

                record = 1;     // read next nibble; it's the color to repeat
                continue;

            case 1:
                // repeat record stage 2

            {
                // repeat 'nibble' color 'count' times
                for (int n = 0; n < count; n++)
                {
                    pixels[pixcount++] = auxpal[nibble];        // getActualAuxPalVal(auxpal, nibble);
                    if (pixcount >= maxpix)
                    {
                        break;
                    }
                }
            }

                //         fprintf(LOGFILE,"repeat: wrote %x times a '%x'\n",count,nibble);

                if (repeatcount == 0)
                {
                    record = 3;     // next one is a run record
                }
                else
                {
                    repeatcount--;
                    record = 0;     // continue with repeat records
                }
                break;

            case 2:
                // multiple repeat stage

                // 'count' specifies the number of repeat record to appear
                //         fprintf(LOGFILE,"multiple repeat: %u\n",count);
                repeatcount = count - 1;
                record      = 0;
                break;

            case 3:
                // run record stage 1
                // copy 'count' nibbles

                //         fprintf(LOGFILE,"run: count: %x\n",count);

                record = 4;     // retrieve next nibble
                continue;

            case 4:
                // run record stage 2

                // now we have a nibble to write
                pixels[pixcount++] = auxpal[nibble];    //getActualAuxPalVal(auxpal, nibble);

                if (--count == 0)
                {
                    //            fprintf(LOGFILE,"run: finished\n");
                    record = 0;     // next one is a repeat again
                }
                else
                {
                    continue;
                }
                break;
            }

            stage = 0;
            // end of while loop
        }
    }
Esempio n. 13
0
 /// <summary>
 /// 重开本局
 /// </summary>
 public SceneSystem.Scene resumeGame()
 {
     player = DataLoader.load <Player>(savedPlayer);
     return(player.stage);
 }
Esempio n. 14
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IData <Circuit> .Load(DataLoader <Circuit> loader, object parameter)
        {
            Name       = loader.ReadPodString();
            MacroIndex = loader.ReadInt32();
        }
        public async void StartSimpleSearch()
        {
            if (string.IsNullOrEmpty(SearchText))
            {
                return;
            }

            SetVisibilities(VisibilityConfigs.SearchInProgress);

            SearchProgressMessage = "Allocating search scope...";

            List <string> searchScope = new List <string>();

            if (SearchTracks)
            {
                searchScope.Add("track");
            }

            if (SearchPlaylists)
            {
                searchScope.Add("playlist");
            }

            if (SearchArtists)
            {
                searchScope.Add("artist");
            }

            if (SearchAlbums)
            {
                searchScope.Add("album");
            }

            if (searchScope.Count > 0)
            {
                int itemsAmount = (12 / searchScope.Count) + (int)(4D / (double)searchScope.Count);

                SearchConfiguration config = new SearchConfiguration()
                {
                    Amount     = itemsAmount,
                    Offset     = 0,
                    Scope      = searchScope,
                    SearchText = SearchText
                };

                if (_simpleResults != null && _simpleResults.FirstOrDefault(x => x.Config.CompareSearch(config)) is SearchResult sr)
                {
                    CurrentSimpleResult = sr;
                }
                else
                {
                    SearchProgressMessage = "Waiting for a response from the spotify servers...";

                    SearchResult result = await DataLoader.GetInstance().Search(config);

                    _simpleResults.Add(result);

                    CurrentSimpleResult = result;
                }
            }

            SetVisibilities(VisibilityConfigs.SimpleResult);
            NotifyPropertyChanged("SimpleTracksVisibility");
            NotifyPropertyChanged("SimplePlaylistsVisibility");
            NotifyPropertyChanged("SimpleArtistsVisibility");
            NotifyPropertyChanged("SimpleAlbumsVisibility");
        }
Esempio n. 16
0
        public void popScene(object data, bool reload = false, bool async = false)
        {
            var json = DataLoader.convert(data.GetType(), data);

            popScene(json, reload, async);
        }
Esempio n. 17
0
    const float STARMOVE_TIME = 1f;                             // time of movement icon select level

    void Awake()
    {
        Data = this;
    }
Esempio n. 18
0
 public static string MapForElectorate(string name)
 {
     Guard.AgainstWhiteSpace(nameof(name), name);
     return(MapForElectorate(DataLoader.FindElectorate(name)));
 }
Esempio n. 19
0
    public static void Apply(EntityAlive Self, string pName, Vector3 local_offset, Vector3 local_rotation)
    {
        if (verbose > 0)
        {
            Printer.Print("MyAttachParticleEffectToEntity: Start");
        }
        if (Self == null)
        {
            return;
        }
        // Transform transform = _params.Transform;
        Transform transform = Self.transform;         //Transform;

        if (verbose > 1)
        {
            Printer.Print("MyAttachParticleEffectToEntity: Start2");
        }
        // if (!_params.Tags.Test_AnySet(this.usePassedInTransformTag)) {
        if (true)
        {
            if (verbose > 1)
            {
                Printer.Print("MyAttachParticleEffectToEntity: usePassedInTransformTag");
            }
            transform = Self.transform;
            // if (this.parent_transform_path != null) transform = GameUtils.FindDeepChild(transform, this.parent_transform_path, true);
        }
        else
        {
            if (verbose > 1)
            {
                Printer.Print("MyAttachParticleEffectToEntity: use Base Transform");
            }
        }
        if (transform == null)
        {
            return;
        }

        GameObject goToInstantiate = DataLoader.LoadAsset <GameObject>((pName.IndexOf('#') < 0) ? ("ParticleEffects/" + pName) : pName);

        string    text       = string.Format("tempParticle_" + goToInstantiate.name, Array.Empty <object>());
        Transform transform2 = transform.Find(text);

        if (transform2 == null)
        {
            if (verbose > 1)
            {
                Printer.Print("MyAttachParticleEffectToEntity: instatiated");
            }
            GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(goToInstantiate);
            if (gameObject == null)
            {
                return;
            }
            if (verbose > 1)
            {
                Printer.Print("MyAttachParticleEffectToEntity: go not null");
            }
            transform2      = gameObject.transform;
            gameObject.name = text;
            Utils.SetLayerRecursively(gameObject, transform.gameObject.layer);
            if (verbose > 1)
            {
                Printer.Print("MyAttachParticleEffectToEntity: rec set");
            }
            transform2.parent        = transform;
            transform2.localPosition = local_offset;
            transform2.localRotation = Quaternion.Euler(local_rotation.x, local_rotation.y, local_rotation.z);
            if (verbose > 1)
            {
                Printer.Print("MyAttachParticleEffectToEntity: return - no sound");
            }
            return;             // No Audio

            AudioPlayer component = transform2.GetComponent <AudioPlayer>();
            if (verbose > 1)
            {
                Printer.Print("MyAttachParticleEffectToEntity: Audio comp");
            }
            if (component != null)
            {
                component.duration = 100000f;
            }
            ParticleSystem[] componentsInChildren = transform2.GetComponentsInChildren <ParticleSystem>();
            if (componentsInChildren != null)
            {
                return;

                if (verbose > 1)
                {
                    Printer.Print("MyAttachParticleEffectToEntity: componentsInChildren");
                }
                for (int i = 0; i < componentsInChildren.Length; i++)
                {
                    if (verbose > 1)
                    {
                        Printer.Print("MyAttachParticleEffectToEntity: children", i, componentsInChildren.Length);
                    }
                    componentsInChildren[i].Stop();
                    // componentsInChildren[i].main.duration = 100000f;
                    // Cannot modify the return value of 'UnityEngine.ParticleSystem.main' because it is not a variable
                    // Pourtant c'est dans le code de base ...
                    // componentsInChildren[i].duration = 100000f; // read only !
                    // componentsInChildren[i].main.duration = 100000f;
                    componentsInChildren[i].Play();
                }
            }
            if (verbose > 0)
            {
                Printer.Print("MyAttachParticleEffectToEntity: DONE");
            }
        }
    }
Esempio n. 20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            objDL = new DataLoader( Request.PhysicalApplicationPath, tbStatus, lblError, OpenCSVList );

            if (Session["ApiService"] != null)
                objDL.API = (ApiService) Session[ "ApiService" ];
            else
            {
                objDL.API = new ApiService();
                Session[ "ApiService" ] = objDL.API;
            }

            // auto configure API according to the setting in the web.config
            strInstance = System.Configuration.ConfigurationManager.AppSettings[ "Instance" ].ToLower();
            switch( strInstance )
            {
                case "dev1":
                    Title = "EmTrac2SF - DEV1";
                    break;
                case "test1":
                    Title = "EmTrac2SF - TEST1";
                    break;
                case "prod":
                    if(Properties.Settings.Default.EmTrac2SF_EMSC_SF_SforceService.StartsWith( "https://login.salesforce.com" ))
                        Title = "EmTrac2SF - PRODUCTION";
                    else
                        lblError.Text = "ERROR:  In order to connect to Production, please switch the Salesforce URL to https://login.salesforce.com in the web.config.";
                    break;
            }
        }
    // Use this for initialization
    void Awake()
    {
        // Singenton
        if(instance == null)
        {
            DontDestroyOnLoad(gameObject);
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        // Make init
        sparql = new SPARQL_Request();
        proData = new List<ProductData>();
    }
Esempio n. 22
0
        public DataExampleViewModel()
        {
            StartLongRunningDataLoader = new DataLoader();
            StartLongRunningWithExceptionDataLoader = new DataLoader(); //swallow exceptions by default
            CacheDataLoader = new DataLoader();
            CacheWithExceptionDataLoader = new DataLoader(); //swallow exceptions by default
            SourceABDataLoader = new DataLoader(); //swallow exceptions by default
            CacheRefreshDataLoader = new DataLoader(); //swallow exceptions by default
            FailCacheDataLoader = new DataLoader(); 
            FailCacheSuccessDataLoader = new DataLoader();


            StartLongRunningCommand = new RelayCommand(() => StartLongRunningAction());
            StartLongRunningWithExceptionCommand = new RelayCommand(() => StartLongRunningWithExceptionAction());
            CacheCommand = new RelayCommand(() => CacheAction());
            CacheWithExceptionCommand = new RelayCommand(() => CacheWithExceptionAction());
            SourceABCommand = new RelayCommand(() => SourceABAction());
            CacheRefreshCommand = new RelayCommand(() => CacheRefreshAction());
            ClearCacheCommand = new RelayCommand(() => ClearCacheAction());
            FailCacheCommand = new RelayCommand(() => FailCacheAction());
            FailCacheSuccessCommand = new RelayCommand(() => FailCacheSuccessAction());

            ClearWebDataCacheCommand = new RelayCommand(() => ClearWebDataCacheCommandAction());
            GetUriCommand = new RelayCommand(() => GetUriCommandAction());

            ImageBrushUri = new Uri("https://pbs.twimg.com/profile_images/478304416148099072/1_rxoQgR.png");

            WebDataCache.Init();

        }
Esempio n. 23
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
            DontDestroyOnLoad(this);
        }
        else
        {
            Destroy(gameObject);
            return;
        }

        // default to playing mode for now
        gameMode = GameMode.PLAYING;

        // Load interaction info here?
        allObjects = new Dictionary<int, Interactable>();
        questTerms = new Dictionary<string, string>();
        sceneParameters = new Dictionary<string, List<InteractableObject.Parameters>>();
        boolSceneParameters = new List<BoolSceneParameter>();
        questList = new Dictionary<string, List<string>>();
        outcomeList = new List<OutcomeManager.outcome>();
        endDayCoroutine = new Dictionary<string, string>();

        // Bind events
        EventManager.OnItemPickup += ItemPickup;

        //item stuff
        allItems = new Dictionary<int, Item>()
        {
            { 123, new Item("Lost Dog", "A lost dog. It seems to really like bacon.", "RaesDog")},
            { 150, new Item("Jewel", "Quit stealing jewels already", "jewel")},
            { 110, new Item("Bacon", "Maybe you could feed this to someone", "baconAndEggs")},
            { 111, new Item("Box", "A mysterious box. Maybe it belongs to someone?", "Box")},
            { 23, new Item("Train Ticket", "A train ticket out of town. You don't need to go anywhere but maybe the ticket will have a use.", "Ticket")},
            { 152, new Item("Alfred's Jewel", "This was a gift from his son.", "alfredsjewel")},
            { 170, new Item("Cocodonut", "A donut covered in coconut shavings.", "Cocodonut")},
            { 171, new Item("Donut Sprinklez", "A rainbow donut. Not sure if this is edible.", "DonutSprinklez")},
            { 172, new Item("Chocoloate Crispies", "Donut holes dipped in chocolate. Yum.", "ChocolateCrispies")},
            { 173, new Item("Minty Munchies", "Donut holes with a mint flavor. How did they do that?", "MintyMunchies")},
            { 174, new Item("Strawberry Squishies", "Donut holes with a strawberry flavor. Looks delicious.", "StrawberrySquishies")},
            { 175, new Item("Potadonut Tots", "Are these donuts or potatoes?", "PotadonutTots")},
            { 176, new Item("Donut Holes Original", "Just your regular donut hole.", "DonutHolesOriginal")},
        };
        itemIDs = new Dictionary<string, int>()
        {
            {"Lost Dog", 123},
            {"Jewel", 150},
            {"Bacon", 110},
            {"Box", 111},
            {"Train Ticket", 23},
            {"Alfred's Jewel", 152},
            {"Cocodonut", 170},
            {"DonutSprinklez", 171},
            {"ChocolateCrispies", 172},
            {"MintyMunchies", 173},
            {"StrawberrySquishies", 174},
            {"PotadonutTots", 175},
            {"DonutHolesOriginal", 176}
        };

        dayData.Inventory = new List<Item>(new Item[9]);

        // Parse Game playerData
        if (PARSING_MODE)
        {
            DataLoader dataLoader = new DataLoader();
        }
        else
        {
            LoadGameData();
        }
        //LoadPlayerData();
    }
Esempio n. 24
0
        public void ValidatePatchXpaths()
        {
            var subject = new PatchDataLoader();
            var dllLoader = new DataLoader();

            var uiDataLoader = new UIDataLoader();

            var patchPath = Path.Combine(Directory.GetCurrentDirectory(), "TestData", "CorePatches.xml");
            var uiPath = Path.Combine(Directory.GetCurrentDirectory(), "TestData", "skin1.xml");

            var loaded = subject.LoadData(patchPath);

            foreach (var definition in loaded.Definitions.Where(d => d.UIPatches != null && d.UIPatches.Any(u => u.FilePath.EndsWith("skin1.xml"))))
            {
                foreach (var uiPatch in definition.UIPatches)
                {
                    Assert.IsTrue(uiPatch.FilePath.EndsWith("skin1.xml")); //need to extend tests for other files

                    var doc = uiDataLoader.FixAndLoadXml(uiPath);

                    var xpathNode = doc.XPathSelectElement(uiPatch.XPath);

                    Assert.IsTrue(xpathNode != null);

                }
            }
        }
Esempio n. 25
0
        public void CollectorNet_ReadFromWriter()
        {
            const int proxyServer   = 22337;
            const int distrServer1  = 22338;
            const int distrServer12 = 22339;
            const int st1           = 22335;
            const int st2           = 22336;

            #region hell

            var writer = new HashWriter(new HashMapConfiguration("TestCollectorNet", HashMapCreationMode.CreateNew, 1, 1, HashFileType.Distributor));
            writer.CreateMap();
            writer.SetServer(0, "localhost", st1, st2);
            writer.Save();

            var common = new CommonConfiguration(1, 100);

            var netconfig = new NetConfiguration("localhost", proxyServer, "testService", 10);
            var toconfig  = new ProxyConfiguration(TimeSpan.FromMinutes(10), TimeSpan.FromMinutes(1),
                                                   TimeSpan.FromMinutes(10), TimeSpan.FromMinutes(10));

            var proxy = new TestGate(netconfig, toconfig, common);

            var distrNet = new DistributorNetConfiguration("localhost",
                                                           distrServer1, distrServer12, "testService", 10);
            var distrConf = new DistributorConfiguration(1, "TestCollectorNet",
                                                         TimeSpan.FromMilliseconds(100000), TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1), TimeSpan.FromMilliseconds(10000));

            var distr = new DistributorApi(distrNet, distrConf, common);

            var storageNet    = new StorageNetConfiguration("localhost", st1, st2, "testService", 10);
            var storageConfig = new StorageConfiguration("TestCollectorNet", 1, 10, TimeSpan.FromHours(1), TimeSpan.FromHours(1),
                                                         TimeSpan.FromHours(1), TimeSpan.FromHours(1), false);

            var storage     = new WriterApi(storageNet, storageConfig, common);
            var async       = new AsyncTaskModule(new QueueConfiguration(4, 10));
            var distributor =
                new DistributorModule(new CollectorModel(new DistributorHashConfiguration(1),
                                                         new HashMapConfiguration("TestCollectorNet", HashMapCreationMode.ReadFromFile, 1, 1,
                                                                                  HashFileType.Collector)), async, new AsyncTasksConfiguration(TimeSpan.FromMinutes(1)));

            var net = new CollectorNetModule(new ConnectionConfiguration("testService", 10),
                                             new ConnectionTimeoutConfiguration(Consts.OpenTimeout, Consts.SendTimeout), distributor);

            distributor.SetNetModule(net);

            var back   = new BackgroundModule(new QueueConfiguration(5, 10));
            var loader = new DataLoader(net, 100, back);

            var parser = new TestIntParser();
            parser.SetCommandsHandler(
                new UserCommandsHandler <TestCommand, Type, TestCommand, int, int, TestDbReader>(
                    new TestUserCommandCreator(), new TestMetaDataCommandCreator()));
            var merge = new OrderMerge(loader, parser);

            var searchModule = new SearchTaskModule("Int", merge, loader, distributor, back, parser);

            storage.Build();
            proxy.Build();
            distr.Build();

            storage.AddDbModule(new TestInMemoryDbFactory());

            storage.Start();
            proxy.Start();
            distr.Start();

            searchModule.Start();
            distributor.Start();
            merge.Start();
            back.Start();
            net.Start();
            async.Start();

            #endregion

            proxy.Int.SayIAmHere("localhost", distrServer1);

            const int count = 20;

            for (int i = 0; i < count; i++)
            {
                var request = proxy.Int.CreateSync(i, i);
                Assert.AreEqual(RequestState.Complete, request.State);
            }

            var reader = searchModule.CreateReader("asc", -1, 20);
            reader.Start();

            for (int i = 0; i < count; i++)
            {
                Assert.IsTrue(reader.IsCanRead);

                reader.ReadNext();

                Assert.AreEqual(i, reader.GetValue(0));
            }
            reader.ReadNext();
            Assert.IsFalse(reader.IsCanRead);

            reader.Dispose();
            back.Dispose();
            net.Dispose();

            storage.Dispose();
            proxy.Dispose();
            distr.Dispose();
            async.Dispose();
        }
Esempio n. 26
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IData <Circuit> .Load(DataLoader <Circuit> loader, object parameter)
        {
            Unknown1 = loader.ReadInt32();
            Unknown2 = loader.ReadInt32();
            Unknown3 = loader.ReadInt32();
        }
Esempio n. 27
0
        private void SaveGameButtonName_Click(String dataSymbol)
        {
            String name = "Saved";

            DataLoader.SaveStringToLocalSettings(dataSymbol, name);
        }
 private PopulationDataSet(TimeSet timeSet)
 {
     Areas.Clear();
     Areas.AddRange(DataLoader.LoadData(timeSet));
 }
 public static void SetupOnlyOnce(TestContext testContext)
 {
     driver = new ChromeDriver();
     dataLoader=new DataLoader();
 }
Esempio n. 30
0
    public GRLoader(string FileName, int ChunkNo)    //For SS1 chunks of art
    {
        useOverrideAuxPalIndex = false;
        OverrideAuxPalIndex    = 0;

        if (!DataLoader.ReadStreamFile(BasePath + FileName, out ImageFileData))
        {
            Debug.Log("Unable to load " + BasePath + pathGR[FileToLoad]);
            return;
        }
        else
        {
            DataLoader.Chunk art_ark;
            DataLoader.LoadChunk(ImageFileData, ChunkNo, out art_ark);

            switch (art_ark.chunkContentType)
            {
            case 3:                    //font //TODO
                break;

            case 2:
            case 17:
                NoOfImages = (int)DataLoader.getValAtAddress(art_ark.data, 0, 16);
                ImageCache = new  Texture2D[NoOfImages];
                //HotSpot=new Vector2[NoOfImages];
                ImageFileDataLoaded = true;
                for (int i = 0; i < NoOfImages; i++)
                {
                    long textureOffset   = (int)DataLoader.getValAtAddress(art_ark.data, 2 + (i * 4), 32);
                    int  CompressionType = (int)DataLoader.getValAtAddress(art_ark.data, textureOffset + 4, 16);
                    int  Width           = (int)DataLoader.getValAtAddress(art_ark.data, textureOffset + 8, 16);
                    int  Height          = (int)DataLoader.getValAtAddress(art_ark.data, textureOffset + 10, 16);
                    //int x1=(int)DataLoader.getValAtAddress(art_ark.data,textureOffset+0xE,8);
                    //int y1=(int)DataLoader.getValAtAddress(art_ark.data,textureOffset+0xF,8);
                    //x1 = 1<<x1;
                    //y1 = 1<<y1;
                    //float vX1; float vY1;

                    //vX1 = (float)x1/(float)Width;
                    //vY1 = (float)y1/(float)Height;
                    //vX1 =0.5f;
                    //if (y1 == 0) cy =       bmp->height; else cy = bmp->y1;
                    //HotSpot[i]=new Vector2(vX1,vY1);
                    if ((Width > 0) && (Height > 0))
                    {
                        if (CompressionType == 4)
                        {                                //compressed
                            char[] outputImg;
                            //  UncompressBitmap(art_ark+textureOffset+BitMapHeaderSize, outputImg,Height*Width);
                            UncompressBitmap(art_ark.data, textureOffset + BitMapHeaderSize, out outputImg, Height * Width);
                            ImageCache[i] = ArtLoader.Image(outputImg, 0, Width, Height, "namehere", GameWorldController.instance.palLoader.Palettes[0], true);
                        }
                        else
                        {                                //Uncompressed
                            ImageCache[i] = ArtLoader.Image(art_ark.data, textureOffset + BitMapHeaderSize, Width, Height, "namehere", GameWorldController.instance.palLoader.Palettes[0], true);
                        }
                    }
                }
                break;
            }

            return;
        }
    }
Esempio n. 31
0
 public ModeSMixer2Service(DataLoader servicesDataLoader = null) : base(servicesDataLoader ?? new DataLoader(null), null, new TimeSpan(0, 0, 15))
 {
 }
Esempio n. 32
0
    public override Texture2D LoadImageAt(int index, bool Alpha)
    {
        if (ImageFileDataLoaded == false)
        {
            if (!LoadImageFile())
            {
                return(base.LoadImageAt(index));
            }
        }
        else
        {
            if (ImageCache[index] != null)
            {
                return(ImageCache[index]);
            }
        }


        long imageOffset = DataLoader.getValAtAddress(ImageFileData, (index * 4) + 3, 32);

        if (imageOffset >= ImageFileData.GetUpperBound(0))
        {                //Image out of range
            return(base.LoadImageAt(index));
        }
        int     BitMapWidth  = (int)DataLoader.getValAtAddress(ImageFileData, imageOffset + 1, 8);
        int     BitMapHeight = (int)DataLoader.getValAtAddress(ImageFileData, imageOffset + 2, 8);
        int     datalen;
        Palette auxpal;
        int     auxPalIndex;

        char[] imgNibbles;
        char[] outputImg;


        switch (DataLoader.getValAtAddress(ImageFileData, imageOffset, 8)) //File type
        {
        case 0x4:                                                          //8 bit uncompressed
        {
            imageOffset       = imageOffset + 5;
            ImageCache[index] = Image(ImageFileData, imageOffset, BitMapWidth, BitMapHeight, "name_goes_here", GameWorldController.instance.palLoader.Palettes[PaletteNo], Alpha);
            return(ImageCache[index]);
        }

        case 0x8:        //4 bit run-length
        {
            if (!useOverrideAuxPalIndex)
            {
                auxPalIndex = (int)DataLoader.getValAtAddress(ImageFileData, imageOffset + 3, 8);
            }
            else
            {
                auxPalIndex = OverrideAuxPalIndex;
            }
            datalen     = (int)DataLoader.getValAtAddress(ImageFileData, imageOffset + 4, 16);
            imgNibbles  = new char[Mathf.Max(BitMapWidth * BitMapHeight * 2, (datalen + 5) * 2)];
            imageOffset = imageOffset + 6;                              //Start of raw data.
            copyNibbles(ImageFileData, ref imgNibbles, datalen, imageOffset);
            auxpal    = PaletteLoader.LoadAuxilaryPal(Loader.BasePath + AuxPalPath, GameWorldController.instance.palLoader.Palettes[PaletteNo], auxPalIndex);
            outputImg = DecodeRLEBitmap(imgNibbles, datalen, BitMapWidth, BitMapHeight, 4);
            //rawOut.texture= Image(outputImg,0, BitMapWidth, BitMapHeight,"name_goes_here",auxpal,true);
            ImageCache[index] = Image(outputImg, 0, BitMapWidth, BitMapHeight, "name_goes_here", auxpal, Alpha);
            return(ImageCache[index]);
        }

        case 0xA:        //4 bit uncompressed//Same as above???
        {
            if (!useOverrideAuxPalIndex)
            {
                auxPalIndex = (int)DataLoader.getValAtAddress(ImageFileData, imageOffset + 3, 8);
            }
            else
            {
                auxPalIndex = OverrideAuxPalIndex;
            }
            datalen     = (int)DataLoader.getValAtAddress(ImageFileData, imageOffset + 4, 16);
            imgNibbles  = new char[Mathf.Max(BitMapWidth * BitMapHeight * 2, (5 + datalen) * 2)];
            imageOffset = imageOffset + 6;                              //Start of raw data.
            copyNibbles(ImageFileData, ref imgNibbles, datalen, imageOffset);
            auxpal            = PaletteLoader.LoadAuxilaryPal(BasePath + AuxPalPath, GameWorldController.instance.palLoader.Palettes[PaletteNo], auxPalIndex);
            ImageCache[index] = Image(imgNibbles, 0, BitMapWidth, BitMapHeight, "name_goes_here", auxpal, Alpha);
            return(ImageCache[index]);
        }

        //break;
        default:
            //Check to see if the file is panels.gr
            if (pathGR[FileToLoad].ToUpper().EndsWith("PANELS.GR"))
            {
                BitMapWidth  = 83;                         //getValAtAddress(textureFile, textureOffset + 1, 8);
                BitMapHeight = 114;                        // getValAtAddress(textureFile, textureOffset + 2, 8);
                if (_RES == "UW2")
                {
                    BitMapWidth  = 79;
                    BitMapHeight = 112;
                }
                imageOffset       = DataLoader.getValAtAddress(ImageFileData, (index * 4) + 3, 32);
                ImageCache[index] = Image(ImageFileData, imageOffset, BitMapWidth, BitMapHeight, "name_goes_here", GameWorldController.instance.palLoader.Palettes[PaletteNo], Alpha);
                return(ImageCache[index]);
            }
            break;
        }

        return(new Texture2D(2, 2));
    }
Esempio n. 33
0
 protected override HandInput ReadInputData(string inputFilePath, HandParameters parameters) => DataLoader.ReadHandInstance(inputFilePath, parameters.IsComplicated);
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     Characters = new ObservableCollection <Character>(DataLoader.Load <Character>("Character.json"));
 }
Esempio n. 35
0
        /// <summary>
        /// Reads data from train and test files, pre-modification
        /// </summary>
        public override void LoadData()
        {
            _trainLoader = TargetName != null ? new DataLoader<FType>(TargetName) : new DataLoader<FType>();
            _testLoader = TargetName != null ? new DataLoader<FType>(TargetName) : new DataLoader<FType>();

            if (!File.Exists(TrainPath))
            {
                Logger.Log("train file " + TrainPath + " not found");
                throw new FileNotFoundException("", TrainPath);
            }

            if (!File.Exists(TestPath))
            {
                Logger.Log("test file " + TestPath + " not found");
                throw new FileNotFoundException("", TestPath);
            }

            // loading train file
            _trainLoader.IsLoadForLearning = true;
            _trainLoader.AddIdsString(IdName);
            _trainLoader.Load(TrainPath);

            foreach (var key in _trainLoader.TargetProb.Keys)
                Logger.Log("prob[" + key.ToString("F0") + "] = " + _trainLoader.TargetProb[key].ToString("F06"));

            Logger.Log("Outliers to drop: " + (int)(_trainLoader.TotalDataLines * OutliersPrct));

            // loading test file
            foreach (var id in _trainLoader.Ids.Keys) // the same id's
                _testLoader.AddIdColumn(id);

            foreach (var col in _trainLoader.SkippedColumns.Keys) // the same columns
                _testLoader.AddSkipColumn(col);

            // loading test file
            _testLoader.Load(TestPath);

            ModifyData();
        }
Esempio n. 36
0
 protected override GMMInput ReadInputData(string inputFilePath, GMMParameters parameters) => DataLoader.ReadGMMInstance(inputFilePath, parameters.ReplicatePoint);
Esempio n. 37
0
    private bool BuildTNovaMap()
    {
        float brushSize = 12f;

        char[] archive_ark;
        if (DataLoader.ReadStreamFile(path, out archive_ark))
        {
            long            address_pointer = 0;
            MapLoader.Chunk lev_ark;
            if (!MapLoader.LoadChunk(archive_ark, chunkToLoad, out lev_ark))
            {
                return(false);
            }

            address_pointer = 0;
            int  meshcount = 1;
            long maxHeight = 0; long minHeight = 0;
            for (int x = 0; x <= height.GetUpperBound(0); x++)
            {
                for (int y = 0; y <= height.GetUpperBound(1); y++)
                {
                    meshcount++;
                    int byte0 = (int)DataLoader.getValAtAddress(lev_ark.data, address_pointer++, 8); //Texture
                    int byte1 = (int)DataLoader.getValAtAddress(lev_ark.data, address_pointer++, 8); //Rotation and part of height
                    int byte2 = (int)DataLoader.getValAtAddress(lev_ark.data, address_pointer++, 8); //Object object list index?

                    if (byte0 > 191)
                    {
                        byte0 = byte0 - 64;
                    }
                    if (byte0 > 127)
                    {
                        byte0 = byte0 - 128;
                    }
                    if (byte0 > 63)
                    {
                        byte0 = byte0 - 64;
                    }

                    texture[x, y] = byte0;

                    byte1        = byte1 & 0xF0; //AND with 11110000b: remove shadow+rotation in lower half of byte
                    height[x, y] = (byte2 << 4) | (byte1 >> 4);
                    if (byte2 > 0x7F)            //negative height
                    {
                        height[x, y] = height[x, y] - 4096;
                    }
                    //height[x,y] =height[x,y] + 2048;
                    if ((x == 0) && (y == 0))
                    {
                        maxHeight = height[x, y];
                        minHeight = height[x, y];
                    }
                    if (height[x, y] > maxHeight)
                    {
                        maxHeight = height[x, y];
                    }
                    if (height[x, y] < minHeight)
                    {
                        minHeight = height[x, y];
                    }
                }
            }



            Debug.Log("max=" + maxHeight + " min=" + minHeight);
            for (int sectionX = 0; sectionX < 8; sectionX++)
            {
                for (int sectionY = 0; sectionY < 8; sectionY++)
                {
                    for (int x = sectionX * 64; x < (sectionX + 1) * 64; x++)
                    {//Count my textures
                        for (int y = sectionY * 64; y < (sectionY + 1) * 64; y++)
                        {
                            textureCount[texture[x, y]]++;//Tracks how many of each texture there is
                        }
                    }

                    int textureUsageCounter = 0;
                    //Clean up my textures
                    for (int i = 0; i <= textureUsage.GetUpperBound(0); i++)
                    {
                        if (textureCount[i] != 0)
                        {
                            textureUsage[i] = textureUsageCounter++;
                        }
                    }

                    Material[] mats       = new Material[textureUsageCounter];
                    int        matcounter = 0;
                    for (int i = 0; i <= textureUsage.GetUpperBound(0); i++)
                    {
                        if (textureCount[i] != 0)
                        {
                            mats[matcounter++] = (Material)Resources.Load("Nova/Materials/nova" + i);
                        }
                    }

                    GameObject Tile = new GameObject("TNOVAMAP_" + sectionX + "_" + sectionY);
                    Tile.transform.parent        = this.gameObject.transform;
                    Tile.transform.position      = Vector3.zero;
                    Tile.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);

                    MeshFilter   mf = Tile.AddComponent <MeshFilter>();
                    MeshRenderer mr = Tile.AddComponent <MeshRenderer>();
                    //  MeshCollider mc = Tile.AddComponent<MeshCollider>();
                    // mc.sharedMesh=null;
                    Mesh mesh = new Mesh();
                    meshcount = 64 * 64;
                    // mesh.subMeshCount=64;//meshcount;//Should be no of visible faces
                    mesh.subMeshCount = textureUsageCounter;
                    Vector3[] verts = new Vector3[meshcount * 4];
                    Vector2[] uvs   = new Vector2[meshcount * 4];

                    int FaceCounter = 0;
                    for (int x = sectionX * 64; x < (sectionX + 1) * 64; x++)
                    {
                        for (int y = sectionY * 64; y < (sectionY + 1) * 64; y++)
                        {
                            // textureCount[texture[x,y]]++;//Tracks how many of each texture there is
                            float[] heights = new float[4];
                            heights[0] = (float)-height[x, y];
                            heights[1] = (float)-height[x, y + 1];
                            heights[2] = (float)-height[x + 1, y + 1];
                            heights[3] = (float)-height[x + 1, y];

                            //Allocate enough verticea and UVs for the faces

                            float cornerX = (float)x * brushSize;
                            float cornerY = (float)y * brushSize;
                            verts[0 + (4 * FaceCounter)] = new Vector3(cornerX + 0.0f, cornerY + 0.0f, heights[0]);
                            verts[1 + (4 * FaceCounter)] = new Vector3(cornerX + 0.0f, cornerY + brushSize, heights[1]);
                            verts[2 + (4 * FaceCounter)] = new Vector3(cornerX + brushSize, cornerY + brushSize, heights[2]);
                            verts[3 + (4 * FaceCounter)] = new Vector3(cornerX + brushSize, cornerY + 0.0f, heights[3]);

                            //Allocate UVs
                            uvs[0 + (4 * FaceCounter)] = new Vector2(0.0f, 0.0f);
                            uvs[1 + (4 * FaceCounter)] = new Vector2(0.0f, 1.0f);
                            uvs[2 + (4 * FaceCounter)] = new Vector2(1.0f, 1.0f);
                            uvs[3 + (4 * FaceCounter)] = new Vector2(1.0f, 0.0f);

                            FaceCounter++;

                            // RenderNovaTile(MapParent,x,y,heights,"tile_" + x + "_" + y );
                        }
                    }

                    mesh.vertices = verts;
                    mesh.uv       = uvs;



                    //for each texture
                    for (int t = 0; t <= textureCount.GetUpperBound(0); t++)
                    {
                        if (textureCount[t] > 0)
                        {//This texture is in use. -> pass it's uvs/verts to the submesh.
                            int [] tris = new int[textureCount[t] * 6];
                            FaceCounter = 0;
                            int triCounter = 0;
                            for (int x = sectionX * 64; x < (sectionX + 1) * 64; x++)
                            {
                                for (int y = sectionY * 64; y < (sectionY + 1) * 64; y++)
                                {
                                    if (texture[x, y] == t)
                                    {//This mesh uses the texture.
                                        tris[0 + (6 * triCounter)] = 0 + (4 * FaceCounter);
                                        tris[1 + (6 * triCounter)] = 1 + (4 * FaceCounter);
                                        tris[2 + (6 * triCounter)] = 2 + (4 * FaceCounter);
                                        tris[3 + (6 * triCounter)] = 0 + (4 * FaceCounter);
                                        tris[4 + (6 * triCounter)] = 2 + (4 * FaceCounter);
                                        tris[5 + (6 * triCounter)] = 3 + (4 * FaceCounter);
                                        triCounter++;
                                    }
                                    FaceCounter++;
                                }
                            }
                            //Apply the tris to the submesh
                            mesh.SetTriangles(tris, textureUsage[t]);
                        }
                    }

                    /*
                     * int [] tris = new int[meshcount*6];
                     * FaceCounter=0;
                     * for (int i=0;i<meshcount;i++)
                     * {
                     * tris[0+ (6*FaceCounter)]=0+(4*FaceCounter);
                     * tris[1+ (6*FaceCounter)]=1+(4*FaceCounter);
                     * tris[2+ (6*FaceCounter)]=2+(4*FaceCounter);
                     * tris[3+ (6*FaceCounter)]=0+(4*FaceCounter);
                     * tris[4+ (6*FaceCounter)]=2+(4*FaceCounter);
                     * tris[5+ (6*FaceCounter)]=3+(4*FaceCounter);
                     * FaceCounter++;
                     * }
                     * mesh.SetTriangles(tris,0);
                     * //mr.material=mat;// MatsToUse;//mats;
                     * mr.sharedMaterial=mat;
                     */


                    mr.materials = mats;//MatsToUse;
                    mesh.RecalculateNormals();
                    mesh.RecalculateBounds();
                    mf.mesh = mesh;
                }
            }


            return(true);
        }
        else
        {
            return(false);
        }
    }
Esempio n. 38
0
        public async Task DataLoaderCacheThenRefreshTest()
        {
            DataLoader a = new DataLoader();

            int count = 0;

            await a.LoadCacheThenRefreshAsync(() => LongRunningOperation(), () => LongRunningOperation(),
                (result) => {
                    count++;
                });

            Assert.AreEqual(LoadingState.Finished, a.LoadingState);

            Assert.IsTrue(a.IsFinished);
            Assert.IsFalse(a.IsBusy);
            Assert.IsFalse(a.IsError);

            Assert.AreEqual(2, count);

        }
Esempio n. 39
0
 /// <summary>
 /// 读取角色
 /// </summary>
 /// <param name="fileName"></param>
 public void loadPlayer()
 {
     savedPlayer = StorageSystem.loadJsonFromFile(PlayerSaveFilename);
     player      = DataLoader.load <Player>(savedPlayer);
 }
Esempio n. 40
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
					LocateBridgeDataLoader = new DataLoader();
					SsdpLocateBridgeDataLoader = new DataLoader();

					RegisterDataLoader = new DataLoader();


					LocateBridgeCommand = new RelayCommand(LocateBridgeAction);
					SsdpLocateBridgeCommand = new RelayCommand(SsdpLocateBridgeAction);

					GetLightsCommand = new RelayCommand(GetLightsAction);

					TurnOnCommand = new RelayCommand(TurnOnAction);
					TurnOffCommand = new RelayCommand(TurnOffAction);
					GreenCommand = new RelayCommand(GreenAction);
					RedCommand = new RelayCommand(RedAction);
					ColorloopCommand = new RelayCommand(ColorloopAction);
					FlashCommand = new RelayCommand(FlashAction);
        }
Esempio n. 41
0
    private Dictionary <long, object> getDataObjectDictionary(string assetName, Type dataType)
    {
        TextAsset manifestTextAsset2 = Resources.Load <TextAsset>(assetName);

        return(DataLoader.loadMasterDictionary(manifestTextAsset2.text, dataType));
    }
Esempio n. 42
0
    private void Start()
    {
        //make sure settings are set to windowed 1080p (reboot exe to take effect)
        PlayerPrefs.SetInt("Screenmanager Is Fullscreen mode", 0);
        PlayerPrefs.SetInt("Screenmanager Resolution Width", 1920);
        PlayerPrefs.SetInt("Screenmanager Resolution Height", 1080);

        DataLoader dl = new DataLoader();
        List<GameAsset> assets = dl.GetGameAssetsList();
        if (!assets.Any())
        {
            title.text = "No Games Found";
        }
        else
        {
            InstantiateGames(assets);
            SetUpGamesAtStart();
            UpdateData();
        }
    }
        public async static Task <List <Course> > Parse(DataLoader loader, string request)
        {
            List <Course> result = new List <Course>();

            string url = $"/search-results?is_popular=true&is_public=true&page=1&type=course";

            if (request != "")
            {
                url += $"&query={request}";
            }

            string text = await loader.GetJsonData(url);

            if (text == "")
            {
                return(result);
            }

            JObject json        = JObject.Parse(text);
            JToken  jsonCourses = null;

            try
            {
                jsonCourses = json["search-results"];
            }
            catch (Exception)
            {
                return(result);
            }

            int courseAmount = 5;

            foreach (JToken courseInfo in jsonCourses)
            {
                Course course   = new Course("", "Stepic platform.", "", Color.LightGreen);
                string courseID = "";

                try
                {
                    courseID = courseInfo["course"].ToString();
                }
                catch (Exception)
                {
                    try
                    {
                        courseID = courseInfo["target_id"].ToString();
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }

                if (courseID == null || courseID == "")
                {
                    continue;
                }

                try
                {
                    course.Name      = courseInfo["course_title"].ToString();
                    course.SourсeRef = $"https://stepik.org/course/{courseID}/promo";
                    string pictureRef = courseInfo["course_cover"].ToString();
                    if (course.Name == null || course.Name == "" || pictureRef == null || pictureRef == "")
                    {
                        continue;
                    }
                    else
                    {
                        course.Picture = new UriImageSource
                        {
                            CachingEnabled = true,
                            Uri            = new Uri(pictureRef)
                        };
                    }
                }
                catch (Exception)
                {
                    continue;
                }

                try
                {
                    text = await loader.GetJsonData($"/courses?ids%5B%5D={courseID}");

                    JToken courseGeneralData = JObject.Parse(text)["courses"][0];
                    course.EnrolledPeopleAmount = courseGeneralData["learners_count"].ToString();

                    text = await loader.GetJsonData($"/users?ids%5B%5D={courseGeneralData["owner"].ToString()}");

                    course.Source = "Stepic platform. Course by " + JObject.Parse(text)["users"][0]["full_name"].ToString();

                    text = await loader.GetJsonData($"/course-review-summaries?ids%5B%5D={courseGeneralData["review_summary"].ToString()}");

                    course.Rating = JObject.Parse(text)["course-review-summaries"][0]["average"].ToString().Substring(0, 4);
                }
                catch (Exception)
                { }

                result.Add(course);

                if (result.Count >= courseAmount)
                {
                    break;
                }
            }

            return(result);
        }
Esempio n. 44
0
        public override void LoadData()
        {
            _trainLoader = TargetName != null ? new DataLoader<FType>(TargetName) : new DataLoader<FType>();

            if (!File.Exists(TrainPath))
            {
                Logger.Log("train file " + TrainPath + " not found");
                throw new FileNotFoundException("", TrainPath);
            }

            // loading train file
            _trainLoader.AddIdsString(IdName);
            _trainLoader.Load(TrainPath);
        }
Esempio n. 45
0
 private void SaveGameButtonValue_Click(String dataSymbol)
 {
     DataLoader.SaveStringToLocalSettings(dataSymbol, gameToSave);
 }
Esempio n. 46
0
        private static double[] GetRowValues(DataModifier modifier, DataLoader loader, Domain.DataRow<float> row)
        {
            if (modifier == null)
                return Array.ConvertAll(row.Coeffs, x => (double)x);

            var vals = new Dictionary<string, double>();
            for (int i = 0; i < row.Coeffs.Length; i++)
            {
                string colname = loader.RowColumnByIdx[i];
                vals.Add(colname, row.Coeffs[i]);
            }
            var mvals = modifier.GetModifiedDataVector(vals);
            return mvals;
        }
Esempio n. 47
0
        public void gotoScene(Type scene, object data, bool reload = false, bool async = false)
        {
            var json = DataLoader.convert(data.GetType(), data);

            gotoScene(scene, json, reload, async);
        }
    /// <summary>
    /// Loads and decodes the strings.pak file as specificed by the Path.
    /// </summary>
    /// <param name="path">Path.</param>
    public void LoadStringsPak(string path)
    {
        //Set some default string numbers that are different from the default in uw2
        switch (_RES)
        {
        case GAME_UW2:

            str_it_looks_to_be_that_of_                       = 26;
            str_they_look_to_be_those_of_                     = 27;
            str_you_are_not_ready_to_advance_                 = 28;
            str_that_is_not_a_mantra_                         = 29;
            str_knowledge_and_understanding_fill_you_         = 30;
            str_you_cannot_advance_any_further_in_that_skill_ = 31;
            str_you_have_advanced_greatly_in_                 = 32;
            str_you_have_advanced_in_                         = 33;
            str_none_of_your_skills_improved_                 = 34;
            str_you_cannot_advance_in_                        = 38;
            str_to_the_north                = 40;
            str_to_the_northeast            = 41;
            str_to_the_east                 = 42;
            str_to_the_southeast            = 43;
            str_to_the_south                = 44;
            str_to_the_southwest            = 45;
            str_to_the_west                 = 46;
            str_to_the_northwest            = 47;
            str_far_far_below_you_1         = 48;
            str_far_far_below_you_2         = 48;
            str_far_below_you_1             = 50;
            str_far_below_you_2             = 50;
            str_below_you_1                 = 52;
            str_below_you_2                 = 52;
            str_underneath_you              = 54;
            str_above_you_1                 = 56;
            str_above_you_2                 = 56;
            str_above_you_3                 = 56;
            str_far_above_you_1             = 59;
            str_far_above_you_2             = 59;
            str_far_far_above_you_1         = 61;
            str_far_far_above_you_2         = 61;
            str_you_detect_a_creature_      = 63;
            str_you_detect_a_few_creatures_ = 64;
            str_you_detect_the_activity_of_many_creatures_ = 65;
            str_you_detect_no_monster_activity_            = 66;
            str__is_currently_active_      = 67;
            str_you_are_currently_         = 68;
            str_you_are_on_the_            = 73;
            str__level_of_the_abyss_       = 74;
            str_it_is_the_                 = 69;
            str__day_of_your_imprisonment_ = 70;
            str_it_has_been_an_uncountable_number_of_days_since_you_entered_the_abyss_ = 71;
            str_you_guess_that_it_is_currently_ = 72;
            str_night_1        = 84;
            str_night_2        = 84;
            str_dawn           = 86;
            str_early_morning  = 87;
            str_morning        = 88;
            str_late_morning   = 89;
            str_mid_day        = 90;
            str_afternoon      = 91;
            str_late_afternoon = 92;
            str_early_evening  = 93;
            str_evening        = 94;
            str_night_3        = 84;
            str__           = 96;
            str_barely      = 97;
            str_mildly      = 98;
            str_badly       = 99;
            str_seriously   = 100;
            str_egregiously = 101;
            str_your_current_vitality_is_     = 102;
            str_your_current_mana_points_are_ = 103;
            str_you_are_   = 104;
            str__poisoned_ = 105;
            str_that_is_too_far_away_to_take_         = 106;
            str_you_cannot_reach_that_                = 107;
            str_that_is_too_heavy_for_you_to_pick_up_ = 108;
            str_you_cannot_pick_that_up_              = 109;
            str_you_detect_no_traps_ = 110;
            str_you_found_a_trap__do_you_wish_to_try_to_disarm_it_1 = 111;
            str_you_catch_a_lovely_fish_ = 112;
            str_no_luck_this_time_       = 113;
            str_you_cannot_fish_there__perhaps_somewhere_else_ = 114;
            str_you_feel_a_nibble_but_the_fish_gets_away_      = 115;
            str__and_       = 116;
            str_starving    = 117;
            str_famished    = 118;
            str_very_hungry = 119;
            str_hungry      = 120;
            str_peckish     = 121;
            str_fed         = 122;
            str_well_fed    = 123;
            str_full        = 124;
            str_satiated    = 125;
            str_fatigued    = 126;
            str_very_tired  = 127;
            str_drowsy      = 128;
            str_awake       = 129;
            str_rested      = 130;
            str_wide_awake  = 131;
            str_you_can_only_use_those_individually__take_one_from_this_group_if_you_wish_to_use_it_ = 132;
            str_your_lockpicking_attempt_failed_ = 133;
            str_you_succeed_in_picking_the_lock_ = 135;
            str_that_is_not_locked_ = 136;
            str_lights_may_only_be_used_if_equipped_ = 137;
            str_that_light_is_already_used_up_       = 138;
            str_with_a_loud_snap_the_wand_cracks_    = 139;
            str_you_are_too_full_to_eat_that_now_    = 140;
            str_it_seems_to_have_no_effect_          = 146;
            str_you_thoughtfully_give_the_bones_a_final_resting_place_ = 148;
            str_the_rock_breaks_into_smaller_pieces_ = 149;
            str__is_nearly_done_                                     = 151;
            str__is_unstable_                                        = 152;
            str__is_stable_                                          = 153;
            str_you_destroyed_the_                                   = 154;
            str_you_damaged_the_                                     = 155;
            str_you_cannot_repair_that_                              = 156;
            str_your_attempt_has_no_effect_on_the_                   = 157;
            str_you_have_partially_repaired_the_                     = 158;
            str_you_have_fully_repaired_the_                         = 159;
            str_the_noise_you_made_has_attracted_attention_          = 160;
            str_you_have_attained_experience_level_                  = 161;
            str_the_bowl_does_not_contain_the_correct_ingredients_   = 162;
            str_you_mix_the_ingredients_into_a_stew_                 = 163;
            str_you_need_a_bowl_to_mix_the_ingredients_              = 164;
            str_enscribed_upon_the_scroll_is_your_map_               = 165;
            str_you_cannot_use_that_                                 = 166;
            str_why_is_this_being_printed_                           = 167;
            str_you_see_nothing_                                     = 168;
            str_nothing_to_get_                                      = 169;
            str_you_cannot_talk_to_that_                             = 170;
            str_using_the_pole_you_trigger_the_switch_               = 171;
            str_the_pole_cannot_be_used_on_that_                     = 172;
            str_impossible_you_are_between_worlds_                   = 173;
            str_you_cannot_select_options_partway_through_an_action_ = 174;
            str_no_save_game_there_                                  = 175;
            str_restore_game_complete_                               = 176;
            str_restore_game_failed_                                 = 177;
            str_save_game_failed_                                    = 178;
            str_save_game_succeeded_                                 = 179;
            str_restoring_game_                                      = 181;
            str_saving_game_                                         = 182;
            str_please_enter_a_save_file_description_                = 183;
            str_error_bad_save_file                                  = 184;
            //str_...=1;
            str_you_see_a_bridge_           = 186;
            str__tasted_putrid_             = 187;
            str__tasted_a_little_rancid_    = 188;
            str__tasted_kind_of_bland_      = 189;
            str__tasted_pretty_good_        = 190;
            str__tasted_great_              = 191;
            str_you_cannot_use_oil_on_that_ = 192;
            str_you_think_it_is_a_bad_idea_to_add_oil_to_the_lit_lantern_ = 193;
            str_adding_oil_you_refuel_the_lantern_ = 194;
            str_the_lantern_is_already_full_       = 195;
            str_dousing_a_cloth_with_oil_and_applying_it_to_the_wood_you_make_a_torch_ = 196;
            str_you_think_it_is_a_bad_idea_to_add_oil_to_the_lit_torch_ = 197;
            str_you_refresh_the_torch_ = 198;
            str_the_torch_is_unused_   = 199;
            str_you_are_unable_to_use_that_from_here_ = 200;
            str_you_cannot_barter_a_container__instead_remove_the_contents_you_want_to_trade_ = 201;
            str_a_level_ = 202;
            str_after_   = 204;
            str_you_press_in_the_button_1 = 209;
            str_you_press_in_the_button_2 = 209;
            str_you_press_in_the_button_3 = 209;
            str_you_flip_the_switch_1     = 212;
            str_you_flip_the_switch_2     = 212;
            str_you_pull_the_lever_1      = 214;
            str_you_pull_the_chain_1      = 215;
            str_you_pull_the_chain_2      = 215;
            str_the_button_returns_to_its_original_state_1 = 217;
            str_the_button_returns_to_its_original_state_2 = 217;
            str_the_button_returns_to_its_original_state_3 = 217;
            str_you_flip_the_switch_1 = 212;
            str_you_flip_the_switch_2 = 212;
            str_you_push_the_lever_2  = 222;
            str_you_return_the_chain_to_its_original_position_1 = 223;
            str_you_return_the_chain_to_its_original_position_2 = 223;
            str_you_are_not_experienced_enough_to_cast_spells_of_that_circle_ = 225;
            str_you_do_not_have_enough_mana_to_cast_the_spell_ = 226;
            str_the_incantation_failed_      = 227;
            str_casting_was_not_successful_  = 228;
            str_the_spell_backfires_         = 229;
            str_you_attempt_to_use_the_wand_ = 230;
            str_you_think_it_will_be_        = 231;
            str__to_repair_the_   = 232;
            str__make_an_attempt_ = 233;
            str_trivial           = 234;
            str_simple            = 235;
            str_possible          = 236;
            str_hard           = 237;
            str_very_difficult = 238;
            str_the_leeches_remove_the_poison_as_well_as_some_of_your_skin_and_blood_ = 239;
            str__is_angered_by_your_action_ = 240;
            str__is_annoyed_by_your_action_ = 241;
            str__notes_your_action_         = 242;
            str_your_vision_distorts_and_you_feel_light_headed_                = 243;
            str_you_manage_to_finish_eating_the_leeches__barely_               = 244;
            str_you_eat_the_candle_but_doubt_that_it_was_good_for_you_         = 245;
            str_the_toadstool_tastes_odd_and_you_begin_to_feel_ill_            = 246;
            str_the_mushroom_causes_your_head_to_spin_and_your_vision_to_blur_ = 247;
            str_the_plant_is_plain_tasting_but_nourishing_ = 248;
            str_although_you_have_to_eat_around_the_thorny_flowers_the_plant_is_quite_good_ = 251;
            str_the_water_refreshes_you_          = 252;
            str_you_drink_the_dark_ale_           = 254;
            str_you_quaff_the_potion_in_one_gulp_ = 255;
            str_as_the_alcohol_hits_you_you_stumble_and_collapse_into_sleep_ = 256;
            str_the_drink_makes_you_feel_a_little_better_for_now_            = 257;
            str_you_wake_feeling_somewhat_unstable_but_better_      = 258;
            str_you_found_a_trap__do_you_wish_to_try_to_disarm_it_2 = 259;
            str_your_rune_of_warding_has_been_set_off_ = 260;
            str_your_hands_are_full_ = 261;
            str_you_can_only_put_runes_in_the_rune_bag_ = 262;
            str_that_item_does_not_fit_ = 263;
            str_the_waters_of_the_fountain_renew_your_strength_ = 264;
            str_you_play_the_instrument_                        = 265;
            str_you_put_the_instrument_down_                    = 266;
            str_that_is_too_heavy_to_take_                      = 268;
            str_there_is_no_space_to_drop_that_                 = 269;
            str_you_need_more_space_to_fire_that_weapon_        = 270;
            str_there_is_not_enough_room_to_release_that_spell_ = 271;
            str_enters_the_abyss___            = 272;
            str_you_reenter_the_abyss___       = 273;
            str_there_is_no_place_to_put_that_ = 274;
            str_you_see_ = 276;
            str_the_spell_unlocks_the_lock_          = 286;
            str_the_spell_has_no_discernable_effect_ = 287;
            str_the_moonstone_is_not_available_      = 289;
            str_the_cauldron_is_empty_ = 290;
            str_gamename = 291;
            str_there_is_no_room_to_create_that_ = 293;
            str_a_rending_sound_fills_the_air_   = 294;
            str_you_cannot_save_or_restore_games_in_the_demo_version_ = 297;



            break;
            //default:
            //Restore=162;
            //IsAngered=225;
            //IsAnnoyed=226;
            //YouSee=260;
            //break;
        }


        string Result          = "";
        long   address_pointer = 0;

        huffman_node[] hman;
        block_dir[]    blocks;
        char[]         Buffer;
        string         Key = "";

        GameStrings = new Hashtable();
        EntryCounts = new Hashtable();

        if (DataLoader.ReadStreamFile(path, out Buffer))
        {
            long NoOfNodes = DataLoader.getValAtAddress(Buffer, address_pointer, 16);
            int  i         = 0;
            hman            = new huffman_node [NoOfNodes];
            address_pointer = address_pointer + 2;
            while (i < NoOfNodes)
            {
                hman[i].symbol = System.Convert.ToChar(Buffer[address_pointer + 0]);
                hman[i].parent = Buffer[address_pointer + 1];
                hman[i].left   = Buffer[address_pointer + 2];
                hman[i].right  = Buffer[address_pointer + 3];
                i++;
                address_pointer = address_pointer + 4;
            }

            long NoOfStringBlocks = DataLoader.getValAtAddress(Buffer, address_pointer, 16);
            blocks          = new block_dir[NoOfStringBlocks];
            address_pointer = address_pointer + 2;
            i = 0;
            while (i < NoOfStringBlocks)
            {
                blocks[i].block_no    = DataLoader.getValAtAddress(Buffer, address_pointer, 16);
                address_pointer       = address_pointer + 2;
                blocks[i].address     = DataLoader.getValAtAddress(Buffer, address_pointer, 32);
                address_pointer       = address_pointer + 4;
                blocks[i].NoOfEntries = DataLoader.getValAtAddress(Buffer, blocks[i].address, 16);                                                      //look ahead and get no of entries.
                EntryCounts["_" + blocks[i].block_no] = blocks[i].NoOfEntries.ToString();
                i++;
            }
            i = 0;
            //
            int Iteration = 0;
            while (i < NoOfStringBlocks)
            {
                address_pointer = 2 + blocks[i].address + blocks[i].NoOfEntries * 2;
                int blnFnd;
                for (int j = 0; j < blocks[i].NoOfEntries; j++)
                {
                    //Based on abysmal /uwadv implementations.
                    blnFnd = 0;
                    //char c;

                    int  bit  = 0;
                    int  raw  = 0;
                    long node = 0;

                    do
                    {
                        node = NoOfNodes - 1;                                                                         // starting node

                        // huffman tree decode loop
                        //This was -1 in the original code!
                        while (hman[node].left != 255 &&
                               hman[node].right != 255)
                        {
                            if (bit == 0)
                            {
                                bit = 8;
                                raw = Buffer[address_pointer++];                                                                                                        //stream.get<uint8_t>();
                            }
                            Iteration++;
                            //Debug.Log("raw=" + raw + "=" + (raw & 0x80));
                            // decide which node is next
                            //node = raw & 0x80 ? hman[node].right
                            //	: hman[node].left;
                            if ((raw & 0x80) == 128)
                            {
                                node = hman[node].right;
                            }
                            else
                            {
                                node = hman[node].left;
                            }

                            raw <<= 1;
                            bit--;
                        }

                        // have a new symbol
                        if ((hman[node].symbol != '|'))
                        {
                            if (blnFnd == 0)
                            {
                                Key = blocks[i].block_no.ToString("000") + "_" + j.ToString("000");
                            }
                            Result += hman[node].symbol;
                            blnFnd  = 1;
                        }
                        else
                        {
                            if ((Result.Length > 0) && (Key.Length > 0))
                            {
                                GameStrings[Key] = Result;
                                Result           = "";
                                Key = "";
                            }
                        }
                    } while (hman[node].symbol != '|');
                }
                i++;
            }
            if ((Result.Length > 0) && (Key.Length > 0))
            {                                    //I still have the very last value to keep.
                GameStrings[Key] = Result;
                Result           = "";
            }
        }
    }
Esempio n. 49
0
    public void ReadAnimData(int auxPalIndex)
    {
        int[] AnimX  = new int[390];
        int[] AnimY  = new int[390];
        int[] AnimXY = new int[776];//For UW2
        int[] UW2_X  = { 35, 36, 37, -1, 39, 40, 41, 42, -1, 44, 45, 46, -1, 48, 49, 50, 51, -1, -1, -1, -1, -1, 57, 58, 59, -1, -1, 62, 63, 64, -1, 132, 133, 134, -1, 136, 137, 138, 139, -1, 141, 142, 143, -1, 145, 146, 147, 148, -1, -1, -1, -1, -1, 154, 155, 156, -1, -1, 159, 160, 161, -1, 229, 230, 231, -1, 233, 234, 235, 236, -1, 238, 239, 240, -1, 242, 243, 244, 245, -1, -1, -1, -1, -1, 251, 252, 253, -1, -1, 256, 257, 258, -1, -1, -1, -1, -1, 330, 331, 332, -1, -1, 335, -1, 337, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 423, 424, 425, -1, 427, 428, 429, 430, -1, 432, 433, 434, -1, 436, 437, 438, 439, -1, -1, -1, -1, -1, 446, 447, 448, -1, -1, -1, 450, 451, 452, 520, 521, 522, -1, 524, 525, 526, 527, -1, 529, 530, 531, -1, 533, 534, 535, 536, -1, -1, -1, -1, -1, 542, 543, 544, -1, -1, 547, 548, 549, -1, 617, 618, 619, -1, 621, 622, 623, 624, -1, 626, 627, 628, -1, 630, 631, 632, 633, -1, -1, -1, -1, -1, 639, 640, 641, -1, -1, 644, 645, 646, -1, -1, -1, -1, -1, 718, 719, 720, -1, 723, -1, 725, -1, -1 };
        int[] UW2_Y  = { 66, 67, 68, -1, 70, 71, 72, 73, -1, 75, 76, 77, -1, 79, 80, 81, 82, -1, -1, -1, -1, -1, 88, 89, 90, -1, -1, 93, 94, 95, -1, 163, 164, 165, -1, 167, 168, 169, 170, -1, 172, 173, 174, -1, 176, 177, 178, 179, -1, -1, -1, -1, -1, 185, 186, 187, -1, -1, 190, 191, 192, -1, 260, 261, 262, -1, 264, 265, 266, 267, -1, 269, 270, 271, -1, 273, 274, 275, 276, -1, -1, -1, -1, -1, 282, 283, 284, -1, -1, 287, 288, 289, -1, -1, -1, -1, -1, 361, 362, 363, -1, -1, 366, -1, 368, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 454, 455, 456, -1, 458, 459, 460, 461, -1, 463, 464, 465, -1, 467, 468, 469, 470, -1, -1, -1, -1, -1, 476, 477, 478, -1, -1, -1, 482, 482, 483, 551, 552, 553, -1, 555, 556, 557, 558, -1, 560, 561, 562, -1, 564, 565, 566, 567, -1, -1, -1, -1, -1, 573, 574, 575, -1, -1, 578, 579, 580, -1, 648, 649, 650, -1, 652, 653, 654, 655, -1, 657, 658, 659, -1, 661, 662, 663, 664, -1, -1, -1, -1, -1, 670, 671, 672, -1, -1, 675, 676, 677, -1, -1, -1, -1, -1, 749, 750, 751, -1, 754, -1, 756, -1, -1 };


        string datfile = "DATA" + sep + "WEAPONS.DAT";
        string cmfile  = "DATA" + sep + "WEAPONS.CM";
        string grfile  = "DATA" + sep + "WEAPONS.GR";

        if (_RES == GAME_UW2)
        {
            datfile = "DATA" + sep + "WEAP.DAT";
            cmfile  = "DATA" + sep + "WEAP.CM";
            grfile  = "DATA" + sep + "WEAP.GR";
        }
        char[] AnimData;
        char[] textureFile;
        int    offset    = 0;
        int    GroupSize = 28;    //28 for uw1

        int MaxHeight = 112;
        int MaxWidth  = 172;

        if (_RES == GAME_UW2)
        {
            MaxHeight = 128;
            MaxWidth  = 208;
        }
        int add_ptr = 0;
        int alpha   = 0;

        DataLoader.ReadStreamFile(BasePath + datfile, out AnimData);
        DataLoader.ReadStreamFile(BasePath + grfile, out textureFile);
        if (_RES != GAME_UW2)
        {
            GroupSize = 28;

            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < GroupSize; j++)
                {
                    AnimX[j + offset] = (int)DataLoader.getValAtAddress(AnimData, add_ptr++, 8);
                }
                for (int j = 0; j < GroupSize; j++)
                {
                    AnimY[j + offset] = (int)DataLoader.getValAtAddress(AnimData, add_ptr++, 8);
                }
                offset = offset + GroupSize;
            }
        }
        else
        {        //In UW2 I just read the values into one array
            for (int i = 0; i <= AnimData.GetUpperBound(0); i++)
            {
                AnimXY[i] = (int)DataLoader.getValAtAddress(AnimData, add_ptr++, 8);
            }
        }


        add_ptr = 0;

        int NoOfTextures = textureFile[2] << 8 | textureFile[1];

        if (_RES == GAME_UW2)
        {
            NoOfTextures = 230;
        }
        ImageCache = new Texture2D[NoOfTextures + 1];

        for (int i = 0; i < NoOfTextures; i++)
        {
            long    textureOffset = DataLoader.getValAtAddress(textureFile, (i * 4) + 3, 32);
            int     BitMapWidth   = (int)DataLoader.getValAtAddress(textureFile, textureOffset + 1, 8);
            int     BitMapHeight  = (int)DataLoader.getValAtAddress(textureFile, textureOffset + 2, 8);
            int     datalen;
            Palette auxpal = PaletteLoader.LoadAuxilaryPal(Loader.BasePath + cmfile, GameWorldController.instance.palLoader.Palettes[PaletteNo], auxPalIndex);
            char[]  imgNibbles;
            char[]  outputImg;
            char[]  srcImg;

            datalen       = (int)DataLoader.getValAtAddress(textureFile, textureOffset + 4, 16);
            imgNibbles    = new char[Mathf.Max(BitMapWidth * BitMapHeight * 2, datalen * 2)];
            textureOffset = textureOffset + 6;                  //Start of raw data.

            copyNibbles(textureFile, ref imgNibbles, datalen, textureOffset);
            //LoadAuxilaryPal(auxPalPath, auxpal, pal, auxPalIndex);
            srcImg    = new char[BitMapWidth * BitMapHeight];
            outputImg = new char[MaxWidth * MaxHeight];
            //Debug.Log("i= " + i + " datalen= " + datalen);
            if (datalen >= 6)
            {
                srcImg = DecodeRLEBitmap(imgNibbles, datalen, BitMapWidth, BitMapHeight, 4);
            }


            //Paste source image into output image.
            int ColCounter = 0; int RowCounter = 0;
            int cornerX;            // = AnimX[i];
            int cornerY;            // = AnimY[i];
            if (_RES != GAME_UW2)
            {
                cornerX = AnimX[i];
                cornerY = AnimY[i];
            }
            else
            {            //Read from XY
                if (UW2_X[i] != -1)
                {
                    cornerX = AnimXY[UW2_X[i]];
                    cornerY = AnimXY[UW2_Y[i]];
                }
                else
                {
                    cornerX = 0;
                    cornerY = BitMapHeight;
                }
            }

            if ((_RES == GAME_UW1) || ((_RES == GAME_UW2) && (UW2_X[i] != -1)))          //Only create if UW1 image or a valid uw2 one
            {
                bool ImgStarted = false;
                for (int y = 0; y < MaxHeight; y++)
                {
                    for (int x = 0; x < MaxWidth; x++)
                    {
                        if ((cornerX + ColCounter == x) && (MaxHeight - cornerY + RowCounter == y) && (ColCounter < BitMapWidth) && (RowCounter < BitMapHeight))
                        {                        //the pixel from the source image is here
                            ImgStarted = true;
                            outputImg[x + (y * MaxWidth)] = srcImg[ColCounter + (RowCounter * BitMapWidth)];
                            ColCounter++;
                        }
                        else
                        {
                            alpha = 0;                          //0
                            outputImg[x + (y * MaxWidth)] = (char)alpha;
                        }
                    }
                    if (ImgStarted == true)
                    {                    //New Row on the src image
                        RowCounter++;
                        ColCounter = 0;
                    }
                }

                ImageCache[i] = Image(outputImg, 0, MaxWidth, MaxHeight, "name_goes_here", auxpal, true);
            }
        }
    }
Esempio n. 50
0
        public async Task DataLoaderCacheCombinationTest()
        {
          DataLoader a = new DataLoader();

          var result = await a.LoadAsync(() => DataCache.GetAsync("testkey", async () => await LongRunningOperation("result_1"), expireDate: DateTime.Now.AddDays(8)));
          Assert.AreEqual("result_1", result);

          //Should get value from cache
          var result_2 = await a.LoadAsync(() => DataCache.GetAsync("testkey", async () => await LongRunningOperation("result_2"), expireDate: DateTime.Now.AddDays(8)));
          Assert.AreEqual("result_1", result_2);

        }
Esempio n. 51
0
        public async Task DataLoaderLoadFallbackToCacheAsync_FailTest()
        {
            DataLoader a = new DataLoader();

            int count = 0;

            await a.LoadFallbackToCacheAsync(() => LongRunningOperationThrowsError(), () => LongRunningOperation(),
                (result) =>
                {
                    count++;
                }, errorCallback: e =>
                {
                    count++;
                    //Handle error
                });

            Assert.AreEqual(LoadingState.Finished, a.LoadingState);

            Assert.IsTrue(a.IsFinished);
            Assert.IsFalse(a.IsBusy);
            Assert.IsFalse(a.IsError);

            Assert.AreEqual(2, count);

        }
Esempio n. 52
0
        public void RunPowerSmallTestsSuccess(string TestFile)
        {
            List <TestData> TestSets = DataLoader.LoadData(TestFile);

            foreach (TestData TestSet in TestSets)
            {
                string AHexVal = "", ADecVal = "", BHexVal = "", BDecVal = "",
                              CHexVal = "", CDecVal = "", DHexVal = "", DDecVal = "",
                              EHexVal = "", EDecVal = "", FHexVal = "", FDecVal = "",
                              GHexVal = "", GDecVal = "", HHexVal = "", HDecVal = "", IHexVal = "", IDecVal = "";
                TestSet.Parameters.TryGetValue("a", out AHexVal);
                TestSet.Parameters.TryGetValue("A", out ADecVal);
                TestSet.Parameters.TryGetValue("b", out BHexVal);
                TestSet.Parameters.TryGetValue("B", out BDecVal);
                TestSet.Parameters.TryGetValue("c", out CHexVal);
                TestSet.Parameters.TryGetValue("C", out CDecVal);
                TestSet.Parameters.TryGetValue("d", out DHexVal);
                TestSet.Parameters.TryGetValue("D", out DDecVal);
                TestSet.Parameters.TryGetValue("e", out EHexVal);
                TestSet.Parameters.TryGetValue("E", out EDecVal);
                TestSet.Parameters.TryGetValue("f", out FHexVal);
                TestSet.Parameters.TryGetValue("F", out FDecVal);
                TestSet.Parameters.TryGetValue("g", out GHexVal);
                TestSet.Parameters.TryGetValue("G", out GDecVal);
                TestSet.Parameters.TryGetValue("h", out HHexVal);
                TestSet.Parameters.TryGetValue("H", out HDecVal);
                TestSet.Parameters.TryGetValue("i", out IHexVal);
                TestSet.Parameters.TryGetValue("I", out IDecVal);

                BigInt A    = new BigInt(TestSet.Size, AHexVal);
                BigInt ADec = new BigInt(TestSet.Size, ADecVal);
                BigInt B    = new BigInt(TestSet.Size, BHexVal);
                BigInt BDec = new BigInt(TestSet.Size, BDecVal);
                BigInt C    = new BigInt(TestSet.Size, CHexVal);
                BigInt CDec = new BigInt(TestSet.Size, CDecVal);
                BigInt D    = new BigInt(TestSet.Size, DHexVal);
                BigInt DDec = new BigInt(TestSet.Size, DDecVal);
                BigInt E    = new BigInt(TestSet.Size, EHexVal);
                BigInt EDec = new BigInt(TestSet.Size, EDecVal);
                BigInt F    = new BigInt(TestSet.Size, FHexVal);
                BigInt FDec = new BigInt(TestSet.Size, FDecVal);
                BigInt G    = new BigInt(TestSet.Size, GHexVal);
                BigInt GDec = new BigInt(TestSet.Size, GDecVal);
                BigInt H    = new BigInt(TestSet.Size, HHexVal);
                BigInt HDec = new BigInt(TestSet.Size, HDecVal);
                BigInt I    = new BigInt(TestSet.Size, IHexVal);
                BigInt IDec = new BigInt(TestSet.Size, IDecVal);

                BigInt BPower = A ^ 0;      // A ^ 0
                BigInt CPower = A ^ 1;      // A ^ 1
                BigInt DPower = A ^ 2;      // A ^ 2
                BigInt EPower = A ^ 3;      // A ^ 3
                BigInt FPower = A ^ 4;      // A ^ 4
                BigInt GPower = A ^ 5;      // A ^ 5
                BigInt HPower = A ^ 6;      // A ^ 6
                BigInt IPower = A ^ 7;      // A ^ 7
                BigInt bPower = ADec ^ 0;   // A ^ 0
                BigInt cPower = ADec ^ 1;   // A ^ 1
                BigInt dPower = ADec ^ 2;   // A ^ 2
                BigInt ePower = ADec ^ 3;   // A ^ 3
                BigInt fPower = ADec ^ 4;   // A ^ 4
                BigInt gPower = ADec ^ 5;   // A ^ 5
                BigInt hPower = ADec ^ 6;   // A ^ 6
                BigInt iPower = ADec ^ 7;   // A ^ 7

                Assert.True(B == BPower, $"Expected B to be equal to A ** 0, but got wrong value: {TestSet.Title}.");
                Assert.True(C == CPower, $"Expected C to be equal to A ** 1, but got wrong value: {TestSet.Title}.");
                Assert.True(D == DPower, $"Expected D to be equal to A ** 2, but got wrong value: {TestSet.Title}.");
                Assert.True(E == EPower, $"Expected E to be equal to A ** 3, but got wrong value: {TestSet.Title}.");
                Assert.True(F == FPower, $"Expected F to be equal to A ** 4, but got wrong value: {TestSet.Title}.");
                Assert.True(G == GPower, $"Expected G to be equal to A ** 5, but got wrong value: {TestSet.Title}.");
                Assert.True(H == HPower, $"Expected H to be equal to A ** 6, but got wrong value: {TestSet.Title}.");
                Assert.True(I == IPower, $"Expected H to be equal to A ** 7, but got wrong value: {TestSet.Title}.");

                Assert.True(BDec == bPower, $"Expected b to be equal to ADec ** 0, but got wrong value: {TestSet.Title}.");
                Assert.True(CDec == cPower, $"Expected c to be equal to ADec ** 1, but got wrong value: {TestSet.Title}.");
                Assert.True(DDec == dPower, $"Expected d to be equal to ADec ** 2, but got wrong value: {TestSet.Title}.");
                Assert.True(EDec == ePower, $"Expected e to be equal to ADec ** 3, but got wrong value: {TestSet.Title}.");
                Assert.True(FDec == fPower, $"Expected f to be equal to ADec ** 4, but got wrong value: {TestSet.Title}.");
                Assert.True(GDec == gPower, $"Expected g to be equal to ADec ** 5, but got wrong value: {TestSet.Title}.");
                Assert.True(HDec == hPower, $"Expected h to be equal to ADec ** 6, but got wrong value: {TestSet.Title}.");
                Assert.True(IDec == iPower, $"Expected H to be equal to ADec ** 7, but got wrong value: {TestSet.Title}.");
            }
        }
Esempio n. 53
0
        public void RunPrimNumberTestsSuccess(string TestFile)
        {
            List <TestData> TestSets = DataLoader.LoadData(TestFile);

            foreach (TestData TestSet in TestSets)
            {
                string AHexVal = "", ADecVal = "", AHexVal1 = "", ADecVal1 = "",
                              AHexVal2 = "", ADecVal2 = "", AHexVal3 = "", ADecVal3 = "",
                              AHexVal4 = "", ADecVal4 = "", AHexVal5 = "", ADecVal5 = "",
                              AHexVal6 = "", ADecVal6 = "", AHexVal7 = "", ADecVal7 = "",
                              AHexVal8 = "", ADecVal8 = "", AHexVal9 = "", ADecVal9 = "",
                              AHexVal10 = "", ADecVal10 = "", AHexVal11 = "", ADecVal11 = "",
                              PHexVal = "", PDecVal = "", FVal = "", EVal = "";
                TestSet.Parameters.TryGetValue("a", out AHexVal);
                TestSet.Parameters.TryGetValue("A", out ADecVal);
                TestSet.Parameters.TryGetValue("a1", out AHexVal1);
                TestSet.Parameters.TryGetValue("A1", out ADecVal1);
                TestSet.Parameters.TryGetValue("a2", out AHexVal2);
                TestSet.Parameters.TryGetValue("A2", out ADecVal2);
                TestSet.Parameters.TryGetValue("a3", out AHexVal3);
                TestSet.Parameters.TryGetValue("A3", out ADecVal3);
                TestSet.Parameters.TryGetValue("a4", out AHexVal4);
                TestSet.Parameters.TryGetValue("A4", out ADecVal4);
                TestSet.Parameters.TryGetValue("a5", out AHexVal5);
                TestSet.Parameters.TryGetValue("A5", out ADecVal5);
                TestSet.Parameters.TryGetValue("a6", out AHexVal6);
                TestSet.Parameters.TryGetValue("A6", out ADecVal6);
                TestSet.Parameters.TryGetValue("a7", out AHexVal7);
                TestSet.Parameters.TryGetValue("A7", out ADecVal7);
                TestSet.Parameters.TryGetValue("a8", out AHexVal8);
                TestSet.Parameters.TryGetValue("A8", out ADecVal8);
                TestSet.Parameters.TryGetValue("a9", out AHexVal9);
                TestSet.Parameters.TryGetValue("A9", out ADecVal9);
                TestSet.Parameters.TryGetValue("a10", out AHexVal10);
                TestSet.Parameters.TryGetValue("A10", out ADecVal10);
                TestSet.Parameters.TryGetValue("a11", out AHexVal11);
                TestSet.Parameters.TryGetValue("A11", out ADecVal11);
                TestSet.Parameters.TryGetValue("p", out PHexVal);
                TestSet.Parameters.TryGetValue("P", out PDecVal);
                TestSet.Parameters.TryGetValue("f", out FVal);
                TestSet.Parameters.TryGetValue("e", out EVal);
                BigInt[] BasesHex = new BigInt[]
                {
                    new BigInt(TestSet.Size, AHexVal), new BigInt(TestSet.Size, AHexVal1),
                    new BigInt(TestSet.Size, AHexVal2), new BigInt(TestSet.Size, AHexVal3),
                    new BigInt(TestSet.Size, AHexVal4), new BigInt(TestSet.Size, AHexVal5),
                    new BigInt(TestSet.Size, AHexVal6), new BigInt(TestSet.Size, AHexVal7),
                    new BigInt(TestSet.Size, AHexVal8), new BigInt(TestSet.Size, AHexVal9),
                    new BigInt(TestSet.Size, AHexVal10), new BigInt(TestSet.Size, AHexVal11)
                };
                BigInt[] BasesDec = new BigInt[]
                {
                    new BigInt(TestSet.Size, ADecVal), new BigInt(TestSet.Size, ADecVal1),
                    new BigInt(TestSet.Size, ADecVal2), new BigInt(TestSet.Size, ADecVal3),
                    new BigInt(TestSet.Size, ADecVal4), new BigInt(TestSet.Size, ADecVal5),
                    new BigInt(TestSet.Size, ADecVal6), new BigInt(TestSet.Size, ADecVal7),
                    new BigInt(TestSet.Size, ADecVal8), new BigInt(TestSet.Size, ADecVal9),
                    new BigInt(TestSet.Size, ADecVal10), new BigInt(TestSet.Size, ADecVal11)
                };

                BigInt P    = new BigInt(TestSet.Size, PHexVal);
                BigInt PDec = new BigInt(TestSet.Size, PDecVal);
                bool   FermatExpectedVal = FVal == "true" ? true : false;
                bool   EulerExpectedVal  = EVal == "true" ? true : false;

                // These instructions always return true (Fermat-Test is unable to detect those numbers), but combined with IsPrimeDiv we got false
                bool isPrimePFermat    = P.IsPrimeFermat(BasesHex);
                bool isPrimePDecFermat = PDec.IsPrimeFermat(BasesDec);
                bool isPrimePEuler     = P.IsPrimeEuler(BasesHex);
                bool isPrimePDecEEuler = PDec.IsPrimeFermat(BasesDec);
                Assert.True(isPrimePFermat == FermatExpectedVal, $"Expected isPrimePFermat to be {FermatExpectedVal}, but got wrong value: {TestSet.Title}.");
                Assert.True(isPrimePDecFermat == FermatExpectedVal, $"Expected isPrimePDecFermat to be {FermatExpectedVal}, but got wrong value: {TestSet.Title}.");
                Assert.True(isPrimePEuler == EulerExpectedVal, $"Expected isPrimePEuler to be {EulerExpectedVal}, but got wrong value: {TestSet.Title}.");
                Assert.True(isPrimePDecEEuler == EulerExpectedVal, $"Expected isPrimePDecEEuler to be {EulerExpectedVal}, but got wrong value: {TestSet.Title}.");
            }
        }
Esempio n. 54
0
        public void RunSquareTestsSuccess(string TestFile)
        {
            List <TestData> TestSets = DataLoader.LoadData(TestFile);

            foreach (TestData TestSet in TestSets)
            {
                string AHexVal = "", ADecVal = "", BHexVal = "", BDecVal = "",
                              CHexVal = "", CDecVal = "", DHexVal = "", DDecVal = "",
                              EHexVal = "", EDecVal = "", FHexVal = "", FDecVal = "",
                              GHexVal = "", GDecVal = "", HHexVal = "", HDecVal = "";
                TestSet.Parameters.TryGetValue("a", out AHexVal);
                TestSet.Parameters.TryGetValue("A", out ADecVal);
                TestSet.Parameters.TryGetValue("b", out BHexVal);
                TestSet.Parameters.TryGetValue("B", out BDecVal);
                TestSet.Parameters.TryGetValue("c", out CHexVal);
                TestSet.Parameters.TryGetValue("C", out CDecVal);
                TestSet.Parameters.TryGetValue("d", out DHexVal);
                TestSet.Parameters.TryGetValue("D", out DDecVal);
                TestSet.Parameters.TryGetValue("e", out EHexVal);
                TestSet.Parameters.TryGetValue("E", out EDecVal);
                TestSet.Parameters.TryGetValue("f", out FHexVal);
                TestSet.Parameters.TryGetValue("F", out FDecVal);
                TestSet.Parameters.TryGetValue("g", out GHexVal);
                TestSet.Parameters.TryGetValue("G", out GDecVal);
                TestSet.Parameters.TryGetValue("h", out HHexVal);
                TestSet.Parameters.TryGetValue("H", out HDecVal);

                BigInt A    = new BigInt(TestSet.Size, AHexVal);
                BigInt ADec = new BigInt(TestSet.Size, ADecVal);
                BigInt B    = new BigInt(TestSet.Size, BHexVal);
                BigInt BDec = new BigInt(TestSet.Size, BDecVal);
                BigInt C    = new BigInt(TestSet.Size, CHexVal);
                BigInt CDec = new BigInt(TestSet.Size, CDecVal);
                BigInt D    = new BigInt(TestSet.Size, DHexVal);
                BigInt DDec = new BigInt(TestSet.Size, DDecVal);
                BigInt E    = new BigInt(TestSet.Size, EHexVal);
                BigInt EDec = new BigInt(TestSet.Size, EDecVal);
                BigInt F    = new BigInt(TestSet.Size, FHexVal);
                BigInt FDec = new BigInt(TestSet.Size, FDecVal);
                BigInt G    = new BigInt(TestSet.Size, GHexVal);
                BigInt GDec = new BigInt(TestSet.Size, GDecVal);
                BigInt H    = new BigInt(TestSet.Size, HHexVal);
                BigInt HDec = new BigInt(TestSet.Size, HDecVal);

                BigInt BSquare = A.Square();       // A * A
                BigInt CSquare = A.Square(4);      // A ** 4
                BigInt DSquare = A.Square(8);      // A ** 8
                BigInt ESquare = A.Square(16);     // A ** 16
                BigInt FSquare = A.Square(32);     // A ** 32
                BigInt GSquare = A.Square(64);     // A ** 64
                BigInt HSquare = A.Square(128);    // A ** 128
                BigInt bSquare = ADec.Square();    // A * A
                BigInt cSquare = ADec.Square(4);   // A ** 4
                BigInt dSquare = ADec.Square(8);   // A ** 8
                BigInt eSquare = ADec.Square(16);  // A ** 16
                BigInt fSquare = ADec.Square(32);  // A ** 32
                BigInt gSquare = ADec.Square(64);  // A ** 64
                BigInt hSquare = ADec.Square(128); // A ** 128

                Assert.True(B == BSquare, $"Expected B to be equal to A * A, but got wrong value: {TestSet.Title}.");
                Assert.True(C == CSquare, $"Expected C to be equal to A ** 4, but got wrong value: {TestSet.Title}.");
                Assert.True(D == DSquare, $"Expected D to be equal to A ** 8, but got wrong value: {TestSet.Title}.");
                Assert.True(E == ESquare, $"Expected E to be equal to A ** 16, but got wrong value: {TestSet.Title}.");
                Assert.True(F == FSquare, $"Expected F to be equal to A ** 32, but got wrong value: {TestSet.Title}.");
                Assert.True(G == GSquare, $"Expected G to be equal to A ** 64, but got wrong value: {TestSet.Title}.");
                Assert.True(H == HSquare, $"Expected H to be equal to A ** 128, but got wrong value: {TestSet.Title}.");
                Assert.True(BDec == bSquare, $"Expected b to be equal to ADec * A, but got wrong value: {TestSet.Title}.");
                Assert.True(CDec == cSquare, $"Expected c to be equal to ADec ** 4, but got wrong value: {TestSet.Title}.");
                Assert.True(DDec == dSquare, $"Expected d to be equal to ADec ** 8, but got wrong value: {TestSet.Title}.");
                Assert.True(EDec == eSquare, $"Expected e to be equal to ADec ** 16, but got wrong value: {TestSet.Title}.");
                Assert.True(FDec == fSquare, $"Expected f to be equal to ADec ** 32, but got wrong value: {TestSet.Title}.");
                Assert.True(GDec == gSquare, $"Expected g to be equal to ADec ** 64, but got wrong value: {TestSet.Title}.");
                Assert.True(HDec == hSquare, $"Expected h to be equal to ADec ** 128, but got wrong value: {TestSet.Title}.");
            }
        }
Esempio n. 55
0
        public async Task DataLoaderLoadErrorHandleTest()
        {
            DataLoader a = new DataLoader();

            var task = a.LoadAsync(() => LongRunningOperationThrowsError(), errorCallback: e =>
            {
                //Handle error
            });

            Assert.AreEqual(LoadingState.Loading, a.LoadingState);

            Assert.IsTrue(a.IsBusy);
            Assert.IsFalse(a.IsFinished);
            Assert.IsFalse(a.IsError);

            //Exception is handled, result is null
            Assert.AreEqual(null, await task);

            Assert.IsFalse(a.IsBusy);
            Assert.IsFalse(a.IsFinished);
            Assert.IsTrue(a.IsError);
        }
Esempio n. 56
0
 // Use this for initialization
 void Start()
 {
     data  = handler.GetComponent <DataLoader>();
     image = GetComponent <Image>();
 }
Esempio n. 57
0
        public DataExampleViewModel()
        {
            StartLongRunningDataLoader = new DataLoader();
            StartLongRunningWithExceptionDataLoader = new DataLoader(); //swallow exceptions by default
            CacheDataLoader = new DataLoader();
            CacheWithExceptionDataLoader = new DataLoader(); //swallow exceptions by default
            SourceABDataLoader = new DataLoader(); //swallow exceptions by default
            CacheRefreshDataLoader = new DataLoader(); //swallow exceptions by default
            FailCacheDataLoader = new DataLoader(); 
            FailCacheSuccessDataLoader = new DataLoader();


            StartLongRunningCommand = new RelayCommand(() => StartLongRunningAction());
            StartLongRunningWithExceptionCommand = new RelayCommand(() => StartLongRunningWithExceptionAction());
            CacheCommand = new RelayCommand(() => CacheAction());
            CacheWithExceptionCommand = new RelayCommand(() => CacheWithExceptionAction());
            SourceABCommand = new RelayCommand(() => SourceABAction());
            CacheRefreshCommand = new RelayCommand(() => CacheRefreshAction());
            ClearCacheCommand = new RelayCommand(() => ClearCacheAction());
            FailCacheCommand = new RelayCommand(() => FailCacheAction());
            FailCacheSuccessCommand = new RelayCommand(() => FailCacheSuccessAction());

            ClearWebDataCacheCommand = new RelayCommand(() => ClearWebDataCacheCommandAction());
            GetUriCommand = new RelayCommand(() => GetUriCommandAction());

        }
Esempio n. 58
0
        public override void LoadData()
        {
            string trainPath="";
            string testPath="";
            string ids="";
            string target="";

            _trainPath = trainPath;
            _testPath = testPath;
            _target = target;

            _trainLoader = _target != null ? new DataLoader<FType>(_target) : new DataLoader<FType>();
            _testLoader = _target != null ? new DataLoader<FType>(_target) : new DataLoader<FType>();

            if (!File.Exists(_trainPath))
            {
                Logger.Log("train file " + _trainPath + " not found");
                throw new FileNotFoundException("", _trainPath);
            }

            if (!File.Exists(_trainPath))
            {
                Logger.Log("test file " + _testPath + " not found");
                throw new FileNotFoundException("", _testPath);
            }

            // loading train file
            _trainLoader.AddIdsString(ids);
            _trainLoader.ProceedRowFunc = ProceedRow;
            _trainLoader.Load(_trainPath);

            _trainProblem = _problemCreator.CreateProblem();

            // loading test file
            foreach (var id in _trainLoader.Ids.Keys) // the same id's
                _testLoader.AddIdColumn(id);

            foreach (var col in _trainLoader.SkippedColumns.Keys) // the same columns
                _testLoader.AddSkipColumn(col);

            // loading
            _testLoader.Load(_testPath);

            _testDataDict = new Dictionary<string, List<double[]>>(); // тестовые данные: id -> список строк на данный id
            _resultDict = new Dictionary<string, int>(); // результат тестовых данных: id -> target

            // модифицируем тестовые данные
            foreach (var row in _testLoader.Rows)
            {
                // сохраняем результат
                if (!_resultDict.ContainsKey(row.Id))
                    _resultDict.Add(row.Id, Convert.ToInt32(row.Target));

                // сохраняем ответ из бюро
                var txy = new double[_testLoader.NVars];
                for (int k = 0; k < _testLoader.NVars; k++)
                {
                    txy[k] = row.Coeffs[k];
                }
                if (!_testDataDict.ContainsKey(row.Id))
                    _testDataDict.Add(row.Id, new List<double[]>());
                _testDataDict[row.Id].Add(txy);
            }
        }