public async Task <IInventoryItem> GetInventoryItemAsync(string hotspot, string graphicsFile, string cursorFile = null,
                                                                 ILoadImageConfig loadConfig = null, bool playerStartsWithItem = false)
        {
            var graphicsImage = await _graphics.LoadImageAsync(graphicsFile, loadConfig);

            var cursorImage = cursorFile == null ? graphicsImage : await _graphics.LoadImageAsync(cursorFile, loadConfig);

            return(getInventoryItem(hotspot, graphicsImage, cursorImage, playerStartsWithItem));
        }
Esempio n. 2
0
            public static async Task LoadAll(IGame game)
            {
                IGraphicsFactory f = game.Factory.Graphics;

                Selector = await f.LoadImageAsync(UIAssetFolder + "hor.png", MagicColor.TopLeftPixel);

                VBar = await f.LoadImageAsync(UIAssetFolder + "vert.png", MagicColor.TopLeftPixel);

                PortraitFrame = await f.LoadImageAsync(UIAssetFolder + "blackframe.png", MagicColor.TopLeftPixel);
            }
Esempio n. 3
0
            public static async Task LoadAll(IGame game)
            {
                IGraphicsFactory f = game.Factory.Graphics;

                for (int i = 0; i < Names.Length; ++i)
                {
                    string name     = Names[i];
                    IImage carmodel = await f.LoadImageAsync(string.Format("{0}carmodel{1}.png", ObjectAssetFolder, i + 1), MagicColor.TopLeftPixel);

                    CarModels.Add(name, carmodel);
                    IImage portrait = await f.LoadImageAsync(string.Format("{0}face{1}.png", UIAssetFolder, i + 1), MagicColor.TopLeftPixel);

                    Drivers.Add(name, new DriverCharacter(name, portrait, carmodel, 90.0F));
                }

                RacerFrames = new IImage[Race.MAX_RACING_CARS];
                for (int i = 0; i < Race.MAX_RACING_CARS; ++i)
                {
                    RacerFrames[i] = await f.LoadImageAsync($"{UIAssetFolder}racerframe{i + 1}.png", MagicColor.TopLeftPixel);
                }
                BannerReady = await f.LoadImageAsync(UIAssetFolder + "banner1.png", MagicColor.TopLeftPixel);

                BannerSet = await f.LoadImageAsync(UIAssetFolder + "banner2.png", MagicColor.TopLeftPixel);

                BannerGo = await f.LoadImageAsync(UIAssetFolder + "banner3.png", MagicColor.TopLeftPixel);

                BannerLoose = await f.LoadImageAsync(UIAssetFolder + "banner4.png", MagicColor.TopLeftPixel);

                BannerWin = await f.LoadImageAsync(UIAssetFolder + "banner5.png", MagicColor.TopLeftPixel);
            }
Esempio n. 4
0
        /// <summary>
        /// Loads a Track definition file and constructs a Track object.
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static async Task <Track> LoadAsync(string defpath, string assetpath, IGraphicsFactory f)
        {
            FileIniDataParser file = new FileIniDataParser();

            file.Parser.Configuration.CommentString = "//";
            IniData inidata = file.ReadFile(defpath);

            if (inidata == null)
            {
                return(null);
            }

            IniGetter ini      = new IniGetter(inidata);
            string    bkgpath  = ini.GetString("track", "background");
            string    maskpath = ini.GetString("track", "mask");
            Dictionary <Color, int> regionColors = new Dictionary <Color, int>();
            int regions = ini.GetInt("track", "regions");

            for (int i = 0; i < regions; ++i)
            {
                string secname = string.Format("region{0}", i);
                if (!inidata.Sections.ContainsSection(secname))
                {
                    continue;
                }
                Color col = Color.FromArgb(255,
                                           (byte)ini.GetInt(secname, "color_r"),
                                           (byte)ini.GetInt(secname, "color_g"),
                                           (byte)ini.GetInt(secname, "color_b"));
                regionColors[col] = i;
            }

            IImage background = await f.LoadImageAsync(assetpath + bkgpath);

            IBitmap mask = await f.LoadBitmapAsync(assetpath + maskpath);

            /*
             * // TODO: find out whether engine provides faster solution
             * int[,] regionMap = new int[mask.Width, mask.Height];
             * for (int x = 0; x < mask.Width; ++x)
             * {
             *  // NOTE: since MonoAGS has Y axis pointing up, we need to invert the lookup array's Y index
             *  for (int y = 0, mapy = mask.Height - 1; y < mask.Height; ++y, --mapy)
             *  {
             *      Color col = mask.GetPixel(x, y);
             *      int index = 0;
             *      regionColors.TryGetValue(col, out index);
             *      regionMap[x, mapy] = index;
             *  }
             * }
             *
             * return new Track(background, regionColors.Count, regionMap);
             */
            Size            trackSize   = mask != null ? new Size(mask.Width, mask.Height) : new Size();
            List <RaceNode> checkpoints = loadCheckpoints(assetpath, trackSize);

            TrackAIData aiData = await loadAIData(assetpath, trackSize, f);

            return(new Track(background, regionColors.Count, mask, regionColors, checkpoints, aiData));
        }
Esempio n. 5
0
        public async Task <IPanel> GetPanelAsync(string id, string imagePath, float x, float y, IObject parent = null, ILoadImageConfig loadConfig = null, bool addToUi = true)
        {
            IImage image = await _graphics.LoadImageAsync(imagePath, loadConfig);

            return(GetPanel(id, image, x, y, parent, addToUi));
        }