This is a collection of services and extensions that I have found helpful across multiple, released FlatRedBall games.
The classes in this repo are not documented outside of XML comments. This is a great place to contribute if you want to give back to the project! See the Docs Index.
This project depends on building FlatRedBall from source to work out of the box because there are some FRB-specific services. However, most of the services and classes are pure C#. Feel free to take just what you need for your MonoGame or Unity project.
Most of the services are singleton classes and most of them need to be initialized
before use. I recommend calling ServiceClass.Instance.Initialize() in your root
Game class before starting a screen. Usually, services that have not been
initialized will throw an exception.
FileService: contains easy wrappers for loading and serializing/deserializing text.GoogleAnalyticsService: a cross-platform REST implementation that can be used to have game telemetry in a free Google Analytics accountLogService: A really basic log system. You should probably use something else that's better!RandomService: The FRB implementation of Random does not allow you to specify a seed. This is just a central container to hold a seed-critical random instance.ScreenshotService: Allows you to easily save screenshots to disk. This is not slow and primarily intended for debugging.SimpleCryptoService: A simple and fast way to encrypt game data so it's not obvious to edit. NOT SAFE for sensitive data.SoundService: A basic 2D sound implementation with distance-based attenuation, pitch variance, and moreUIService: A central manager that allows you to register menus and manage your game's UI state.
Extensions methods for several FRB types are available to make common tasks more convenient.
CameraExtensions: Currently only offers a helper for getting a random position within the view of the camera.CollectionExtensions: Adds a Linq-likeRandom()method to many collection types and has some helpers for converting between collection types.ColorExtensions: Provides an HSB/HSL color mode and methods to convert between HSB and RGBCursorExtensions: Helpers for using cursors with gamepadsEntityExtensions: Methods primarily useful for AI behavior. Helpers for finding distance and rotation between positioned entities.MathExtensions: Helpers for common 2D game math.RandomExtensions: Helpers for common random tasks like getting a random color or a randomfloatwithin a range.SpriteExtensions: Makes it easy to colorize a sprite in a single line of code.
Google Sheets is a powerful game design application! You can design all of your game data with the indexes, checks, calculations, and comparisons you need to manage and balance your content.
But you need a simple system to get game design data into your game. That's what these tools are for!
- Set up an App Script for your Google Sheets project using Extensions > App Script in Google Sheets
- Add the JS and HTML file in this repo's folder to your App Script
- This will add a new menu option: Game Design > Convert to JSON
- Create your game data with headers and rows
- Select the data, including headers, and choose the Convert to JSON menu option
- A side panel will pop up with the selected data converted to JSON
- Create a POCO model for your game data and deserialize the JSON into your game with the
FileServiceprovided in NarfoxGameTools - OPTIONAL: encrypt the data, if desiged using the
SimpleCryptoServiceprovided in NarfoxGameTools