本文整理汇总了C#中Entity.Get方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.Get方法的具体用法?C# Entity.Get怎么用?C# Entity.Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity.Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateEntity
protected override void UpdateEntity(float dt, Entity entity)
{
var position = entity.Get<Position>();
var prev = entity.Get<PreviousPosition>();
position.X.CopyTo(prev.X, 0);
position.Y.CopyTo(prev.Y, 0);
}
示例2: Assign
public static void Assign(this UpdatePositionMsg msg, Entity entity)
{
msg.Id = entity.Id;
msg.X = entity.Get<Pos>().X;
msg.Y = entity.Get<Pos>().Y;
msg.Dir = entity.Get<Motion>().Dir;
msg.Speed = entity.Get<Motion>().Dir;
}
示例3: GetEffectiveBody
public static Body GetEffectiveBody(Entity e)
{
var body = e.Get(Body);
if (body == null) {
return null;
}
var position = e.Get(Located.Position);
return body.Offset(position);
}
示例4: UpdateEntity
protected override void UpdateEntity(float dt, Entity entity)
{
var position = entity.Get<Position>();
var direction = entity.Get<Direction>();
for (int i = 0; i < entity.Count(); ++i)
{
position.X[i] += direction.X[i] * dt;
position.Y[i] += direction.Y[i] * dt;
}
}
示例5: Kill
public static bool Kill(Entity zombie, Vector2? explosionVelocity)
{
const float LotsOfDamage = 1000 * 1000;
zombie.Get<CHealth>().TakeDamage(LotsOfDamage);
if (explosionVelocity.HasValue)
{
ZombieHelper.TriggerBloodExplosion(zombie.Transform, explosionVelocity.Value);
}
zombie.Get<CZombieInfo>().SetKillReason(KillReason.Instakill);
return true;
}
示例6: Attach
public static void Attach(Entity result, Property<Matrix> property = null)
{
AkGameObjectTracker tracker = result.Get<AkGameObjectTracker>();
if (tracker == null)
{
tracker = new AkGameObjectTracker();
result.Add(tracker);
if (property == null)
property = result.Get<Transform>().Matrix;
tracker.Add(new Binding<Matrix>(tracker.Matrix, property));
}
}
示例7: OnTick
internal void OnTick(Entity entity, TickMessage tick)
{
// 로그아웃 한 상태에서 Tickable이 남아있는 유저는 Tick을 수행하지 않도록 한다.
if (entity.Has<Player>() && !entity.Get<Player>().Logged)
{
entity.Detach<Tickable>();
return;
}
if (entity.Has<Fightable>())
{
var fightable = entity.Get<Fightable>();
if (fightable.IsAlive)
{
if (++fightable.RecoveryCurrentTick >= fightable.RecoveryTickCount)
{
var recovery = DataCenter.Instance.GetDatum<InteractTemplate>((int)InteractTemplate.Ids.Recovery);
EffectSystem.Affect(entity, recovery);
fightable.RecoveryCurrentTick = 0;
}
}
}
if (entity.Has<Eatable>())
{
}
if (entity.Has<EntityGenerate>())
{
var entityGenerate = entity.Get<EntityGenerate>();
if (entityGenerate.IsGeneratable)
{
if (entityGenerate.Resource >= entityGenerate.NeededResourceToGen)
{
// generate!
entityGenerate.Resource -= entityGenerate.NeededResourceToGen;
}
entityGenerate.Resource += entityGenerate.IncResource;
}
}
// 다음 Tick을 요청한다.
if (entity.Has<Tickable>())
{
var nextMsg = new TickMessage {Id = entity.Id};
nextMsg.ExecuteDelayed(entity, entity.Get<Tickable>().Interval);
}
}
示例8: Initialize
public override void Initialize()
{
this.RegisterSystems();
FPSCamera camera = new FPSCamera(new Vector3(0f, 0f, 0f), Vector3.Zero,
Blackboard.Get<GraphicsDevice>("GraphicsDevice").Viewport.AspectRatio, 0.05f, 100f);
Entity fpscounter = new Entity();
fpscounter.AddComponent(new Transform2DComponent() { Position = new Vector2(5, 150) });
fpscounter.AddComponent(new FPSCounterComponent());
fpscounter.AddComponent(new GUITextComponent());
Entity pos = new Entity();
pos.AddComponent(new PositionalTrackingComponent() { Target = camera.Get<Transform3DComponent>() });
pos.AddComponent(new GUITextComponent());
pos.AddComponent(new Transform2DComponent() { Position = new Vector2(5, 180) });
Entity model = new Entity();
model.AddComponent(new Transform3DComponent(new Vector3(0f, -1f, 2f)));
model.Get<Transform3DComponent>().Rotation = new Vector3(0f, MathHelper.PiOver2, 3f*MathHelper.PiOver2);
Model m = Blackboard.Get<ContentManager>("ContentManager").Load<Model>("dragon");
model.AddComponent(new ModelComponent() { Model = m });
this.AddEntity(model);
this.AddEntity(pos);
this.AddEntity(fpscounter);
this.AddEntity(camera);
}
示例9: OnEntityAdded
public override void OnEntityAdded(Entity entity)
{
if (entity.ComponentTypes.Contains(typeof(InputComponent)))
{
_inputComponent = entity.Get<InputComponent>();
}
}
示例10: TakeDamage
public static bool TakeDamage(Entity zombie, float damage, Vector2? explosionVelocity)
{
CHealth health = zombie.Get<CHealth>();
if (!health.IsAlive)
{
return true;
}
IBoosterState boosterState = zombie.EntityWorld.Services.Get<IBoosterState>();
bool killed = health.TakeDamage(damage * BoosterHelper.GetZombieDamageRedcutionMultiplier(boosterState));
if (explosionVelocity.HasValue)
{
if (killed)
{
ZombieHelper.TriggerBloodExplosion(zombie.Transform, explosionVelocity.Value);
}
else
{
ZombieHelper.TriggerBloodSplatter(zombie.Transform, Vector2.Zero);
}
}
if (killed)
{
zombie.Get<CZombieInfo>().SetKillReason(KillReason.Normal);
}
return killed;
}
示例11: UpdateEntity
protected override void UpdateEntity(float dt, Entity entity)
{
if (entity.Count() == 0)
{
return;
}
var direction = entity.Get<Direction>();
var position = entity.Get<Position>();
var input = entity.Get<InputComponent>();
var hotspots = entity.Get<Hotspots>();
float accel = dt * 0.8f;
if (input.Right)
{
direction.X[0] = direction.X[0] + accel * (24.0f - direction.X[0]);
}
if (input.Left)
{
direction.X[0] = direction.X[0] + accel * (-24.0f - direction.X[0]);
}
if (!(input.Left || input.Right))
{
if (hotspots.BottomHit[0])
{
direction.X[0] = direction.X[0] + dt * (0 - direction.X[0]);
}
else
{
direction.X[0] = direction.X[0] + dt * .1f * (0 - direction.X[0]);
}
}
if (input.Jump && hotspots.BottomHit[0])
{
if (input.Down)
{
direction.Y[0] = 1.5f;
entity.Transform(0, input.DroppingPlayer);
input.DroppingPlayer.Get<TypeChanger>().Transformation = entity;
input.DroppingPlayer.Get<TypeChanger>().TTL = 0.8f;
}
else
{
direction.Y[0] = -32.0f;
}
}
}
示例12: Update
public override void Update()
{
if(Game.IsRunning && Entity.Components.Get<UIComponent>(UIComponent.Key).Enabled)
{
castle = (from entities in SceneSystem.SceneInstance where entities.Name == "Castle" select entities).FirstOrDefault();
((TextBlock)Entity.Components.Get<UIComponent>(UIComponent.Key).RootElement.VisualChildren.ElementAt(4)).Text = "Złoto: " + ((CastleController)castle.Get<ScriptComponent>(ScriptComponent.Key).Scripts[0]).gold.ToString();
((TextBlock)Entity.Components.Get<UIComponent>(UIComponent.Key).RootElement.VisualChildren.ElementAt(5)).Text = "Zdrowie: " + ((CastleController)castle.Get<ScriptComponent>(ScriptComponent.Key).Scripts[0]).health.ToString();
((TextBlock)Entity.Components.Get<UIComponent>(UIComponent.Key).RootElement.VisualChildren.ElementAt(6)).Text = "Jednostki: " + ((CastleController)castle.Get<ScriptComponent>(ScriptComponent.Key).Scripts[0]).units.ToString();
((TextBlock)Entity.Components.Get<UIComponent>(UIComponent.Key).RootElement.VisualChildren.ElementAt(7)).Text = "Kilofy: " + ((CastleController)castle.Get<ScriptComponent>(ScriptComponent.Key).Scripts[0]).pickaxes.ToString();
((TextBlock)Entity.Components.Get<UIComponent>(UIComponent.Key).RootElement.VisualChildren.ElementAt(8)).Text = "Miecze: " + ((CastleController)castle.Get<ScriptComponent>(ScriptComponent.Key).Scripts[0]).swords.ToString();
((TextBlock)Entity.Components.Get<UIComponent>(UIComponent.Key).RootElement.VisualChildren.ElementAt(9)).Text = "Łuki: " + ((CastleController)castle.Get<ScriptComponent>(ScriptComponent.Key).Scripts[0]).bowArrows.ToString();
((TextBlock)Entity.Components.Get<UIComponent>(UIComponent.Key).RootElement.VisualChildren.ElementAt(10)).Text = "Różdżki " + ((CastleController)castle.Get<ScriptComponent>(ScriptComponent.Key).Scripts[0]).wands.ToString();
//Keyboard Input
if(Input.IsKeyReleased(Keys.Escape))
{
((Game)Game).Exit();
}
if(Input.IsKeyReleased(Keys.K))
{
ProduceUnit("KILOF");
}
if(Input.IsKeyReleased(Keys.M))
{
ProduceUnit("MIECZ");
}
if(Input.IsKeyReleased(Keys.L))
{
ProduceUnit("ŁUK");
}
if(Input.IsKeyReleased(Keys.R))
{
ProduceUnit("RÓŻDŻKA");
}
}
}
示例13: OnBulletHitCallback
public override bool OnBulletHitCallback(UpdateContext updateContext, CBullet bullet, Entity entityHit)
{
if (entityHit.Get<CHealth>().IsAlive && ZombieHelper.TakeDamage(entityHit, updateContext.DeltaSeconds * 10f, null))
{
ZombieHelper.TriggerBloodExplosion(entityHit.Transform, Vector2.Zero);
}
return false;
}
示例14: Main
static void Main(string[] args)
{
ReplaceInFile("C:\\Users\\Javier\\Desktop\\hola.txt", "C:\\Users\\Javier\\Desktop\\hola3.txt", "las personas","el mundo");
///////////////////////////
//Se prueba objeto entity
///////////////////////////
//Método Set (no case sensitive)
Entity e = new Entity();
e.Set("Nombre", "Javier");
e.Set("Nombre", "Alonso");
e.Set("Apellido", "Alvarez");
e.Set("edad", 20);
e.Set("fecha_nacimiento", new DateTime(1992,2,2));
//Método Get (no case sensitive)
Console.WriteLine("Información de Javier:");
Console.WriteLine("Nombre: " + (string)e.Get("Nombre"));
Console.WriteLine("Apellido: " + (string)e.Get("apellido"));
Console.WriteLine("Edad: " + (int)e.Get("edad"));
Console.WriteLine("Fecha de Nacimiento: " + (DateTime)e.Get("fecha_nacimiento"));
///////////////////////////
///////////////////////////
ManejadorBaseDatos.Instancia.EjecutarScript("AYA");
///////////////////////////
//Se prueba DA
///////////////////////////
// Prueba Carga XML con DA
Entities sp = new XMLLoader().loadXML("C://Users//Javier//.netbeans//7.1.2//config//GF3//domain1//tmsite//da//da.xml");
// Prueba Ejecutar SP con objeto entity
Entity parametros = new Entity();
parametros.Set("pID", 1);
parametros.Set("pCarro","Toyota");
parametros.Set("pNombre","Javier");
///////////////////////////
///////////////////////////
Console.ReadKey();
}
示例15: UpdateEntity
protected override void UpdateEntity(float dt, Entity entity)
{
var tc = entity.Get<TypeChanger>();
if ((tc.TTL -= dt) <= 0)
{
for (int i = 0; i < entity.Count(); ++i)
{
entity.Transform(i, tc.Transformation);
}
}
}