NetAF 2.4.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package NetAF --version 2.4.1
                    
NuGet\Install-Package NetAF -Version 2.4.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NetAF" Version="2.4.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NetAF" Version="2.4.1" />
                    
Directory.Packages.props
<PackageReference Include="NetAF" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NetAF --version 2.4.1
                    
#r "nuget: NetAF, 2.4.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NetAF@2.4.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NetAF&version=2.4.1
                    
Install as a Cake Addin
#tool nuget:?package=NetAF&version=2.4.1
                    
Install as a Cake Tool

<div align="center">

NetAF

A C# library that provides a framework for building text adventures and interactive stories in .NET.

main-ci GitHub release NuGet NuGet Downloads codecov Quality Gate Status Maintainability Rating Security Rating Vulnerabilities Bugs License Documentation Status

</div>

Overview

NetAF is a .NET Standard 2.0 implementation of a framework for building text based adventures.

NetAF_example

At its core NetAF provides simple classes for developing game elements:

Environments

Environments are broken down in to three elements - Overworld, Region and Room. An Overworld contains one or more Regions. A Region contains one or more Rooms. A Room can contain up to six exits (north, south, east, west, up and down).

Overworld
├── Region
│   ├── Room
│   ├── Room
│   ├── Room
├── Region
│   ├── Room
│   ├── Room

Exits

Rooms contain exits. Exits can be locked to block progress through the game.

// create a test room
Room room = new("Test Room", "A test room.");
        
// add an exit to the north
room.AddExit(new(Direction.North));

Items

Items add richness to a game. Items support interaction with the player, rooms, other items and NPC's. Items can morph in to other items. For example, using item A on item B may cause item B to morph into item C.

Item sword = new("Sword", "The heroes sword.");

Playable Character

Each NetAF game has a single playable character. The game is played through the view point of the playable character.

PlayableCharacter player = new("Dave", "The hero of the story.");

Non-playable Characters

