private void OnTriggerEnter(Collider otherCollider) { Debug.Log("Set IsHurt trigger here and take damage"); bool isGuarding = m_Animator.GetBool("isGuarding"); if (otherCollider.gameObject.tag == "EnemyHitBox" && !isGuarding) { BaseHitBox enemyHitbox = otherCollider.gameObject.GetComponent <BaseHitBox>(); Vector3 direction = enemyHitbox.GetDirection(m_RigidBody); float force = enemyHitbox.m_Damages[0].m_KnockbackForce; float damageAmount = enemyHitbox.m_Damages[0].m_DamageAmount; AddImpact(direction, force); if (damageAmount > m_KnockdownThreshold) { m_Animator.SetBool("isKnockdowned", true); StartCoroutine(RecoverFromKnockdown()); } else { m_Animator.SetTrigger("stagger"); } if (enemyHitbox.m_ShouldDestroyOnCollide) { Destroy(enemyHitbox.transform.gameObject); } } }
private void OnParticleCollision(GameObject other) { Debug.Log("Particle Collission" + other); bool isGuarding = m_Animator.GetBool("isGuarding"); if (other.tag == "EnemyHitBox" && !isGuarding) { BaseHitBox enemyHitbox = other.GetComponent <BaseHitBox>(); Vector3 direction = enemyHitbox.GetDirection(m_RigidBody); float force = enemyHitbox.m_Damages[0].m_KnockbackForce; float damageAmount = enemyHitbox.m_Damages[0].m_DamageAmount; AddImpact(direction, force); if (damageAmount > m_KnockdownThreshold) { m_Animator.SetBool("isKnockdowned", true); StartCoroutine(RecoverFromKnockdown()); } else { m_Animator.SetTrigger("stagger"); } } }
private void Client_OnKilledShared(bool killedBy, Character attacker, ref uLink.NetworkMessageInfo info) { Controllable controllable; bool flag; AudioClipArray trait = base.GetTrait <CharacterSoundsTrait>().death; AudioClip item = trait[UnityEngine.Random.Range(0, trait.Length)]; item.Play(base.transform.position, 1f, 1f, 10f); bool flag1 = base.localControlled; if (flag1) { base.rposLimitFlags = RPOSLimitFlags.KeepOff | RPOSLimitFlags.HideInventory | RPOSLimitFlags.HideContext | RPOSLimitFlags.HideSprites; DeathScreen.Show(); } BaseHitBox remote = base.idMain.GetRemote <BaseHitBox>(); if (remote) { remote.collider.enabled = false; } if (!killedBy || !attacker) { controllable = null; flag = false; } else { controllable = attacker.controllable; flag = (!controllable ? false : controllable.localPlayerControlled); } base.AdjustClientSideHealth(0f); if (flag1 || flag) { InterpTimedEvent.Queue(this, "ClientLocalDeath", ref info); if (!flag1) { InterpTimedEvent.Remove(this, true); } else { InterpTimedEvent.Clear(true); } } else { Collider[] componentsInChildren = base.GetComponentsInChildren <Collider>(); for (int i = 0; i < (int)componentsInChildren.Length; i++) { Collider collider = componentsInChildren[i]; if (collider) { collider.enabled = false; } } InterpTimedEvent.Queue(this, "RAG", ref info); NetCull.DontDestroyWithNetwork(this); } }
// Start is called before the first frame update private void Awake() { m_Camera = Camera.main; m_CharacterController = GameObject.FindGameObjectWithTag("Player").GetComponentInChildren <CharacterController>(); m_PlayerController = GameObject.FindGameObjectWithTag("Player").GetComponentInChildren <PlayerController>(); m_Animator = GameObject.FindGameObjectWithTag("Player").GetComponentInChildren <Animator>(); m_BaseHitBox = gameObject.GetComponent <BaseHitBox>(); }
private void Client_OnKilledShared(bool killedBy, Character attacker, ref NetworkMessageInfo info) { Controllable controllable; bool flag2; AudioClipArray death = base.GetTrait <CharacterSoundsTrait>().death; death[Random.Range(0, death.Length)].Play(base.transform.position, (float)1f, (float)1f, (float)10f); bool localControlled = base.localControlled; if (localControlled) { base.rposLimitFlags = RPOSLimitFlags.HideSprites | RPOSLimitFlags.HideContext | RPOSLimitFlags.HideInventory | RPOSLimitFlags.KeepOff; DeathScreen.Show(); } BaseHitBox remote = base.idMain.GetRemote <BaseHitBox>(); if (remote != null) { remote.collider.enabled = false; } if (killedBy && (attacker != null)) { controllable = attacker.controllable; flag2 = (controllable != null) && controllable.localPlayerControlled; } else { controllable = null; flag2 = false; } base.AdjustClientSideHealth(0f); if (!localControlled && !flag2) { foreach (Collider collider in base.GetComponentsInChildren <Collider>()) { if (collider != null) { collider.enabled = false; } } InterpTimedEvent.Queue(this, "RAG", ref info); NetCull.DontDestroyWithNetwork((MonoBehaviour)this); } else { InterpTimedEvent.Queue(this, "ClientLocalDeath", ref info); if (localControlled) { InterpTimedEvent.Clear(true); } else { InterpTimedEvent.Remove(this, true); } } }
private void OnParticleCollision(GameObject other) { Debug.Log("Particle Collission" + other); bool isGuarding = m_Animator.GetBool("isGuarding"); if (other.tag == "EnemyHitBox" && !isGuarding) { BaseHitBox enemyHitbox = other.GetComponent <BaseHitBox>(); Vector3 direction = enemyHitbox.GetDirection(m_RigidBody); float force = enemyHitbox.m_Damage.m_KnockbackForce; AddImpact(direction, force); } }
private void OnTriggerEnter(Collider otherCollider) { Debug.Log("Set IsHurt trigger here and take damage"); bool isGuarding = m_Animator.GetBool("isGuarding"); if (otherCollider.gameObject.tag == "EnemyHitBox" && !isGuarding) { BaseHitBox enemyHitbox = otherCollider.gameObject.GetComponent <BaseHitBox>(); Vector3 direction = enemyHitbox.GetDirection(m_RigidBody); float force = enemyHitbox.m_Damage.m_KnockbackForce; AddImpact(direction, force); } }
private void setUpProperBoxCollider() { //To-Do: Figure out the proper size for this species box Collider, then set it BaseHitBox hitBox = this.gameObject.GetComponentInChildren <BaseHitBox>(); if (hitBox) { BoxCollider2D collider = hitBox.GetComponent <BoxCollider2D>(); if (collider) { collider.size = _BoxColliderSize; collider.offset = _BoxColliderOffset; } } }
//Check if mouse if over the base box collider becuz we clicked the aggro one private bool RayCastExactSpot(Vector3 MouseRaw, GameObject parent) { if (_printStatements) { Debug.Log("RayCastExactSpot"); } Vector3 mousePos = Camera.main.ScreenToWorldPoint(MouseRaw); Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y); LayerMask _LayerMask = (1 << 9) | (1 << 12); //idk //does it matter that distance is 19 if were dir is 0 vector? is this depth? RaycastHit2D[] hits = Physics2D.RaycastAll(mousePos, Vector2.zero); if (hits.Length > 1) { // print("looking thru hits--- if this code i wana know ab it (steve)"); foreach (var h in hits) { //print(h.collider.gameObject); //Debug.Log("Found" + h.collider.gameObject); if (h.collider.GetComponent <BaseHitBox>()) { //print("found hitbox"); BaseHitBox hitBox = h.collider.GetComponent <BaseHitBox>(); //print("parent=" + hitBox.transform.parent); if (hitBox.transform.parent == parent) { // print("return t"); return(true); } } } } return(false); }