コード例 #1
0
		public async Task<IAnimation> LoadAnimationFromSpriteSheetAsync(ISpriteSheet spriteSheet,
			IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null)
		{
			animationConfig = animationConfig ?? new AGSAnimationConfiguration ();
			string filePath = spriteSheet.Path;
			IResource resource = await Task.Run(() =>_resources.LoadResource (filePath));
			if (resource == null) {
				throw new InvalidOperationException ("Failed to load sprite sheet from " + filePath);
			}
			IBitmap bitmap = await Task.Run(() => _bitmapLoader.Load (resource.Stream));
			int cellsInRow, cellsInCol, cellsTotal, cellX, cellY, cellsToGrab, cellsGrabbed = 0;
			Point mainStep, secondStep;
			AGSAnimation animation;
			getSpriteSheetData (bitmap, spriteSheet, animationConfig, out cellsInRow, out cellsInCol,
								out cellsTotal, out cellX, out cellY, out cellsToGrab, out mainStep, out secondStep,
								out animation);
			for (int currentCell = 0; cellsGrabbed < cellsToGrab; currentCell++) 
			{
				if (currentCell >= spriteSheet.StartFromCell) 
				{
                    Rectangle rect; IBitmap clone; string path; ITexture tex;
                    getImageInfo (bitmap, cellX, cellY, spriteSheet, loadConfig, filePath, out rect, out clone, out path, out tex);
                    IImage image = _loadImage (tex, clone, path, loadConfig, spriteSheet);
					_addAnimationFrame (image, animation);
					cellsGrabbed++;
				}

				nextCell (mainStep, secondStep, cellsInRow, cellsInCol, ref cellX, ref cellY);
			}
			animation.Setup ();
			return animation;
		}
コード例 #2
0
		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);
		}
コード例 #3
0
		public IInventoryItem GetInventoryItem(string hotspot, string graphicsFile, string cursorFile = null, 
			ILoadImageConfig loadConfig = null, bool playerStartsWithItem = false)
		{
			var graphicsImage = _graphics.LoadImage(graphicsFile, loadConfig);
			var cursorImage = cursorFile == null ? graphicsImage : _graphics.LoadImage(cursorFile, loadConfig);
			return getInventoryItem (hotspot, graphicsImage, cursorImage, playerStartsWithItem);
		}
コード例 #4
0
ファイル: GLImage.cs プロジェクト: tzachshabtay/MonoAGS
        public GLImage(IBitmap bitmap, string id, ITexture texture, ISpriteSheet spriteSheet, ILoadImageConfig loadConfig)
		{
			OriginalBitmap = bitmap;
			Width = bitmap.Width;
			Height = bitmap.Height;
			ID = id;
			Texture = texture;
			SpriteSheet = spriteSheet;
			LoadConfig = loadConfig;
		}
コード例 #5
0
		public async Task<IOutfit> LoadOutfitFromFoldersAsync(string baseFolder, string walkLeftFolder = null, string walkRightFolder = null,
			string walkDownFolder = null, string walkUpFolder = null, string idleLeftFolder = null, string idleRightFolder = null,
			string idleDownFolder = null, string idleUpFolder = null, string speakLeftFolder = null, string speakRightFolder = null,
			string speakDownFolder = null, string speakUpFolder = null,
			IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null)
		{
			IOutfit outfit = _resolver.Resolve<IOutfit> ();

            outfit[AGSOutfit.Idle] = await _graphics.LoadDirectionalAnimationFromFoldersAsync(baseFolder, idleLeftFolder, idleRightFolder,
				idleDownFolder, idleUpFolder, animationConfig, loadConfig);

            outfit[AGSOutfit.Walk] = await _graphics.LoadDirectionalAnimationFromFoldersAsync (baseFolder, walkLeftFolder, walkRightFolder,
				walkDownFolder, walkUpFolder, animationConfig, loadConfig);

            outfit[AGSOutfit.Speak] = await _graphics.LoadDirectionalAnimationFromFoldersAsync (baseFolder, speakLeftFolder, speakRightFolder,
				speakDownFolder, speakUpFolder, animationConfig, loadConfig);

			return outfit;
		}
