Interface ISayComponent
A component which adds the ability to speak for an entity.
Inherited Members
Namespace: AGS.API
Assembly: AGS.API.dll
Syntax
[RequiredComponent(typeof(ITranslateComponent), false)]
[RequiredComponent(typeof(IHasRoomComponent), false)]
[RequiredComponent(typeof(IOutfitComponent), true)]
[RequiredComponent(typeof(IFaceDirectionComponent), true)]
public interface ISayComponent : IComponent, IDisposable, INotifyPropertyChanged
Properties
| Improve this Doc View SourceOnBeforeSay
An event which allows you to manipulate the text label just before it is being rendered, and to allow you to have a custom skip text implementation.
Declaration
IBlockingEvent<BeforeSayEventArgs> OnBeforeSay { get; }
Property Value
Type | Description |
---|---|
IBlockingEvent<BeforeSayEventArgs> | The on before say. |
SpeechConfig
Gets the speech configuration.
Declaration
ISayConfig SpeechConfig { get; }
Property Value
Type | Description |
---|---|
ISayConfig | The speech config. |
Methods
| Improve this Doc View SourceSayAsync(String, Nullable<PointF>, Nullable<PointF>)
Say the specified text asynchronously. This basically does the following:
- Puts text on the screen for some time
- Change the character animation to the speaking animation
- Optionally display a portrait of the character
- Optionally play an audio clip You can configure how the text is rendered (color, font, etc: see text rendering section for more on the all the options that you have for text rendering), when the text is skipped (by time and how much, by mouse, both, or none which means you implement text skipping yourself), a label to host the text with a border(see the section about borders) and background color, and a text offset to offset the location of the text.That offset will be relative to the default text display location which will be selected by the engine: The engine, by default, tries to place the text above the character and a little to the side, unless the text won't fit the screen, then it changes the location to ensure the text fits the screen. If you don't like that behavior you can implement your own text location by implementing the ISayLocationProvider interface (and hooking it up, see the section about customizability).
As for the portrait, you can configure the object which shows the portrait(this is a standard object, so it can has everything a normal object has, including animations, scaling, rotations, etc), plus a strategy on where to position the portrait(SpeakerPosition- on the top, either left or right based on where the speaker is standing, Alternating- top right, then top left, then top right, etc or Custom which leaves the portrait positioning to you) and custom offsets for both the portrait and for the text from the portrait.
In order to play an audio clip, the text you pass to the speech method should have a number at the beginning prefixed by an ampersand, for example, "&17 Hello there!". If the number exists, the engine will look for an audio file with the first four capital letters of your character's id followed by the number. So if the line was said by "Christopher", the engine will look for the file "CHRI17". Those files should be placed in a special folder, under Assets -> Speech -> English. Note: In future revisions we're planning on introducing multi-language support, and also other ways of building the speech "database". If the engine does not find the file it will not play an audio clip, and in any way the "&17" will be stripped away from the text and will not be displayed on screen.
Declaration
Task SayAsync(string text, PointF? textPosition = default(PointF? ), PointF? portraitPosition = default(PointF? ))
Parameters
Type | Name | Description |
---|---|---|
System.String | text | Text. |
System.Nullable<PointF> | textPosition | Optional position (bottom-left by default, subscribe OnBeforeSay and change the Pivot of the label to override it) for where the text will be placed. If not provided, the engine will place the text above the character's head. The interface for selecting the default text position (if none is passed here) is ISayLocationProvider and you can override it if needed to provide default text (and portrait) locations. |
System.Nullable<PointF> | portraitPosition | Optional position for where the portrait will be placed (if there is a portrait configured). If no position provided the engine will place the portrait based on the portrait configuration (PortraitConfig), assuming there is a portrait configuration. The interface for selecting the default portrait position (if none is passed here) is ISayLocationProvider and you can override it if needed to provide default portrait (and text) locations. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Examples
await cHero.SayAsync("&17 Hello there!"); //Will say "Hello there!" and will play "JASO17.ogg" (assuming the character name is "Jason" and JASO17.ogg exists in Assets/Speech/English)
Task waitForTalk = cHero.SayAsync("Walking Home!");
await cHero.WalkAsync(home); //character will walk and talk at the same time.
await waitForTalk; //Waiting for the talk to complete before moving to the next setnence.
await cHero.SayAsync("And, I'm home!", (200, 100)); //The text for this sentence will be placed at co-ordinates (200, 100) instead of above the character's head.