本文整理汇总了C#中EntityBase类的典型用法代码示例。如果您正苦于以下问题:C# EntityBase类的具体用法?C# EntityBase怎么用?C# EntityBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntityBase类属于命名空间,在下文中一共展示了EntityBase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SendDestroyEntity
public void SendDestroyEntity(EntityBase entity)
{
SendPacket(new DestroyEntityPacket
{
EntityId = entity.EntityId
});
}
开发者ID:IdentErr,项目名称:c-raft,代码行数:7,代码来源:Client.Send.cs
示例2: CanBePlacedOn
protected override bool CanBePlacedOn(EntityBase who, StructBlock block, StructBlock targetBlock, BlockFace targetSide)
{
Chunk chunk = GetBlockChunk(block);
if (chunk == null)
return false;
bool isDoubleChestNearby = false;
int chestCount = 0;
chunk.ForNSEW(block.Coords, uc =>
{
byte? nearbyBlockId = block.World.GetBlockId(uc);
if (nearbyBlockId == null)
return;
// Cannot place next to a double chest
if (nearbyBlockId == (byte)BlockData.Blocks.Chest)
{
chestCount++;
if (chunk.IsNSEWTo(uc, (byte)BlockData.Blocks.Chest))
isDoubleChestNearby = true;
}
});
if (isDoubleChestNearby || chestCount > 1)
return false;
return base.CanBePlacedOn(who, block, targetBlock, targetSide);
}
开发者ID:TheaP,项目名称:c-raft,代码行数:28,代码来源:BlockChest.cs
示例3: Place
public override void Place(EntityBase entity, StructBlock block, StructBlock targetBlock, BlockFace face)
{
Player player = (entity as Player);
if (player == null)
return;
if (face == BlockFace.Down)
return;
switch (face)
{
case BlockFace.Down: return;
case BlockFace.Up: block.MetaData = (byte)MetaData.Torch.Standing;
break;
case BlockFace.West: block.MetaData = (byte)MetaData.Torch.West;
break;
case BlockFace.East: block.MetaData = (byte)MetaData.Torch.East;
break;
case BlockFace.North: block.MetaData = (byte)MetaData.Torch.North;
break;
case BlockFace.South: block.MetaData = (byte)MetaData.Torch.South;
break;
}
base.Place(entity, block, targetBlock, face);
}
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:25,代码来源:BlockRedstoneTorch.cs
示例4: EntityDamageEventArgs
public EntityDamageEventArgs(EntityBase entity, short damage, Client damagedBy, DamageCause cause)
: base(entity)
{
Damage = damage;
DamagedBy = damagedBy;
Cause = cause;
}
开发者ID:RevolutionSmythe,项目名称:c-raft,代码行数:7,代码来源:EntityEventArgs.cs
示例5: Awake
void Awake() {
mEnt = GetComponent<EntityBase>();
mEnt.spawnCallback += OnEntitySpawn;
mEnt.setStateCallback += OnEntityState;
mTimeWarp = GetComponent<TimeWarp>();
}
开发者ID:PushoN,项目名称:game-off-2013,代码行数:7,代码来源:EntityControllerCurvePath.cs
示例6: GetClientValidationData
/// <summary>
/// Returns client validation rule to help client validation libraries.
/// </summary>
/// <param name="propertyName">Property name reference to get the client validation rules.</param>
/// <returns><see cref="ClientValidationRule"/></returns>
public IEnumerable<ClientValidationRule> GetClientValidationData(string propertyName, EntityBase entity)
{
var predicates = Assertions
.Where(a => a.AccessorMemberNames.Contains(propertyName) && a.WhenAssertion == null)
.SelectMany(a => a.BasePredicates)
.Where(p => p.ClienteValidationRule != null);
foreach (var predicate in predicates)
{
predicate.ClienteValidationRule.ErrorMessage = string.Format(predicate.ValidationMessage, ValidationHelper.ResourceManager.GetString(propertyName));
yield return predicate.ClienteValidationRule;
}
var assertionsWithWhen = Assertions
.Where(a => a.AccessorMemberNames.Contains(propertyName) && a.WhenAssertion != null && a.BasePredicates.Any(p => p.ClienteValidationRule != null));
foreach (var assertion in assertionsWithWhen)
{
if (assertion.WhenAssertion.Evaluate(entity, null))
{
var predicatesWithWhen = assertion.BasePredicates.Where(p => p.ClienteValidationRule != null);
foreach (var predicate in predicatesWithWhen)
{
predicate.ClienteValidationRule.ErrorMessage = string.Format(predicate.ValidationMessage, ValidationHelper.ResourceManager.GetString(propertyName));
yield return predicate.ClienteValidationRule;
}
}
}
}
开发者ID:tiagomaximo,项目名称:LiteFx,代码行数:35,代码来源:Assert.cs
示例7: DropItems
protected override void DropItems(EntityBase who, StructBlock block, List<ItemInventory> overridedLoot = null)
{
var world = block.World;
var server = world.Server;
overridedLoot = new List<ItemInventory>();
// TODO: Fully grown drops 1 Wheat & 0-3 Seeds. 0 seeds - very rarely
if (block.MetaData == 7)
{
ItemInventory item = ItemHelper.GetInstance((short) BlockData.Items.Wheat);
item.Count = 1;
overridedLoot.Add(item);
sbyte seeds = (sbyte)server.Rand.Next(3);
if (seeds > 0)
{
item = ItemHelper.GetInstance((short) BlockData.Items.Seeds);
item.Count = seeds;
overridedLoot.Add(item);
}
}
else if (block.MetaData >= 5)
{
var seeds = (sbyte)server.Rand.Next(3);
if (seeds > 0)
{
ItemInventory item = ItemHelper.GetInstance((short) BlockData.Items.Seeds);
item.Count = seeds;
overridedLoot.Add(item);
}
}
base.DropItems(who, block, overridedLoot);
}
开发者ID:TheaP,项目名称:c-raft,代码行数:32,代码来源:BlockCrops.cs
示例8: DoDeath
protected override void DoDeath(EntityBase killedBy)
{
sbyte count = (sbyte)Server.Rand.Next(2);
if (count > 0)
Server.DropItem(World, (int)this.Position.X, (int)this.Position.Y, (int)this.Position.Z, new Interfaces.ItemStack((short)Chraft.World.BlockData.Items.Pork, count, 0));
// TODO: if death by fire drop cooked pork
}
开发者ID:RevolutionSmythe,项目名称:c-raft,代码行数:7,代码来源:Pig.cs
示例9: ShouldInitWithDynamicData
public void ShouldInitWithDynamicData()
{
entity = new EntityBase(JsonConvert.DeserializeObject("{\"id\":1,\"name\":\"General\"}".Replace("'", "\"")));
Assert.That(entity.GetDynamicProperty<int>("id"), Is.EqualTo(1));
Assert.That(entity.GetDynamicProperty<string>("name"), Is.EqualTo("General"));
}
开发者ID:danielsaidi,项目名称:desk-csharp-sdk,代码行数:7,代码来源:DeskEntityTests.cs
示例10: Place
public override void Place(EntityBase entity, StructBlock block, StructBlock targetBlock, BlockFace face)
{
// Load the blocks surrounding the position (NSEW) not diagonals
BlockData.Blocks[] nsewBlocks = new BlockData.Blocks[4];
UniversalCoords[] nsewBlockPositions = new UniversalCoords[4];
int nsewCount = 0;
block.Chunk.ForNSEW(block.Coords, (uc) =>
{
nsewBlocks[nsewCount] = (BlockData.Blocks)block.World.GetBlockId(uc);
nsewBlockPositions[nsewCount] = uc;
nsewCount++;
});
// Count chests in list
if (nsewBlocks.Where((b) => b == BlockData.Blocks.Chest).Count() > 1)
{
// Cannot place next to two chests
return;
}
for (int i = 0; i < 4; i++)
{
UniversalCoords p = nsewBlockPositions[i];
if (nsewBlocks[i] == BlockData.Blocks.Chest && block.Chunk.IsNSEWTo(p, (byte)BlockData.Blocks.Chest))
{
// Cannot place next to a double chest
return;
}
}
base.Place(entity, block, targetBlock, face);
}
开发者ID:Smjert,项目名称:c-raft,代码行数:31,代码来源:BlockChest.cs
示例11: DoDeath
protected override void DoDeath(EntityBase killedBy)
{
var killedByMob = killedBy as Mob;
UniversalCoords coords = UniversalCoords.FromAbsWorld(Position.X, Position.Y, Position.Z);
ItemInventory item;
if (killedByMob != null && killedByMob.Type == MobType.Skeleton)
{
// If killed by a skeleton drop a music disc
sbyte count = 1;
if (Server.Rand.Next(2) > 1)
item = ItemHelper.GetInstance(BlockData.Items.Disc13);
else
item = ItemHelper.GetInstance(BlockData.Items.DiscCat);
item.Count = count;
item.Durability = 0;
Server.DropItem(World, coords, item);
}
else
{
sbyte count = (sbyte)Server.Rand.Next(2);
if (count > 0)
{
item = ItemHelper.GetInstance(BlockData.Items.Gunpowder);
item.Count = count;
Server.DropItem(World, coords, item);
}
}
base.DoDeath(killedBy);
}
开发者ID:TheaP,项目名称:c-raft,代码行数:30,代码来源:Creeper.cs
示例12: Awake
void Awake() {
Renderer[] renders = GetComponentsInChildren<Renderer>(true);
if(renders.Length > 0) {
List<Renderer> validRenders = new List<Renderer>(renders.Length);
foreach(Renderer r in renders) {
if(r.sharedMaterial.HasProperty(modProperty)) {
validRenders.Add(r);
}
}
mRenderers = new Renderer[validRenders.Count];
mBlinkMats = new Material[validRenders.Count];
for(int i = 0, max = mBlinkMats.Length; i < max; i++) {
mRenderers[i] = validRenders[i];
validRenders[i].sharedMaterial = mBlinkMats[i] = new Material(validRenders[i].sharedMaterial);
mBlinkMats[i].SetFloat(modProperty, 0.0f);
}
}
mEnt = GetComponent<EntityBase>();
if(mEnt)
mEnt.setBlinkCallback += OnEntityBlink;
mStats = GetComponent<Stats>();
if(mStats)
mStats.changeHPCallback += OnStatsHPChange;
tk2dBaseSprite[] sprites = GetComponentsInChildren<tk2dBaseSprite>(true);
foreach(tk2dBaseSprite spr in sprites) {
spr.SpriteChanged += OnSpriteChanged;
}
}
开发者ID:PushoN,项目名称:game-off-2013,代码行数:34,代码来源:EntityDamageBlinker.cs
示例13: ValidationError
/// <summary>
/// Initializes a new instance of the ValidationError class.
/// </summary>
/// <param name="errorMessage">The error message.</param>
/// <param name="entity">The invalid entity.</param>
/// <param name="property">The invalid property.</param>
/// <param name="validationGroup">The validation group this error violates.</param>
public ValidationError(string errorMessage, EntityBase entity, string propertyName, string validationGroup)
{
_errorMessage = errorMessage;
_entity = entity;
_propertyName = propertyName;
_validationGroup = validationGroup;
}
开发者ID:vamsimg,项目名称:healthstopweb,代码行数:14,代码来源:ValidationError.cs
示例14: Activate
public void Activate(Type type, EntityBase ent)
{
animSprite.Play(mTypeClips[(int)type]);
mEnt = ent;
mState = State.Activate;
mCurDelay = 0;
}
开发者ID:ddionisio,项目名称:GitGirl,代码行数:7,代码来源:Reticle.cs
示例15: EntityPropertyEquals
public static bool EntityPropertyEquals(EntityBase entity1, EntityBase entity2, string property)
{
if (!entity1.GetType().Equals(entity2.GetType()))
{
throw new TechnicalException("Type:" + entity1.GetType() +" of Entity1 is not as same as Type:" + entity2.GetType() + " of Entity2");
}
object value1 = entity1;
object value2 = entity2;
string[] fieldArray = property.Split('.');
foreach (string singleField in fieldArray)
{
if (value1 == null && value2 == null)
{
return true;
}
PropertyInfo singlePropInfo = getPropertyInfo(value1, singleField);
value1 = singlePropInfo.GetValue(value1, null);
value2 = singlePropInfo.GetValue(value2, null);
if ((value1 != null && value1.Equals(value2)) || value2 != null)
{
return false;
}
}
return true;
}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:29,代码来源:EntityHelper.cs
示例16: SendEntity
internal void SendEntity(EntityBase entity)
{
PacketHandler.SendPacket(new CreateEntityPacket
{
EntityId = entity.EntityId
});
}
开发者ID:Eipok,项目名称:c-raft,代码行数:7,代码来源:Client.Send.cs
示例17: ComponentRemovedFromEntity
public void ComponentRemovedFromEntity(EntityBase entity, Type componentClass)
{
if (_components.ContainsKey(componentClass))
{
RemoveIfMatch(entity);
}
}
开发者ID:kinlam,项目名称:RUN-SHOOT,代码行数:7,代码来源:ComponentMatchingFamily.cs
示例18: DropItems
protected override void DropItems(EntityBase entity, StructBlock block)
{
LootTable = new List<ItemStack>();
if (block.World.Server.Rand.Next(5) == 0)
LootTable.Add(new ItemStack((short)BlockData.Blocks.Sapling, 1));
base.DropItems(entity, block);
}
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:7,代码来源:BlockLeaves.cs
示例19: CanBePlacedOn
protected override bool CanBePlacedOn(EntityBase who, StructBlock block, StructBlock targetBlock, BlockFace targetSide)
{
if (targetBlock.Type == (byte)BlockData.Blocks.Reed && targetSide == BlockFace.Up)
return true;
if ((targetBlock.Type != (byte)BlockData.Blocks.Sand &&
targetBlock.Type != (byte)BlockData.Blocks.Dirt &&
targetBlock.Type != (byte)BlockData.Blocks.Grass &&
targetBlock.Type != (byte)BlockData.Blocks.Soil) || targetSide != BlockFace.Up)
return false;
bool isWater = false;
var chunk = GetBlockChunk(block);
if (chunk == null)
return false;
chunk.ForNSEW(targetBlock.Coords,
delegate(UniversalCoords uc)
{
byte? blockId = block.World.GetBlockId(uc);
if (blockId != null && (blockId == (byte)BlockData.Blocks.Water || blockId == (byte)BlockData.Blocks.Still_Water))
isWater = true;
});
if (!isWater)
return false;
return base.CanBePlacedOn(who, block, targetBlock, targetSide);
}
开发者ID:TheaP,项目名称:c-raft,代码行数:31,代码来源:BlockReed.cs
示例20: DoDeath
protected override void DoDeath(EntityBase killedBy)
{
var killedByMob = killedBy as Mob;
UniversalCoords coords = UniversalCoords.FromAbsWorld(Position.X, Position.Y, Position.Z);
if (killedByMob != null && killedByMob.Type == MobType.Skeleton)
{
// If killed by a skeleton drop a music disc
sbyte count = 1;
short item;
if (Server.Rand.Next(2) > 1)
{
item = (short)BlockData.Items.Disc13;
}
else
{
item = (short)BlockData.Items.DiscCat;
}
Server.DropItem(World, coords, new Interfaces.ItemStack(item, count, 0));
}
else
{
sbyte count = (sbyte)Server.Rand.Next(2);
if (count > 0)
Server.DropItem(World, coords, new Interfaces.ItemStack((short)BlockData.Items.Gunpowder, count, 0));
}
base.DoDeath(killedBy);
}
开发者ID:Nirad,项目名称:c-raft,代码行数:27,代码来源:Creeper.cs
注:本文中的EntityBase类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论