コード例 #6
0
		public async Task<IDirectionalAnimation> LoadDirectionalAnimationFromFoldersAsync(string baseFolder, string leftFolder = null,
			string rightFolder = null, string downFolder = null, string upFolder = null,
			IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null)
		{
			if (leftFolder == null && rightFolder == null && downFolder == null && upFolder == null) return null;

			AGSDirectionalAnimation dirAnimation = new AGSDirectionalAnimation ();
			if (leftFolder != null) dirAnimation.Left = await LoadAnimationFromFolderAsync(baseFolder + leftFolder, animationConfig, loadConfig);
			if (rightFolder != null) dirAnimation.Right = await LoadAnimationFromFolderAsync(baseFolder + rightFolder, animationConfig, loadConfig);
			if (downFolder != null) dirAnimation.Down = await LoadAnimationFromFolderAsync(baseFolder + downFolder, animationConfig, loadConfig);
			if (upFolder != null) dirAnimation.Up = await LoadAnimationFromFolderAsync(baseFolder + upFolder, animationConfig, loadConfig);

			if (dirAnimation.Left != null && dirAnimation.Right == null) {
				dirAnimation.Right = createLeftRightAnimation (dirAnimation.Left);
			}

			if (dirAnimation.Right != null && dirAnimation.Left == null) {
				dirAnimation.Left = createLeftRightAnimation (dirAnimation.Right);
			}

			return dirAnimation;
		}
コード例 #7
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));
        }
コード例 #8
0
        private IImage loadImage(ITexture texture, IBitmap bitmap, string id, ILoadImageConfig config, ISpriteSheet spriteSheet)
		{
			manipulateImage(bitmap, config);
			bitmap.LoadTexture(null);
			GLImage image = new GLImage (bitmap, id, texture, spriteSheet, config);

			if (_textures != null)
                _textures.GetOrAdd (image.ID, () => image.Texture);
			return image;
		}
コード例 #9
0
 private ITexture createTexture(ILoadImageConfig config)
 {
     ITextureConfig textureConfig = config == null ? null : config.TextureConfig;
     TypedParameter textureConfigParam = new TypedParameter(typeof(ITextureConfig), textureConfig);
     return _resolver.Resolve<ITexture>(textureConfigParam);
 }
コード例 #10
0
		private async Task<IAnimation> loadAnimationFromResourcesAsync (List<IResource> resources,
			IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null)
		{
			AGSAnimation animation = getAnimation (animationConfig, resources.Count);

			foreach (IResource resource in resources) 
			{
				var image = await loadImageAsync (resource, loadConfig);
				addAnimationFrame (image, animation);
			}
			animation.Setup ();
			return animation;
		}
コード例 #11
0
        private IImage loadImage(IResource resource, ILoadImageConfig config = null)
		{
			ITexture tex = createTexture(config);
			try
			{
				IBitmap bitmap = _bitmapLoader.Load(resource.Stream);
				return loadImage (tex, bitmap, resource.ID, config, null);
			}
			catch (ArgumentException e)
			{
				Debug.WriteLine("Failed to load image from {0}, is it really an image?\r\n{1}", resource.ID, e.ToString());
				return null;
			}
		}
コード例 #12
0
		public async Task<IAnimation> LoadAnimationFromSpriteSheetAsync (ISpriteSheet spriteSheet, 
			IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null)
		{
			return await _spriteSheetLoader.LoadAnimationFromSpriteSheetAsync (spriteSheet, animationConfig, loadConfig);
		}
コード例 #13
0
        public IImage LoadImage(string path, ILoadImageConfig config = null)
		{
			IResource resource = _resources.LoadResource(path);
            return loadImage(resource, config);
		}
コード例 #14
0
 public IImage LoadImage(IBitmap bitmap, ILoadImageConfig config = null, string id = null)
 {
     return(loadImage(bitmap, config, id));
 }
コード例 #15
0
        public IImage LoadImage(string path, ILoadImageConfig config = null)
        {
            IResource resource = _resources.LoadResource(path);

            return(loadImage(resource, config));
        }
コード例 #16
0
 public IAnimation LoadAnimationFromSpriteSheet(ISpriteSheet spriteSheet,
                                                IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null)
 {
     return(_spriteSheetLoader.LoadAnimationFromSpriteSheet(spriteSheet, animationConfig, loadConfig));
 }
コード例 #17
0
 public async Task <IAnimation> LoadAnimationFromSpriteSheetAsync(ISpriteSheet spriteSheet,
                                                                  IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null)
 {
     return(await _spriteSheetLoader.LoadAnimationFromSpriteSheetAsync(spriteSheet, animationConfig, loadConfig));
 }
コード例 #18
0
 public async Task <IAnimation> LoadAnimationFromFolderAsync(string folderPath,
                                                             IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null)
 {
     return(await loadAnimationFromResourcesAsync(folderPath, await Task.Run(() => _resources.LoadResources(folderPath)),
                                                  animationConfig, loadConfig));
 }
