当前位置: 首页>>代码示例>>C#>>正文


C# Unit.TakeDamage方法代码示例

本文整理汇总了C#中Unit.TakeDamage方法的典型用法代码示例。如果您正苦于以下问题:C# Unit.TakeDamage方法的具体用法?C# Unit.TakeDamage怎么用?C# Unit.TakeDamage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Unit的用法示例。


在下文中一共展示了Unit.TakeDamage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UseAbility

    public override void UseAbility(Unit target)
    {
        base.UseAbility (target);
        Vector3 pos = map.TileCoordToWorldCoord (target.tileX, target.tileY);
        myVisualEffects.Add (effectLib.CreateVisualEffect ("Hit1", pos).GetComponent<EffectController> ());
        int dmg = (int)(damage * myCaster.damageDealtMod);
        myCaster.AddGuardPoints (2);

        // if the target is normal or smaller size
        if (target.mySize <= UnitSize.Normal) {
            int diffX = target.tileX - myCaster.tileX;
            int diffY = target.tileY - myCaster.tileY;

            //deal damage, if not dodged, apply effect
            if (target.TakeDamage(dmg, effectLib.getSoundEffect ("Shield Slam"), true, myCaster) != -1) {
                target.ApplyEffect (new Snare ("Barged", duration, effectLib.getIcon("Barge").sprite));
                target.ShowCombatText ("Snared", myTarget.statusCombatText);
                if (map.UnitCanEnterTile(myCaster.tileX+(diffX*2), myCaster.tileY+(diffY*2))) {
                    target.SlideToTile(myCaster.tileX+(diffX*2), myCaster.tileY+(diffY*2));
                    myCaster.SlideToTile(myCaster.tileX+(diffX), myCaster.tileY+(diffY));
                }
            }
        } else {
            if (target.TakeDamage(dmg, effectLib.getSoundEffect ("Shield Slam"), true, myCaster) != -1) {
                target.ApplyEffect (new Snare ("Barged", duration, effectLib.getIcon("Barge").sprite));
                target.ShowCombatText ("Snared", myTarget.statusCombatText);
            }
        }
    }
开发者ID:JohnEz,项目名称:TileBasedEngine,代码行数:29,代码来源:Barge.cs

示例2: RunEffect

	public override void RunEffect(Unit u, bool reapply = false)
    {
 	    base.RunEffect(u, reapply);

        //deal damage 
		if (!reapply) {
			u.TakeDamage (damage, null, false);
		}
    }
开发者ID:JohnEz,项目名称:TileBasedEngine,代码行数:9,代码来源:Dot.cs

示例3: Attack

    public void Attack(Unit enemy)
    {
        enemy.TakeDamage(this.BaseDamage * CalculateSpecialDamageMults(this, enemy));
        this.TakeDamage(enemy.BaseDamage * CalculateSpecialDamageMults(enemy, this) * enemy.DamageMultiplier.Defense);
        _gc.Busy = true;

        Attacked = true;
        PlayAttackAnimation(enemy);
    }
开发者ID:ZeronSix,项目名称:ld30,代码行数:9,代码来源:Unit.cs

示例4: UseAbility

    public override void UseAbility(Unit target)
    {
        base.UseAbility (target);
        int combo = myCaster.UseGuardPoints ();
        int dmg = (int)(damage * myCaster.damageDealtMod);

        if (target.TakeDamage(dmg * combo, effectLib.getSoundEffect ("Shield Slam"), true, myCaster) != -1) {
            target.ApplyEffect(new Stun("Shield Slammed", (int)(combo / 2), effectLib.getIcon("Shield Slam").sprite));
            target.ShowCombatText ("Stunned", target.statusCombatText);
        }
    }
开发者ID:JohnEz,项目名称:TileBasedEngine,代码行数:11,代码来源:ShieldSlam.cs

示例5: UseAbility

    public override void UseAbility(Unit target)
    {
        base.UseAbility(target);
        int dmg = (int)(damage * myCaster.damageDealtMod);

        //deal damage, if not dodged, apply effect
        if (target.TakeDamage (dmg, effectLib.getSoundEffect ("Crippling Strike"), true, myCaster) != -1) {
            myCaster.AddGuardPoints (1);
        }

        Vector3 pos = map.TileCoordToWorldCoord (target.tileX, target.tileY);
        myVisualEffects.Add (effectLib.CreateVisualEffect ("Slash1", pos).GetComponent<EffectController> ());
    }
开发者ID:JohnEz,项目名称:TileBasedEngine,代码行数:13,代码来源:GuardianStrike.cs

