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


C# Entity.Refresh方法代码示例

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


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

示例1: Process

        public override void Process(Entity e)
        {
            Damage d = e.GetComponent<Damage>();
            Health h = e.GetComponent<Health>();

            if (d.Seconds <= 0)
            {
                e.RemoveComponent<Damage>(d);
                e.Refresh();

                return;
            }

            d.Seconds -= (float)world.Delta / 1000;

            h.SetHealth(e, h.CurrentHealth - d.DamagePerSecond * (world.Delta / 1000));

            Sprite s = e.GetComponent<Sprite>();

            Vector2 offset;
            if (!e.Tag.Contains("Boss"))
            {
                double mes = Math.Sqrt(s.CurrentRectangle.Width * s.CurrentRectangle.Height / 4);
                offset = new Vector2((float)((r.NextDouble() * 2 - 1) * mes), (float)((r.NextDouble() * 2 - 1) * mes));
            }
            else
            {
                offset = new Vector2((float)((r.NextDouble() * 2 - 1) * s.CurrentRectangle.Width / 2), (float)((r.NextDouble() * 2 - 1) * s.CurrentRectangle.Height / 2));
            }
            world.CreateEntity("GREENFAIRY", e, ConvertUnits.ToSimUnits(offset)).Refresh();
        }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:31,代码来源:DamageSystem.cs

示例2: AttachToEntity

        /// <summary>
        /// Attaches a control to an <see cref="Entity"/> instance, using the specified offset.
        /// </summary>
        /// <param name="control">Control instance being attached to the entity.</param>
        /// <param name="entity">Entity instance to which the control is being attached.</param>
        /// <param name="offset">Offset from the entity's position to display the control.</param>
        public static void AttachToEntity(this Control control, Entity entity, Vector2 offset)
        {
            ControlComponent controlComponent = new ControlComponent()
            {
                Control = control,
                Offset = offset
            };

            entity.AddComponent<ControlComponent>(controlComponent);
            entity.Refresh();
        }
开发者ID:bigangryguy,项目名称:BrassKnuckles,代码行数:17,代码来源:ControlExtension.cs

示例3: Process

        public override void Process(Entity e)
        {
            Slow slow = slowMapper.Get(e);
            if (slow != null && slow != Slow.None) //If particle is slowing
            {
                slow.Elapsed--;
                if (slow.Elapsed <= 0)
                {
                    e.RemoveComponent<Slow>(slow);
                    IDamping d = dampingMapper.Get(e);
                    d.LinearDamping = 0;
                    d.AngularDamping = 0;
                    if (e.HasComponent<AI>())
                    {
                        AI a = e.GetComponent<AI>();
                        e.RemoveComponent<AI>(e.GetComponent<AI>());
                        a.Calculated = false;
                        e.AddComponent<AI>(a);
                    }

                    e.Refresh();
                    return;
                }
                IVelocity velocity = velocityMapper.Get(e);
                IDamping damping = dampingMapper.Get(e);

                //Slow particle angular speed
                if (velocity.AngularVelocity > slow.AngularTargetVelocity || damping.AngularDamping != slow.AngularSlowRate)
                    damping.AngularDamping = slow.AngularSlowRate;
                else
                    damping.AngularDamping = 0;

                //Slow particle linear speed
                if (velocity.LinearVelocity.Length() - slow.LinearTargetVelocity.Length() > 1 || damping.LinearDamping != slow.LinearSlowRate)
                    damping.LinearDamping = slow.LinearSlowRate;
                else
                    damping.LinearDamping = 0;

                SpawnFrostEffect(e);
            }
        }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:41,代码来源:SlowSystem.cs

示例4: CreateShoot

        public static Func<Body, bool> CreateShoot(Entity ent, float speed, float shootDistance, bool rotateTo)
        {
            return
                (target) =>
                {
                    Body b = ent.GetComponent<Body>();
                    float distance = Vector2.Distance(b.Position, target.Position);

                    Vector2 direction = target.Position - (b.Position + ent.GetComponent<Inventory>().CurrentGun.GunOffsets[0]);
                    direction.Normalize();
                    b.RotateTo(direction);
                    if (distance > shootDistance)
                    {
                        direction *= 5f;
                        b.LinearVelocity = direction;
                    }

                    else
                    {
                        b.LinearVelocity = new Vector2(MathHelper.SmoothStep(b.LinearVelocity.X, 0, 0.1f), MathHelper.SmoothStep(b.LinearVelocity.Y, 0, 0.1f));
                        ent.GetComponent<Inventory>().CurrentGun.BulletsToFire = true;
                    }
                    ent.Refresh();
                    return false;
                };
        }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:26,代码来源:AI.cs

