Show / Hide Table of Contents

    Interface IFaceDirectionComponent

    Gives the ability for a character to change the direction he/she is facing.

    Inherited Members
    IComponent.Name
    IComponent.Entity
    IComponent.RegistrationType
    IComponent.Init(IEntity, Type)
    IComponent.AfterInit()
    System.IDisposable.Dispose()
    System.ComponentModel.INotifyPropertyChanged.PropertyChanged
    Namespace: AGS.API
    Assembly: AGS.API.dll
    Syntax
    [RequiredComponent(typeof(IAnimationComponent), true)]
    [RequiredComponent(typeof(ITranslateComponent), true)]
    public interface IFaceDirectionComponent : IComponent, IDisposable, INotifyPropertyChanged

    Properties

    | Improve this Doc View Source

    CurrentDirectionalAnimation

    Gets or sets the current directional animation used by the character to face to different directions.

    Declaration
    IDirectionalAnimation CurrentDirectionalAnimation { get; set; }
    Property Value
    Type Description
    IDirectionalAnimation

    The current directional animation.

    Examples
    cEgo.CurrentDirectionalAnimation = cEgo.Outfit.IdleAnimation;
    await cEgo.FaceDirectionAsync(Direction.Right); //character is facing right doing nothing (idle).
    cEgo.CurrentDirectionalAnimation = dancingAnimation;
    awaut cEgo.FaceDirectionAsync(Direction.Down); //character is now doing a dance right to our face!
    | Improve this Doc View Source

    Direction

    Gets the current direction that the character is facing. Down -> the character is looking directly at the camera. Up -> The character's back is facing the camera.

    Declaration
    Direction Direction { get; }
    Property Value
    Type Description
    Direction

    The direction.

    Examples
    if (cEgo.Direction == Direction.Down)
    {
        await cEgo.SayAsync("I'm looking right at you!");
    }

    Methods

    | Improve this Doc View Source

    FaceDirectionAsync(Direction)

    Changes the direction the character is facing to asynchronously (without blocking the game).

    Declaration
    Task FaceDirectionAsync(Direction direction)
    Parameters
    Type Name Description
    Direction direction

    The direction to face.

    Returns
    Type Description
    System.Threading.Tasks.Task

    The task that should be awaited on to signal completion.

    Examples
    private async Task faceDown()
    {
        await cEgo.FaceDirectionAsync(Direction.Down);
    }
    private async Task faceDownAndDoStuffInBetween()
    {
        Task faceDirectionCompleted = cEgo.FaceDirectionAsync(Direction.Down);
        await cSomeOtherDude.SayAsync("Let me know when you finished turning around..");
        await faceDirectionCompleted;;
        await cEgo.SayAsync("All done!");
    }
    | Improve this Doc View Source

    FaceDirectionAsync(IObject)

    Changes the direction the character is facing to asynchronously (without blocking the game), so it will face the specified object.

    Declaration
    Task FaceDirectionAsync(IObject obj)
    Parameters
    Type Name Description
    IObject obj

    The object to face.

    Returns
    Type Description
    System.Threading.Tasks.Task

    The task that should be awaited on to signal completion.

    Examples
    private async Task lookAtMirror()
    {
        await cEgo.FaceDirectionAsync(oMirror);
    }
    private async Task lookAtMirrorAndDoStuffInBetween()
    {
        Task faceMirrorCompleted = cEgo.FaceDirectionAsync(oMirror);
        await cSomeOtherDude.SayAsync("Let me know when you see the mirror.");
        await faceMirrorCompleted;
        await cEgo.SayAsync("Yes, I see it now!");
    }
    | Improve this Doc View Source

    FaceDirectionAsync(Single, Single)

    Changes the direction the character is facing to asynchronously (without blocking the game), so it will face (x,y).

    Declaration
    Task FaceDirectionAsync(float x, float y)
    Parameters
    Type Name Description
    System.Single x

    The x position.

    System.Single y

    The y position.

    Returns
    Type Description
    System.Threading.Tasks.Task

    The task that should be awaited on to signal completion.

    Examples
    private async Task face100100()
    {
        await cEgo.FaceDirectionAsync(100f,100f);
    }
    | Improve this Doc View Source

    FaceDirectionAsync(Single, Single, Single, Single)

    Changes the direction the character is facing to asynchronously (without blocking the game), so it will face (toX,toY), assuming it is currently facing (fromX,fromY).

    Declaration
    Task FaceDirectionAsync(float fromX, float fromY, float toX, float toY)
    Parameters
    Type Name Description
    System.Single fromX

    From x.

    System.Single fromY

    From y.

    System.Single toX

    To x.

    System.Single toY

    To y.

    Returns
    Type Description
    System.Threading.Tasks.Task
    Examples
    private async Task armyLookOneByOne()
    {
        await cGeneral.SayAsync("Everybody, look at the way I'm looking.");
        await cGeneral.FaceDirectionAsync(150f, 150f);
        foreach (var soldier in soldiers)
        {
            await soldier.FaceDirectionAsync(cGeneral.X, cGeneral.Y, 150f, 150f); //Awaiting each soldier before going over to the next, meaning the will change directions one by one.
        }    
        await cGeneral.SayAsync("Took you long enough!");    
    }
    private async Task armyLookAtTheSameTime()
    {
        await cGeneral.SayAsync("Everybody, look at the way I'm looking.");
        await cGeneral.FaceDirectionAsync(150f, 150f);
        List{Task} tasks = new List{Task}(soldiers.Count);
        foreach (var soldier in soldiers)
        {
            tasks.Add(soldier.FaceDirectionAsync(cGeneral.X, cGeneral.Y, 150f, 150f)); 
        }
        await Task.WhenAll(tasks);
        await cGeneral.SayAsync("Took you long enough!");
    }
    private async Task armyLookAtRandomTimes()
    {
        await cGeneral.SayAsync("Everybody, look at the way I'm looking.");
        await cGeneral.FaceDirectionAsync(150f, 150f);
        List{Task} tasks = new List{Task}(soldiers.Count);
        foreach (var soldier in soldiers)
        {
            tasks.Add(Task.Delay(MathUtils.Random().Next(10,50)).ContinueWith(soldier.FaceDirectionAsync(cGeneral.X, cGeneral.Y, 150f, 150f))); 
        }
        await Task.WhenAll(tasks);
        await cGeneral.SayAsync("Took you long enough!");
    }

    See Also

    IComponent
    • Improve this Doc
    • View Source
    Back to top Generated by DocFX