private void OnEntityHit(IDamage damageComponent, GameObject target) { if (Equals(this.gameObject, target)) { _HealthComponent.TakeDamage(damageComponent.Damage); } }
public bool Explode() { if (m_boatPart.Health <= 0) { return(false); } Collider[] objects = Physics.OverlapSphere(transform.position, m_boatPart.Radius); List <IDamage> damageables = new List <IDamage>(); for (int i = 0; i < objects.Length; i++) { IDamage damageable = objects[i].GetComponent <IDamage>(); if (damageable != null) { damageables.Add(damageable); } } for (int i = 0; i < damageables.Count; i++) { damageables[i].Take(m_boatPart.Damage); } return(true); }
public int Caculate(IDamage damage) { //驱散处理 //this.m_Caster.GetOrAddUnitComponent<BuffComponent>().Disperse(this.m_SkillData.Mute); //处理计算后的返回值 return(damage.Handle(this)); }
/// <summary> /// 检测伤害(显示命中声音) /// </summary> /// <param name="iDamage"></param> /// <param name="fieldName"></param> private void IDamageStateChagned(IDamage iDamage, string fieldName) { if (string.Equals(fieldName, GameState.GetFieldNameStatic <IDamage, int>(temp => temp.WeaponPhysicHit))) { EnumWeaponTypeByPlayerState weaponType = (EnumWeaponTypeByPlayerState)iDamage.WeaponPhysicHit; PhysicHitAudioStruct physicHitAudioStruct = physicHitAudios.FirstOrDefault(temp => temp.WeaponType == weaponType); if (physicHitAudioStruct != null) { audioSources[3].clip = physicHitAudioStruct.Clip; audioSources[3].Play(); } } else if (string.Equals(fieldName, GameState.GetFieldNameStatic <IDamage, int>(temp => temp.MagicTypeHit))) { if (iDamage.MagicTypeHit >= (int)EnumSkillType.MagicCombinedLevel2Start && iDamage.MagicTypeHit < (int)EnumSkillType.MagicCombinedLevel2End) { MagicHitAudioStruct magicHitAudioStruct = magicHitAduios.FirstOrDefault(temp => temp.SkillType == iDamage.MagicTypeHit); if (magicHitAudioStruct != null) { audioSources[3].clip = magicHitAudioStruct.Clip; audioSources[3].Play(); } } } }
private void Instance_OnDealDamage(CreatureStats creature, IDamage arg2) { if (creature == _creature && impact != null) { GameHelper.instance.PlaySoundShot(impact); } }
private void Instance_OnDeathPlayer(CreatureStats creature, IDamage arg2) { if (creature == _creature && death != null) { GameHelper.instance.PlaySoundShot(death); } }
void Boom() { if (flagBoom) { return; } flagBoom = true; // disable collider before explosion to avoid unnecessary OnCollisionEnter2D() calls circle.enabled = false; timeoutTimer.Stop(false); int count = Physics2D.OverlapCircleNonAlloc(transform.position, BoomRadius, clds, Global.DamageCollideLayers); for (int i = 0; i < count; i++) { if (clds[i] != null) { IDamage dam = clds[i].GetComponent <IDamage>(); if (dam != null) { Damage dmg = Instantiate(ContactDamage); dmg.instigator = instigator; dmg.damageSource = transform; dmg.point = transform.position; dam.TakeDamage(dmg); } } } Destroy(gameObject); Instantiate(explosion, transform.position, Quaternion.identity); }
void Start() { if (mydamage == null) { mydamage = GetComponentInParent <IDamage> (); } }
void DoDamage(float damage, int layer, IDamage self) { //get hits this frame RaycastHit[] hits = GetHits(layer); //foreach hit foreach (RaycastHit hit in hits) { //only if hit something if (hit.transform == null) { continue; } IDamage enemyHit = hit.transform.GetComponentInParent <IDamage>(); //if can hit if (CanHit(enemyHit, self)) { //add to already hits alreadyHits.Add(enemyHit); //and do damage enemyHit.ApplyDamage(self, damage); } } }
private void DamageSystem_OnDeathPlayer(CreatureStats c, IDamage damage) { _allPlayers.Remove(c); c.gameObject.tag = "DeathPlayer"; c.gameObject.layer = 2; c.GetComponent <CharacterController>().enabled = false; //Удаляем все состояния ICharacterState[] states = c.GetComponents <ICharacterState>(); foreach (var state in states) { Destroy(state); } if (_currentPlayer == c) { ChangePlayer(); } //Заплатк адля конца if (_allPlayers.FirstOrDefault(x => x.team == 1) == null) { endPoint.SetActive(true); } }
public virtual int CalculateDamage(IDamage damage) { int totalDamage = damage.Dice.RollDice(); totalDamage += AddDamageStatBonus(damage); return(totalDamage); }
private void Instance_OnDeathPlayer(CreatureStats creature, IDamage arg2) { if (creature == _creature) { _animator.SetBool("death", true); } }
public int Caculate(IDamage damage) { //驱散处理 this.m_Caster.Disperse(this.m_Attribute.Mute); //处理计算后的返回值 return(damage.Handle(this)); }
void Update() { if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { Transform objectHit = hit.transform; MonoBehaviour[] mono; mono = objectHit.gameObject.GetComponents <MonoBehaviour>(); foreach (MonoBehaviour item in mono) { if (item is IDamage) { IDamage temp = item as IDamage; temp.TakeDamage(); return; } } } } }
private void OnTriggerEnter(Collider other) { if (other.tag == "Wall") { PlayerBase.transform.position = new Vector3(PlayerRef.StartPos.x, PlayerRef.StartPos.y, PlayerRef.StartPos.z); } if (other.tag == "Enemy") { EnemyRef = other.GetComponent <BaseEnemy>(); if (!EnemyRef.Attacked) { EnemiesHit.Add(other.GetComponent <BaseEnemy>()); EnemyRef.Attacked = true; IDamage DamRef = other.GetComponent <IDamage>(); if (DamRef != null) { DamRef.TakeDamage(SkillManager.Instance.DashDamage); DamRef.SetDamageText(SkillManager.Instance.DashDamage, false); } EnemyRef.DamEffect(DamageEffects.ElectricEffect); StartCoroutine(ResetAttacked()); } } }
void AirbotHit() { hitCount = Physics2D.BoxCastNonAlloc(transform.position, box.size, 0, velocity, RaycastHits, raylength, Global.CharacterDamageLayers); for (int i = 0; i < hitCount; i++) { hit = RaycastHits[i]; IDamage dam = hit.transform.GetComponent <IDamage>(); if (dam != null) { Damage dmg = Instantiate(ContactDamage); dmg.instigator = this; dmg.damageSource = transform; dmg.point = hit.point; if (dam.TakeDamage(dmg)) { hitpause = true; pathAgent.SetPath(new Vector3(hit.point.x, hit.point.y, 0) + Vector3.up * hitPauseOffset); animator.Play("laugh"); hitPauseTimer.Start(1, null, delegate { hitpause = false; animator.Play("idle"); }); } } } }
protected BaseAttack(string name, int attack, IDamage damage, AppendageType appendages) { this.Name = name; this.Attack = attack; this.Damage = damage; this.Appendages = appendages; }
private void OnCollisionEnter(Collision other) { if (m_projectile.IsExploded) { return; } Collider[] objects = Physics.OverlapSphere(transform.position, m_projectile.Radius); List <IDamage> damageables = new List <IDamage>(); for (int i = 0; i < objects.Length; i++) { IDamage damageable = objects[i].GetComponent <IDamage>(); if (damageable != null) { damageables.Add(damageable); } } for (int i = 0; i < damageables.Count; i++) { damageables[i].Take(m_projectile.Damage); } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.name == "Pet(Clone)") { CanDamage = false; } if (CanDamage) { if (CanSwing) { IDamage damageInterface = other.GetComponent <IDamage>(); if (damageInterface != null) { damageInterface.TakeDamage(Damage); damageInterface.SetDamageText(Damage, Crit); //playerref.StopAnim(); //playerref.CanMove(); //playerref.AnimationEvent(); //PC.canMove = true; //SwordRef.anim.SetBool("Swing", false); //PR.CanTurn = true; // SwordRef.canSwing = true; CanSwing = false; } } } else { CanDamage = true; // INCASE THE PLAYER HITS THE PET } }
public override int TakeCombatDamage(int totalDamage, IDamage damage, IMobileObject attacker, uint combatRound) { int takenDamage = base.TakeCombatDamage(totalDamage, damage, attacker, combatRound); if (damage.Type == DamageType.Fire) { TookFireDamage = true; } if (RoundOfDamage.LastAttacker == attacker && RoundOfDamage.CombatRound == combatRound) { RoundOfDamage.TotalDamage += Math.Max(0, takenDamage); } else { RoundOfDamage = new RoundOfDamage() { TotalDamage = takenDamage, LastAttacker = attacker, CombatRound = combatRound }; } ProcessIfHeadCutOff(attacker); return(takenDamage); }
public void SetDamage(IDamage obj) { if (obj != null) { obj.SetDamage(new DamageInfo(_bulletDamage)); } }
public void ShowDamage(IDamage damage, Vector3 pos, float upVal = 150, float upTime = 2f) { var s = new string[3]; s[0] = damage.AttackDamage.ToString(); s[1] = damage.CriticalDamage <= 0 ? "" : damage.CriticalDamage.ToString(); s[2] = damage.AttachDamage <= 0 ? "" : damage.AttachDamage.ToString(); ShowTxt(s, pos, upVal, upTime); }
public void ReceiveDamage(IDamage damage, float damageValue) { healthRate -= damageValue / (MaxHealth * block.BlockLevel); if (healthRate <= 0) { block.ParentShip.CollapseBlockWithRecursion(block.Pos); } }
private void OnTriggerExit2D(Collider2D collision) { if (collision.CompareTag("Player")) { HitTarget = null; idamage = null; } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Player")) { HitTarget = collision.gameObject; idamage = HitTarget.GetComponent <IDamage>(); } }
public void TakeDamage(IDamage damage) { Unit.Stats.Health.Reduce(damage); if (Unit.Stats.Health.IsDepleted) { Die(); } }
private int DealDamage(IMobileObject attacker, IMobileObject defender, IDamage damage) { int totalDamage = attacker.CalculateDamage(damage); int damageReceived = defender.TakeCombatDamage(totalDamage, damage, attacker, _combatRound); return(damageReceived); }
public void TakeHit(IDamage hitBy) { OnHit(); var direction = Vector3.Normalize(transform.position - hitBy.transform.position); rigidbody.AddForce(direction * forceAmount, ForceMode.Impulse); }
public void ShowDamageTxt(IDamage damage, Vector3 pos) { uIDamageFonts[index].ShowDamage(damage, Camera.main.WorldToScreenPoint(pos), 240, 0.7f); if (++index >= uIDamageFonts.Length) { index = 0; } }
public SkillManager(IWriteToClient writer, IUpdateClientUI updateClientUi, IDice dice, IDamage damage, ICombat fight) { _writer = writer; _updateClientUi = updateClientUi; _dice = dice; _damage = damage; _fight = fight; }
void OnEnable() { // tp.Test(); test = (IDamage)tp.GetComponent(typeof(IDamage)); test.Damaged(1); test = (IDamage)tc.GetComponent(typeof(IDamage)); test.Damaged(1); }