void Start() { monHP = 40; monDir = Random.Range(0, 2); monAtk = 5; monAtkSpd = 0.666f; monSpd = 3.75f; isAtk = false; isReached = 0; player = GameObject.Find("Player"); eliteMonster = this.gameObject; detectRng = GameObject.Find(eliteMonster.name + "/Range"); gridMgr = player.GetComponentInChildren <GridManager>(); monMgr = GameObject.Find("GameManager").GetComponent <MonsterManager>(); textMesh = this.GetComponentInChildren <TextMesh>(); monPos = new Vector3(Random.Range(1, 69), 0, Random.Range(1, 69)); eliteMonster.transform.position = monPos; atkState = new EAttackState(this); ptlState = new EPatrolState(this); chsState = new EChaseState(this); detectRng.GetComponent <Renderer>().enabled = false; textMesh.GetComponent <Renderer>().enabled = false; curState = ptlState; }
private void Awake() { roamState = gameObject.AddComponent <ERoamState>(); chaseState = gameObject.AddComponent <EChaseState>(); searchState = gameObject.AddComponent <ESearchState>(); if (GetComponent <EAttackState>() != null) { attackState = GetComponent <EAttackState>(); } else if (GetComponent <ERangedAttackState>() != null) { attackState = GetComponent <ERangedAttackState>(); } else { attackState = gameObject.AddComponent <EAttackState>(); } navAgent = GetComponent <UnityEngine.AI.NavMeshAgent>(); myCollisionRadius = GetComponent <CapsuleCollider>().radius; audioSource = GetComponent <AudioSource>(); }