private void OnStationKilled(IDamageTaker station) { isSessionActive = false; Debug.Log("gameover"); enemySpawner.Reset(); GameOver?.Invoke(); }
public void Damaged(IDamageTaker health) { if (!m_damaged) { ++m_hittedAmount; m_damaged = true; } }
public void DealDamageTo(IDamageTaker damageTaker) { if (damageTaker == null) { throw new ArgumentNullException(nameof(damageTaker)); } damageTaker.Take(_damage); }
private void OnTriggerEnter(Collider other) { IDamageTaker damageTaker = other.GetComponentInParent <IDamageTaker>(); if (damageTaker != null) { damageTaker.TakeDamage(damage); } ammoTaker.RetutrnToPool(this); }
public void Damaged(IDamageTaker health) { if (!f_runOver) { f_controller.GroundMovement.MovingRight = !f_controller.GroundMovement.MovingRight; f_controller.Velocity = new Vector2(-f_controller.Velocity.x, f_controller.Velocity.y); f_damage.Abort(); f_futureStates = m_futureStatesHelper; } }
private void OnEnemyDie(IDamageTaker damageTaker) { var enemy = damageTaker as Enemy; Score += enemy.PointsValue; spawned[enemy.GroupId].Remove(enemy); Debug.Log("enemy killed"); assetDispenser.PutEnemy(enemy); eventListener.ScoreSet(Score); if (Score > TopScore) { TopScore = Score; } }
protected void ChooseState() { player = damageDealer.CanAtack(); if (player == null) { animator.SetBool("Run", true); animator.SetBool("Atack", false); navMeshAgent.isStopped = false; navMeshAgent.destination = destenation; } else { animator.SetBool("Run", false); animator.SetBool("Atack", true); navMeshAgent.isStopped = true; navMeshAgent.velocity = Vector3.zero; } }
public void Damaged(IDamageTaker damageTaker) { //f_damage.Abort(); m_shallMove = false; if (damageTaker == null) { // since I don't have the contact point anymore; i just create it again List <Collider2D> colliders = DamageHelper.ContactList; // This is not generally correct Transform oldParent = transform.parent; transform.localRotation = Quaternion.identity; float newX = transform.localPosition.x - SPEED_FACTOR * f_speed / 50f * (m_right ? 1 : -1) * 0.5f; transform.localPosition = new Vector3(newX, newX * (m_a * newX + m_b), transform.localPosition.z); transform.position = transform.position + Vector3.back * 3; transform.SetParent(colliders[0].transform, true); Destroy(oldParent.gameObject); m_originalScale = transform.localScale; m_explodeCooldown = f_cooldownExplosionFrames; StartCoroutine(SetEnabled()); // when hitting in a bad angle, this might be false, so I set it to true again } else { if (transform.parent.name.StartsWith("Spit")) { Destroy(transform.parent.gameObject); } else { Destroy(transform.gameObject); } } }
private void FixedUpdate() { if (target == null) { return; } if (needToMove) { meshAgent.destination = destenation; meshAgent.speed = 2 * bossStats.Speed; } else { meshAgent.speed = 0; damageDealer.transform.LookAt(target.transform); } player = damageDealer.CanAtack(); if (player != null && timer <= 0) { Atack(); } }
public void Construct(IFactory <string, IDamageTaker> damageTakerFactory, SignalBus bus) { this.damageTaker = damageTakerFactory.Create(this.DamageTakerTag); bus.Subscribe <Pursuer.PursuerSpawned>(this.OnEnemySpawned); }
/// <summary> /// Deal damage to damage taker from hit object. /// </summary> /// <param name="hitObject">Object that was hit by raycast</param> private void DealDamage(RaycastHit hitObject) { IDamageTaker damageTaker = hitObject.collider.GetComponent <IDamageTaker>(); damageTaker?.TakeDamage(_damage); }
private void FixedUpdate() { //FIX m_damage = 1; List <Collider2D> colliderList = DamageHelper.ContactList; //colliderList.Clear(); ContactFilter2D cf = new ContactFilter2D(); cf.SetLayerMask((int)f_eDamageReceiver); cf.useLayerMask = true; f_collider.OverlapCollider(cf, colliderList); bool hittedOne = false; for (int i = 0; i < colliderList.Count; ++i) { hittedOne = true; IDamageTaker health = colliderList[i].GetComponent <IDamageTaker>(); if (health == null) { health = colliderList[i].transform.parent.GetComponent <IDamageTaker>(); } if (f_hittedAlready.Add(health)) { if (health != null) { if (health.Controller == null || health.Controller.enabled) { Vector2 dir = m_direction; if (m_direction == Vector2.zero) { //TODO a velocity - b velocity (or other way round) } bool shallSpawn = true; if (health.Controller is Player p) { shallSpawn = !(p.ActiveStackedState is CharacterHitted || p.CurrentHitted > 0); } if (shallSpawn) { Instantiate(Consts.Instance.PreHit, (colliderList[i].transform.position + f_collider.transform.position) / 2f, Quaternion.identity); } health.TakeDamage(m_damage, dir); f_damager?.Damaged(health); } } else if (f_reportEveryHit) { f_damager?.Damaged(null); } } } if (f_selfDestroy && hittedOne) { Destroy(gameObject); } ++m_currentDuration; if (m_currentDuration == f_maxFrames) { Abort(); } }
public void Damage(IDamageTaker target) { strength -= target.DoDamage(strength); }
private void Awake() { _damageTaker = GetComponent <IDamageTaker>(); _statusEffectsUpdate = StatusEffectsUpdate; _oneSecond = new WaitForSeconds(1); }
private void FixedUpdate() { //FIX f_damage = 1; bool hittedSth = false; if (f_colliders != null && f_colliders.Length != 0) { List <Collider2D> colliderList = DamageHelper.ContactList; ContactFilter2D cf = new ContactFilter2D(); cf.SetLayerMask((int)f_eDamageReceiver); cf.useLayerMask = true; HashSet <Collider2D> colliderSet = new HashSet <Collider2D>(); List <(Collider2D self, Collider2D other)> colliderCombos = new List <(Collider2D, Collider2D)>(); for (int i = 0; i < f_colliders.Length; ++i) { if (f_colliders[i] == null) { continue; } f_colliders[i].OverlapCollider(cf, colliderList); for (int j = 0; j < colliderList.Count; ++j) { if (colliderSet.Add(colliderList[j])) { colliderCombos.Add((f_colliders[i], colliderList[j])); } } } for (int i = 0; i < colliderCombos.Count; ++i) { hittedSth = true; IDamageTaker health = colliderCombos[i].other.GetComponent <IDamageTaker>(); if (health != null) { bool shallSpawn = true; if (health.Controller is Player p) { shallSpawn = !(p.ActiveStackedState is CharacterHitted || p.CurrentHitted > 0); } if (shallSpawn) { Instantiate(Consts.Instance.PreHit, (colliderCombos[i].self.transform.position + colliderCombos[i].other.transform.position) / 2f, Quaternion.identity); } //TODO; this should still bump the toucher backwards a bit //TODO; Also, I would still actually want the damaged HashSet since otherwise I kill other creatures very fast health.TakeDamage(f_damage, Vector2.zero); } } } else { Debug.LogWarning("HERE"); //TODO; this is not reached anymore List <Collider2D> colliderList = DamageHelper.ContactList; ContactFilter2D cf = new ContactFilter2D(); cf.SetLayerMask((int)f_eDamageReceiver); cf.useLayerMask = true; f_collider.OverlapCollider(cf, colliderList); //TODO; this is ugly and unnecessary if the other one is enabled if (colliderList.Count == 0) { if (f_collider2 != null) { f_collider2.OverlapCollider(cf, colliderList); } } for (int i = 0; i < colliderList.Count; ++i) { hittedSth = true; IDamageTaker health = colliderList[i].GetComponent <IDamageTaker>(); if (health != null) { //TODO; this should still bump the toucher backwards a bit //TODO; Also, I would still actually want the damaged HashSet since otherwise I kill other creatures very fast health.TakeDamage(f_damage, Vector2.zero); } } } if (f_destroySelf && hittedSth) { Destroy(gameObject); } }