public void RequestNextAction() { if (aiBehaviour && aiBehaviour.enabled) { if (isInterruptAction) { // interruptAction finished currentAction = aiBehaviour.GetCurrentAction(); } else { currentAction = aiBehaviour.GetNextAction(); } } else { currentAction = defaultAction; } isInterruptAction = false; }
public virtual void Start() { defaultAction.moveTarget = Vector3.positiveInfinity; moveController = GetComponent <IEnemyMoveController2D>(); aiBehaviour = GetComponent <AiBehaviour>(); animator = GetComponent <Animator>(); spriteRenderer = GetComponent <SpriteRenderer>(); hitBox = GetComponentInChildren <HitBox>(); if (aiBehaviour && aiBehaviour.enabled) { aiBehaviour.defaultAction = defaultAction; currentAction = aiBehaviour.GetCurrentAction(); } else { currentAction = defaultAction; } boxCollider = GetComponent <BoxCollider2D>(); hurtBox = GetComponent <HurtBox>(); if (!hurtBox) { // search in children hurtBox = transform.GetComponentInChildren <HurtBox>(); } // init ENEMY state currentState = new EnemyIdleState(this); if (randomDelaySeconds > 0) { delayTime = Random.Range(0F, randomDelaySeconds); animator.speed = 0; } }