private void OnEntityHit(IDamage damageComponent, GameObject target)
 {
     if (Equals(this.gameObject, target))
     {
         _HealthComponent.TakeDamage(damageComponent.Damage);
     }
 }
Ejemplo n.º 2
0
    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);
    }
Ejemplo n.º 3
0
 public int Caculate(IDamage damage)
 {
     //驱散处理
     //this.m_Caster.GetOrAddUnitComponent<BuffComponent>().Disperse(this.m_SkillData.Mute);
     //处理计算后的返回值
     return(damage.Handle(this));
 }
Ejemplo n.º 4
0
 /// <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();
             }
         }
     }
 }
Ejemplo n.º 5
0
 private void Instance_OnDealDamage(CreatureStats creature, IDamage arg2)
 {
     if (creature == _creature && impact != null)
     {
         GameHelper.instance.PlaySoundShot(impact);
     }
 }
Ejemplo n.º 6
0
 private void Instance_OnDeathPlayer(CreatureStats creature, IDamage arg2)
 {
     if (creature == _creature && death != null)
     {
         GameHelper.instance.PlaySoundShot(death);
     }
 }
Ejemplo n.º 7
0
    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);
    }
Ejemplo n.º 8
0
 void Start()
 {
     if (mydamage == null)
     {
         mydamage = GetComponentInParent <IDamage> ();
     }
 }
Ejemplo n.º 9
0
    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);
            }
        }
    }
Ejemplo n.º 10
0
    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);
        }
    }
Ejemplo n.º 11
0
        public virtual int CalculateDamage(IDamage damage)
        {
            int totalDamage = damage.Dice.RollDice();

            totalDamage += AddDamageStatBonus(damage);
            return(totalDamage);
        }
Ejemplo n.º 12
0
 private void Instance_OnDeathPlayer(CreatureStats creature, IDamage arg2)
 {
     if (creature == _creature)
     {
         _animator.SetBool("death", true);
     }
 }
Ejemplo n.º 13
0
 public int Caculate(IDamage damage)
 {
     //驱散处理
     this.m_Caster.Disperse(this.m_Attribute.Mute);
     //处理计算后的返回值
     return(damage.Handle(this));
 }
Ejemplo n.º 14
0
    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;
                    }
                }
            }
        }
    }
Ejemplo n.º 15
0
    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());
            }
        }
    }
Ejemplo n.º 16
0
 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");
                 });
             }
         }
     }
 }
Ejemplo n.º 17
0
 protected BaseAttack(string name, int attack, IDamage damage, AppendageType appendages)
 {
     this.Name       = name;
     this.Attack     = attack;
     this.Damage     = damage;
     this.Appendages = appendages;
 }
Ejemplo n.º 18
0
    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);
        }
    }
Ejemplo n.º 19
0
 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
     }
 }
Ejemplo n.º 20
0
        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);
        }
Ejemplo n.º 21
0
 public void SetDamage(IDamage obj)
 {
     if (obj != null)
     {
         obj.SetDamage(new DamageInfo(_bulletDamage));
     }
 }
Ejemplo n.º 22
0
 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);
 }
Ejemplo n.º 23
0
 public void ReceiveDamage(IDamage damage, float damageValue)
 {
     healthRate -= damageValue / (MaxHealth * block.BlockLevel);
     if (healthRate <= 0)
     {
         block.ParentShip.CollapseBlockWithRecursion(block.Pos);
     }
 }
Ejemplo n.º 24
0
 private void OnTriggerExit2D(Collider2D collision)
 {
     if (collision.CompareTag("Player"))
     {
         HitTarget = null;
         idamage   = null;
     }
 }
Ejemplo n.º 25
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("Player"))
     {
         HitTarget = collision.gameObject;
         idamage   = HitTarget.GetComponent <IDamage>();
     }
 }
Ejemplo n.º 26
0
 public void TakeDamage(IDamage damage)
 {
     Unit.Stats.Health.Reduce(damage);
     if (Unit.Stats.Health.IsDepleted)
     {
         Die();
     }
 }
Ejemplo n.º 27
0
        private int DealDamage(IMobileObject attacker, IMobileObject defender, IDamage damage)
        {
            int totalDamage = attacker.CalculateDamage(damage);

            int damageReceived = defender.TakeCombatDamage(totalDamage, damage, attacker, _combatRound);

            return(damageReceived);
        }
Ejemplo n.º 28
0
    public void TakeHit(IDamage hitBy)
    {
        OnHit();

        var direction = Vector3.Normalize(transform.position - hitBy.transform.position);

        rigidbody.AddForce(direction * forceAmount, ForceMode.Impulse);
    }
Ejemplo n.º 29
0
 public void ShowDamageTxt(IDamage damage, Vector3 pos)
 {
     uIDamageFonts[index].ShowDamage(damage, Camera.main.WorldToScreenPoint(pos), 240, 0.7f);
     if (++index >= uIDamageFonts.Length)
     {
         index = 0;
     }
 }
Ejemplo n.º 30
0
 public SkillManager(IWriteToClient writer, IUpdateClientUI updateClientUi, IDice dice, IDamage damage, ICombat fight)
 {
     _writer         = writer;
     _updateClientUi = updateClientUi;
     _dice           = dice;
     _damage         = damage;
     _fight          = fight;
 }
Ejemplo n.º 31
0
    void OnEnable()
    {
        //		tp.Test();
        test = (IDamage)tp.GetComponent(typeof(IDamage));
        test.Damaged(1);

        test = (IDamage)tc.GetComponent(typeof(IDamage));
        test.Damaged(1);
    }