示例#1
0
    public void GetBeHit(JN_Date jn_date, float sx)
    {
        if (roleDate.isDie)
        {
            return;
        }
        //if (!roleDate.isCanBeHit) return;
        float addxue = jn_date.atkPower - roleDate.def;

        addxue         = addxue > 0 ? addxue : 1;
        roleDate.live -= addxue;
        if (roleDate.live < 0)
        {
            roleDate.live = 0;
        }
        //print("live "+ roleDate.live);

        //判断是否在躲避阶段  无法被攻击
        //判断击中特效播放位置
        //击退 判断方向
        float _psScaleX = sx;

        //判断是否在空中
        //挨打动作  判断是否破硬直
        //判断是否生命被打空

        if (!IsPlayAudio)
        {
            return;
        }
        //HitTX(_psScaleX, "BloodSplatCritical2D1");
        //HitTX(_psScaleX, "jizhong", roleDate.beHitVudio);


        string tx_1 = "";

        if (BeHitGameBody)
        {
            tx_1 = BeHitGameBody.GetComponent <RoleDate>().BeHitTX_1;
        }
        if (tx_1 != "")
        {
            print("  >>tx_1 " + tx_1);

            GameObject hitTx_1 = Resources.Load(tx_1) as GameObject;
            hitTx_1 = ObjectPools.GetInstance().SwpanObject2(hitTx_1);
            HitTXPos(hitTx_1);
        }


        //击中特效类型 8 和 9 都是 火焰类的
        if (jn_date.HitInSpecialEffectsType == 8 || jn_date.HitInSpecialEffectsType == 9)
        {
            //一般粒子 特殊的 击中
            //HitTX(_psScaleX, "BloodSplatCritical3", "", 2, false, false, -txPos);
            return;
        }



        HitTX(_psScaleX, "BloodSplatCritical3", "", 2, false, false);
        if (jn_date.HitInSpecialEffectsType != 3)
        {
            HitTX(_psScaleX, "jizhong", roleDate.beHitVudio, 4, true, true);
        }
    }
示例#2
0
    void OnTriggerEnter2D(Collider2D Coll)
    {
        gameBody     = Coll.GetComponent <GameBody>();
        roleDate     = Coll.GetComponent <RoleDate>();
        _rigidbody2D = Coll.GetComponent <Rigidbody2D>();

        //atkObj = txObj.GetComponent<JN_base>().atkObj;
        //print(atkObj.name);

        print(" ---coll name " + Coll.name + "    roledate " + roleDate);

        if (roleDate && !IsCanHitBoss && roleDate.enemyType == "boss")
        {
            return;
        }

        JN_Date jn_date = GetComponent <JN_Date>();

        if (roleDate != null && roleDate.team != jn_date.team)
        {
            //print("击中的2Dbox  "+Coll.GetComponent<BoxCollider2D>().transform.position);

            if (roleDate.isDie)
            {
                return;
            }
            //if (!roleDate.isCanBeHit) return;
            //取到施展攻击角色的方向
            //float _roleScaleX = -atkObj.transform.localScale.x;


            if (IsCanBeDodge)
            {
                //print("roleDate  " + roleDate);
                //print(" isCanbeihit  " + roleDate.isCanBeHit);
                if (!roleDate.isCanBeHit)
                {
                    return;
                }
            }

            //这个已经不需要了
            //if (Coll.GetComponent<BeHit>()) Coll.GetComponent<BeHit>().GetBeHit(jn_date, _roleScaleX);


            //print("   这里是否进来  " + Coll.transform.position.x + "  -------    " + this.transform.parent.transform.transform);
            if (this.transform.parent)
            {
                atkScaleX = Coll.transform.position.x < this.transform.parent.transform.position.x ? -1 : 1;
            }
            GetBeHit(jn_date, atkScaleX);
            //力作用  这个可以防止 推力重叠 导致任务飞出去
            Vector3 tempV3 = _rigidbody2D.velocity;
            _rigidbody2D.velocity = new Vector3(0, tempV3.y, tempV3.z);

            if (jn_date != null && gameBody != null)
            {
                gameBody.HasBeHit();

                if (this.transform.parent == null)
                {
                    return;
                }
                if (Coll.transform.position.x > this.transform.parent.transform.position.x)
                {
                    //Coll.GetComponent<Rigidbody2D>().AddForce(new Vector2(400 , 0));
                    Coll.GetComponent <GameBody>().GetZongTuili(new Vector2(400, 0));
                }
                else
                {
                    //Coll.GetComponent<Rigidbody2D>().AddForce(new Vector2(-400 , 0));
                    Coll.GetComponent <GameBody>().GetZongTuili(new Vector2(-400, 0));
                }
            }


            //毒伤害
            if (jn_date.DuChixuShanghai != 0)
            {
                //print(beHitObj.name + "  --beihitteam  " + BeHitRoleDate.team + "  jnteam  " + jn_date.team + "   atkObjname " + atkObj.name);
                if (gameBody != null && roleDate.team != jn_date.team)
                {
                    gameBody.GetComponent <ChiXuShangHai>().InDu(jn_date.DuChixuShanghai, jn_date.DuChixuShanghaiTime);
                }
            }

            if (jn_date.HuoChixuShanghai != 0)
            {
                if (gameBody != null && roleDate.team != jn_date.team)
                {
                    gameBody.GetComponent <ChiXuShangHai>().InHuo(jn_date.HuoChixuShanghai, jn_date.HuoChixuShanghaiTime);
                }
            }
        }
    }
示例#3
0
 void StopMove()
 {
     //print("   ????stopmove!!!!!  ");
     //_gameBody.SetXSpeedZero();
     _gameBody.GetComponent <Rigidbody2D>().velocity = Vector2.zero;
 }