| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class RockAttackTrigger : AttackTrigger
- {
- public string fatName = "¶Ü¼×±ø";
- public GameObject rockRoller;
- public Vector3 impactRockForcDriction = new Vector3(-1, 0.2f, 0);
- public Vector3 impactFatForcDriction = new Vector3(1, 0.2f, 0);
- public float fatForceMul = 100f;
- public float rockForceMul = 100f;
- private float collisionStopDuration = 0.2f;
- private float curStopTime = 0f;
- public List<BeHitTrigger> attcakFat;
- public List<BeHitTrigger> attcakedFat;
- public int attackFatNumber = 1;
- private int curattackFatNumber = 0;
- private int damage;
- public int damageMultiple = 10;
- protected override void OnTriggerEnter(Collider other)
- {
- BeHitTrigger hitTrigger = other.GetComponent<BeHitTrigger>();
- if (hitTrigger)
- {
- if (hitTrigger.owner.transform.gameObject.GetComponent<RockRoller>())
- {
- return;
- }
- if (hitTrigger.owner.transform.gameObject.GetComponent<Demonic>())
- {
- if (hitTrigger.owner.transform.gameObject.GetComponent<Demonic>().myName == fatName)
- {
- attcakFat.Add(hitTrigger);
- }
- }
- base.OnTriggerEnter(other);
- }
- }
- private void OnTriggerStay(Collider other)
- {
- BeHitTrigger hitTrigger = other.GetComponent<BeHitTrigger>();
- if (attcakFat.Contains(hitTrigger))
- {
- return;
- }
- if (!hitTrigger)
- {
- return;
- }
- if (hitTrigger.owner.transform.gameObject.GetComponent<Demonic>())
- {
- if (hitTrigger.owner.transform.gameObject.GetComponent<Demonic>().myName == fatName)
- {
- attcakFat.Add(hitTrigger);
- }
- }
- }
- public void Update()
- {
-
- if (curStopTime < collisionStopDuration)
- {
- curStopTime += Time.deltaTime;
- attcakFat.Clear();
- }
- if (attcakFat.Count > 0 && curStopTime > collisionStopDuration && curattackFatNumber < attackFatNumber)
- {
- foreach (BeHitTrigger hitTrigger in attcakFat)
- {
- if (attcakedFat.Contains(hitTrigger))
- {
- continue;
- }
- GameObject fat = hitTrigger.owner.transform.gameObject;
- Demonic fatD = hitTrigger.owner.transform.gameObject.GetComponent<Demonic>();
- AttackTrigger at = hitTrigger.owner.transform.gameObject.GetComponentInChildren<RockAttackTrigger>();
- if (fatD.state != CharacterState.Attack)
- {
- HandleFatCollision(fat);
- attcakedFat.Add(hitTrigger);
- damage = attackMethod.attackInfo.damage * damageMultiple;
- hitTrigger.BeHit(damage);
- }
- if (at)
- {
- if (at.attackMethod.attackInfo != null)
- {
- if (at.attackMethod.attackInfo.attackMethod_Type != AttackMethod_Type.Attack_Summon)
- {
- HandleFatCollision(fat);
- attcakedFat.Add(hitTrigger);
- damage = attackMethod.attackInfo.damage * damageMultiple;
- hitTrigger.BeHit(damage);
- }
- }
- }
- if (curattackFatNumber >= attackFatNumber)
- {
- attcakFat.Clear();
- HandleRockCollision(rockRoller);
- curattackFatNumber = 0;
- curStopTime = 0f;
- attcakedFat.Clear();
- break;
- }
- }
- }
- }
- private void HandleRockCollision(GameObject fat)
- {
- if (rockRoller.GetComponent<RockRoller>().state == CharacterState.Die)
- {
- return;
- }
- Rigidbody rockRb = rockRoller.GetComponentInParent<Rigidbody>();
- RockRoller Roller = rockRoller.GetComponentInParent<RockRoller>();
- Roller.ChangeState(CharacterState.Fall);
- rockRb.AddForce(impactRockForcDriction * rockForceMul, ForceMode.Impulse);
- }
- private void HandleFatCollision(GameObject fat)
- {
- Rigidbody fatRb = fat.GetComponent<Rigidbody>();
- Demonic fater = fat.GetComponent<Demonic>();
- fater.GetComponentInChildren<AttributeStatus>().isFly = false;
- fater.GetComponentInChildren<AttributeStatus>().hitState = 0;
- fater.ChangeState(CharacterState.SpecialStatus_BlowUp);
- fatRb.AddForce(impactFatForcDriction * fatForceMul, ForceMode.Impulse);
- curattackFatNumber += 1;
- }
- }
|