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


C# Entity.Equals方法代码示例

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


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

示例1: OnCollide

        public override void OnCollide(Entity source)
        {
            // "einsammeln"
            bool sucess = false;

            if (CanBePickedUp)
            {
                if (source.Equals((Game as Game1).Player))
                {
                    sucess = (source as PlayerClasses.Player).Give(Items.Potion);
                }
            }

            if(sucess)
                base.OnCollide(source);
        }
开发者ID:floAr,项目名称:WarTornLands,代码行数:16,代码来源:EntityPotion.cs

示例2: Move

 public void Move(Entity entity, Entity.Movement movement)
 {
     int speed = 3;
     if(entity.ID == 56) speed = 5;
     if (isSprinting && entity.Equals(player)) speed = speed * 2;
     bool collidided = false;
     switch (movement)
     {
         case Entity.Movement.Forward:
             while (willCollide(new Rectangle(entity.x, entity.y - speed, entity.x + entity.width, (entity.y - speed) + entity.height)))
             {
                 collidided = true;
                 speed--;
             }
             entity.direction = Entity.Movement.Forward;
             entity.y -= speed;
             if (entity.Equals(player)) offset.Y += speed;
             break;
         case Entity.Movement.Left:
             while (willCollide(new Rectangle(entity.x - speed, entity.y, (entity.x - speed) + entity.width, entity.y + entity.height)))
             {
                 collidided = true;
                 speed--;
             }
             entity.direction = Entity.Movement.Left;
             entity.x -= speed;
             if (entity.Equals(player)) offset.X += speed;
             break;
         case Entity.Movement.Back:
             while (willCollide(new Rectangle(entity.x, entity.y + speed, entity.x + entity.width, (entity.y + speed) + entity.height)))
             {
                 collidided = true;
                 speed--;
             }
             entity.direction = Entity.Movement.Back;
             entity.y += speed;
             if (entity.Equals(player)) offset.Y -= speed;
             break;
         case Entity.Movement.Right:
             while (willCollide(new Rectangle(entity.x + speed, entity.y, (entity.x + speed) + entity.width, entity.y + entity.height)))
             {
                 collidided = true;
                 speed--;
             }
             entity.direction = Entity.Movement.Right;
             entity.x += speed;
             if (entity.Equals(player)) offset.X -= speed;
             break;
     }
     if(collidided && !entity.Equals(player))
     {
         int i = rand.Next(1, 5);
         switch (i)
         {
             case 1:
                 entity.direction = Entity.Movement.Back;
                 break;
             case 2:
                 entity.direction = Entity.Movement.Forward;
                 break;
             case 3:
                 entity.direction = Entity.Movement.Left;
                 break;
             case 4:
                 entity.direction = Entity.Movement.Right;
                 break;
         }
     }
 }
开发者ID:robodylan,项目名称:LD-33,代码行数:69,代码来源:Game.cs

示例3: Entity_OnInt32PropertyChange

        /// <summary>
        ///     The entity_ on int 32 property change.
        /// </summary>
        /// <param name="sender">
        ///     The sender.
        /// </param>
        /// <param name="args">
        ///     The args.
        /// </param>
        private void Entity_OnInt32PropertyChange(Entity sender, Int32PropertyChangeEventArgs args)
        {
            if (!sender.Equals(this.Unit) || args.PropertyName != "m_NetworkActivity")
            {
                return;
            }

            if (this.Unit == null || !this.Unit.IsValid)
            {
                Entity.OnInt32PropertyChange -= this.Entity_OnInt32PropertyChange;
                return;
            }

            if (!Game.IsInGame || Game.IsPaused)
            {
                return;
            }

            var newValue = (NetworkActivity)args.NewValue;
            var oldValue = (NetworkActivity)args.OldValue;
            if (newValue == this.lastUnitActivity || newValue == oldValue)
            {
                return;
            }

            var canCancel = this.CanCancelAttack();
            var wasAttacking = false;
            if (!this.IsAttackOnCoolDown() || canCancel)
            {
                wasAttacking = this.isAttacking;
                this.lastUnitActivity = newValue;
                this.isAttacking = newValue == NetworkActivity.Attack || newValue == NetworkActivity.Crit
                                   || newValue == NetworkActivity.Attack2 || newValue == NetworkActivity.AttackEvent
                                   || newValue == NetworkActivity.AttackEventBash
                                   || newValue == NetworkActivity.EarthshakerTotemAttack;
            }

            if (wasAttacking && canCancel && !this.isAttacking
                && (oldValue == NetworkActivity.Attack || oldValue == NetworkActivity.Crit
                    || oldValue == NetworkActivity.Attack2 || oldValue == NetworkActivity.AttackEvent
                    || oldValue == NetworkActivity.AttackEventBash || oldValue == NetworkActivity.EarthshakerTotemAttack))
            {
                this.AttackEnd();
            }

            if (!this.isAttacking || (!this.isAttacking && !canCancel))
            {
                return;
            }

            this.LastUnitAttackStart = Game.RawGameTime;
            this.NextUnitAttackEnd =
                (float)(this.LastUnitAttackStart * 1000 + UnitDatabase.GetAttackRate(this.Unit) * 1000);
            this.NextUnitAttackRelease =
                (float)(this.LastUnitAttackStart * 1000 + UnitDatabase.GetAttackPoint(this.Unit) * 1000);
            this.AttackOrderSent = false;
            this.AttackStart();
        }
开发者ID:EnsageSharp,项目名称:Ensage.Common,代码行数:67,代码来源:AttackAnimationTracker.cs

示例4: GetOwnerName

 // --→ Function: Get Midas Owner Name
 private static string GetOwnerName(Entity owner)
 {
     return owner.Equals(mHero) ? owner.Name.Replace("npc_dota_hero_", "") : "spirit_bear";
 }
开发者ID:vitac1998,项目名称:ensagesharp-1,代码行数:5,代码来源:AutoMidas.cs

示例5: shareAble

        private bool shareAble(Entity searchedEntity1, Entity searchedEntity2)
        {
            if (searchedEntity1 == null || searchedEntity2 == null)
                //there is no constraint on both of entities
                return true;

            return searchedEntity1.Equals(searchedEntity2);
        }
开发者ID:m9ra,项目名称:KnowledgeDialog2,代码行数:8,代码来源:WildcardTriplet.cs


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