Exemplo n.º 1
0
        public xxxFollowLeader(IBoid host)
        {
            _host     = host;
            _flockers = new List <IBoid>();

            _behind              = new Boid();
            _behind._position    = _host._Position;
            _behind._velocity    = _host._Velocity;
            _behind._maxVelocity = _host._MaxVelocity;

            _ahead              = new Boid();
            _ahead._position    = _host._Position;
            _ahead._velocity    = _host._Velocity;
            _ahead._maxVelocity = _host._MaxVelocity;

            _arrive     = new Arrive(_host);
            _evade      = new Evade(_host);
            _separation = new Separation(_host);
            _aligement  = new Aligement(_host);

            _separation._boids = _flockers;
            _aligement._boids  = _flockers;

            _aligement._RADIUS  = 15f;
            _separation._RADIUS = 3f;

            _aligement._WEIGHT  = 1f;
            _separation._WEIGHT = 9f;
        }
Exemplo n.º 2
0
        public Engagement(IBoid host)
        {
            _host     = host;
            _flockers = new List <IBoid>();

            _ahead              = new Boid();
            _ahead._position    = _host._Position;
            _ahead._velocity    = _host._Velocity;
            _ahead._maxVelocity = _host._MaxVelocity;

            _arrive     = new Arrive(_host);
            _evade      = new Evade(_host);
            _separation = new Separation(_host);

            _arrive._target = _target;
            _evade._target  = _ahead;

            _separation._boids  = _flockers;
            _separation._RADIUS = 1.0f;
            _separation._WEIGHT = 0.75f;
        }
Exemplo n.º 3
0
        private void UpdateHunterBehavoir()
        {
            List <IBehavor> behavors        = GetBehavoirs(m_HunterBehavoirs[HunterStatus]);
            ObjectAvoidance objectAvoidance = null;
            Arrive          arrive          = null;

            if (m_ObjectAvoidanceActive)
            {
                objectAvoidance       = new ObjectAvoidance(m_Radius, LayerMask);
                objectAvoidance.Label = BehaviorEnum.ObjectAvoid.ToString();
                behavors.Add(objectAvoidance);
            }
            if (m_ArriveActive)
            {
                arrive       = new Arrive(m_Target.transform);
                arrive.Label = "Arrive";
                behavors.Add(arrive);
            }

            m_Steering.SetBehaviors(objectAvoidance, arrive, behavors, behavors[0].Label);
        }
Exemplo n.º 4
0
        public void SetBehaviors(ObjectAvoidance objectAvoidance, Arrive arrive, BehavorList behavorList, string label = "")
        {
            m_Label           = label;
            m_BehavorList     = behavorList;
            m_ObjectAvoidance = objectAvoidance;
            m_Arrive          = arrive;

            foreach (IBehavor behavor in m_BehavorList)
            {
                behavor.Start(new BehavorContext(m_Position, m_Velocity, m_Settings));
                if (m_Arrive != null && m_ObjectAvoidance != null)
                {
                    if (behavor.Label != m_Arrive.Label && behavor.Label != m_ObjectAvoidance.Label)
                    {
                        behavor.SetPriorty(1);
                    }
                }
                else
                {
                    behavor.SetPriorty(1);
                }
            }
        }
Exemplo n.º 5
0
        private void Start()
        {
            if (m_Behavior == BehaviorEnum.Keyboard || m_Behavior == BehaviorEnum.SeekClickPoint)
            {
                m_Target = null;
            }
            else
            {
                if (m_Target == null)
                {
                    m_Target = GameObject.Find("Player");
                }
                if (m_Target == null)
                {
                    m_Target = GameObject.Find("Target");
                }
            }

            m_Steering = GetComponent <Steering>();

            List <IBehavor> behavors = new List <IBehavor>();
            string          label    = m_Behavior.ToString();

            switch (m_Behavior)
            {
            case BehaviorEnum.Keyboard:
                behavors.Add(new KeyBoard());
                break;

            case BehaviorEnum.SeekClickPoint:
                behavors.Add(new ClickSeekPoint());
                break;

            case BehaviorEnum.Seek:
                behavors.Add(new Seek(m_Target.transform));
                break;

            case BehaviorEnum.Flee:
                behavors.Add(new Flee(m_Target.transform));
                break;

            case BehaviorEnum.FollowPath:
                behavors.Add(new FollowPath(m_WaitPoints));
                break;

            case BehaviorEnum.Pursue:
                behavors.Add(new Persue(m_Target.transform));
                break;

            case BehaviorEnum.Evade:
                behavors.Add(new Evade(m_Target.transform));
                break;

            case BehaviorEnum.Wander:
                behavors.Add(new Wander());
                break;

            case BehaviorEnum.Hide:
                behavors.Add(new Hide(m_Target.transform));
                break;

            default:
                Debug.LogError($"Behavior of Type{m_Behavior} not implemented yet!");
                break;
            }
            ObjectAvoidance objectAvoidance = null;
            Arrive          arrive          = null;

            if (m_ObjectAvoidanceActive)
            {
                objectAvoidance       = new ObjectAvoidance(m_Radius, LayerMask);
                objectAvoidance.Label = BehaviorEnum.ObjectAvoid.ToString();
                behavors.Add(objectAvoidance);
            }
            if (m_ArriveActive)
            {
                arrive       = new Arrive(m_Target.transform);
                arrive.Label = "Arrive";
                behavors.Add(arrive);
            }
            behavors[0].Label = label;
            m_Steering.SetBehaviors(objectAvoidance, arrive, behavors, label);
        }