| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- using Base.Common;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class DashEffect : MonoBehaviour
- {/*
- public bool canHit; //canHit==true的时候造成伤害
- public bool isEnemy;
- public bool isBoss;
- public AttackInfo attackInfo; //冲刺造成的伤害
- public List<Character> beHitTriggers = new List<Character>(); //能被冲刺造成伤害的单位
- public GameObject rushEffect; //造成伤害时的刀光效果
- public float targetY; //刀光的高度
- public GameObject aim;
- public float offset;
- public Character owner;
- private bool isInVain; //击中光球,攻击无效
- private void Awake()
- {
- if (!isBoss)
- {
- if (isEnemy)
- {
- attackInfo = GetComponentInParent<Enemy>().Attack_summonInfos[0];
- }
- else
- {
- attackInfo = GetComponentInParent<Demonic>().Attack_summonInfos[0];
- }
- }
- }
- private void Update()
- {
- if (canHit)
- {
- for (int i = 0; i < beHitTriggers.Count; i++)
- {
- DashAttack(beHitTriggers[i]);
- }
- beHitTriggers = new List<Character>();
- }
- }
- private void OnTriggerEnter(Collider other)
- {
- Photosphere photosphere = other.GetComponentInParent<Photosphere>();
- if (photosphere)
- {
- isInVain = true;
- photosphere.Reflex(owner.beHitTrigger, attackInfo.damage);
- return;
- }
- //作为己方冲刺可检测enemy
- BeHitTrigger beHitTrigger = other.GetComponent<BeHitTrigger>();
- if(beHitTrigger!=null&& Util.CheckCanHit(owner.tag, beHitTrigger.owner.tag))
- {
- if (isEnemy && beHitTrigger.owner.tag == "Player" && isInVain)
- {
- return;
- }
- Character character = other.GetComponentInParent<Character>();
- if (!beHitTriggers.Exists(t => t == character))
- {
- beHitTriggers.Add(character);
- }
- }
- }
- private void OnTriggerExit(Collider other)
- {
- //作为己方冲刺可检测enemy
- BeHitTrigger beHitTrigger = other.GetComponent<BeHitTrigger>();
- if (beHitTrigger != null && Util.CheckCanHit(owner.tag, beHitTrigger.owner.tag))
- {
- Character character = other.GetComponentInParent<Character>();
- if (beHitTriggers.Exists(t => t == character))
- {
- beHitTriggers.Remove(character);
- }
- }
- }
-
- //造成伤害
- public void DashAttack(Character character)
- {
- if(character == null)
- {
- return;
- }
- if (character.state == CharacterState.Die)
- {
- return;
- }
- PlayerController playerController = character.GetComponent<PlayerController>();
- if(playerController!=null && playerController.isBaseBtnOut)
- {
- return;
- }
- try
- {
- character.BeHit(attackInfo.damage, attackInfo.force * attackInfo.attackDir,
- attackInfo.changeHurt, attackInfo.repelValue);
- if (character.debugAttackFrom)
- {
- character.DebugAttackFrom(owner.name, attackInfo.damage);
- }
- }
- catch
- {
- print(character.name);
- print(attackInfo);
- }
- //造成伤害时的刀光效果
- if(rushEffect != null)
- {
- GameObject effect = Instantiate(rushEffect);
- effect.transform.position =
- Vector3.Lerp(character.transform.position + Vector3.up * targetY * offset,
- aim.transform.position, 0.5f);
- }
- }*/
- }
|