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


C# Actor.InflictDamage方法代码示例

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


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

示例1: Tick

        public IActivity Tick(Actor self)
        {
            if (isCanceled) return NextActivity;
            if (remainingTicks == 0)
            {
                var health = self.TraitOrDefault<Health>();
                if (health == null) return NextActivity;

                var unitCost = self.Info.Traits.Get<ValuedInfo>().Cost;
                var repairsUnits = host.Info.Traits.Get<RepairsUnitsInfo>();
                var costPerHp = (repairsUnits.URepairPercent * unitCost) / health.MaxHP;
                var hpToRepair = Math.Min(host.Info.Traits.Get<RepairsUnitsInfo>().URepairStep, health.MaxHP - health.HP);
                var cost = (int)Math.Ceiling(costPerHp * hpToRepair);
                if (!self.Owner.PlayerActor.Trait<PlayerResources>().TakeCash(cost))
                {
                    remainingTicks = 1;
                    return this;
                }

                self.InflictDamage(self, -hpToRepair, null);
                if (health.DamageState == DamageState.Undamaged)
                    return NextActivity;

                if (host != null)
                    host.Trait<RenderBuilding>()
                        .PlayCustomAnim(host, "active");

                remainingTicks = (int)(repairsUnits.RepairRate * 60 * 25);
            }
            else
                --remainingTicks;

            return this;
        }
开发者ID:mgatland,项目名称:OpenRA,代码行数:34,代码来源:Repair.cs

示例2: Tick

        public IActivity Tick(Actor self)
        {
            if (isCanceled) return NextActivity;
            if (remainingTicks == 0)
            {
                var hostBuilding = self.World.FindUnits(self.CenterLocation, self.CenterLocation)
                    .FirstOrDefault(a => a.traits.Contains<RenderBuilding>());

                var unitCost = self.Info.Traits.Get<BuildableInfo>().Cost;
                var hp = self.Info.Traits.Get<OwnedActorInfo>().HP;

                var costPerHp = (hostBuilding.Info.Traits.Get<RepairsUnitsInfo>().URepairPercent * unitCost) / hp;
                var hpToRepair = Math.Min(hostBuilding.Info.Traits.Get<RepairsUnitsInfo>().URepairStep, hp - self.Health);
                var cost = (int)Math.Ceiling(costPerHp * hpToRepair);
                if (!self.Owner.TakeCash(cost))
                {
                    remainingTicks = 1;
                    return this;
                }

                self.InflictDamage(self, -hpToRepair, null);
                if (self.Health == hp)
                    return NextActivity;

                if (hostBuilding != null)
                    hostBuilding.traits.Get<RenderBuilding>()
                        .PlayCustomAnim(hostBuilding, "active");

                remainingTicks = (int)(self.World.Defaults.RepairRate * 60 * 25);
            }
            else
                --remainingTicks;

            return this;
        }
开发者ID:comradpara,项目名称:OpenRA,代码行数:35,代码来源:Repair.cs

