| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class SoulBoom : MonoBehaviour
- {
- [HideInInspector]
- public float time;
- public float boomTime;
- [HideInInspector]
- public bool isBoom;
- public AttackInfo attackInfo;
- public float destroyTime;
- public List<MoveCharacter> characters = new List<MoveCharacter>();
- public bool isTransfiguration;
- public float soulUnstableTime;
- public Transform parent;
- private void Start()
- {
- parent = GameObject.Find("SoulBoom").transform;
- }
- private void Update()
- {
- time += Time.deltaTime;
- if (time >= boomTime)
- {
- if (time < boomTime + 0.1)
- {
- GetComponent<Collider>().enabled = true;
- }
- else
- {
- if (!isBoom)
- {
- transform.parent = parent;
- for (int i = 0; i < characters.Count; i++)
- {
- if (characters[i].state == CharacterState.Die)
- {
- continue;
- }
- PlayerController playerController =
- characters[i].GetComponent<PlayerController>();
- if (playerController != null && playerController.isBaseBtnOut)
- {
- continue;
- }
- Vector3 target;
- Vector3 pos1 = characters[i].transform.position;
- Vector3 pos2 = transform.position;
- target = (pos1 - pos2).normalized;
- characters[i].BeHit
- (attackInfo.damage, target * attackInfo.force, true, attackInfo.repelValue);
-
- }
- isBoom = true;
- }
- }
- }
- if (time >= destroyTime)
- {
- gameObject.SetActive(false);
- }
- }
- private void OnTriggerEnter(Collider other)
- {
-
- BeHitTrigger beHitTrigger = other.GetComponent<BeHitTrigger>();
- if (beHitTrigger != null
- && (other.transform.parent.parent.parent.gameObject.layer == 6
- || other.transform.parent.parent.parent.gameObject.layer == 7))
- {
- MoveCharacter character = other.GetComponentInParent<MoveCharacter>();
- if (character.rb == null)
- {
- character = character.transform.parent.GetComponent<MoveCharacter>();
- }
- if (!characters.Exists(t => t == character))
- {
- characters.Add(character);
- }
- }
- //if (!isTransfiguration && beHitTrigger != null
- // && (other.transform.parent.parent.parent.gameObject.layer == 6
- // || other.transform.parent.parent.parent.gameObject.layer == 7))
- //{
- // print(111);
- // MoveCharacter character = other.GetComponentInParent<MoveCharacter>();
- // if (character.rb == null)
- // {
- // character = character.transform.parent.GetComponent<MoveCharacter>();
- // }
- // if (!characters.Exists(t => t == character))
- // {
- // characters.Add(character);
- // }
- //}
- //if (isTransfiguration && beHitTrigger != null && other.transform.parent.parent.parent.gameObject.layer == 8)
- //{
- // MoveCharacter character = other.GetComponentInParent<MoveCharacter>();
- // if (!characters.Exists(t => t == character))
- // {
- // characters.Add(character);
- // }
- //}
- }
- private void OnTriggerExit(Collider other)
- {
- BeHitTrigger beHitTrigger = other.GetComponent<BeHitTrigger>();
- if (beHitTrigger != null
- && (other.transform.parent.parent.parent.gameObject.layer == 6
- || other.transform.parent.parent.parent.gameObject.layer == 7))
- {
- MoveCharacter character = other.GetComponentInParent<MoveCharacter>();
- if (characters.Exists(t => t == character))
- {
- characters.Remove(character);
- }
- }
- //if (!isTransfiguration && beHitTrigger != null
- // && (other.transform.parent.parent.parent.gameObject.layer == 6
- // || other.transform.parent.parent.parent.gameObject.layer == 7))
- //{
- // MoveCharacter character = other.GetComponentInParent<MoveCharacter>();
- // if (characters.Exists(t => t == character))
- // {
- // characters.Remove(character);
- // }
- //}
- //if (isTransfiguration && beHitTrigger != null && other.transform.parent.parent.parent.gameObject.layer == 8)
- //{
- // MoveCharacter character = other.GetComponentInParent<MoveCharacter>();
- // if (characters.Exists(t => t == character))
- // {
- // characters.Remove(character);
- // }
- //}
- }
- }
|