示例6: RunTrigger

	public override void RunTrigger (Unit host, Unit attacker = null)
	{
		if (attacker != null) {
			base.RunTrigger (host, attacker);

			int dmg = (int)(damage * myCaster.damageDealtMod);

			attacker.TakeDamage (dmg, effectLib.getSoundEffect ("Sword1"), false, myCaster);

			Vector3 pos = attacker.transform.position;
			effectLib.CreateVisualEffect ("Slash1", pos);
		}
	}
开发者ID:JohnEz,项目名称:TileBasedEngine,代码行数:13,代码来源:DamageAttackerTrigger.cs

示例7: UseAbility

    public override void UseAbility(Unit target)
    {
        base.UseAbility (target);
        int dmg = (int)(damage * myCaster.damageDealtMod);

        //deal damage, if not dodged, apply effect
        if (target.TakeDamage (dmg, effectLib.getSoundEffect ("Divine Sacrifice"), true, myCaster) != -1) {
            //apply an on death trigger
            target.AddTrigger (new DivineSacrificeTrigger ("Divine Sacrifice", myCaster, duration, effectLib, manaGain, effectLib.getIcon("Divine Sacrifice").sprite));
        }

        Vector3 pos = map.TileCoordToWorldCoord (target.tileX, target.tileY);
        myVisualEffects.Add (effectLib.CreateVisualEffect ("Divine Sacrifice", pos).GetComponent<EffectController> ());
    }
开发者ID:JohnEz,项目名称:TileBasedEngine,代码行数:14,代码来源:DivineSacrifice.cs

示例8: UseAbility

    public override void UseAbility(Unit target)
    {
        base.UseAbility (target);

        int dmg = (int)(damage * myCaster.damageDealtMod);

        //deal damage, if not dodged, apply effect
        if (target.TakeDamage (dmg, effectLib.getSoundEffect ("Lacerate"), true, myCaster) != -1) {
            target.ApplyEffect (new Dot ("Lacerate", duration, bleedDmg, stacks, effectLib.getIcon("Lacerate").sprite));
        }

        Vector3 pos = map.TileCoordToWorldCoord (target.tileX, target.tileY);
        myVisualEffects.Add (effectLib.CreateVisualEffect ("Slash1", pos).GetComponent<EffectController> ());
    }
开发者ID:JohnEz,项目名称:TileBasedEngine,代码行数:14,代码来源:Lacerate.cs

示例9: RunTrigger

	public override void RunTrigger (Unit host, Unit attacker = null)
	{
		base.RunTrigger (host, null);

		int dmg = (int)(damage * myCaster.damageDealtMod);

		host.TakeDamage (dmg, null, false, null);
		host.ApplyEffect (new Stun ("Crackling Arrow", 1));

		Vector3 pos = host.transform.position;
		effectLib.CreateVisualEffect ("Hit1", pos);

		myCaster.GetComponent<AudioSource> ().PlayOneShot (effectLib.getSoundEffect ("Crackling Arrow Pop"));
	}
开发者ID:JohnEz,项目名称:TileBasedEngine,代码行数:14,代码来源:CracklingArrowTrigger.cs

示例10: UseAbility

    public override void UseAbility(Unit target)
    {
        base.UseAbility(target);
        int dmg = (int)(damage * myCaster.damageDealtMod);

        HealingDealtEffect healEffect = new HealingDealtEffect ("Smite", duration, healingMod, stacks, effectLib.getIcon("Smite").sprite);

        //deal damage, if not dodged, apply effect
        target.TakeDamage (dmg, effectLib.getSoundEffect ("Crippling Strike"), true, myCaster);
        myCaster.ApplyEffect (healEffect);
        myCaster.AddTrigger(new RemoveEffect ("smite remove", myCaster, TriggerType.Heal, healEffect, effectLib, duration, effectLib.getIcon("Smite").sprite));

        Vector3 pos = map.TileCoordToWorldCoord (target.tileX, target.tileY);
        myVisualEffects.Add (effectLib.CreateVisualEffect ("Slash1", pos).GetComponent<EffectController> ());
    }
开发者ID:JohnEz,项目名称:TileBasedEngine,代码行数:15,代码来源:Smite.cs

示例11: UseAbility

    public override void UseAbility(Unit target)
    {
        cooldown = maxCooldown;
        AbilityFinished = false;
        myTarget = target;

        int dmg = (int)(damage * myCaster.damageDealtMod);

        //deal damage, if not dodged, apply effect
        if (target.TakeDamage (dmg, null, true, myCaster) != -1) {
            if (target.ApplyEffect (new Stun ("Frozen", duration, effectLib.getIcon("Flash Freeze").sprite))) {
                target.ShowCombatText ("Stunned", target.statusCombatText);
            }
        }
    }
