public override void OnStateEnter(Animator animator, AnimatorStateInfo animatorStateInfo, int layerIndex) { wielder = animator.GetComponent <AICombatant>(); currentAttack = wielder.attacks[attackIndex]; currentAttack.currentMovementBehaviour = currentMovementBehaviour; currentAttack.StateStart(); }
private void Start() { oriScale = transform.localScale; player = GameObject.FindGameObjectWithTag("Player"); aiPatrol = GetComponent <AIPatrol>(); aiAttack = GetComponentInChildren <AIAttack>(); }
protected void Start() { shipMovement = GetComponent <AIMovement>(); shipHealth = GetComponent <AIHealth>(); shipAttack = GetComponent <AIAttack>(); ShipsController.Instance.AddShip(this); }
private void Awake() { ri = GetComponent <Rigidbody2D>(); ai = GetComponent <MonsterAI>(); ani = monsterRenderer.GetComponent <Animator>(); spriteRenderer = monsterRenderer.GetComponent <SpriteRenderer>(); aiAttack = GetComponent <AIAttack>(); }
void HitCheck() { AIAttack attackState = _manager.CurrentStateComponent as AIAttack; if (attackState) { attackState.AttackCheck(); } }
public void attack_select(int attackIndex) { // Make sure the index is in range if (attackIndex > this.attacks.Length - 1) { Debug.LogWarning("AI Combat Handler: Cannot select attack with index of " + attackIndex); return; } // Unequip our current attack if (this.attackCurrent != null) { this.attackCurrent.attackEquipped = false; } // Select our new attack this.attackCurrent = this.attacks [attackIndex]; this.attackCurrent.attackEquipped = true; }
IEnumerator AIFollowHero() { while (true) { if (player != null && Vector3.Distance(transform.position, player.gameObject.transform.position) > 22f) { //Debug.Log("敌人已走远,放弃攻击!!!"); yield break; } if (player != null && Vector3.Distance(transform.position, player.gameObject.transform.position) <= 10f) //最远距离16 { AIAttack aa = GetComponent <AIAttack>(); aa.Att(); yield return(new WaitForSeconds(3.2f)); } TowardToTargetAndRun(player.transform.position); Vector3 dir = player.transform.position - transform.position; transform.Translate(dir.normalized * Time.deltaTime * speed * 0.8f, Space.World); yield return(new WaitForEndOfFrame()); } }
// Use this for initialization void Awake() { AIAttack = GetComponentInParent <AIAttack> (); photonView = GetComponentInParent <PhotonView> (); }
private void Awake() { _aiAttack = GetComponent <AIAttack>(); }
private void OnEnable() { creator = target as AIAttack; }
protected new void Awake() { base.Awake(); aiAttack = GetComponent <AIAttack>(); }
void action() { if(changeState == true) { randomNum = getRandomNum(randMin,randMax); if(randomNum >= randMax-(aggressiveLevel * 15))//the lower aggreesive level the lower chance to attack { int offset; myAIState = AIState.attack; randomNum = getRandomNum(randMin, randMax); if (currentMana <= startingMana / 5)//left 20% offset = 30;//will want to go melee combat as much as possible else offset = -30; if (randomNum >= randMax / 2 + offset) { randomNum = getRandomNum(randMin, randMax); if (randomNum >= randMax / 2) myAIStateAttack = AIAttack.rangeSingle; else myAIStateAttack = AIAttack.rangeMultiple; } else myAIStateAttack = AIAttack.melee; //myAIStateAttack = AIAttack.melee; } else { myAIState = AIState.idle; } changeState = false; } if (myAIState != AIState.idle) { // Debug.Log("in not idle"); randomAttribute();//random move and jump } }