Beispiel #1
0
        /// <summary>
        /// Create a new StopMovementAction.
        /// </summary>
        /// <param name="_charDriver">The driver of the character that will perform the attack.</param>
        /// <param name="_zeroVelocity">Also request to remove any X and Y velocity from character.</param>
        public StopMovementAction(ICharacterDriver _charDriver, bool _zeroVelocity = false)
        {
            charDriver   = _charDriver;
            zeroVelocity = _zeroVelocity;

            _Action = StopMovementExec;
        }
        /// <summary>
        /// Create a new SetInvencibilityAction.
        /// </summary>
        /// <param name="_charDriver">The driver of the character that will be configured.</param>
        /// <param name="_invencible">Character invencibility property value.</param>
        public SetInvencibilityAction(ICharacterDriver _charDriver, bool _invencible = true)
        {
            charDriver = _charDriver;
            invencible = _invencible;

            _Action = SetInvencibilityExec;
        }
Beispiel #3
0
        /// <summary>
        /// Create a new MoveForwardAction.
        /// </summary>
        /// <param name="_charDriver">The driver of the character that will perform the attack.</param>
        /// <param name="_run">The character movement is to run?</param>
        public MoveForwardAction(ICharacterDriver _charDriver, bool _run = false)
        {
            charDriver = _charDriver;
            run        = _run;

            _Action = MoveForwardExec;
        }
		/// <summary>
		/// Create a new WaitSomeTimeAction.
		/// </summary>
		/// <param name="_charDriver">The character that will wait.</param>
		/// <param name="_cooldown">The cooldown resource that controls the waiting.</param>
		public WaitSomeTimeAction(ICharacterDriver _charDriver, Cooldown _cooldown)
		{
			charDriver = _charDriver;
			cooldown = _cooldown;

			_Action = WaitSomeTimeExec;
		}
        /// <summary>
        /// Create a new AttackAAction.
        /// </summary>
        /// <param name="_charDriver">The driver of the character that will perform the attack.</param>
        /// <param name="_GetTargetFunc">A Func to retrieve the current target transform.</param>
        /// <param name="_reverse">Set the back to the target isnted of the face?</param>
        public SDSetFaceToTarget(ICharacterDriver _charDriver, Func <Vector3> _GetTargetFunc, bool _reverse = false)
        {
            charDriver    = _charDriver;
            GetTargetFunc = _GetTargetFunc;
            reverse       = _reverse;

            _Action = SDSetFaceToTargetExec;
        }
 /// <summary>
 /// Create a new IsTargetInRangeConditional.
 /// </summary>
 /// <param name="_charDriver">The character driver from the onwer of this action.</param>
 /// <param name="_targetLayer">The target layer mask (to check collisions).</param>
 /// <param name="_range">The range (as a box).</param>
 public IsTargetInRangeConditional(ICharacterDriver _charDriver, LayerMask _targetLayer, Vector2 _range)
 {
     charDriver  = _charDriver;
     targetLayer = _targetLayer;
     range       = _range;
     offset      = Vector2.zero;
     _Bool       = IsTargetInRangeTest;
 }
		/// <summary>
		/// Create a new MoveToDestnAction.
		/// </summary>
		/// <param name="_charDriver">The driver of the character that will move.</param>
		/// <param name="_GetDestnFunc">A Func to retrieve the current destination.</param>
		/// <param name="_run">If the character is supposed to run (default is to walk).</param>
		/// <param name="_axisMvmt">If the character is supposed to move up and down to reach its destination.</param>
		public MoveToDestnAction(ICharacterDriver _charDriver, Func<Vector3> _GetDestnFunc, bool _run = false, bool _axisMvmt = false)
		{
			charDriver = _charDriver;
			GetDestnFunc = _GetDestnFunc;
			run = _run;
			axisMvmt = _axisMvmt;

			_Action = MoveToDestnExec;
		}
 /// <summary>
 /// Create a new IsTargetInRangeConditional.
 /// </summary>
 /// <param name="_charDriver">The character driver from the onwer of this action.</param>
 /// <param name="_targetLayer">The target layer mask (to check collisions).</param>
 /// <param name="_range">The range (as a box).</param>
 /// <param name="_offset">Add an offset to the collision box position.</param>
 public IsTargetInRangeConditional(ICharacterDriver _charDriver, LayerMask _targetLayer, Vector2 _range, Vector2 _offset)
 {
     charDriver  = _charDriver;
     targetLayer = _targetLayer;
     range       = _range;
     radius      = 0;
     offset      = _offset;
     _Bool       = IsTargetInRangeTest;
 }
 /// <summary>
 /// Create a new IsTargetInRangeConditional.
 /// </summary>
 /// <param name="_charDriver">The character driver from the onwer of this action.</param>
 /// <param name="_targetLayer">The target layer mask (to check collisions).</param>
 /// <param name="_radius">The range (as a circle).</param>
 /// <param name="_offset">Add an offset to the collision box position.</param>
 public IsTargetInRangeConditional(ICharacterDriver _charDriver, LayerMask _targetLayer, float _radius, Vector2 _offset)
 {
     charDriver  = _charDriver;
     targetLayer = _targetLayer;
     radius      = _radius;
     range       = Vector2.zero;
     offset      = _offset;
     _Bool       = IsTargetInRangeTest;
 }
