コード例 #1
0
ファイル: Monster.cs プロジェクト: OFTNgames/SmallGame
    private void OnCollisionEnter2D(Collision2D collision)
    {
        ICanTakeDamage _canTakeDamage = collision.collider.gameObject.GetComponent <ICanTakeDamage>();

        if (_canTakeDamage != null)
        {
            _canTakeDamage.TakeDamage();
        }
    }
コード例 #2
0
    /// <summary>
    /// called by melleeWeapon
    /// </summary>
    /// <param name="Target"></param>
    public void DealDamage(ICanTakeDamage Target)
    {
        if (isServer || test)
        {
            Debug.Log("yo2");


            Target.TakeDamage(mainAttackDamage, this);
        }
    }
コード例 #3
0
    public void Attack()
    {
        Collider2D[] damage = Physics2D.OverlapCircleAll(attPos.position, attackRange, enemiesLayer);

        for (int i = 0; i < damage.Length; i++)
        {
            ICanTakeDamage objToTakeDamage = damage[i].GetComponent <ICanTakeDamage>();
            if (objToTakeDamage != null)
            {
                objToTakeDamage.TakeDamage();
            }
        }
    }
コード例 #4
0
ファイル: WeaponAttack.cs プロジェクト: Pbasnal/PrisonEscape
        public AttackStage Attack(ICanTakeDamage canTakeDamage, float baseDamageAmount)
        {
            attackTimer += Time.deltaTime;
            if (!attacked && attackTimer < anticipationTimeInMs)
            {
                Debug.Log(string.Format("Anticipating: {0}", 0));
                return(AttackStage.Anticipation);
            }
            else if (!attacked && attackTimer > anticipationTimeInMs)
            {
                canTakeDamage.TakeDamage(baseDamageAmount * damageMultiplier);
                attacked = true;
                return(AttackStage.Contact);
            }
            else if (attacked && attackTimer < recoveryTimeInMs + anticipationTimeInMs)
            {
                Debug.Log(string.Format("Recovering: {0}", 0));
                return(AttackStage.Recovery);
            }

            return(AttackStage.Complete);
        }
コード例 #5
0
 public void Attack(ICanTakeDamage canTakeDamage)
 {
     canTakeDamage.TakeDamage(damageToDeal);
 }
コード例 #6
0
 protected override void OnCollideTakeDamage(Collider2D other, ICanTakeDamage takedamage)
 {
     takedamage.TakeDamage(Damage, Vector2.zero, gameObject);
     SoundManager.PlaySfx(soundHitEnemy, soundHitEnemyVolume);
     DestroyProjectile();
 }