Beispiel #1
0
        /// <summary>
        ///     Ticks the target prey if there is any selected.
        /// </summary>
        /// <returns>FALSE if the target prey ran away, TRUE if everything is normal.</returns>
        private void TickTargetAwareness()
        {
            // Check if there is a target at all to tick.
            if (_target == null)
            {
                return;
            }

            // There is a change we will not tick awareness this time.
            if (GameSimulationApp.Instance.Random.NextBool())
            {
                return;
            }

            // Check target ticking if not null and shooting word not none.
            if ((_target != null) && (ShootingWord != HuntWord.None))
            {
                _target.TickTarget();
            }

            // Check if the target wants to run away from the hunter.
            if (!_target.ShouldRunAway)
            {
                return;
            }

            // Add the prey to list of things that got away.
            _preyEscaped.Add(new PreyItem(_target));

            // Fire event that hunting mode will attach form in response to.
            TargetFledEvent?.Invoke(_target);

            // Reset target and shooting word.
            ClearTarget();
        }
        /// <summary>
        /// Tick the current robot target. Check for the key word and if the robot has retreated.
        /// </summary>
        private void TickAwareness()
        {
            // Check if there's an active target. Roll the die to continue.
            if (_robotTarget == null || GameCore.Instance.Random.NextBool())
            {
                return;
            }

            // Check that there's an active hunting word, if not pick one.
            if ((_robotTarget != null) && (HuntWord != HuntingWord.None))
            {
                _robotTarget.TickTarget();
            }

            // Trigger an event if the robot has retreated.
            if (!_robotTarget.ShouldRetreat)
            {
                return;
            }
            _robotsEscaped.Add(new Robot(_robotTarget));
            TargetFledEvent?.Invoke(_robotTarget);
            ClearTarget();
        }