Beispiel #10
0
        /// <summary>
        /// Create a new IsArrivedAtDestnConditional.
        /// </summary>
        /// <param name="_charDriver">The character driver (transform) to check.</param>
        /// <param name="_GetDestnFunc">A Func to retrieve the current destination.</param>
        /// <param name="_checkAxis">Will check both, horizontal and vertical positioning. (default is false; check only
        /// horizontal axis).</param>
        public IsArrivedAtDestnConditional(ICharacterDriver _charDriver, Func <Vector3> _GetDestnFunc, bool _checkAxis = false, float _offset = Offset)
        {
            charDriver   = _charDriver;
            GetDestnFunc = _GetDestnFunc;
            checkAxis    = _checkAxis;
            offset       = _offset;

            _Bool = IsArrivedAtDestinationTest;
        }
Beispiel #11
0
        /// <summary>
        /// Create a new AttackAAction.
        /// </summary>
        /// <param name="_charDriver">The driver of the character that owns the action. Use to calculate orientation (left or right).</param>
        /// <param name="_GetTargetFunc">A Func to retrieve the current target GameObject.</param>
        /// <param name="_SetCurrDestnIdx">A method to set the current destination index.</param>
        /// <param name="offset">The picked position will be "curr target pos" plus this offset.</param>
        public SDPickPointInFrontOfTargetAction(ICharacterDriver _charDriver, Func <GameObject> _GetTargetFunc, Action <Vector3> _SetDestnFunc, Vector2 _offset)
        {
            charDriver    = _charDriver;
            GetTargetFunc = _GetTargetFunc;
            SetDestnFunc  = _SetDestnFunc;
            offset        = _offset;

            _Action = PickPointInFrontOfTargetExec;
        }
Beispiel #12
0
        // Use this for initialization
        protected override void Start()
        {
            charDriver = GetComponent <ICharacterDriver>();
            // Check if range was initialized.
            Assert.IsTrue(range != Vector2.zero, "Range parameter was not initialized.");

            // Check if there at least 2 points to be patrolled.
            Assert.IsNotNull <Transform[]>(pointsToPatrol);
            Assert.IsTrue(pointsToPatrol.Length >= 2);
            // Check if current destn index is valid.
            Assert.IsTrue((startingPointToPatrolIdx >= 0) && (startingPointToPatrolIdx < pointsToPatrol.Length));

            base.Start();
        }
Beispiel #13
0
        public static void DisplayAttackAreaCircle(ICharacterDriver driver, float radius, Vector2 offset)
        {
            RaycastOrigins raycastOrigins = driver.GetRaycastOrigins();
            bool           isFacingRight  = driver.IsFacingRight();

            Vector2 center = ((isFacingRight) ? raycastOrigins.rightCenter : raycastOrigins.leftCenter);

            // Add offset.
            center.x += offset.x * ((isFacingRight) ? 1 : -1);
            center.y += offset.y;

            // Centralize.
            center.x += (radius / 2) * ((isFacingRight) ? 1 : -1);
            Gizmos.DrawWireSphere(center, radius);
        }