示例5: CreateCannon

        public static Func<Body, bool> CreateCannon(Entity ent, bool rotateTo)
        {
            float shootDistance = ConvertUnits.ToSimUnits(700);

            return
                (target) =>
                {
                    Body b = ent.GetComponent<Body>();
                    float distance = Vector2.Distance(b.Position, target.Position);

                    if (distance < shootDistance)
                    {
                        Vector2 direction = target.Position - b.Position;
                        direction.Normalize();
                        if (rotateTo)
                        {
                            b.RotateTo(direction);
                            ent.GetComponent<Inventory>().CurrentGun.BulletsToFire = true;
                        }
                    }

                    b.LinearVelocity = ent.GetComponent<Origin>().Parent.GetComponent<Body>().LinearVelocity;

                    ent.Refresh();
                    return false;
                };
        }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:27,代码来源:AI.cs

示例6: ProcessEntities

        protected override void ProcessEntities(Dictionary<int, Entity> entities)
        {
            base.ProcessEntities(entities);

            timesCalled++;
            elapsedSeconds += .333f;
            elapsedMinutes += .333f / 60f;

            difficulty = (int)(elapsedMinutes);

            #region Scoring

            Score s = Base.GetComponent<Score>();

            if (elapsedSeconds % 1 == 0)
                ScoreSystem.GivePoints(10 * difficulty);

            #endregion Scoring

            #region Spawning

            if (timesCalled == 1)
            {
                World.CreateEntity(BossTemplate, 1, Base.GetComponent<Body>()).Refresh();
            }

            //Every 5/3 seconds spawn

            if (timesCalled % 5 == 0)
            {
                int type;
                mooksToSpawn = (MookSpawnRate != -1) ? ((MookSpawnRate == 0) ? difficulty : MookSpawnRate) : 0;
                thugsToSpawn = (ThugSpawnRate != -1) ? ((ThugSpawnRate == 0) ? ((r.Next(1, 100) * difficulty > 90) ? 1 : 0) : ThugSpawnRate) : 0;
                gunnersToSpawn = (GunnerSpawnRate != -1) ? ((GunnerSpawnRate == 0) ? (int)(difficulty / 9) : GunnerSpawnRate) : 0;
                huntersToSpawn = (HunterSpawnRate != -1) ? ((HunterSpawnRate == 0) ? (int)(difficulty / 15) : HunterSpawnRate) : 0;
                destroyersToSpawn = (DestroyerSpawnRate != -1) ? ((DestroyerSpawnRate != 0) ? (int)(difficulty / 30) : DestroyerSpawnRate) : 0;

                type = r.Next(8);
                for (int i = 0; i < mooksToSpawn; i++)
                {
                    if (string.IsNullOrEmpty(MookSprite))
                        World.CreateEntity(MookTemplate, type, Base.GetComponent<Body>()).Refresh();
                    else
                        World.CreateEntity(MookTemplate, type, Base.GetComponent<Body>(), MookSprite).Refresh();
                }

                type = r.Next(4);
                for (int i = 0; i < thugsToSpawn; i++)
                {
                    if (string.IsNullOrEmpty(ThugSprite))
                        World.CreateEntity(ThugTemplate, type, Base.GetComponent<Body>()).Refresh();
                    else
                        World.CreateEntity(ThugTemplate, type, Base.GetComponent<Body>(), ThugSprite).Refresh();
                }

                for (int i = 0; i < gunnersToSpawn; i++)
                {
                }

                for (int i = 0; i < huntersToSpawn; i++)
                {
                }

                for (int i = 0; i < destroyersToSpawn; i++)
                {
                }
            }

            if ((int)(elapsedMinutes) >= lastBoss)
            {
                //Boss.
                int tier = Math.Min(difficulty, 3);
                Boss = World.CreateEntity(BossTemplate, tier, Base.GetComponent<Body>());
                Boss.Refresh();
                lastBoss++;
            }

            #endregion Spawning
        }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:79,代码来源:DirectorSystem.cs


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