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


C# WPos.ToCPos方法代码示例

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


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

示例1: Explosion

 public Explosion(World world, WPos pos, string style)
 {
     this.world = world;
     this.pos = pos;
     this.cell = pos.ToCPos();
     anim = new Animation("explosion");
     anim.PlayThen(style, () => world.AddFrameEndTask(w => w.Remove(this)));
 }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:8,代码来源:Explosion.cs

示例2: Smoke

 public Smoke(World world, WPos pos, string trail)
 {
     this.world = world;
     this.pos = pos;
     this.cell = pos.ToCPos();
     anim = new Animation(trail);
     anim.PlayThen("idle",
         () => world.AddFrameEndTask(w => w.Remove(this)));
 }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:9,代码来源:Smoke.cs

示例3: Explosion

 public Explosion(World world, WPos pos, string sequence, string palette)
 {
     this.world = world;
     this.pos = pos;
     this.cell = pos.ToCPos();
     this.palette = palette;
     anim = new Animation(world, "explosion");
     anim.PlayThen(sequence, () => world.AddFrameEndTask(w => w.Remove(this)));
 }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:9,代码来源:Explosion.cs

示例4: Corpse

 public Corpse(World world, WPos pos, string image, string sequence, string paletteName)
 {
     this.world = world;
     this.pos = pos;
     this.cell = pos.ToCPos();
     this.paletteName = paletteName;
     anim = new Animation(image);
     anim.PlayThen(sequence, () => world.AddFrameEndTask(w => w.Remove(this)));
 }
开发者ID:TiriliPiitPiit,项目名称:OpenRA,代码行数:9,代码来源:Corpse.cs

