public static void CB_COMP_vHealthController(GameObject target) { if (target.GetComponent <vHealthController>()) { if (!target.GetComponent <SyncHealthController>()) { target.AddComponent <SyncHealthController>(); } E_Helpers.SetObjectIcon(target, E_Core.h_genericIcon); vHealthController hc = target.GetComponent <vHealthController>(); if (!E_PlayerEvents.HasUnityEvent(hc.onReceiveDamage, "SendDamageOverNetwork", target.GetComponent <SyncHealthController>())) { UnityEventTools.AddPersistentListener(hc.onReceiveDamage, target.GetComponent <SyncHealthController>().SendDamageOverNetwork); } } if (target.GetComponentInChildren <vHealthController>()) { foreach (vHealthController hc in target.GetComponentsInChildren <vHealthController>()) { if (!hc.gameObject.GetComponent <SyncHealthController>()) { hc.gameObject.AddComponent <SyncHealthController>(); } E_Helpers.SetObjectIcon(hc.gameObject, E_Core.h_genericIcon); if (!E_PlayerEvents.HasUnityEvent(hc.onReceiveDamage, "SendDamageOverNetwork", hc.gameObject.GetComponent <SyncHealthController>())) { UnityEventTools.AddPersistentListener(hc.onReceiveDamage, hc.gameObject.GetComponent <SyncHealthController>().SendDamageOverNetwork); } } } }
private void OnTriggerStay(Collider other) { if (targetTag.Contains(other.tag) && target == null) { var _target = new Vector3(other.transform.position.x, other.transform.position.y + targetOffSetY, other.transform.position.z); var v3Target = (_target - aimReference.position); var angleOfTarget = Vector3.Angle(v3Target, angleReference.forward); if (angleOfTarget < maxAngle && !CheckObtacles(_target)) { target = other.GetComponent <vHealthController>(); onFindTarget.Invoke(); } } }
public void FindFriend() { var fGO = FindObjectsOfType <vHealthController>().vToList().Find(p => p.gameObject.CompareTag(friendTag)); if (fGO) { friend = fGO; controller = friend.GetComponent <vAICompanionControl>(); if (controller && !controller.aICompanions.Contains(this)) { controller.aICompanions.Add(this); } } }
//[SerializeField] PushableUnitData[] storedPushables = new PushableUnitData[0]; //[Serializable] //class PushableUnitData //{ // public Transform t = null; // public Vector3 storedHitPint = new Vector3(); // public int maxCount = 0; // public int currCount = 0; // public PushableUnitData(){ } // public PushableUnitData(Transform t, Vector3 storedHitPint, int maxCount) // { // this.t = t; // this.storedHitPint = storedHitPint; // this.maxCount = maxCount; // } // public void OnPushed() // { // currCount = currCount + 1; // } // public bool IsMaxed() => currCount >= maxCount; //} protected override void ApplyDamage(Transform target, Vector3 hitPoint) { if (storedTargets.Contains(target)) { return; } PushableUnit pUnit = target.GetComponent <PushableUnit>(); vHealthController healthController = target.GetComponent <vHealthController>(); if (healthController == null) { vDamageRecieverSimple receiver = target.GetComponent <vDamageRecieverSimple>(); if (receiver == null) { return; } healthController = receiver.targetReciever.GetComponent <vHealthController>(); } if (healthController == null) { return; } if (pUnit == null) { pUnit = healthController.GetComponent <PushableUnit>(); } if (pUnit == null) { base.ApplyDamage(target, hitPoint); return; } OnContactHappened(healthController.transform); bool didPush = pUnit.TryPush(pushData, transform.position, OnRecovered, damage.damageValue); if (!didPush) { return; } //storedPushables = new PushableUnitData(healthController.transform,hitPoint,pUnit.) storedTargets.Add(healthController.transform); storedHitPoints[healthController.transform] = hitPoint; }
void Start() { healthControl = transform.GetComponentInParent <vHealthController>(); if (healthControl == null) { Debug.LogWarning("The character must have a ICharacter Interface"); Destroy(this.gameObject); } healthControl.onReceiveDamage.AddListener(Damage); _healthSlider.maxValue = healthControl.maxHealth; _healthSlider.value = _healthSlider.maxValue; _damageDelay.maxValue = healthControl.maxHealth; _damageDelay.value = _healthSlider.maxValue; _damageCounter.text = string.Empty; if (healthBar) { healthBar.SetActive(false); } }
void ResetTarget() { target = null; onLostTarget.Invoke(); }
public static void CB_CONTEXT_vHealthController(MenuCommand command) { vHealthController prefab = (vHealthController)command.context; CB_COMP_vHealthController(prefab.gameObject); }
public virtual void Awake() { hc = GetComponent <vHealthController>(); }
void Start() { _rigidbody = GetComponent <Rigidbody>(); character = GetComponent <vHealthController>(); character.onReceiveDamage.AddListener(TakeDamage); }