Beispiel #14
0
        /// <summary>
        /// Display the attack area.
        /// </summary>
        /// <param name="driver">Character's driver.</param>
        /// <param name="range">Attack range.</param>
        public static void DisplayAttackArea(ICharacterDriver driver, Vector2 range, Vector2 offset)
        {
            RaycastOrigins raycastOrigins = driver.GetRaycastOrigins();
            bool           isFacingRight  = driver.IsFacingRight();

            Vector2 center = ((isFacingRight) ? raycastOrigins.rightCenter : raycastOrigins.leftCenter);

            // Add offset.
            center.x += offset.x * ((isFacingRight) ? 1 : -1);
            center.y += offset.y;

            // Centralize the central point.
            center.x += (range.x / 2) * ((isFacingRight) ? 1 : -1);
            Gizmos.DrawWireCube(center, new Vector3(range.x, range.y, 0));
        }
Beispiel #15
0
 /// <summary>
 /// Create a new ProvokeAAction.
 /// </summary>
 /// <param name="_charDriver">The driver of the character that will perform the provoke.</param>
 public ProvokeAAction(ICharacterDriver _charDriver)
 {
     charDriver = _charDriver;
     _Action    = ProvokeAExec;
 }
Beispiel #16
0
 /// <summary>
 /// Create a new JumpAction.
 /// </summary>
 /// <param name="_charDriver">The driver of the character that will perform the attack.</param>
 public JumpAction(ICharacterDriver _charDriver)
 {
     charDriver = _charDriver;
     _Action    = JumpExec;
 }
		/// <summary>
		/// Create a new IsGroundedConditional.
		/// </summary>
		/// <param name="_charDriver">The driver of the character to check if it is grounded.</param>
		public IsGroundedConditional(ICharacterDriver _charDriver)
		{
			charDriver = _charDriver;
			_Bool = IsGroundedTest;
		}
		/// <summary>
		/// Create a new IsHurtConditional.
		/// </summary>
		/// <param name="_charDriver">The driver of the character to check if it is hurt.</param>
		public IsHurtConditional(ICharacterDriver _charDriver)
		{
			charDriver = _charDriver;
			_Bool = IsHurtTest;
		}
		/// <summary>
		/// Create a new IsExecutingActionConditional.
		/// </summary>
		/// <param name="_charDriver">The driver of the character to check.</param>
		public IsExecutingActionConditional(ICharacterDriver _charDriver)
		{
			charDriver = _charDriver;
			_Bool = IsExecutingActionTest;
		}
Beispiel #20
0
 /// <summary>
 /// Create a new SpecialAttackAAction.
 /// </summary>
 /// <param name="_charDriver">The driver of the character that will perform the attack.</param>
 public SpecialAttackAAction(ICharacterDriver _charDriver) : base(_charDriver)
 {
 }
Beispiel #21
0
		/// <summary>
		/// Create a new IsProvokingConditional.
		/// </summary>
		/// <param name="_charDriver">The driver of the character to check.</param>
		public IsProvokingConditional(ICharacterDriver _charDriver)
		{
			charDriver = _charDriver;
			_Bool = IsProvokingTest;
		}
Beispiel #22
0
 /// <summary>
 /// Create a new AttackAAction.
 /// </summary>
 /// <param name="_charDriver">The driver of the character that will perform the attack.</param>
 public AttackAAction(ICharacterDriver _charDriver)
 {
     charDriver = _charDriver;
     _Action    = AttackAExec;
 }
Beispiel #23
0
 /// <summary>
 /// Create a new AttackBAction.
 /// </summary>
 /// <param name="_charDriver">The driver of the character that will perform the attack.</param>
 public AttackBAction(ICharacterDriver _charDriver) : base(_charDriver)
 {
 }
		/// <summary>
		/// Create a new IsDeadConditional.
		/// </summary>
		/// <param name="_charDriver">The driver of the character to check if it is dead.</param>
		public IsDeadConditional(ICharacterDriver _charDriver)
		{
			charDriver = _charDriver;
			_Bool = IsDeadTest;
		}
Beispiel #25
0
 /// <summary>
 /// Create a new ExecActionAction.
 /// </summary>
 /// <param name="_charDriver">The driver of the character that will perform the provoke.</param>
 public ExecActionAction(ICharacterDriver _charDriver)
 {
     charDriver = _charDriver;
     _Action    = ExecActionExec;
 }