示例3: DoImpact

        public virtual void DoImpact(Actor victim, Actor firedBy, IEnumerable<int> damageModifiers)
        {
            if (!IsValidAgainst(victim, firedBy))
                return;

            var damage = Util.ApplyPercentageModifiers(Damage, damageModifiers.Append(DamageVersus(victim)));
            victim.InflictDamage(firedBy, damage, this);
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:8,代码来源:DamageWarhead.cs

示例4: DoImpact

        public override void DoImpact(Actor victim, Actor firedBy, IEnumerable<int> damageModifiers)
        {
            var healthInfo = victim.Info.Traits.GetOrDefault<HealthInfo>();
            if (healthInfo == null)
                return;

            // Damage is measured as a percentage of the target health
            var damage = Util.ApplyPercentageModifiers(healthInfo.HP, damageModifiers.Append(Damage, DamageVersus(victim.Info)));
            victim.InflictDamage(firedBy, damage, this);
        }
开发者ID:rhamilton1415,项目名称:OpenRA,代码行数:10,代码来源:HealthPercentageDamageWarhead.cs

示例5: Tick

        public void Tick(Actor self)
        {
            var info = self.Info.Traits.Get<SelfHealingInfo>();

            if ((float)self.Health / self.GetMaxHP() >= info.HealIfBelow)
                return;

            if (--ticks <= 0)
            {
                ticks = info.Ticks;
                self.InflictDamage(self, -info.Step, null);
            }
        }
开发者ID:comradpara,项目名称:OpenRA,代码行数:13,代码来源:SelfHealing.cs

示例6: Tick

        public void Tick(Actor self)
        {
            if (--poisonTicks > 0) return;

            var rl = self.World.WorldActor.Trait<ResourceLayer>();
            var r = rl.GetResource(self.Location);
            if( r == null ) return;
            if( !info.Resources.Contains(r.info.Name) ) return;

            var weapon = Rules.Weapons[info.Weapon.ToLowerInvariant()];

            self.InflictDamage( self.World.WorldActor, weapon.Warheads[ 0 ].Damage, weapon.Warheads[ 0 ] );
            poisonTicks = weapon.ROF;
        }
开发者ID:sonygod,项目名称:OpenRA-Dedicated-20120504,代码行数:14,代码来源:PoisonedByTiberium.cs

示例7: Tick

        public override Activity Tick(Actor self)
        {
            if (IsCanceled) return NextActivity;
            if (host != null && !host.IsInWorld) return NextActivity;

            health = self.TraitOrDefault<Health>();
            if (health == null) return NextActivity;
            if (health.DamageState == DamageState.Undamaged)
            {
                var helicopter = self.TraitOrDefault<Helicopter>();
                if (helicopter != null)
                {
                    if (helicopter.Info.RearmBuildings.Contains(host.Info.Name) && self.HasTrait<LimitedAmmo>())
                    {
                        if (self.Trait<LimitedAmmo>().FullAmmo() == false)
                            return NextActivity;
                    }

                    return helicopter.TakeOff(host);
                }

                return NextActivity;
            }

            if (remainingTicks == 0)
            {
                var repairsUnits = host.Info.Traits.Get<RepairsUnitsInfo>();
                var unitCost = self.Info.Traits.Get<ValuedInfo>().Cost;
                var hpToRepair = repairsUnits.HpPerStep;
                var cost = Math.Max(1, (hpToRepair * unitCost * repairsUnits.ValuePercentage) / (health.MaxHP * 100));

                if (!self.Owner.PlayerActor.Trait<PlayerResources>().TakeCash(cost))
                {
                    remainingTicks = 1;
                    return this;
                }

                self.InflictDamage(self, -hpToRepair, null);

                foreach (var depot in host.TraitsImplementing<INotifyRepair>())
                    depot.Repairing(self, host);

                remainingTicks = repairsUnits.Interval;
            }
            else
                --remainingTicks;

            return this;
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:49,代码来源:Repair.cs

示例8: Tick

        public override Activity Tick(Actor self)
        {
            if (IsCanceled) return NextActivity;
            if (host == null || !host.IsInWorld) return NextActivity;

            health = self.TraitOrDefault<Health>();
            if (health == null) return NextActivity;

            if (health.DamageState == DamageState.Undamaged)
            {
                Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", repairsUnits.FinishRepairingNotification, self.Owner.Faction.InternalName);
                return NextActivity;
            }

            if (remainingTicks == 0)
            {
                var unitCost = self.Info.Traits.Get<ValuedInfo>().Cost;
                var hpToRepair = repairsUnits.HpPerStep;
                var cost = Math.Max(1, (hpToRepair * unitCost * repairsUnits.ValuePercentage) / (health.MaxHP * 100));

                if (!played)
                {
                    played = true;
                    Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", repairsUnits.StartRepairingNotification, self.Owner.Faction.InternalName);
                }

                if (!self.Owner.PlayerActor.Trait<PlayerResources>().TakeCash(cost))
                {
                    remainingTicks = 1;
                    return this;
                }

                self.InflictDamage(self, -hpToRepair, null);

                foreach (var depot in host.TraitsImplementing<INotifyRepair>())
                    depot.Repairing(self, host);

                remainingTicks = repairsUnits.Interval;
            }
            else
                --remainingTicks;

            return this;
        }
开发者ID:rhamilton1415,项目名称:OpenRA,代码行数:44,代码来源:Repair.cs

示例9: DoImpact

 public virtual void DoImpact(Actor victim, Actor firedBy, IEnumerable<int> damageModifiers)
 {
     var damage = Util.ApplyPercentageModifiers(Damage, damageModifiers.Append(DamageVersus(victim.Info)));
     victim.InflictDamage(firedBy, damage, this);
 }
开发者ID:rhamilton1415,项目名称:OpenRA,代码行数:5,代码来源:DamageWarhead.cs

示例10: Tick

        public override Activity Tick(Actor self)
        {
            if (IsCanceled)
            {
                if (remainingTicks-- == 0)
                    return NextActivity;

                return this;
            }

            if (host.Type == TargetType.Invalid || health == null)
                return NextActivity;

            if (closeEnough.LengthSquared > 0 && !host.IsInRange(self.CenterPosition, closeEnough))
                return NextActivity;

            if (health.DamageState == DamageState.Undamaged)
            {
                if (host.Actor.Owner != self.Owner)
                {
                    var exp = host.Actor.Owner.PlayerActor.TraitOrDefault<PlayerExperience>();
                    if (exp != null)
                        exp.GiveExperience(repairsUnits.PlayerExperience);
                }

                Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", repairsUnits.FinishRepairingNotification, self.Owner.Faction.InternalName);
                return NextActivity;
            }

            if (remainingTicks == 0)
            {
                var unitCost = self.Info.TraitInfo<ValuedInfo>().Cost;
                var hpToRepair = repairsUnits.HpPerStep;
                var cost = Math.Max(1, (hpToRepair * unitCost * repairsUnits.ValuePercentage) / (health.MaxHP * 100));

                if (!played)
                {
                    played = true;
                    Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", repairsUnits.StartRepairingNotification, self.Owner.Faction.InternalName);
                }

                if (!self.Owner.PlayerActor.Trait<PlayerResources>().TakeCash(cost, true))
                {
                    remainingTicks = 1;
                    return this;
                }

                self.InflictDamage(self, new Damage(-hpToRepair));

                foreach (var depot in host.Actor.TraitsImplementing<INotifyRepair>())
                    depot.Repairing(host.Actor, self);

                remainingTicks = repairsUnits.Interval;
            }
            else
                --remainingTicks;

            return this;
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:59,代码来源:Repair.cs

示例11: Tick

        public void Tick(Actor self)
        {
            if (!isRepairing) return;

            if (remainingTicks == 0)
            {
                var csv = self.Info.Traits.GetOrDefault<CustomSellValueInfo>();
                var buildingValue = csv != null ? csv.Value : self.Info.Traits.Get<BuildableInfo>().Cost;
                var maxHP = self.Info.Traits.Get<BuildingInfo>().HP;
                var costPerHp = (self.World.Defaults.RepairPercent * buildingValue) / maxHP;
                var hpToRepair = Math.Min(self.World.Defaults.RepairStep, maxHP - self.Health);
                var cost = (int)Math.Ceiling(costPerHp * hpToRepair);
                if (!self.Owner.TakeCash(cost))
                {
                    remainingTicks = 1;
                    return;
                }

                self.World.AddFrameEndTask(w => w.Add(new RepairIndicator(self)));
                self.InflictDamage(self, -hpToRepair, null);
                if (self.Health == maxHP)
                {
                    isRepairing = false;
                    return;
                }
                remainingTicks = (int)(self.World.Defaults.RepairRate * 60 * 25);
            }
            else
                --remainingTicks;
        }
开发者ID:comradpara,项目名称:OpenRA,代码行数:30,代码来源:Building.cs

示例12: attack

        private void attack(Actor actor, string weapon, int damage)
        {
            if (weapon != null)
            {
                var w = self.World.Map.Rules.Weapons[weapon.ToLowerInvariant()];
                w.Impact(Target.FromActor(actor), self, Enumerable.Empty<int>());
            }
            else
            {
                actor.InflictDamage(self, damage, null);
                if (actor.IsDead)
                {
                    var wda = actor.TraitsImplementing<WithDeathAnimation>().FirstOrDefault(s => s.Info.DeathSequence != null);
                    if (wda != null)
                    {
                        var palette = wda.Info.DeathSequencePalette;
                        if (wda.Info.DeathPaletteIsPlayerPalette)
                            palette += self.Owner.InternalName;

                        wda.SpawnDeathAnimation(actor, wda.Info.DeathSequence, palette);
                    }
                }
            }
        }
开发者ID:Holloweye,项目名称:OpenRA,代码行数:24,代码来源:Passable.cs


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