コード例 #1
0
ファイル: EnemyAI.cs プロジェクト: HypeCounter/Forsaken
        void Update()
        {
            distanceToPlayer = Vector3.Distance(player.transform.position, transform.position);
            WeaponSystem weaponSystem = GetComponent <WeaponSystem>();

            currentWeaponRange = weaponSystem.GetCurrentWeapon().GetMaxAttackRange();


            if (distanceToPlayer > chaseRadius && state != State.patrolling)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(Patrol());
            }
            if (distanceToPlayer <= chaseRadius && state != State.chasing)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(ChasePlayer());
            }
            if (distanceToPlayer <= currentWeaponRange && state != State.attacking)
            {
                StopAllCoroutines();


                weaponSystem.AttackTarget(player.gameObject);
            }
        }
コード例 #2
0
 void OnMouseOverPotentiallyWalkable(Vector3 destination)
 {
     if (Input.GetMouseButton(0))
     {
         weaponSystem.StopAttacking();
         myCharacter.SetDestination(destination);
     }
 }