Beispiel #1
0
        private void UpdateTarget(ZombieAgent zombie)
        {
            if (zombie.state != ZombieAgent.State.Idle)
            {
                // If we have an active target wait for arrival.
                if (!zombie.ReachedTarget())
                {
                    return;
                }

                zombie.AddVisitedZone(zombie.target);
            }

            if (_state.IsBloodMoon)
            {
                zombie.target = _playerZones.GetRandomClosest(zombie.pos, _prng, 200.0f, null);
                if (zombie.target == null)
                {
                    zombie.target = GetNextTarget(zombie);
                }
            }
            else
            {
                zombie.target = GetNextTarget(zombie);
            }

            zombie.targetPos = GetTargetPos(zombie.target);
            zombie.state     = ZombieAgent.State.Wandering;
        }
Beispiel #2
0
        private void UpdateTarget(ZombieAgent zombie, WorldEvent ev)
        {
            if (ev != null)
            {
                var dist = Vector3.Distance(zombie.pos, ev.Pos);
                if (dist <= ev.Radius)
                {
                    Vector3 soundDir = new Vector3();
                    soundDir.x = _prng.Get(-1.0f, 1.0f);
                    soundDir.z = _prng.Get(-1.0f, 1.0f);

                    soundDir.Normalize();
                    soundDir *= (dist * 0.75f);

                    zombie.targetPos = ev.Pos + soundDir;

#if DEBUG
                    Log.Out("Reacting to sound at {0}", ev.Pos);
#endif
                    return;
                }
            }

            // If we have an activate target wait for arrival.
            if (!zombie.ReachedTarget())
            {
                return;
            }

            if (_worldState.IsBloodMoon())
            {
                zombie.target = _playerZones.GetRandomClosest(zombie.pos, _prng, 200.0f);
                if (zombie.target == null)
                {
                    zombie.target = GetNextTarget(zombie);
                }
            }
            else
            {
                zombie.target = GetNextTarget(zombie);
            }

            zombie.targetPos = GetTargetPos(zombie.target);
        }