Non-playable characters (NPC's) can be added to rooms and can help drive the narrative. NPC's can hold conversations, contains items, and interact with items.

NonPlayableCharacter npc = new("Gary", "The antagonist of the story.");

Commands

NetAF provides commands for interacting with game elements:

  • Drop X - drop an item.
  • Examine X - allows items, characters and environments to be examined.
  • Take X - take an item.
  • Talk to X - talk to a NPC, where X is the NPC.
  • Use X on Y - use an item. Items can be used on a variety of targets. Where X is the item and Y is the target.
  • N, S, E, W, U, D - traverse through the rooms in a region.

NetAF also provides global commands to help with game flow and option management:

  • About - display version information.
  • CommandsOn / CommandsOff - toggle commands on/off.
  • Exit - exit the game.
  • Help - display the help screen.
  • KeyOn / KeyOff - turn the Key on/off.
  • Map - display the map.
  • New - start a new game.

Custom commands can be added to games without the need to extend the existing interpretation.

Interpretation

NetAF provides classes for handling interpretation of input. Interpretation is extensible with the ability for custom interpreters to be added outside of the core NetAF library.

Conversations

Conversations can be held between the player and a NPC. Conversations support multiple lines of dialogue and responses.

image

Attributes

All game assets support customisable attributes. This provides the possibility to build systems within a game, for example adding currency and trading, adding HP to enemies, MP to your character, durability to Items etc.

Rendering

NetAF provides frames for rendering the various game screens. These are fully extensible and customisable. These include:

  • Scene frame.
  • Help frame.
  • Map frame.
  • Title frame.
  • Completion frame.
  • Game over frame.
  • Transition frame.
  • Conversation frame.

Maps

Maps are automatically generated for regions and rooms, and can be viewed with the map command:

image

Maps display visited rooms, exits, player position, if an item is in a room, lower floors and more.

Getting Started

Clone the repo/pull NuGet

Clone the repo:

git clone https://github.com/benpollarduk/netaf.git

Or add the NuGet package:

dotnet add package NetAF

Hello World

// create the player. this is the character the user plays as
PlayableCharacter player = new("Dave", "A young boy on a quest to find the meaning of life.");

// create region maker. the region maker simplifies creating in game regions. a region contains a series of rooms
RegionMaker regionMaker = new("Mountain", "An imposing volcano just East of town.")
{
    // add a room to the region at position x 0, y 0, z 0
    [0, 0, 0] = new("Cavern", "A dark cavern set in to the base of the mountain.")
};

// create overworld maker. the overworld maker simplifies creating in game overworlds. an overworld contains a series or regions
OverworldMaker overworldMaker = new("Daves World", "An ancient kingdom.", regionMaker);

// create the callback for generating new instances of the game
// - information about the game
// - an introduction to the game, displayed at the star
// - asset generation for the overworld and the player
// - the conditions that end the game
// - the configuration for the game
var gameCreator = Game.Create(
    new("The Life of Dave", "A very low budget adventure.", "Ben Pollard"),
    "Dave awakes to find himself in a cavern...",
    AssetGenerator.Retained(overworldMaker.Make(), player),
    GameEndConditions.NoEnd,
    GameConfiguration.Default);

// begin the execution of the game
Game.Execute(gameCreator);

Tutorial

The quickest way to start getting to grips with NetAF is to take a look at the Getting Started page.

Example game

An example game is provided in the NetAF.Examples directory and have been designed with the aim of showcasing the various features.

Running the examples

The example applications can be used to execute the example NetAF game and demonstrate the core principals of the framework. Set the NetAF.Examples project as the start up project and then build and run to start the application.

Documentation

Please visit https://benpollarduk.github.io/NetAF-docs/ to view the NetAF documentation.

For Open Questions

Visit https://github.com/benpollarduk/NetAF/issues

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on NetAF:

Package Downloads
NetAF.Blazor

An open source library containing Blazor components to allow NetAF to be using in Blazor applications. For examples see the project website at https://github.com/benpollarduk/netaf.blazor.

NetAF.Imaging

An extension to the NetAF library to add imaging capabilities. For examples see the project website at https://github.com/benpollarduk/netaf.imaging.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.8.6 281 7/14/2025
3.8.5 161 7/14/2025
3.8.4 122 7/11/2025
3.8.3 174 7/10/2025
3.8.2 168 7/10/2025
3.8.1 169 7/10/2025
3.8.0 160 7/10/2025
3.7.14 165 7/2/2025
3.7.13 167 7/2/2025
3.7.12 173 6/30/2025
3.7.11 320 5/14/2025
3.7.10 250 5/13/2025
3.7.9 174 5/8/2025
3.7.8 166 5/8/2025
3.7.7 184 5/7/2025
3.7.6 187 5/1/2025
3.7.5 172 5/1/2025
3.7.4 158 5/1/2025
3.7.3 193 4/29/2025
3.7.2 197 4/28/2025
3.7.1 148 4/25/2025
3.7.0 135 4/25/2025
3.6.3 196 4/24/2025
3.6.2 187 4/24/2025
3.6.1 334 4/24/2025
3.6.0 221 4/22/2025
3.5.2 229 4/17/2025
3.5.1 208 4/16/2025
3.5.0 226 4/15/2025
3.4.6 213 4/15/2025
3.4.5 255 4/10/2025
3.4.4 195 4/10/2025
3.4.3 193 4/9/2025
3.4.2 218 4/8/2025
3.4.1 203 4/8/2025
3.4.0 183 4/8/2025
3.3.8 206 3/30/2025
3.3.7 190 3/30/2025
3.3.6 190 3/30/2025
3.3.5 154 3/28/2025
3.3.4 174 3/27/2025
3.3.3 172 3/27/2025
3.3.2 668 3/25/2025
3.3.1 493 3/24/2025
3.3.0 452 3/24/2025
3.2.15 258 3/18/2025
3.2.14 166 3/16/2025
3.2.13 166 3/16/2025
3.2.12 124 3/15/2025
3.2.11 105 3/15/2025
3.2.10 102 3/15/2025
3.2.9 122 3/14/2025
3.2.8 158 3/14/2025
3.2.7 174 3/13/2025
3.2.6 180 3/13/2025
3.2.5 173 3/13/2025
3.2.4 184 3/13/2025
3.2.3 176 3/13/2025
3.2.2 183 3/13/2025
3.2.1 168 3/13/2025
3.2.0 226 3/11/2025
3.1.2 187 3/11/2025
3.1.1 229 3/9/2025
3.1.0 191 3/9/2025
3.0.3 243 3/7/2025
3.0.2 237 3/7/2025
3.0.1 238 3/7/2025
3.0.0 303 3/6/2025
2.10.7 249 3/5/2025
2.10.6 250 3/4/2025
2.10.5 241 3/4/2025
2.10.4 228 3/4/2025
2.10.3 237 3/4/2025
2.10.2 250 3/4/2025
2.10.1 184 2/28/2025
2.10.0 134 2/28/2025
2.9.17 302 1/14/2025
2.9.16 139 1/10/2025
2.9.15 141 1/10/2025
2.9.14 132 1/10/2025
2.9.13 287 12/6/2024
2.9.12 142 12/6/2024
2.9.11 143 12/5/2024
2.9.10 159 12/5/2024
2.9.9 145 12/5/2024
2.9.8 144 12/4/2024
2.9.7 130 12/4/2024
2.9.6 182 12/3/2024
2.9.5 157 11/29/2024
2.9.4 135 11/29/2024
2.9.3 131 11/29/2024
2.9.2 136 11/29/2024
2.9.1 373 11/28/2024
2.9.0 253 11/26/2024
2.8.2 141 11/24/2024
2.8.1 143 11/24/2024
2.8.0 156 11/23/2024
2.7.3 141 11/22/2024
2.7.2 142 11/22/2024
2.7.1 140 11/22/2024
2.7.0 145 11/22/2024
2.6.13 145 11/21/2024
2.6.12 134 11/18/2024
2.6.11 134 11/18/2024
2.6.10 135 11/18/2024
2.6.9 145 11/17/2024
2.6.8 141 11/17/2024
2.6.7 126 11/16/2024
2.6.6 136 11/16/2024
2.6.5 151 11/15/2024
2.6.4 144 11/15/2024
2.6.3 125 11/15/2024
2.6.2 155 11/15/2024
2.6.1 143 11/14/2024
2.6.0 140 11/14/2024
2.5.7 143 11/13/2024
2.5.6 160 11/12/2024
2.5.5 139 11/12/2024
2.5.4 152 11/10/2024
2.5.3 141 11/6/2024
2.5.2 159 11/4/2024
2.5.1 140 11/3/2024
2.5.0 143 11/3/2024
2.4.5 139 11/3/2024
2.4.4 149 11/3/2024
2.4.3 138 11/3/2024
2.4.2 130 11/3/2024
2.4.1 136 11/2/2024
2.4.0 144 11/2/2024
2.3.3 179 10/29/2024
2.3.2 144 10/28/2024
2.3.1 135 10/28/2024
2.3.0 139 10/28/2024
2.2.4 152 10/27/2024
2.2.3 131 10/27/2024
2.2.2 132 10/27/2024
2.2.1 144 10/27/2024
2.2.0 146 10/27/2024
2.1.3 143 10/25/2024
2.1.2 146 10/23/2024
2.1.1 139 10/23/2024
2.1.0 153 10/22/2024
2.0.1 128 10/21/2024
2.0.0 131 10/21/2024

Added persistence for game state to and from file. Removed ability for Items to morph and for Exits to be added or removed from a Room except during construction.