コード例 #1
0
    public void acceptDamage(DamageAcceptorRegistry.DamageArgs argInArgs)
    {
        if (destructible)
        {
            float locDamage = argInArgs.dmg;

            if (locDamage > 0)
            {
                if (hitPoints > locDamage)
                {
                    hitPoints -= locDamage;
                    locDamage  = 0;
                }
                else
                {
                    hitPoints = 0;
                    Invoke("Destruct", 0.02f);
                    DamageProvider dp = argInArgs.source.GetComponent <DamageProvider>();
                    if (dp != null)
                    {
                        dp.ReportKill(this);
                    }
                }
            }
        }
        Push(argInArgs.knockback);
    }
コード例 #2
0
    private void OnTriggerEnter(Collider other)
    {
        DamageProvider dp = other.GetComponentInParent <DamageProvider>();

        if (dp != null)
        {
            _currHealth -= dp.Damage;
            if (_currHealth > _maxHealth)
            {
                _currHealth = _maxHealth;
            }
            if (_currHealth <= 0)
            {
                Died(dp.Damage);
                if (DieEvent != null)
                {
                    DieEvent(this);
                }
            }
            else
            {
                Damaged(dp.Damage);
                if (DamageEvent != null)
                {
                    DamageEvent(this);
                }
            }
            Destroy(dp.gameObject);
        }
        _isDamaged = _currHealth < _maxHealth;
    }
コード例 #3
0
ファイル: Brawler.cs プロジェクト: foxor/MorphiumCard
 protected override IEnumerable<DynamicProvider> TemplatingArguments()
 {
     thornsProvider = new DamageProvider(2);
     yield return Attack;
     yield return Defense;
     yield return thornsProvider.Provider;
 }
コード例 #4
0
 private void Start()
 {
     lr = GetComponent <LineRenderer> ();
     lr.SetVertexCount(0);
     UpdateFromMaterialChange();
     dp = GetComponent <DamageProvider>();
 }
コード例 #5
0
    public override bool Engage(Vector3 newTarget)
    {
        bool result = false;

        if ((Time.time - previousShotTime) >= (1f / fireRate))
        {
            GameObject proj = Instantiate(Resources.Load(projectileResourceName, typeof(GameObject)),
                                          barrel.transform.position, Quaternion.FromToRotation(Vector3.right, newTarget - this.transform.position))
                              as GameObject;
            previousShotTime = Time.time;

            proj.transform.parent = gpParent.transform;
            DamageProvider dp = GetComponentInParent <DamageProvider>();
            if (dp != null)
            {
                proj.GetComponent <Projectile>().damageSource = ((Component)dp).gameObject;
            }
            else
            {
                proj.GetComponent <Projectile>().damageSource = this.gameObject;
            }
            proj.GetComponent <Projectile>().damage = damage;
            audioSource.Play();

            result = true;
        }

        return(result);
    }
コード例 #6
0
 void Start()
 {
     line = GetComponentInChildren <LineRenderer> ();
     cc   = GetComponentInChildren <CapsuleCollider> ();
     l    = GetComponentInChildren <Light> ();
     dp   = GetComponentInChildren <DamageProvider>();
 }
コード例 #7
0
    public virtual void acceptDamage(DamageAcceptorRegistry.DamageArgs argInArgs)
    {
        //Debug.Log("AIAcceptDmg" + argInArgs.dmg);
        if (this.gameObject == null)
        {
            return;
        }
        if (stats.isDead)
        {
            return;
        }
        float locDamage = argInArgs.dmg;

        if (stats.currentArmorPoints > 0)
        {
            if (stats.currentArmorPoints > locDamage)
            {
                stats.currentArmorPoints -= locDamage;
                locDamage = 0;
            }
            else
            {
                stats.currentArmorPoints = 0;
                locDamage -= stats.currentArmorPoints;
            }
        }
        if (locDamage > 0)
        {
            if (stats.currentHitPoints > locDamage)
            {
                stats.currentHitPoints -= locDamage;
                locDamage = 0;
                Knockback(argInArgs.knockback);
            }
            else
            {
                stats.currentHitPoints = 0;
                stats.isDead           = true;
                DamageProvider dp = argInArgs.source.GetComponent <DamageProvider>();
                if (dp != null)
                {
                    dp.ReportKill(this);
                }
                Die(argInArgs);
            }
        }
        Transform healthbar = transform.Find("HealthBar");

        if (healthbar != null)
        {
            healthbar.transform.Find("Level").GetComponent <Image>().fillAmount = stats.currentHitPoints / stats.totalHitPoints;
        }
    }
コード例 #8
0
 public override void Apply(string guid)
 {
     Minion minion = GameState.GetMinion(guid);
     if (minion != null) {
         DamageProvider damage = new DamageProvider(minion.Durability);
         TargetingRequirements allMinions = new TargetingRequirements(
             (int)TargetTypeFlag.Friendly | (int)TargetTypeFlag.Enemy | (int)TargetTypeFlag.Minion,
             global::TargetingType.All
         );
         foreach (string targetGuid in allMinions.AllowedTargets()) {
             damage.Apply(targetGuid, minion.GUID);
         }
     }
 }
コード例 #9
0
 void Start()
 {
     deadline = Time.time + time;
     active   = true;
     dp       = GetComponent <DamageProvider>();
 }
コード例 #10
0
ファイル: Minion.cs プロジェクト: foxor/MorphiumCard
 public Minion()
 {
     GUID = Guid.NewGuid().ToString();
     damageProvider = new MinionDamageProvider(this);
 }
コード例 #11
0
 void Start()
 {
     origin = transform.position;
     dp     = GetComponentInChildren <DamageProvider> ();
 }
コード例 #12
0
ファイル: EyeLasers.cs プロジェクト: foxor/MorphiumCard
 protected override System.Collections.Generic.IEnumerable<DynamicProvider> TemplatingArguments()
 {
     Damage = new ActiveMorphidDamageProvider(0, () => lastCostCheck * 2);
     yield return Damage.Provider;
 }
コード例 #13
0
ファイル: PlayerView.cs プロジェクト: MatthewAdams2/geekMVC
 private void OnCollisionEnter(Collision collision)
 {
     DamageProvider = collision.gameObject.GetComponent <DamageProvider>();
 }
コード例 #14
0
ファイル: PlayerView.cs プロジェクト: MatthewAdams2/geekMVC
 public void DoLateUpdate()
 {
     DamageProvider = null;
 }
コード例 #15
0
 void Start()
 {
     dp = GetComponent <DamageProvider>();
 }