コード例 #19
0
 public IAnimation LoadAnimationFromFolder(string folderPath,
                                           IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null)
 {
     return(loadAnimationFromResources(folderPath, _resources.LoadResources(folderPath), animationConfig, loadConfig));
 }
コード例 #20
0
        public IPanel GetPanel(string id, string imagePath, float x, float y, IObject parent = null, ILoadImageConfig loadConfig = null, bool addToUi = true)
        {
            IImage image = _graphics.LoadImage(imagePath, loadConfig);

            return(GetPanel(id, image, x, y, parent, addToUi));
        }
コード例 #21
0
ファイル: GLImage.cs プロジェクト: tzachshabtay/MonoAGS
 public GLImage(IBitmap bitmap, string id, ITexture texture, ISpriteSheet spriteSheet, ILoadImageConfig loadConfig)
 {
     OnImageDisposed = new AGSEvent();
     OriginalBitmap  = bitmap;
     Width           = bitmap.Width;
     Height          = bitmap.Height;
     ID          = id;
     Texture     = texture;
     SpriteSheet = spriteSheet;
     LoadConfig  = loadConfig;
 }
コード例 #22
0
        public async Task <IImage> LoadImageAsync(string filePath, ILoadImageConfig config = null)
        {
            IResource resource = await Task.Run(() => _resources.LoadResource(filePath));

            return(await loadImageAsync(resource, config));
        }
コード例 #23
0
		public IAnimation LoadAnimationFromSpriteSheet (ISpriteSheet spriteSheet, 
			IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null)
		{
			return _spriteSheetLoader.LoadAnimationFromSpriteSheet (spriteSheet, animationConfig, loadConfig);
		}
コード例 #24
0
        private async Task <IAnimation> loadAnimationFromResourcesAsync(string samplePath, List <IResource> resources,
                                                                        IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null)
        {
            AGSAnimation animation = getAnimation(samplePath, animationConfig, resources.Count);

            foreach (IResource resource in resources)
            {
                var image = await loadImageAsync(resource, loadConfig);

                addAnimationFrame(image, animation);
            }
            animation.Setup();
            return(animation);
        }
コード例 #25
0
		public IImage LoadImage(IBitmap bitmap, ILoadImageConfig config = null, string id = null)
		{
            return loadImage(bitmap, config, id);
		}
コード例 #26
0
        public async Task <IDirectionalAnimation> LoadDirectionalAnimationFromFoldersAsync(string baseFolder, string leftFolder = null,
                                                                                           string rightFolder = null, string downFolder = null, string upFolder = null,
                                                                                           IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null)
        {
            if (leftFolder == null && rightFolder == null && downFolder == null && upFolder == null)
            {
                return(null);
            }

            AGSDirectionalAnimation dirAnimation = new AGSDirectionalAnimation();

            if (leftFolder != null)
            {
                dirAnimation.Left = await LoadAnimationFromFolderAsync(baseFolder + leftFolder, animationConfig, loadConfig);
            }
            if (rightFolder != null)
            {
                dirAnimation.Right = await LoadAnimationFromFolderAsync(baseFolder + rightFolder, animationConfig, loadConfig);
            }
            if (downFolder != null)
            {
                dirAnimation.Down = await LoadAnimationFromFolderAsync(baseFolder + downFolder, animationConfig, loadConfig);
            }
            if (upFolder != null)
            {
                dirAnimation.Up = await LoadAnimationFromFolderAsync(baseFolder + upFolder, animationConfig, loadConfig);
            }

            if (dirAnimation.Left != null && dirAnimation.Right == null)
            {
                dirAnimation.Right = createLeftRightAnimation(dirAnimation.Left);
            }

            if (dirAnimation.Right != null && dirAnimation.Left == null)
            {
                dirAnimation.Left = createLeftRightAnimation(dirAnimation.Right);
            }

            return(dirAnimation);
        }
コード例 #27
0
		public async Task<IImage> LoadImageAsync (string filePath, ILoadImageConfig config = null)
		{
			IResource resource = await Task.Run(() => _resources.LoadResource(filePath));
            return await loadImageAsync(resource, config);
		}
コード例 #28
0
		public IAnimation LoadAnimationFromFiles(IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null, params string[] files)
		{
			return loadAnimationFromResources(_resources.LoadResources(files), animationConfig, loadConfig);
		}
