/// <summary> /// Will create a sprite with multiple frames from the image at the given fileLocation when loadResource is called /// Note, fileLocation[0] will also be used as this resources ID /// </summary> /// <param name="fileLocation">The Locations of all of the images to be used by this sprite /// Note, all of the images must be the same size for them to be dispayed properly</param> /// <param name="rows">The number of images in a row that are contained in the image File</param> public Sprite(String[] fileLocation, int rows) : base(fileLocation[0], LibraryResource.convertResourceType(ResourceType.SPRITE)) { if (fileLocation != null) { imageFileLocations = new String[fileLocation.Length]; for (int loop = 0; loop < imageFileLocations.Length; loop++) { if (fileLocation[loop] != null) { imageFileLocations[loop] = fileLocation[loop]; } else { imageFileLocations[loop] = null; } } } if (rows > 0) { this.rows = rows; } this.collumns = 1; this.offset = 0; totalFrames = (rows * collumns * imageFileLocations.Length) - offset; }
/// <summary> /// Will add the given resource to the library using its ID as the ///Key that can be used to access it with. Note if another resource in the library ///has the same ID as the given resource this resource can not be added /// </summary> /// <param name="newResource">The Resource to be added</param> /// <returns>If True the resource was successfully added, if False, no changes were made</returns> public bool addResource(LibraryResource newResource) { if (newResource != null && !library.ContainsKey(newResource.getID())) { library.Add(newResource.getID(), newResource); LibraryCollection.AddFirst(newResource); return(true); } return(false); }
/// <summary> /// Will remove the library Resource with the given ID from the library if one exists /// </summary> /// <param name="resourceID">the ID of the targetResource</param> /// <returns>If True the resource was successfully added, if False, no changes were made</returns> public bool addRemoveResource(string resourceID) { if (resourceID != null && library.ContainsKey(resourceID)) { LibraryResource removed = library[resourceID]; library.Remove(resourceID); LibraryCollection.Remove(removed); return(true); } return(false); }
/// <summary> /// Will create a sprite with 1 frame from the image at the given fileLocation when loadResource is called /// Note, fileLocation will also be used as this resources ID /// </summary> /// <param name="fileLocation">the location of the image file that will be loaded</param> public Sprite(String fileLocation) : base(fileLocation, LibraryResource.convertResourceType(ResourceType.SPRITE)) { if (fileLocation != null) { imageFileLocations = new String[1]; imageFileLocations[0] = fileLocation; } this.rows = 1; this.collumns = 1; this.offset = 0; totalFrames = (rows * collumns * imageFileLocations.Length) - offset; }
/// <summary> /// Will create a loadable sound managing the given sound /// </summary> /// <param name="fileLocation"></param> public Sound(string fileLocation) : base(fileLocation, LibraryResource.convertResourceType(ResourceType.SOUND)) { if (fileLocation != null) { try{ soundLocation = new Uri(AppDomain.CurrentDomain.BaseDirectory + fileLocation); } catch (UriFormatException e) { Console.Error.WriteLine("ERROR Locating fileLocation: " + e.Message); } } }
/// <summary> /// Will initialize a LoadableFont to manage a Font with the following properties /// </summary> /// <param name="fontName">The Name of the Font that will be used, "Arial", "Times New Roman" Note The Fonts must already be installed on the computer to be put into use</param> /// <param name="fontSize">The Size in points the Font will be, note Must be greater than zero</param> /// <param name="fontStyle">The Style, Bold, Italic,</param> public LoadableFont(string fontName, float fontSize, FontStyle fontStyle) : base(createFontID(fontName, fontSize, fontStyle), LibraryResource.convertResourceType(ResourceType.FONT)) { if (fontName != null && !fontName.Equals("")) { name = fontName; } if (fontSize > 0) { size = fontSize; } style = fontStyle; }
/// <summary> /// Will create a sprite with multiple frames from the image at the given fileLocation when loadResource is called /// Note, fileLocation will also be used as this resources ID /// </summary> /// <param name="fileLocation">the location of the image file that will be loaded</param> /// <param name="rows">The number of images in each row in the image File</param> /// <param name="collumns">The number of images in each collumn in the image File</param> /// <param name="offset">The number of frames that are missing from the last row of image. /// Note, It is assumed that the existing images are right oriented</param> public Sprite(String fileLocation, int rows, int collumns, int offset) : base(fileLocation, LibraryResource.convertResourceType(ResourceType.SPRITE)) { if (fileLocation != null) { imageFileLocations = new String[1]; imageFileLocations[0] = fileLocation; } if (rows > 0) { this.rows = rows; } if (collumns > 0) { this.collumns = collumns; } if (offset > 0) { this.offset = offset; } totalFrames = (rows * collumns * imageFileLocations.Length) - offset; }