Beispiel #1
0
        void Update()
        {
            distanceToPlayer = Vector3.Distance(player.transform.position, transform.position);
            WeponSystem weponSystem = GetComponent <WeponSystem>();

            currentWeponRange = weponSystem.GetCurrentWepon().GetMaxAttackRange();

            bool inWeponCircle    = distanceToPlayer <= currentWeponRange;
            bool inChaseCircle    = distanceToPlayer > currentWeponRange && distanceToPlayer <= chaseRadius;
            bool outsideChaseRing = distanceToPlayer > chaseRadius;

            if (outsideChaseRing)
            {
                StopAllCoroutines();
                weponSystem.StopAttacking();
                StartCoroutine(Patrol());
            }
            if (inChaseCircle)
            {
                StopAllCoroutines();
                StartCoroutine(ChasePlayer());
            }
            if (inWeponCircle)
            {
                StopAllCoroutines();
                state = State.attacking;
                weponSystem.AttackTarget(player.gameObject);
            }
        }
Beispiel #2
0
 void Start()
 {
     character   = GetComponent <Character>();
     abilities   = GetComponent <SpecialAbilities>();
     audioSource = GetComponent <AudioSource>();
     weponSystem = GetComponent <WeponSystem>();
     RegisterForMouseEvents();
 }