示例5: Parachute

        public Parachute(Actor cargo, WPos dropPosition)
        {
            this.cargo = cargo;

            var pai = cargo.Info.Traits.GetOrDefault<ParachuteAttachmentInfo>();
            paraAnim = new Animation(cargo.World, pai != null ? pai.ParachuteSprite : "parach");
            paraAnim.PlayThen("open", () => paraAnim.PlayRepeating("idle"));

            if (pai != null)
                parachuteOffset = pai.Offset;

            // Adjust x,y to match the target subcell
            cargo.Trait<IPositionable>().SetPosition(cargo, dropPosition.ToCPos());
            var cp = cargo.CenterPosition;
            pos = new WPos(cp.X, cp.Y, dropPosition.Z);
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:16,代码来源:Parachute.cs

示例6: Tick

        public void Tick(World world)
        {
            ticks++;
            anim.Tick();

            // Missile tracks target
            if (args.GuidedTarget.IsValidFor(args.SourceActor))
                targetPosition = args.GuidedTarget.CenterPosition;

            var dist = targetPosition + offset - pos;
            var desiredFacing = Traits.Util.GetFacing(dist, facing);
            var desiredAltitude = targetPosition.Z;
            var jammed = info.Jammable && world.ActorsWithTrait<JamsMissiles>().Any(j => JammedBy(j));

            if (jammed)
            {
                desiredFacing = facing + world.SharedRandom.Next(-20, 21);
                desiredAltitude = world.SharedRandom.Next(-43, 86);
            }
            else if (!args.GuidedTarget.IsValidFor(args.SourceActor))
                desiredFacing = facing;

            facing = Traits.Util.TickFacing(facing, desiredFacing, info.ROT);
            var move = new WVec(0, -1024, 0).Rotate(WRot.FromFacing(facing)) * info.Speed.Range / 1024;
            if (targetPosition.Z > 0 && info.TurboBoost)
                move = (move * 3) / 2;

            if (pos.Z != desiredAltitude)
            {
                var delta = move.HorizontalLength * info.MaximumPitch.Tan() / 1024;
                var dz = (targetPosition.Z - pos.Z).Clamp(-delta, delta);
                move += new WVec(0, 0, dz);
            }

            pos += move;

            if (info.Trail != null && --ticksToNextSmoke < 0)
            {
                world.AddFrameEndTask(w => w.Add(new Smoke(w, pos - 3 * move / 2, info.Trail)));
                ticksToNextSmoke = info.TrailInterval;
            }

            if (info.ContrailLength > 0)
                trail.Update(pos);

            var cell = pos.ToCPos();

            var shouldExplode = (pos.Z < 0) // Hit the ground
                || (dist.LengthSquared < MissileCloseEnough.Range * MissileCloseEnough.Range) // Within range
                || (info.RangeLimit != 0 && ticks > info.RangeLimit) // Ran out of fuel
                || (!info.High && world.ActorMap.GetUnitsAt(cell)
                    .Any(a => a.HasTrait<IBlocksBullets>())) // Hit a wall
                || (!string.IsNullOrEmpty(info.BoundToTerrainType) && world.GetTerrainType(cell) != info.BoundToTerrainType); // Hit incompatible terrain

            if (shouldExplode)
                Explode(world);
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:57,代码来源:Missile.cs

示例7: Tick

        public void Tick(World world)
        {
            if (anim != null)
                anim.Tick();

            pos = WPos.LerpQuadratic(args.Source, target, angle, ticks, length);

            if (info.Trail != null && --smokeTicks < 0)
            {
                var delayedPos = WPos.LerpQuadratic(args.Source, target, angle, ticks - info.TrailDelay, length);
                world.AddFrameEndTask(w => w.Add(new Smoke(w, delayedPos, info.Trail)));
                smokeTicks = info.TrailInterval;
            }

            if (info.ContrailLength > 0)
                trail.Update(pos);

            if (ticks++ >= length || (!info.High && world.ActorMap
                .GetUnitsAt(pos.ToCPos()).Any(a => a.HasTrait<IBlocksBullets>())))
            {
                Explode(world);
            }
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:23,代码来源:Bullet.cs

示例8: DoImpact

        public static void DoImpact(WPos pos, WarheadInfo warhead, WeaponInfo weapon, Actor firedBy, float firepowerModifier)
        {
            var world = firedBy.World;
            var targetTile = pos.ToCPos();

            if (!world.Map.IsInMap(targetTile))
                return;

            var isWater = pos.Z == 0 && world.GetTerrainInfo(targetTile).IsWater;
            var explosionType = isWater ? warhead.WaterExplosion : warhead.Explosion;

            if (explosionType != null)
                world.AddFrameEndTask(w => w.Add(new Explosion(w, pos, explosionType)));

            Sound.Play(GetImpactSound(warhead, isWater), pos);

            var smudgeLayers = world.WorldActor.TraitsImplementing<SmudgeLayer>().ToDictionary(x => x.Info.Type);

            if (warhead.Size[0] > 0)
            {
                var resLayer = world.WorldActor.Trait<ResourceLayer>();
                var allCells = world.FindTilesInCircle(targetTile, warhead.Size[0]).ToList();

                // `smudgeCells` might want to just be an outer shell of the cells:
                IEnumerable<CPos> smudgeCells = allCells;
                if (warhead.Size.Length == 2)
                    smudgeCells = smudgeCells.Except(world.FindTilesInCircle(targetTile, warhead.Size[1]));

                // Draw the smudges:
                foreach (var sc in smudgeCells)
                {
                    var smudgeType = world.GetTerrainInfo(sc).AcceptsSmudgeType.FirstOrDefault(t => warhead.SmudgeType.Contains(t));
                    if (smudgeType == null) continue;

                    SmudgeLayer smudgeLayer;
                    if (!smudgeLayers.TryGetValue(smudgeType, out smudgeLayer))
                        throw new NotImplementedException("Unknown smudge type `{0}`".F(smudgeType));

                    smudgeLayer.AddSmudge(sc);
                    if (warhead.Ore)
                        resLayer.Destroy(sc);
                }

                // Destroy all resources in range, not just the outer shell:
                foreach (var cell in allCells)
                {
                    if (warhead.Ore)
                        resLayer.Destroy(cell);
                }
            }
            else
            {
                var smudgeType = world.GetTerrainInfo(targetTile).AcceptsSmudgeType.FirstOrDefault(t => warhead.SmudgeType.Contains(t));
                if (smudgeType != null)
                {
                    SmudgeLayer smudgeLayer;
                    if (!smudgeLayers.TryGetValue(smudgeType, out smudgeLayer))
                        throw new NotImplementedException("Unknown smudge type `{0}`".F(smudgeType));

                    smudgeLayer.AddSmudge(targetTile);
                }
            }

            if (warhead.Ore)
                world.WorldActor.Trait<ResourceLayer>().Destroy(targetTile);

            switch (warhead.DamageModel)
            {
                case DamageModel.Normal:
                    {
                        var maxSpread = warhead.Spread * (float)Math.Log(Math.Abs(warhead.Damage), 2);
                        var range = new WRange((int)maxSpread * 1024 / Game.CellSize);
                        var hitActors = world.FindActorsInCircle(pos, range);

                        foreach (var victim in hitActors)
                        {
                            var damage = (int)GetDamageToInflict(pos, victim, warhead, weapon, firepowerModifier);
                            victim.InflictDamage(firedBy, damage, warhead);
                        }
                    } break;

                case DamageModel.PerCell:
                    {
                        foreach (var t in world.FindTilesInCircle(targetTile, warhead.Size[0]))
                            foreach (var unit in world.FindActorsInBox(t, t))
                                unit.InflictDamage(firedBy,
                                    (int)(warhead.Damage * warhead.EffectivenessAgainst(unit.Info)), warhead);
                    } break;
            }
        }
开发者ID:TiriliPiitPiit,项目名称:OpenRA,代码行数:90,代码来源:Combat.cs


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