| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- using Base.Common;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class AttackTrigger : MonoBehaviour
- {
- public Character owner;
- public List<BeHitTrigger> trigedObjs;
- public int damage;
- public Vector3 force;
- public bool changeHurt;
- public float repelValue;
- public int offsetY = 1;
- public float hitRate = 1;
- private bool isInVain; //»÷ÖйâÇò£¬¹¥»÷ÎÞЧ
- private void Awake()
- {
- owner = GetComponentInParent<Character>();
-
- }
- 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)
- {
- bool triged = false;
- for (int i = 0; i < trigedObjs.Count; i++)
- {
- if (trigedObjs[i] == hitTrigger)
- {
- triged = true;
- break;
- }
- }
- if (!triged)
- {
- trigedObjs.Add(hitTrigger);
- }
- }
- }
- private void OnEnable()
- {
- trigedObjs.Clear();
- }
- private void OnDisable()
- {
- 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)
- {
- trigedObjs[i].BeHit(damage, force, changeHurt, repelValue);
- if (owner.GetComponent<Demonic>())
- {
- trigedObjs[i].attackerID = owner.GetComponent<Demonic>().id;
- }
- }
- }
- }
- }
- }
|