void Awake() { //주인공 게임오브젝트 추출 var player = GameObject.FindGameObjectsWithTag("PLAYER"); //주인공의 Transform 컴포넌트 추출 if (player != null) { playerTr = player[0].GetComponent <Transform>(); } //적 캐릭터의 Transform 컴포넌트 추출 enemyTr = GetComponent <Transform>(); //Animator 컴포넌트 추출 animator = GetComponent <Animator>(); //이동을 제어하는 MoveAgent 클래스를 추출 moveAgent = GetComponent <MoveAgent>(); //총알 발사를 제어하는 EnemyFire 클래스를 추출 enemyFire = GetComponent <EnemyFire>(); //시야각 및 추적 반경을 제어하는 EnemyFOV 클래스를 추출 enemyFOV = GetComponent <EnemyFOV>(); //코루틴 지연시간 생성 ws = new WaitForSeconds(0.3f); //Cycle Offset 값을 불규칙하게 변경 animator.SetFloat(hashOffset, Random.Range(0.0f, 1.0f)); //Speed 값을 불규칙하게 변경 animator.SetFloat(hashWalkSpeed, Random.Range(1.0f, 1.2f)); }
void Awake() { var player = GameObject.FindGameObjectWithTag("PLAYER"); if (player != null) { playerTr = player.GetComponent <Transform>(); } enemyTr = GetComponent <Transform>(); animator = GetComponent <Animator>(); moveAgent = GetComponent <MoveAgent>(); enemyFire = GetComponent <EnemyFire>(); enemyFOV = GetComponent <EnemyFOV>(); ws = new WaitForSeconds(0.3f); animator.SetFloat(hashOffset, Random.Range(0.0f, 1.0f)); animator.SetFloat(hashWalkSpeed, Random.Range(1.0f, 1.2f)); }
private void OnSceneGUI() { //EnemyFOV 클래스를 참조 EnemyFOV fov = (EnemyFOV)target; //원주 위의 시작점의 좌표를 계산(주어진 각도의 1/2) Vector3 formAnglePos = fov.CirclePoint(-fov.viewAngle * 0.5f); //원의 색상을 흰색으로 지정 Handles.color = Color.white; //외각선만 표현하는 원반을 그림 Handles.DrawWireDisc(fov.transform.position //원점 좌표 , Vector3.up //노멀 벡터 , fov.viewRange); //원의 반지름 //부채꼴의 색상을 지정 Handles.DrawSolidArc(fov.transform.position //원점 좌표 , Vector3.up //노멀 벡터 , formAnglePos //부채꼴의 시작 좌표 , fov.viewAngle //부채꼴의 각도 , fov.viewRange); //부채꼴의 반지름 //시야각의 텍스트를 표시 Handles.Label(fov.transform.position + (fov.transform.forward * 2.0f) , fov.viewAngle.ToString()); }
private void Awake() { //주인공 게임 오브젝트 추출 var player = GameObject.FindGameObjectWithTag("Player"); //주인공의 트렌스폼 컨포넌트 추출 if (player != null) { playerTr = player.GetComponent <Transform>(); } //적 캐릭터의 트렌스폼 컨포넌트 추출 enemyTr = GetComponent <Transform>(); //Animator 컴포넌트 추출 animator = GetComponent <Animator>(); //이동을 제어하는 MoveAgent 클래스를 추출 moveAgent = GetComponent <MoveAgent>(); //총알 발사를 제어하는 EnemyFire 클래스를 추출 enemyFire = GetComponent <EnemyFire>(); enemyFOV = GetComponent <EnemyFOV>(); //코루틴 지연시간 생성 ws = new WaitForSeconds(0.3f); animator.SetFloat(hashOffset, Random.Range(0.0f, 1.0f)); animator.SetFloat(hashWalkSpeed, Random.Range(1.0f, 1.2f)); }
void Awake() { //Player GameObject 추출 var player = GameManager.instance.Player; //Player와 Enemy의 Transform 추출 if (player != null) { playerTr = player.GetComponent <Transform>(); playerLv = player.GetComponent <PlayerLv>(); } enemyTr = GetComponent <Transform>(); //Anumator 추출 animator = GetComponent <Animator>(); //MoveAgent 추출 moveagent = GetComponent <MoveAgent>(); //EnemyFire 추출 enemyFire = GetComponent <EnemyFire>(); //EnemyFOV 추출 enemyFOV = GetComponent <EnemyFOV>(); //코루틴 지연 시간 ws = new WaitForSeconds(0.3f); //Offset값과 Speed 값을 불규칙하게 변경 animator.SetFloat(hashOffset, Random.Range(0.0f, 1.0f)); animator.SetFloat(hashwalkSpeed, Random.Range(1.0f, 1.2f)); }
protected virtual void Awake() { player = GameObject.FindGameObjectWithTag("Player"); playerHealth = player.GetComponent <PlayerHealth>(); enemyHealth = GetComponent <EnemyHealth>(); sight = GetComponentInChildren <EnemyFOV>(); anim = GetComponent <Animator>(); }
private void Start() { FOV = GetComponent <EnemyFOV>(); player = Player.singleton.transform; thisenem = GetComponent <Enemy>(); StartCoroutine(FSM()); RoamPosition = new Vector3(UnityEngine.Random.Range(transform.position.x - 5f, transform.position.x + 5f), UnityEngine.Random.Range(transform.position.y - 5f, transform.position.y + 5f), 0); }
private void Awake() { ws = new WaitForSeconds(judgeTime); fov = GetComponent <EnemyFOV>(); move = GetComponent <EnemyMove>(); attack = GetComponent <EnemyAttack>(); //이렇게 하면 자기한테 맞는 Attack 이 가져와져 _status = GetComponentInChildren <StatusAnimation>(); //자식에 달려있는 상태 }
private void Awake() { moveAgent = GetComponent <MoveAgent>(); animator = GetComponent <Animator>(); enemyFire = GetComponent <EnemyFire>(); enemyFOV = GetComponent <EnemyFOV>(); animator.SetFloat(hashOffset, Random.Range(0, 1.0f)); animator.SetFloat(hashWalkSpeed, Random.Range(1.0f, 1.2f)); }
void Awake() { anim = GetComponent <Animator>(); hurtSound = GetComponent <AudioSource>(); capsuleCollider = GetComponent <CapsuleCollider>(); playerShooting = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerShooting>(); enemyMovement = GetComponentInParent <EnemyMovement>(); currentEffect = new Effect(this, enemyMovement); sight = GetComponentInChildren <EnemyFOV>(); InitHealth(); }
private void OnSceneGUI() { EnemyFOV fov = (EnemyFOV)target; Vector3 formAnglePos = fov.CirclePoint(-fov.viewAngle * 0.5f); Handles.color = Color.white; Handles.DrawWireDisc(fov.transform.position, Vector3.up, fov.viewRange); Handles.color = new Color(1, 1, 1, 0.2f); Handles.Label(fov.transform.position + (fov.transform.forward * 2.0f), fov.viewAngle.ToString()); }
void Awake() { player = GameObject.FindGameObjectWithTag("Player").transform; playerHealth = player.GetComponent <PlayerHealth>(); enemyHealth = GetComponent <Health>(); nav = GetComponent <UnityEngine.AI.NavMeshAgent>(); sight = GetComponentInChildren <EnemyFOV>(); anim = GetComponent <Animator>(); attack = GetComponent <IAttack>(); enemyPatrol = GetComponent <EnemyPatrol>(); }
// Start is called before the first frame update private void Awake() { enemyFOV = GetComponent <EnemyFOV>(); rigid = GetComponent <Rigidbody2D>(); patrolPoint[0] = new Vector3(transform.position.x, transform.position.y, transform.position.z); for (int i = 0; i < patrolPoint.Length; i++) { patrolPoint[i] = new Vector3(patrolPoint[0].x + patrolDistance * (i), patrolPoint[0].y, patrolPoint[0].z); patrolList.Add(patrolPoint[i]); } destination = patrolPoint[0]; }
private void OnSceneGUI() { EnemyFOV fov = (EnemyFOV)target; Vector2 fromAngle = fov.CirclePoint(-fov.viewAngle * 0.5f); Handles.color = Color.white; Handles.DrawWireDisc(fov.transform.position, Vector3.forward, fov.viewRange); Handles.color = new Color(1, 1, 1, 0.2f); Handles.DrawSolidArc(fov.transform.position, Vector3.forward, fromAngle, fov.viewAngle, fov.viewRange); //GUIStyle style = new GUIStyle(); //style.fontSize = 35; //Handles.Label(fov.transform.position + new Vector3(0, 0.5f, 0), fov.viewAngle.ToString(), style); }
private void Awake() { // Player 오브젝트를 씬에서 찾음 var playerObject = GameObject.FindGameObjectWithTag("Player"); if (playerObject != null) { playerTransform = playerObject.GetComponent <Transform>(); } moveAgent = GetComponent <MoveAgent>(); animator = GetComponent <Animator>(); enemyFire = GetComponent <EnemyFire>(); enemyFOV = GetComponent <EnemyFOV>(); waitSecond = new WaitForSeconds(refreshAICycle); }
private void OnSceneGUI() { EnemyFOV fov = (EnemyFOV)target; Vector3 fromAnglePos = fov.CirclePoint(-fov.viewAngle * 0.5f); Handles.color = new Color(1, 1, 1, 0.2f); Handles.DrawSolidArc(fov.transform.position, //원 중심 좌표 Vector3.up, //부채꼴의 노멀 벡터 fromAnglePos, //부채꼴 시작 좌표 fov.viewAngle, //시야각 fov.viewRange //반지름 ); Handles.Label(fov.transform.position + (fov.transform.forward * 2.0f), fov.viewAngle.ToString()); }
private void OnSceneGUI() { EnemyFOV fov = (EnemyFOV)target; //원주 위의 시작점의 좌표 계산 (주어진 각도의 절반) Vector3 fromAnglePos = fov.CirclePoint(-fov.viewAngle * 0.5f); //원의 색상을 흰색으로 지정 Handles.color = Color.white; //외각선만 표현하는 원반을 그림(원점 좌표, 노멀 벡터, 원의 반지름) Handles.DrawWireDisc(fov.transform.position, Vector3.up, fov.viewRange); //부채꼴 색상 지정 Handles.DrawSolidArc(fov.transform.position, Vector3.up, fromAnglePos, fov.viewAngle, fov.viewRange); Handles.Label(fov.transform.position + (fov.transform.forward * 2.0f), fov.viewAngle.ToString()); }
private void OnSceneGUI() { EnemyFOV fov = (EnemyFOV)target; Handles.color = Color.white; Handles.DrawWireArc(fov.transform.position, Vector3.forward, Vector3.up, 360, fov.viewRadius); Vector3 viewAngleA = fov.DirFromAngle(-fov.viewAngle / 2, false); Vector3 viewAngleB = fov.DirFromAngle(fov.viewAngle / 2, false); Handles.DrawLine(fov.transform.position, (fov.transform.position + viewAngleA * fov.viewRadius)); Handles.DrawLine(fov.transform.position, fov.transform.position + viewAngleB * fov.viewRadius); Handles.color = Color.red; foreach (Transform visibleTarget in fov.visibleTargets) { Handles.DrawLine(fov.transform.position, visibleTarget.position); } }
private void OnSceneGUI() { EnemyFOV ScriptFOV = (EnemyFOV)target; Handles.color = Color.white; Handles.DrawWireArc(ScriptFOV.transform.position, Vector3.up, Vector3.forward, 360, ScriptFOV.Radius); Vector3 viewAngle1 = ScriptFOV.DirectionFromAngle(-ScriptFOV.Angle / 2, false); Vector3 viewAngle2 = ScriptFOV.DirectionFromAngle(ScriptFOV.Angle / 2, false); Handles.DrawLine(ScriptFOV.transform.position, ScriptFOV.transform.position + viewAngle1 * ScriptFOV.Radius); Handles.DrawLine(ScriptFOV.transform.position, ScriptFOV.transform.position + viewAngle2 * ScriptFOV.Radius); Handles.color = Color.magenta; foreach (Transform visibleTargets in ScriptFOV.visibleTargets) { Handles.DrawLine(ScriptFOV.transform.position, visibleTargets.position); } }