Beispiel #1
0
        private void Start()
        {
            currentState = State.Patrol;
            ListBots.Add(this);

            cooldownMeeting = AIManager.Instance.maxMeetingCooldown / sociableLevel;
            var ratie = (AIManager.Instance.maxViewDistance - AIManager.Instance.minViewDistance) / 9f;

            viewDistance = AIManager.Instance.minViewDistance + (sociableLevel - 1) * ratie;

            _agent    = GetComponent <NavMeshAgent>(); // iau Navmesh Agentul
            _animator = GetComponent <Animator>();     // iau animatorul

            _obstacle =
                GetComponent <NavMeshObstacle>(); // iau obstacolul ca sa il activez atunci cand vorbesc si se opresc
            _obstacle.enabled = false;

            _agent.autoBraking = false; // sa nu se opreasca cand se aproprie de destinatie

            if (head == null)
            {
                head = gameObject;
            }
            if (placeHolderInfectedUI != null)
            {
                _ui = placeHolderInfectedUI.GetComponent <InfectedUI>();
            }
            SetUpPosHolder();
            if (alreadyInfected)
            {
                StartInfection();
            }

            UnityEngine.Random.InitState(10);
            if (uiManager == null)
            {
                uiManager = GetComponentInChildren <BotUI>();
            }
            if (uiManager != null)
            {
                uiManager.SetGizmosName(name);
            }
            _stateMachine = new FiniteStateMachine(this);
            _stateMachine.ChangeState(new PatrolState(_stateMachine));
        }