Coder Social home page Coder Social logo

text-event-toolkit's Introduction

Text Event Toolkit

Setup:

Install the package.

Set up code to trigger events.

Write action methods.

Create events in the editor window

Triggering events:

Events can be created by calling TextEvent.CreateRandom(), TextEvent.CreateRandomWithLabel(string) or CreateFromIndex(int). Once an event is created it can be presented to the player by calling EnterEvent()

Example

TextEvent.CreateRandom().EnterEvent();

or

TextEvent.CreateRandomWithLabel("Combat").EnterEvent();

Action system:

Methods can be exposed to the editor window by decorating them with the TextEventAction atribute, passing in a friendly name for the action. int, float bool and string arguments are supported, the name and default values of the arguments are also exposed to the editor window. These methods can be set in the editor window to be triggered with a result.

Example:

using DevonMillar.TextEvents;

public class TextEventActions
{
    static Player player;

    [TextEventAction("Damage player")]
    public static void DamagePlayer(float damage = 5.0f)
    {
        player.Damage(damage);
    }
    [TextEventAction("Give item")]
    public static void GiveItem(string item)
    {
        player.GiveItem(item);
    }
    [TextEventAction("Add status effect")]
    public static void AddStatusEffect(string effect)
    {
        player.AddStatusEffect(effect);
    }
    [TextEventAction("Remove status effect")]
    public static void RemoveStatusEffect(string effect)
    {
        player.RemoveStatusEffect(effect);
    }
}

Actions can now be added to results in the editor window

image

Designing events

The text event editor can be opened by clicking the "Text Event Editor" button in the Tools menu.

Structure of an event:

Events contain choices, choices contain any number of results. Results contain any number of actions. A result is chosen at random when a choice is picked by the player.

Event > Choice > Result > Actions

Choices

Choices are the options that are given to the player in the event. Choices can contain any number of results. Choices can be folded in the editor image

Results

One child result is chosen at random when a choice is picked by the player.

Each result has a "Chance" variable that affects the chance of it being selected. A result can contain it's own text and any number of actions which will be executed if chosen. Results text is shown to the player if picked. If a result has no text the event will be exited as soon as it is chosen. Results can also contain other choices for branching choice events. image

Actions

Actions are the effects that a result has. These are set up per project. They are executed when the parent result is chosen. image

The editor window

image

Limitations:

Action methods being removed from the codebase while they are in use will throw when trying to trigger the action

The editor tool may need to be closed and reopened on scirpt compilation.

Action methods must be public and static, and their arguments only support int, float, bool, string

text-event-toolkit's People

Contributors

woofwoofgrr avatar milazazo avatar

Watchers

 avatar

Forkers

milazazo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.