本文整理汇总了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);
}
示例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;
}
}
}
示例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();
}
示例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";
}
示例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);
}