using System;
using System.Collections.Generic;
using UnityEngine;
namespace EasyTalk.Character
{
///
/// Defines attributes for a character, such as their name, icons, and portrayal images/spritesheets.
///
[Serializable]
public class CharacterDefinition
{
///
/// The name of the character.
///
[SerializeField]
private string characterName;
///
/// A collection of displayable icons for the character.
///
[SerializeField]
private List iconsSprites = new List();
///
/// A collection of displayable portraits for the character.
///
[SerializeField]
private List portrayalSprites = new List();
///
/// Indicates whether the character should use their own unique gibberish audio, rather than the defaults.
///
[SerializeField]
private bool overrideDefaultGibberishAudio = false;
///
/// The collection of gibberish audio clips used for the character.
///
[SerializeField]
private List gibberishAudioClips = new List();
///
/// Gets or sets the name of the character.
///
public string CharacterName
{
get { return characterName; }
set { this.characterName = value; }
}
///
/// GEts the List of icons for the character.
///
public List IconsSprites
{
get { return iconsSprites; }
}
///
/// Gets the List of portraits for the character.
///
public List PortrayalSprites
{
get { return portrayalSprites; }
}
public bool OverrideDefaultGibberishAudio
{
get { return overrideDefaultGibberishAudio; }
set { overrideDefaultGibberishAudio = value; }
}
///
/// Gets the List of gibberish audio clips used by the character.
///
public List GibberishAudioClips
{
get { return gibberishAudioClips; }
}
///
/// Returns the character's icon which has the specified ID, if it exists.
///
/// The ID of the icon to retrieve.
/// The specified icon, if it exists; otherwise null.
public AnimatableDisplayImage GetIconSprite(string id)
{
foreach(AnimatableDisplayImage icon in iconsSprites)
{
if(icon.ID.Equals(id))
{
return icon;
}
}
return null;
}
///
/// Returns the character's portrait which has the specified ID, if it exists.
///
/// The ID of the portrait to retrieve.
/// The specified portrait, if it exists; otherwise null.
public AnimatableDisplayImage GetPortrayalSprite(string id)
{
foreach (AnimatableDisplayImage sprite in portrayalSprites)
{
if (sprite.ID.Equals(id))
{
return sprite;
}
}
return null;
}
}
///
/// Defines attributes of an image, which can also be animated if it includes more than one sprite.
///
[Serializable]
public class AnimatableDisplayImage
{
///
/// The ID used to reference the image.
///
[SerializeField]
private string id = "";
///
/// The default target display ID on which the image should be displayed.
///
[SerializeField]
private string targetId = "";
///
/// The sprite sequence used for the image's animation, or a single image in the case of non-animated images.
///
[SerializeField]
private List sprites = new List();
///
/// When set to true, the initial image will be chosen from the sprite list randomly when shown.
///
[SerializeField]
private bool randomizeImageWhenShown = false;
///
/// The animation mode used for the animation sequence when multiple sprites are defined.
///
[SerializeField]
private AnimationMode animationMode = AnimationMode.NONE;
///
/// The number of times per second that the image index will be updated.
///
[SerializeField]
private float frameRate = 16;
///
/// Gets or sets the ID of the image.
///
public string ID
{
get { return id; }
set { this.id = value; }
}
///
/// Gets or sets the default target display ID for the image.
///
public string TargetID
{
get { return targetId; }
set { this.targetId = value; }
}
///
/// Gets or sets the List of sprites for the image's sprite sequence.
///
public List Sprites
{
get { return sprites; }
set { this.sprites = value; }
}
///
/// Gets or sets whether the starting image will be selected randomly from the sprite list when shown.
///
public bool RandomizeImageWhenShown
{
get { return randomizeImageWhenShown; }
set { this.randomizeImageWhenShown = value; }
}
///
/// Gets or sets the sprite sequence animation mode to use.
///
public AnimationMode AnimationMode
{
get { return animationMode; }
set { this.animationMode = value; }
}
///
/// Gets or sets the frame rate (in frames per second) for the animation.
///
public float FrameRate
{
get { return frameRate; }
set { this.frameRate = value; }
}
}
///
/// Defines animation modes for AnimatableDisplayImages.
///
[Serializable]
public enum AnimationMode
{
NONE, LOOP, PING_PONG, RANDOM
}
}