|
@@ -18,6 +18,7 @@ public class AttackTrigger : MonoBehaviour
|
|
|
public Character owner;
|
|
public Character owner;
|
|
|
[Header("是否为单体攻击")]
|
|
[Header("是否为单体攻击")]
|
|
|
public bool isSingleAttack;
|
|
public bool isSingleAttack;
|
|
|
|
|
+ public bool cantSingleAttack; //单体攻击单位是否已经攻击了
|
|
|
[Header("攻击对象")]
|
|
[Header("攻击对象")]
|
|
|
public List<BeHitTrigger> trigedObjs;
|
|
public List<BeHitTrigger> trigedObjs;
|
|
|
[Header("攻击属性")]
|
|
[Header("攻击属性")]
|
|
@@ -27,7 +28,7 @@ public class AttackTrigger : MonoBehaviour
|
|
|
public float repelValue;
|
|
public float repelValue;
|
|
|
public int offsetY = 1;
|
|
public int offsetY = 1;
|
|
|
public float hitRate = 1;
|
|
public float hitRate = 1;
|
|
|
- private bool isInVain; //击中光球,攻击无效
|
|
|
|
|
|
|
+ //private bool isInVain; //击中光球,攻击无效
|
|
|
[Header("只有空中单位会被造成眩晕")]
|
|
[Header("只有空中单位会被造成眩晕")]
|
|
|
public bool onlyFlyCanWeak;
|
|
public bool onlyFlyCanWeak;
|
|
|
|
|
|
|
@@ -38,42 +39,72 @@ public class AttackTrigger : MonoBehaviour
|
|
|
|
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
private void OnTriggerEnter(Collider other)
|
|
|
{
|
|
{
|
|
|
- if (isInVain)
|
|
|
|
|
- {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- Photosphere photosphere = other.GetComponentInParent<Photosphere>();
|
|
|
|
|
- if (photosphere && Util.CheckCanHit(owner.tag, "Player"))
|
|
|
|
|
- {
|
|
|
|
|
- isInVain = true;
|
|
|
|
|
- photosphere.Reflex(owner.beHitTrigger, damage);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- BeHitTrigger hitTrigger = other.GetComponent<BeHitTrigger>();
|
|
|
|
|
- if (hitTrigger != null)
|
|
|
|
|
|
|
+ //光球脚本,先注释掉,之后再移走
|
|
|
|
|
+ //if (isInVain)
|
|
|
|
|
+ //{
|
|
|
|
|
+ // return;
|
|
|
|
|
+ //}
|
|
|
|
|
+
|
|
|
|
|
+ //Photosphere photosphere = other.GetComponentInParent<Photosphere>();
|
|
|
|
|
+ //if (photosphere && Util.CheckCanHit(owner.tag, "Player"))
|
|
|
|
|
+ //{
|
|
|
|
|
+ // isInVain = true;
|
|
|
|
|
+ // photosphere.Reflex(owner.beHitTrigger, damage);
|
|
|
|
|
+ // return;
|
|
|
|
|
+ //}
|
|
|
|
|
+ if (!isShoot)
|
|
|
{
|
|
{
|
|
|
- bool triged = false;
|
|
|
|
|
- for (int i = 0; i < trigedObjs.Count; i++)
|
|
|
|
|
|
|
+ BeHitTrigger hitTrigger = other.GetComponent<BeHitTrigger>();
|
|
|
|
|
+ if (hitTrigger != null && !hitTrigger.owner.isDie && Util.CheckCanHit(owner.tag, hitTrigger.owner.tag) )
|
|
|
{
|
|
{
|
|
|
- if (trigedObjs[i] == hitTrigger)
|
|
|
|
|
|
|
+ if (isSingleAttack && cantSingleAttack)
|
|
|
{
|
|
{
|
|
|
- triged = true;
|
|
|
|
|
- break;
|
|
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (onlyFlyCanWeak && !hitTrigger.owner.canFly)
|
|
|
|
|
+ {
|
|
|
|
|
+ MoveCharacter moveCharacter = hitTrigger.owner.GetComponent<MoveCharacter>();
|
|
|
|
|
+ if (moveCharacter)
|
|
|
|
|
+ {
|
|
|
|
|
+ moveCharacter.newTotalWeakTime = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //计算护甲减免
|
|
|
|
|
+ int curDamage = damage;
|
|
|
|
|
+ int am = hitTrigger.owner.armor;
|
|
|
|
|
+ if (am > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ int ap = owner.armorPiercing;
|
|
|
|
|
+ int c = am - ap;
|
|
|
|
|
+ if (c < 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ c = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ curDamage = (int)(curDamage * (100f / (100 + c)) + 0.5f);
|
|
|
|
|
+ }
|
|
|
|
|
+ hitTrigger.BeHit(curDamage, force, changeHurt, repelValue);
|
|
|
|
|
+ if (hitTrigger.owner.debugAttackFrom)
|
|
|
|
|
+ {
|
|
|
|
|
+ hitTrigger.owner.DebugAttackFrom(owner.name, curDamage);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (owner.GetComponent<Demonic>())
|
|
|
|
|
+ {
|
|
|
|
|
+ hitTrigger.attackerID = owner.GetComponent<Demonic>().id;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (isSingleAttack)
|
|
|
|
|
+ {
|
|
|
|
|
+ cantSingleAttack = true;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if (!triged)
|
|
|
|
|
- {
|
|
|
|
|
- trigedObjs.Add(hitTrigger);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
private void OnEnable()
|
|
|
{
|
|
{
|
|
|
trigedObjs.Clear();
|
|
trigedObjs.Clear();
|
|
|
- }
|
|
|
|
|
- private void OnDisable()
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ cantSingleAttack = false;
|
|
|
if (isShoot)
|
|
if (isShoot)
|
|
|
{
|
|
{
|
|
|
CharacterColliders cc = GetComponentInParent<CharacterColliders>();
|
|
CharacterColliders cc = GetComponentInParent<CharacterColliders>();
|
|
@@ -87,60 +118,9 @@ public class AttackTrigger : MonoBehaviour
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- int attackTimeLimit = 1;
|
|
|
|
|
- if (isInVain)
|
|
|
|
|
- {
|
|
|
|
|
- isInVain = false;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- for (int i = 0; i < trigedObjs.Count; i++)
|
|
|
|
|
- {
|
|
|
|
|
- if (trigedObjs[i] && Util.CheckCanHit(owner.tag, trigedObjs[i].owner.tag) && !trigedObjs[i].owner.isDie)
|
|
|
|
|
- {
|
|
|
|
|
- if (isSingleAttack && attackTimeLimit == 0)
|
|
|
|
|
- {
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- if (onlyFlyCanWeak && !trigedObjs[i].owner.canFly)
|
|
|
|
|
- {
|
|
|
|
|
- MoveCharacter moveCharacter = trigedObjs[i].owner.GetComponent<MoveCharacter>();
|
|
|
|
|
- if (moveCharacter)
|
|
|
|
|
- {
|
|
|
|
|
- moveCharacter.newTotalWeakTime = 0;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- //计算护甲减免
|
|
|
|
|
- int curDamage = damage;
|
|
|
|
|
- int am = trigedObjs[i].owner.armor;
|
|
|
|
|
- if (am > 0)
|
|
|
|
|
- {
|
|
|
|
|
- int ap = owner.armorPiercing;
|
|
|
|
|
- int c = am - ap;
|
|
|
|
|
- if (c < 0)
|
|
|
|
|
- {
|
|
|
|
|
- c = 0;
|
|
|
|
|
- }
|
|
|
|
|
- curDamage = (int)(curDamage * (100f / (100 + c)) + 0.5f);
|
|
|
|
|
- }
|
|
|
|
|
- trigedObjs[i].BeHit(curDamage, force, changeHurt, repelValue);
|
|
|
|
|
- if (trigedObjs[i].owner.debugAttackFrom)
|
|
|
|
|
- {
|
|
|
|
|
- trigedObjs[i].owner.DebugAttackFrom(owner.name, curDamage);
|
|
|
|
|
- }
|
|
|
|
|
- if (owner.GetComponent<Demonic>())
|
|
|
|
|
- {
|
|
|
|
|
- trigedObjs[i].attackerID = owner.GetComponent<Demonic>().id;
|
|
|
|
|
- }
|
|
|
|
|
- if (isSingleAttack)
|
|
|
|
|
- {
|
|
|
|
|
- attackTimeLimit--;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ private void OnDisable()
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|