开发者ID:JohnEz,项目名称:TileBasedEngine,代码行数:15,代码来源:FlashFreeze.cs

示例12: UseAbility

    public override void UseAbility(Unit target)
    {
        base.UseAbility (target);
        int dmg = (int)(damage * myCaster.damageDealtMod);
        int combo = myCaster.UseGuardPoints ();

        int dirX = myCaster.tileX - target.tileX;
        int dirY = myCaster.tileY - target.tileY;

        int currX = myCaster.tileX + dirX;
        int currY = myCaster.tileY + dirY;

        //create effect facing target
        if (dirX < 0 || dirY > 0) {
            Vector3 pos = map.TileCoordToWorldCoord (myCaster.tileX, myCaster.tileY) + new Vector3(0.3f, 0, 0);
            myVisualEffects.Add (effectLib.CreateVisualEffect ("Point Blank", pos).GetComponent<EffectController> ());
        } else {
            Vector3 pos = map.TileCoordToWorldCoord (myCaster.tileX, myCaster.tileY) + new Vector3(0.3f * -1, 0, 0);
            myVisualEffects.Add (effectLib.CreateVisualEffect ("Point Blank", pos, true).GetComponent<EffectController> ());
        }

        myCaster.GetComponent<AudioSource> ().PlayOneShot (effectLib.getSoundEffect ("Point Blank"));

        int count = 0;

        while (map.UnitCanEnterTile(currX, currY) && count < combo) {
            currX += dirX;
            currY += dirY;
            ++count;
        }

        currX -= dirX;
        currY -= dirY;

        if (currX != myCaster.tileX || currY != myCaster.tileY) {
            myCaster.SlideToTile (currX, currY);
        }

        //cant dodge or block this finisher
        target.TakeDamage (dmg * combo, null, false, myCaster);
    }
开发者ID:JohnEz,项目名称:TileBasedEngine,代码行数:41,代码来源:PointBlank.cs

示例13: UseAbility

    public override void UseAbility(Unit target)
    {
        base.UseAbility (target);

        int count = 0;

        //check if it has fire debuff
        foreach (Effect eff in target.myEffects) {
            if (eff.name.Contains("Lacerate")) {
                count = eff.stack;
            }
        }

        int dmg = (int)((damage * count) * myCaster.damageDealtMod);

        //deal damage
        target.TakeDamage (dmg, effectLib.getSoundEffect ("Lacerate"), true, myCaster);

        Vector3 pos = map.TileCoordToWorldCoord (target.tileX, target.tileY);
        myVisualEffects.Add (effectLib.CreateVisualEffect ("Slash2", pos).GetComponent<EffectController> ());
    }
开发者ID:JohnEz,项目名称:TileBasedEngine,代码行数:21,代码来源:Flurry.cs

示例14: UseAbility

    public override void UseAbility(Unit target)
    {
        base.UseAbility (target);

        int dmg = (int)(damage * myCaster.damageDealtMod);

        float mod = 1;

        // if its a mana user
        if (target.maxMana != 0) {
            //calculate the modifier
            mod = 2 - ((float)target.mana / (float)target.maxMana)*2;
        }

        dmg = (int)(dmg * mod);

        //deal damage, if it was not dodged
        if (target.TakeDamage (dmg, effectLib.getSoundEffect ("Arcane Pulse"), true, myCaster) != -1) {
            myCaster.AddRemoveMana(manaGain);
        }

        Vector3 pos = map.TileCoordToWorldCoord (target.tileX, target.tileY);
        myVisualEffects.Add (effectLib.CreateVisualEffect ("Arcane Pulse", pos).GetComponent<EffectController> ());
    }
开发者ID:JohnEz,项目名称:TileBasedEngine,代码行数:24,代码来源:ArcanePulse.cs

示例15: Execute

 /// <summary>
 /// Execute the specified source and target.
 /// </summary>
 /// <param name="source">Source.</param>
 /// <param name="target">Target.</param>
 public void Execute(Unit target)
 {
     switch (abilityType)
     {
         case AbilityType.Damage:
             target.TakeDamage(m_amount);
             break;
         case AbilityType.Heal:
             target.TakeDamage(-m_amount);
             break;
         default:
             break;
     }
 }
开发者ID:Zac-King,项目名称:Unity-Prototyping,代码行数:19,代码来源:Unit.cs


注:本文中的Unit.TakeDamage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。