示例#1
0
        /// <summary>
        ///   Awake.
        /// </summary>
        private void Awake()
        {
            _stateMachineController = new StateMachineController();
            _navMeshAgent           = GetComponent <NavMeshAgent>();
            _entity = GetComponent <Entity>();

            EntityIdle        entityIdle        = new EntityIdle();
            EntityChasePlayer entityChasePlayer = new EntityChasePlayer(_navMeshAgent);
            EntityAttack      entityAttack      = new EntityAttack();
            EntityDead        entityDead        = new EntityDead();

            _stateMachineController.Add(entityIdle);
            _stateMachineController.Add(entityChasePlayer);
            _stateMachineController.Add(entityAttack);

            _stateMachineController.AddAnyStateTransition(entityDead, () => _entity.IsDead);

            Player player = FindObjectOfType <Player>();

            _stateMachineController.AddStateTransition(entityIdle,
                                                       entityChasePlayer,
                                                       () => FlatDistance(_navMeshAgent.transform.position, player.transform.position) < 5);
            _stateMachineController.AddStateTransition(entityChasePlayer,
                                                       entityAttack,
                                                       () => FlatDistance(_navMeshAgent.transform.position, player.transform.position) < 2);

            _stateMachineController.ChangeState(entityIdle);
        }
示例#2
0
        public bool Remove(EntityIdle idle)
        {
            Debug.Assert(idle != null);

            lock (_list)
                return(_list.Remove(idle));
        }
示例#3
0
        public bool Contains(EntityIdle idle)
        {
            Debug.Assert(idle != null);

            lock (_list)
                return(_list.Contains(idle));
        }
示例#4
0
        public void Add(EntityIdle idle)
        {
            Debug.Assert(idle != null);

            lock (_list)
                _list.Add(idle);
        }
示例#5
0
 public static void OnEntityIdle(GameObject arg1)
 {
     EntityIdle?.Invoke(arg1);
 }