public override void OnStateEnter(Animator animator, AnimatorStateInfo animatorStateInfo, int layerIndex)
 {
     wielder       = animator.GetComponent <AICombatant>();
     currentAttack = wielder.attacks[attackIndex];
     currentAttack.currentMovementBehaviour = currentMovementBehaviour;
     currentAttack.StateStart();
 }
Пример #2
0
 private void Start()
 {
     oriScale = transform.localScale;
     player   = GameObject.FindGameObjectWithTag("Player");
     aiPatrol = GetComponent <AIPatrol>();
     aiAttack = GetComponentInChildren <AIAttack>();
 }
Пример #3
0
    protected void Start()
    {
        shipMovement = GetComponent <AIMovement>();
        shipHealth   = GetComponent <AIHealth>();
        shipAttack   = GetComponent <AIAttack>();

        ShipsController.Instance.AddShip(this);
    }
Пример #4
0
 private void Awake()
 {
     ri             = GetComponent <Rigidbody2D>();
     ai             = GetComponent <MonsterAI>();
     ani            = monsterRenderer.GetComponent <Animator>();
     spriteRenderer = monsterRenderer.GetComponent <SpriteRenderer>();
     aiAttack       = GetComponent <AIAttack>();
 }
Пример #5
0
    void HitCheck()
    {
        AIAttack attackState = _manager.CurrentStateComponent as AIAttack;

        if (attackState)
        {
            attackState.AttackCheck();
        }
    }
Пример #6
0
    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;
    }
Пример #7
0
    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());
        }
    }
Пример #8
0
 // Use this for initialization
 void Awake()
 {
     AIAttack   = GetComponentInParent <AIAttack> ();
     photonView = GetComponentInParent <PhotonView> ();
 }
Пример #9
0
 private void Awake()
 {
     _aiAttack = GetComponent <AIAttack>();
 }
Пример #10
0
 private void OnEnable()
 {
     creator = target as AIAttack;
 }
Пример #11
0
 protected new void Awake()
 {
     base.Awake();
     aiAttack = GetComponent <AIAttack>();
 }
Пример #12
0
    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
        }
    }