コード例 #29
0
 private IImage loadImage(IBitmap bitmap, ILoadImageConfig config = null, string id = null)
 {
     id = id ?? Guid.NewGuid().ToString();
     ITexture tex = createTexture(config);
     return loadImage(tex, bitmap, id, config, null);
 }
コード例 #30
0
		public IAnimation LoadAnimationFromFolder (string folderPath, 
			IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null)
		{
			return loadAnimationFromResources(_resources.LoadResources(folderPath), animationConfig, loadConfig);
		}
コード例 #31
0
        private async Task<IImage> loadImageAsync (IResource resource, ILoadImageConfig config = null)
		{
			try 
			{
                if (resource == null) return new EmptyImage(1f, 1f);
				IBitmap bitmap = await Task.Run(() => _bitmapLoader.Load (resource.Stream));
				ITexture tex = createTexture(config);
				return loadImage(tex, bitmap, resource.ID, config, null);
			} 
			catch (ArgumentException e) 
			{
				Debug.WriteLine ("Failed to load image from {0}, is it really an image?\r\n{1}", resource.ID, e.ToString ());
				return null;
			}
		}
コード例 #32
0
		private void getImageInfo(IBitmap bitmap, int cellX, int cellY, ISpriteSheet spriteSheet, 
                                  ILoadImageConfig loadConfig, string filePath, 
                                  out Rectangle rect, out IBitmap clone, out string path, out ITexture texture)
		{
            texture = new GLTexture(loadConfig.TextureConfig, _graphics);
			rect = new Rectangle (cellX * spriteSheet.CellWidth,
										cellY * spriteSheet.CellHeight, spriteSheet.CellWidth, spriteSheet.CellHeight);
			clone = bitmap.Crop (rect);
			path = string.Format ("{0}_{1}_{2}", rect.X, rect.Y, filePath);
		}
コード例 #33
0
		private void manipulateImage(IBitmap bitmap, ILoadImageConfig config)
		{
			if (config == null) return;
			if (config.TransparentColorSamplePoint != null)
			{
				Color transparentColor = bitmap.GetPixel((int)config.TransparentColorSamplePoint.Value.X,
					(int)config.TransparentColorSamplePoint.Value.Y);
				bitmap.MakeTransparent(transparentColor);
			}
		}
コード例 #34
0
ファイル: AGSUIFactory.cs プロジェクト: tzachshabtay/MonoAGS
		public IPanel GetPanel(string id, string imagePath, float x, float y, ILoadImageConfig loadConfig = null, bool addToUi = true)
		{
			IImage image = _graphics.LoadImage(imagePath, loadConfig);
			return GetPanel(id, image, x, y, addToUi);
		}
コード例 #35
0
 private IImage getImage(ITexture texture, ISpriteSheet spriteSheet, ILoadImageConfig loadConfig)
 {
     return(new GLImage(AGSGame.Device.BitmapLoader.Load((int)Width, (int)Height), ID, texture, spriteSheet, loadConfig));
 }
コード例 #36
0
        public async Task <ISlider> GetSliderAsync(string id, string imagePath, string handleImagePath, float value, float min, float max,
                                                   IObject parent = null, ITextConfig config = null, ILoadImageConfig loadConfig = null, bool addToUi = true)
        {
            var image = imagePath == null ? null : await _graphics.LoadImageAsync(imagePath, loadConfig);

            var handleImage = handleImagePath == null ? null : await _graphics.LoadImageAsync(handleImagePath, loadConfig);

            return(getSlider(id, image, handleImage, value, min, max, parent, config, addToUi));
        }
コード例 #37
0
		public async Task<IAnimation> LoadAnimationFromFilesAsync(IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null, params string [] files)
		{
			return await loadAnimationFromResourcesAsync(await Task.Run(() => _resources.LoadResources (files)), 
			                                             animationConfig, loadConfig);
		}
コード例 #38
0
        public async Task <IOutfit> LoadOutfitFromFoldersAsync(string baseFolder, string walkLeftFolder = null, string walkRightFolder = null,
                                                               string walkDownFolder  = null, string walkUpFolder  = null, string idleLeftFolder  = null, string idleRightFolder  = null,
                                                               string idleDownFolder  = null, string idleUpFolder  = null, string speakLeftFolder = null, string speakRightFolder = null,
                                                               string speakDownFolder = null, string speakUpFolder = null,
                                                               IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null)
        {
            IOutfit outfit = _resolver.Container.Resolve <IOutfit> ();

            outfit[AGSOutfit.Idle] = await _graphics.LoadDirectionalAnimationFromFoldersAsync(baseFolder, idleLeftFolder, idleRightFolder,
                                                                                              idleDownFolder, idleUpFolder, animationConfig, loadConfig);

            outfit[AGSOutfit.Walk] = await _graphics.LoadDirectionalAnimationFromFoldersAsync(baseFolder, walkLeftFolder, walkRightFolder,
                                                                                              walkDownFolder, walkUpFolder, animationConfig, loadConfig);

            outfit[AGSOutfit.Speak] = await _graphics.LoadDirectionalAnimationFromFoldersAsync(baseFolder, speakLeftFolder, speakRightFolder,
                                                                                               speakDownFolder, speakUpFolder, animationConfig, loadConfig);

            return(outfit);
        }
