本文整理汇总了C#中System.Entity.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.GetType方法的具体用法?C# Entity.GetType怎么用?C# Entity.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Entity
的用法示例。
在下文中一共展示了Entity.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: doCollision
public void doCollision(Entity ent)
{
if (ent.GetType() == typeof(FlyingEnemy) ||
ent.GetType() == typeof(SpawnerEnemy) ||
ent.GetType() == typeof(GuardEnemy))
{
health -= 1.0f;
}
if (ent.GetType() == typeof(InfoPad))
{
String newPower = ((InfoPad)ent).power;
if (!powers.isAvailable(newPower))
{
powers.makeAvailable(newPower);
LogState.instance.catIntoLog("Discovered: " + newPower + "\n");
LogState.instance.catIntoAvailable(newPower);
LogState.instance.clearInput();
ent.health = 0;
}
else
{
if (!justHit)
{
LogState.instance.catIntoLog("Already know " + newPower + "\n");
justHit = true;
ent.health = 0;
}
}
}
}
示例2: Create
public Guid Create( Entity entity )
{
// TODO: can the ID be assigned manually? I can't remember
Guid id = Guid.NewGuid();
entity.Id = id;
string name = entity.GetType().Name;
if( data.ContainsKey( name ) == false ) {
data.Add( name, new EntityCollection() );
}
if( name == "Entity" ) {
Entity de = ( Entity )entity;
// We set name here to support DynamicEntity
name = de.LogicalName;
de[name + "id"] = id;
}
else {
entity.GetType().GetProperty( name + "id" ).SetValue( entity, id, null );
}
if( !data.ContainsKey( name ) ) {
data[ name ] = new EntityCollection();
}
data[ name ].Entities.Add( entity );
if( m_persist ) {
PersistToDisk( m_filename );
}
return id;
}
示例3: AddEntity
protected internal void AddEntity(Entity e)
{
//Automatically detect proxy types assembly if an early bound type was used.
if (ProxyTypesAssembly == null &&
e.GetType().IsSubclassOf(typeof(Entity)))
{
ProxyTypesAssembly = Assembly.GetAssembly(e.GetType());
}
ValidateEntity(e); //Entity must have a logical name and an Id
//Add the entity collection
if (!Data.ContainsKey(e.LogicalName))
{
Data.Add(e.LogicalName, new Dictionary<Guid, Entity>());
}
if (Data[e.LogicalName].ContainsKey(e.Id))
{
Data[e.LogicalName][e.Id] = e;
}
else
{
Data[e.LogicalName].Add(e.Id, e);
}
//Update metadata for that entity
if (!AttributeMetadata.ContainsKey(e.LogicalName))
AttributeMetadata.Add(e.LogicalName, new Dictionary<string, string>());
//Update attribute metadata
if (ProxyTypesAssembly != null)
{
//If the context is using a proxy types assembly then we can just guess the metadata from the generated attributes
var type = FindReflectedType(e.LogicalName);
if (type != null)
{
var props = type.GetProperties();
foreach (var p in props)
{
if (!AttributeMetadata[e.LogicalName].ContainsKey(p.Name))
AttributeMetadata[e.LogicalName].Add(p.Name, p.Name);
}
}
else
throw new Exception(string.Format("Couldnt find reflected type for {0}", e.LogicalName));
}
else
{
//If dynamic entities are being used, then the only way of guessing if a property exists is just by checking
//if the entity has the attribute in the dictionary
foreach (var attKey in e.Attributes.Keys)
{
if (!AttributeMetadata[e.LogicalName].ContainsKey(attKey))
AttributeMetadata[e.LogicalName].Add(attKey, attKey);
}
}
}
示例4: GetRoundtripEntity
internal static Entity GetRoundtripEntity(Entity entity)
{
Entity roundtripEntity = (Entity)Activator.CreateInstance(entity.GetType());
IDictionary<string, object> roundtripState = ObjectStateUtility.ExtractRoundtripState(entity.GetType(), entity.OriginalValues);
roundtripEntity.ApplyState(roundtripState);
return roundtripEntity;
}
示例5: Format
public string Format(Entity entity)
{
var key = entity.GetType();
if (!htmlTags.ContainsKey(key))
throw new Exception(string.Format("HtmlFormatter got unknown Entity: {0}", entity.GetType()));
var strToFormat = htmlTags[key];
var entityContent = entity.GetSubEntitiesFormat(this);
return string.Format(strToFormat, entityContent);
}
示例6: Add
public void Add(Entity entity)
{
if (entity.Self.Id == null)
session.Save(entity);
var existingObject = ((IList<CachedEntity>)Find(entity.GetType(), entity.Self.Id)).FirstOrDefault();
if (existingObject == null)
{
entities.Add(new CachedEntity {Id = entity.Self.Id, Type = entity.GetType(), Value = entity});
}
else
{
existingObject.Value = entity;
}
}
示例7: Collider
public bool Collider(Entity entity_a, Entity entity_b)
{
float entity_a_LH = entity_a.X - entity_a.Width/2; //LH
float entity_a_RH = entity_a.X + entity_a.Width/2; //RH
float entity_a_T = entity_a.Y - entity_a.Height/2; //Top
float entity_a_B = entity_a.Y +entity_a.Height/2; //Btm
//Let's get centre of entity_b for a little more realism/accuracy
float entity_b_X = entity_b.X;// +(entity_b.Width * 0.5f);
float entity_b_Y = entity_b.Y;// +(entity_b.Height * 0.5f);
if (entity_b_X >= entity_a_LH && entity_b_X <= entity_a_RH && entity_b_Y <= entity_a_B && entity_b_Y >= entity_a_T)
{
//On enemy collission with tower increase capacity of tower - or this can be ran in main game loop
if (entity_a.GetType() == typeof(Tower))
{
//Temporary for testing - set object to inactive for list clean up - Pass responsibility to enemy directly
entity_b.Active = false;
}
return true;
}
else
{
return false;
}
}
示例8: OnBoxCollision
public override void OnBoxCollision(Entity collided, Rectangle intersect)
{
// Collides with another Hero
if (collided.GetType() == typeof (Hero)) _tint = Color.Red;
base.OnBoxCollision(collided, intersect);
}
示例9: ScoreKill
public void ScoreKill(Entity entity)
{
if ((entity.GetType() == typeof(Alien)) && (entity.PlayerNumber != PlayerNumber))
{
Match.GetInstance().GetPlayer(PlayerNumber).Kills++;
}
else if ((entity.GetType() == typeof(Ship)) && (entity.PlayerNumber != PlayerNumber))
{
Match.GetInstance().GetPlayer(PlayerNumber).Kills++;
}
else if (((entity.GetType() == typeof(AlienFactory)) || (entity.GetType() == typeof(MissileController))) &&
(entity.PlayerNumber != PlayerNumber))
{
Match.GetInstance().GetPlayer(PlayerNumber).Kills++;
}
}
示例10: CheckCollision
/// <summary>
/// Generic collision detection function.
/// Checks collisions between two Entities.
/// </summary>
/// <param name="a">the first Entity.</param>
/// <param name="b">the second Entity.</param>
/// <returns>True if the two Entities are colliding; false otherwise.</returns>
public static bool CheckCollision(Entity a, Entity b)
{
if (b.GetType() == typeof(MysteryBox))
{
return CheckCollision(a, (MysteryBox)b);
}
else
{
if (a.myModel != null && b.myModel != null)
{
for (int i = 0; i < a.myModel.Meshes.Count; i++)
{
BoundingSphere HeroSphere = a.myModel.Meshes[i].BoundingSphere;
HeroSphere.Center += a.getPOSITION();
for (int j = 0; j < b.myModel.Meshes.Count; j++)
{
BoundingSphere EnemySphere = b.myModel.Meshes[j].BoundingSphere;
EnemySphere.Center += b.getPOSITION();
if (HeroSphere.Intersects(EnemySphere))
{
//collision!
return true;
}
}
}
}
return false;
}
}
示例11: CreateSerializer
/// <summary>
/// 为指定的实体创建一个 DataContractSerializer。
/// 此过程会通过引用属性、列表属性,递归搜索实体类中所涉及到的其它所有实体类型,
/// 并传递给 DataContractSerializer 作为已知类型,否则,将无法序列化。
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public static DataContractSerializer CreateSerializer(Entity entity)
{
var graph = new SerializationEntityGraph();
graph.DeepSearch(entity);
return new DataContractSerializer(entity.GetType(), graph._knownTypes);
}
示例12: addEntity
public void addEntity(Entity type, Vector2 position, Game game)
{
Type t = type.GetType();
if (t == typeof(InfoPad))
{
entities.Add(new InfoPad(position, ((InfoPad)type).power));
}
else if (t == typeof(FlyingEnemy))
{
entities.Add(new FlyingEnemy(position));
}
else if (t == typeof(SpawnerEnemy))
{
entities.Add(new SpawnerEnemy(position));
}
else if (t == typeof(GuardEnemy))
{
entities.Add(new GuardEnemy(position));
}
else
{ }
entities.Last<Entity>().LoadContent(game);
}
示例13: OnCollision
public override bool OnCollision(Entity ent, byte collide)
{
if (ent.GetType() == typeof(TheGame.Models.Player.Player)) {
TheGame.Models.Player.Player player = (TheGame.Models.Player.Player) ent;
player.Finished = true;
}
return false;
}
示例14: GetId
internal static object GetId(Entity entity)
{
if (entity == null)
{
return null;
}
return entity.GetType().InvokeMember("Id", BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.Public, null, entity, null, CultureInfo.InvariantCulture);
}
示例15: DieAHorribleDeath
//Aka Kill (Sam)
public void DieAHorribleDeath(Entity murderer = null)
{
game.entities_toremove.Add (this);
if (murderer == null) { return; }
string name = murderer.GetType ().FullName;
if (name == "NoMoreClones.FriendlyBullet") {
game.score += score_worth;
}
}