private void Awake() { manualInput = GetComponent <ManualInput>(); animationProgress = GetComponent <AnimationProgress>(); aiProgress = GetComponentInChildren <AIProgress>(); damageDetector = GetComponentInChildren <DamageDetector>(); boxCollider = GetComponent <BoxCollider>(); animator = GetComponentInChildren <Animator>(); obstacle = GetComponent <NavMeshObstacle>(); collisionSpheres = GetComponentInChildren <CollisionSpheres>(); collisionSpheres.owner = this; CollisionSpheres.SetupColliders(boxCollider, out float bottom, out float top, out float front, out float back, out float right, out float left); collisionSpheres.PlaceEdgeSphere(bottom, top, front, back, left, right); collisionSpheres.FindEveryChild(gameObject.transform); aiController = GetComponentInChildren <AIController>(); if (aiController == null) { if (obstacle != null) { obstacle.carving = true; } } RegisterCharacter(); }
public virtual void OnGetHit(DamageDef damageDef) { if (ShouldShowHitAnimation(damageDef.damage, currentRole)) { currentState = AIState.REACT_HIT; progress = AIProgress.INIT; } }
public virtual void Update() { if (progress == AIProgress.END) { progress = AIProgress.INIT; SwitchState(); stateStartTime = Time.time; UpdateNow(); } if (ShouldUpdate()) { UpdateBehaviour(); } }
public virtual void Awake() { baseAgentController = transform.GetComponent <BaseAgentController>(); GameObject gameManager = GameObject.FindGameObjectWithTag("GameController"); prafabHolder = gameManager.GetComponent <PrafabHolder>(); aiUtils = gameManager.GetComponentInChildren <AIUtils>(); animationController = transform.GetComponentInChildren <CustomAnimationController>(); eventHelper = transform.GetComponentInChildren <SimpleEventHelper>(); shootPoint = aiUtils.GetShootPoint(transform); player = GameObject.FindGameObjectWithTag("Player"); currentRole = GetComponent <Enemy>(); currentRole.statusManager.notifyStatusChange += OnStatusChange; eventHelper.notifyGetHit += OnGetHit; currentState = AIState.IDLE; stateStartTime = Time.time; progress = AIProgress.END; resetPatrolPoint(); }