Пример #1
0
    /// <summary>
    /// 缓冲池重置所有属性
    /// </summary>
    void OnEnable()
    {
        rb = gameObject.AddComponent <Rigidbody>();
        //Debug.Log("OnEnable执行"+transform.position);
        status  = aistatus.run;
        oldname = string.Empty;
        isdead  = false;
        Bip01   = transform.FindChild("xiongdonghua/Bip01").gameObject;
        // arrowtarget = transform.FindChild("xiongdonghua/ArrowTarget").gameObject;
        AiOnHurt ao = Bip01.AddComponent <AiOnHurt>();

        ao.acontroll = this;
        neck         = Bip01.transform.FindChild("Bip01 骨盆/Bip01 Spine/Bip01 Spine1/Bip01 Neck").gameObject;
        head         = neck.transform.FindChild("Bip01 头部/Bip01 头部Nub").gameObject;
        lefthand     = neck.transform.FindChild("Bip01 L Clavicle/Bip01 L UpperArm/Bip01 L Forearm/Bip01 L Hand").gameObject;
        righthand    = neck.transform.FindChild("Bip01 R Clavicle/Bip01 R UpperArm/Bip01 R Forearm/Bip01 R Hand").gameObject;
        //Debug.Log("neck::"+neck+head+lefthand+righthand);
        //生成时检查是否身上带有箭并销毁
        for (int i = 0; i < Bip01.transform.childCount; i++)
        {
            if (Bip01.transform.GetChild(i).name.Equals("Arrow(Clone)"))
            {
                Bip01.transform.GetChild(i).GetComponent <Bulletcontroll>().AddToPool();
            }
        }

        Destroy(oldshield);
        Destroy(oldweapon);
        Destroy(oldheater);
    }
Пример #2
0
    void OnTriggerEnter(Collider collision)
    {
        switch (collision.tag)
        {
        case "Player":
            status = aistatus.attack;
            //  InvokeRepeating("Attack", 1f, 2f);
            break;

        case "AI":
            if (nav.enabled)
            {
                //   nav.SetDestination(uppos);
            }

            break;

        case "PlayerBullet":
            //  Destroy(gameObject);

            Bulletcontroll bcontroll = collision.GetComponent <Bulletcontroll>();
            CateDownHp(bcontroll.damage);
            //  collision.transform.SetParent(transform);

            //Debug.Log("collisionPlayerBullet" + collision.name + HP);
            break;

        case "Walls":
            break;

        default:
            break;
        }
    }
Пример #3
0
    void ChoiseStatus()
    {
        if (Vector3.Distance(transform.position, endpos) <= 2f && !isattack)
        {
            status   = aistatus.attack;
            isattack = true;
        }
        if (!isalive && Vector3.Distance(transform.position, endpos) > 1.5f)
        {
            status = aistatus.run;
            // Debug.Log("rrrrrrrrrr");
            isalive = true;
        }
        //if (Vector3.Distance(transform.position, uppos) <= 0.5f )
        //{
        //    nav.SetDestination(endpos);
        //}
        //Debug.Log(status.ToString());
        if (status != tempstatus)
        {
            //Debug.Log(status.ToString());
            tempstatus = status;
            switch (status)
            {
            case aistatus.ido:
                AnimPlay("isidle", true);
                break;

            case aistatus.attack:

                AnimPlay("isattack", true);

                break;

            case aistatus.die:
                //Debug.Log("执行多少次?");
                //   msg.FlyText(true, gread, transform.position,true);
                AnimPlay("isdead", true);

                break;

            case aistatus.walk:
            case aistatus.inspeackter:
            case aistatus.damage:
            case aistatus.run:
                //默认动画为行走,第二次开始需打开navmeshagint
                AnimPlay("", false);
                break;

            default:
                break;
            }
        }
    }
Пример #4
0
 /// <summary>
 /// 减血调用
 /// </summary>
 /// <param name="downHP"></param>
 public void CateDownHp(int downHP)
 {
     //Debug.Log(downHP+"剩余血量::::"+hp);
     if (hp > 0)
     {
         HP -= downHP;
         msg.FlyText(false, downHP, transform.position);
     }
     else
     {
         status = aistatus.die;
         if (!isdead)
         {
             msg.FlyText(true, gread, transform.position, true);
             isdead = true;
         }
     }
 }