public void GetBeHit(JN_Date jn_date, float sx) { //print("被击中 !! "+this.transform.name+" 攻击力 "+ jn_date.atkPower+" 我的防御力 "+this.GetComponent<RoleDate>().def); 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; //判断是否在空中 //挨打动作 判断是否破硬直 //判断是否生命被打空 HitTX(_psScaleX, "BloodSplatCritical2D1"); HitTX(_psScaleX, "jizhong"); }
protected override void GetInit() { _jnDate = GetComponent <JN_Date>(); _ysAtkPower = _jnDate.atkPower; if (CJhitKuai.activeSelf) { CJhitKuai.SetActive(false); } }
void GetKuai(JN_Date jn_date, Vector3 _position) { hitKuai = Resources.Load("jn_fk") as GameObject; hitKuai = ObjectPools.GetInstance().SwpanObject2(hitKuai); hitKuai.transform.parent = this.transform; //指定 碰撞块位置 hitKuai.transform.position = _position; //指定 特效方向 hitKuai.transform.localScale = new Vector3(jn_date._scaleW, jn_date._scaleW, hitKuai.transform.localScale.z); }
private void OnEnable() { HitFK.SetActive(true); ZhuTX.gameObject.SetActive(true); if (!_jnDate) { _jnDate = GetComponent <JN_Date>(); } if (!_theTime) { _theTime = GetComponent <TheTimer>(); } _theTime.TimesAdd(_jnDate.TXDisTime, DisTX); //print("-----------------------> zhutexiao 延迟消失的时间 "); }
public void GetBeHit(JN_Date jn_date, float sx) { //print("被击中 !! "+this.transform.name+" 攻击力 "+ jn_date.atkPower+" 我的防御力 "+this.GetComponent<RoleDate>().def); gameBody = GetComponent <GameBody>(); roleDate = GetComponent <RoleDate>(); if (roleDate.isDie) { return; } float addxue = jn_date.atkPower - this.GetComponent <RoleDate>().def; addxue = addxue > 0 ? addxue : 1; roleDate.live -= addxue; if (roleDate.live < 0) { roleDate.live = 0; } //print("live "+ roleDate.live); if (!roleDate.isCanBeHit) { return; } if (gameBody != null) { //判断是否破防 D 代办事项 if (jn_date.atkPower - roleDate.yingzhi > 0) { } gameBody.HasBeHit(); } //判断是否在躲避阶段 无法被攻击 //判断击中特效播放位置 //击退 判断方向 float _psScaleX = sx; //判断是否在空中 //挨打动作 判断是否破硬直 //判断是否生命被打空 Bloods(_psScaleX); }
void OnTriggerEnter2D(Collider2D Coll) { gameBody = Coll.GetComponent <GameBody>(); roleDate = Coll.GetComponent <RoleDate>(); _rigidbody2D = Coll.GetComponent <Rigidbody2D>(); var txObj = this.transform.parent; atkObj = txObj.GetComponent <JN_base>().atkObj; JN_Date jn_date = txObj.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 (Coll.GetComponent<BeHit>()) Coll.GetComponent<BeHit>().GetBeHit(jn_date, _roleScaleX); GetBeHit(jn_date, _roleScaleX); //力作用 这个可以防止 推力重叠 导致任务飞出去 Vector3 tempV3 = _rigidbody2D.velocity; _rigidbody2D.velocity = new Vector3(0, tempV3.y, tempV3.z); if (jn_date != null && gameBody != null) { //判断是否破防 D 代办事项 if (jn_date.atkPower - roleDate.yingzhi > roleDate.yingzhi * 0.5) { gameBody.HasBeHit(); //Coll.GetComponent<Rigidbody2D>().AddForce(new Vector2(400 * _roleScaleX, 0)); gameBody.GetZongTuili(new Vector2(400 * _roleScaleX, 0)); } else if (jn_date.atkPower - roleDate.yingzhi > 0) { gameBody.HasBeHit(); //Coll.GetComponent<Rigidbody2D>().AddForce(new Vector2(300 * _roleScaleX, 0)); gameBody.GetZongTuili(new Vector2(300 * _roleScaleX, 0)); if (atkObj && jn_date._type == "1") { atkObjV3Zero(); //atkObj.GetComponent<Rigidbody2D>().AddForce(new Vector2(-300 * _roleScaleX, 0)); atkObj.GetComponent <GameBody>().GetZongTuili(new Vector2(-300 * _roleScaleX, 0)); } } else { if (atkObj && jn_date._type == "1") { atkObjV3Zero(); //atkObj.GetComponent<Rigidbody2D>().AddForce(new Vector2(-500 * _roleScaleX, 0)); atkObj.GetComponent <GameBody>().GetZongTuili(new Vector2(-500 * _roleScaleX, 0)); } } } //判断作用力与反作用力 硬直判断 // //Coll.GetComponent<Rigidbody2D>().AddForce(new Vector2(0, 300)); //如果是碰撞就消失 调用消失方法 if (jn_date != null && jn_date._type == "3") { //if (gameObject) ObjectPools.GetInstance().DestoryObject2(gameObject); txObj.GetComponent <JN_base>().DisObj(); } } }
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); } } } }
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); } }
public void GetPositionAndTeam(Vector3 _position, float team, float _sacaleX, GameObject obj, bool isSkill = false) { //print(obj.transform.position.y + " - " + GameObject.Find("/MainCamera").transform.position.y); atkObj = obj; jn_date = GetComponent <JN_Date>(); if (jn_date == null) { return; } jn_date.team = team; sacaleX = _sacaleX; //根据数据 获取新的位置 _position = new Vector3(_position.x + jn_date._xdx * _sacaleX, _position.y + jn_date._xdy, _position.z); //print( jn_date.name+" xdx "+ jn_date._xdx + " 、、、、///////////////////----------------------------------_position "+ _position); //指定特效位置 this.transform.position = _position; //this.transform.parent = obj.transform.parent; //print("parent "+this.transform.parent); //print("jn_date._scaleW "+jn_date._scaleW); //print(); //this.transform.localScale = new Vector3(jn_date._scaleW,jn_date._scaleH,1); //TX_weizhiyupan(); GetFuDaiTX(); //print("-------------------------->>>>???? " + obj.name + " _sacaleX " + _sacaleX+ " this.transform.localScale.x " + this.transform.localScale.x); if (!isSkill) { ShowHitFK(); } else { if (_hitKuai != null) { //print(" -----------> 2222222 _hitKuai "+_hitKuai+" name "+_hitKuai.name + " ? "+ _hitKuai.GetComponent<HitKuai>()); //print("hitkuai "+_hitKuai.transform.parent); _hitKuai.GetComponent <HitKuai>().GetTXObj(this.gameObject, true); } else { //print(" 3333333 "); ShowHitFK(); } } //特效缩放大小 //this.transform.localScale = new Vector3(jn_date._scaleW, jn_date._scaleH, 1); //特效方向 if (GetComponent <MyParticlesScale>() != null && GetComponent <MyParticlesScale>().IsUseThis) { if (_sacaleX > 0) { GetComponent <MyParticlesScale>().SetParticlesScale(1); this.transform.localScale = new Vector3(jn_date._scaleW, jn_date._scaleW, jn_date._scaleW); } else { GetComponent <MyParticlesScale>().SetParticlesScale(-1); this.transform.localScale = new Vector3(-jn_date._scaleW, -jn_date._scaleW, -jn_date._scaleW); } } if (GetComponent <JN_Date>().IsChanFXBYAtkObj) { this.transform.localScale = new Vector3(_sacaleX, 1, 1); } if (jn_date._type == "2" || jn_date._type == "3") { //2 持续型 //GetKuai(jn_date, _position); jn_date.moveXSpeed = Mathf.Abs(jn_date.moveXSpeed); jn_date.moveXSpeed *= -_sacaleX; //StartCoroutine(ObjectPools.GetInstance().IEDestory2ByTime(hitKuai,jn_date._disTime)); } if (jn_date._type == "6") { GetComponent <TX_Dianqiang>().GetStart(); GetComponent <TX_Dianqiang>().SetSpeedFX(_sacaleX); } //GetKuai(_atkVVo, _position); //StartCoroutine(ObjectPools.GetInstance().IEDestory2(hitKuai)); if (!IsControlDis) { StartCoroutine(ObjectPools.GetInstance().IEDestory2ByTime(gameObject, jn_date.TXDisTime)); } }