Esempio n. 1
0
 /// <summary>
 /// Copies the state from another <see cref="ActorAction"/>.
 /// </summary>
 /// <param name="other">An <see cref="ActorAction"/> to copy state from.</param>
 public void CopyFrom(ActorAction other)
 {
     this.Value     = other.Value;
     this.LastValue = other.LastValue;
     this.Tolerance = other.Tolerance;
     this.HeldTime  = other.HeldTime;
     this.Icon      = other.Icon;
 }
Esempio n. 2
0
        /// <summary>
        /// Activates an action by copying values from another.
        /// </summary>
        /// <param name="name">The name of the action to activate.</param>
        /// <param name="other">The source action.</param>
        public void Activate(string name, ActorAction other)
        {
            ActorAction action = this.GetOrCreateAction(name);

            if (action != null)
            {
                action.CopyFrom(other);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Deactives an action.
        /// </summary>
        /// <param name="name">The name of the action.</param>
        public void Deactivate(string name)
        {
            ActorAction action = this.GetOrCreateAction(name);

            if (action != null)
            {
                action.Value = Vector2.zero;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Actives an action.
        /// </summary>
        /// <param name="name">The name of the action.</param>
        /// <param name="value">The value to activate with.</param>
        public void Activate(string name, Vector2 value)
        {
            ActorAction action = this.GetOrCreateAction(name);

            if (action != null)
            {
                action.Value = value;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Determines if an action was active in the last frame.
        /// </summary>
        /// <param name="name">The name of the action.</param>
        /// <returns>True if the action was active last frame.</returns>
        public bool WasActive(string name)
        {
            ActorAction action = this.GetOrCreateAction(name);

            return(action != null && action.WasActive);
        }
Esempio n. 6
0
        /// <summary>
        /// Gets the icon assigned to an action.
        /// </summary>
        /// <param name="name">The name of the action.</param>
        /// <returns>The icon assigned to an action.</returns>
        public Sprite GetIcon(string name)
        {
            ActorAction action = this.GetOrCreateAction(name);

            return(action != null ? action.Icon : null);
        }
Esempio n. 7
0
        /// <summary>
        /// Gets the non-normalized value of an action. If you are looking for
        /// the normalized value use <see cref="IActorController.GetDirection"/>.
        /// </summary>
        /// <param name="name">The name of the action.</param>
        /// <returns>The value of an action.</returns>
        public Vector2 GetVector(string name)
        {
            ActorAction action = this.GetOrCreateAction(name);

            return(action != null ? action.Value : Vector2.zero);
        }
Esempio n. 8
0
        /// <summary>
        /// Clears an action's hold time and value.
        /// </summary>
        /// <param name="name">The name of the action.</param>
        public void Flush(string name)
        {
            ActorAction action = this.GetOrCreateAction(name);

            action.Flush();
        }
Esempio n. 9
0
        /// <summary>
        /// Is not active this frame but was active last frame.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public bool IsReleased(string name)
        {
            ActorAction action = this.GetOrCreateAction(name);

            return(action != null && !action.IsActive && action.WasActive);
        }
Esempio n. 10
0
        /// <summary>
        /// Returns true if the action has been active for the given duration.
        /// </summary>
        /// <param name="name">The name of the action.</param>
        /// <param name="duration">A duration in seconds.</param>
        /// <returns>True if the action has been active for the given duration.</returns>
        public bool IsHeldFor(string name, float duration)
        {
            ActorAction action = this.GetOrCreateAction(name);

            return(action != null && action.HeldTime > duration);
        }
Esempio n. 11
0
        public Vector2 GetVector(string actionName)
        {
            ActorAction action = this.GetOrCreateAction(actionName);

            return(action?.Value ?? Vector2.zero);
        }
Esempio n. 12
0
        public bool IsTriggered(string actionName)
        {
            ActorAction action = this.GetOrCreateAction(actionName);

            return(action != null && action.IsActive && !action.WasActive);
        }
Esempio n. 13
0
        public bool IsActive(string actionName)
        {
            ActorAction action = this.GetOrCreateAction(actionName);

            return(action != null && action.IsActive);
        }
Esempio n. 14
0
        public void Activate(string actionName, ActorAction other)
        {
            ActorAction action = this.GetOrCreateAction(actionName);

            action?.CopyFrom(other);
        }
Esempio n. 15
0
        public Sprite GetIcon(string actionName)
        {
            ActorAction action = this.GetOrCreateAction(actionName);

            return(action?.Icon);
        }