コード例 #39
0
		public async Task<IAnimation> LoadAnimationFromFolderAsync (string folderPath,
			IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null)
		{
			return await loadAnimationFromResourcesAsync (await Task.Run(() => _resources.LoadResources (folderPath)), 
			                                   animationConfig, loadConfig);
		}
コード例 #40
0
        public async Task <IAnimation> LoadAnimationFromSpriteSheetAsync(ISpriteSheet spriteSheet,
                                                                         IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null)
        {
            animationConfig = animationConfig ?? new AGSAnimationConfiguration();
            string    filePath = spriteSheet.Path;
            IResource resource = await Task.Run(() => _resources.LoadResource(filePath));

            if (resource == null)
            {
                throw new InvalidOperationException("Failed to load sprite sheet from " + filePath);
            }
            IBitmap bitmap = await Task.Run(() => _bitmapLoader.Load(resource.Stream));

            int          cellsInRow, cellsInCol, cellsTotal, cellX, cellY, cellsToGrab, cellsGrabbed = 0;
            Point        mainStep, secondStep;
            AGSAnimation animation;

            getSpriteSheetData(bitmap, spriteSheet, animationConfig, out cellsInRow, out cellsInCol,
                               out cellsTotal, out cellX, out cellY, out cellsToGrab, out mainStep, out secondStep,
                               out animation);
            for (int currentCell = 0; cellsGrabbed < cellsToGrab; currentCell++)
            {
                if (currentCell >= spriteSheet.StartFromCell)
                {
                    Rectangle rect; IBitmap clone; string path; ITexture tex;
                    getImageInfo(bitmap, cellX, cellY, spriteSheet, loadConfig, filePath, out rect, out clone, out path, out tex);
                    IImage image = _loadImage(tex, clone, path, loadConfig, spriteSheet);
                    _addAnimationFrame(image, animation);
                    cellsGrabbed++;
                }

                nextCell(mainStep, secondStep, cellsInRow, cellsInCol, ref cellX, ref cellY);
            }
            animation.Setup();
            return(animation);
        }
コード例 #41
0
ファイル: AGSUIFactory.cs プロジェクト: tzachshabtay/MonoAGS
		public async Task<ISlider> GetSliderAsync(string id, string imagePath, string handleImagePath, float value, float min, float max,
			ITextConfig config = null, ILoadImageConfig loadConfig = null, bool addToUi = true)
		{
			var image = await _graphics.LoadImageAsync(imagePath, loadConfig);
			var handleImage = await _graphics.LoadImageAsync(handleImagePath, loadConfig);
			return getSlider(id, image, handleImage, value, min, max, config, addToUi);
		}
コード例 #42
0
 public IAnimation LoadAnimationFromFiles(IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null, params string[] files)
 {
     if (files.Length == 0)
     {
         throw new InvalidOperationException("No files given to LoadAnimationFromFiles");
     }
     return(loadAnimationFromResources(files[0], _resources.LoadResourcesFromPaths(files), animationConfig, loadConfig));
 }
コード例 #43
0
ファイル: AGSUIFactory.cs プロジェクト: tzachshabtay/MonoAGS
		public async Task<IPanel> GetPanelAsync(string id, string imagePath, float x, float y, ILoadImageConfig loadConfig = null, bool addToUi = true)
		{
			IImage image = await _graphics.LoadImageAsync(imagePath, loadConfig);
			return GetPanel (id, image, x, y, addToUi);
		}
コード例 #44
0
 public async Task <IAnimation> LoadAnimationFromFilesAsync(IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null, params string [] files)
 {
     if (files.Length == 0)
     {
         throw new InvalidOperationException("No files given to LoadAnimationFromFilesAsync");
     }
     return(await loadAnimationFromResourcesAsync(files[0], await Task.Run(() => _resources.LoadResourcesFromPaths(files)),
                                                  animationConfig, loadConfig));
 }