本文整理汇总了C#中Entity.GetID方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.GetID方法的具体用法?C# Entity.GetID怎么用?C# Entity.GetID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity.GetID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveMessageImmediate
/*
* A person (or entity) can remove speech after moving onto another state
*
*/
public void RemoveMessageImmediate(Entity entity)
{
if (speechBubbles.ContainsKey(entity.GetID())) {
SpeechBubble speechBubble = speechBubbles[entity.GetID()];
if (speechBubble.panel != null)
speechBubble.panel.RemoveSpeechBubble();
speechBubbles.Remove(entity.GetID());
}
}
示例2: RemoveMessageDelayed
Dictionary<int, SpeechBubble> speechBubbles = new Dictionary<int, SpeechBubble>(); // first int is entity id
#endregion Fields
#region Methods
/*
* A person (or entity) can remove speech after completing showing speech bubble
* (called from speech bubble panel)
*
* Delay removal (therefore introducing timeout to next continuous speech bubble)
*/
public void RemoveMessageDelayed(Entity entity)
{
if (speechBubbles.ContainsKey(entity.GetID())) {
// make sure we're not already waiting for removal
if (!speechBubbles[entity.GetID()].waitingForRemoval) {
// setup delayed removal
speechBubbles[entity.GetID()].waitingForRemoval = true;
int removalTimeInSeconds = TimeController.TimeInSeconds + speechRemovalTimeDelayInSeconds;
speechBubbles[entity.GetID()].removalTimeInSeconds = removalTimeInSeconds;
removeQueue.Enqueue(speechBubbles[entity.GetID()]);
}
}
}
示例3: CostNode
public CostNode(Cost cost, Entity entity, int time)
{
Entity = entity;
EntityID = Entity.GetID();
CostPerHour = cost.costPerHour;
TimeInMinutes = time;
}
示例4: HandleCollisionEnd
public override void HandleCollisionEnd( Entity collider )
{
if( null == collider )
{
//-- Ignore null targets
return;
}
if( IsAffectedTarget( collider ) )
{
//-- Check if this entity is one of our targets
int targetSlotIndex = -1;
if( m_TargetLookup.TryGetValue( collider.GetID(), out targetSlotIndex ) )
{
//-- If so, deactivate it
}
}
}
示例5: HandleCollision
/// <summary>
/// The implementation of this method code assumes that this function does
/// not get called twice for the same entity unless there is a 'HandleCollisionEnd'
/// call for that entity in between.
/// </summary>
public override void HandleCollision( Entity collider )
{
if( (null == collider) || (collider.GetID() == InstanceID.Invalid_IID) )
{
//-- Don't accept null or invalid targets
return;
}
if( !m_Active )
{
//-- Don't accept targets when inactive
return;
}
if( IsAffectedTarget( collider ) )
{
int newTargetSlotIndex = -1;
if( 0 < m_FreeSlots.Count )
{
//-- There's an expired target we can use
int slotIndex = m_FreeSlots.Dequeue();
//-- Re-initilize expired target with new data
HotSpotTarget target = m_TargetPool[slotIndex];
{
target.TargetEntityID = collider.GetID();
target.AffectationCount = 0;
target.Active = true;
}
newTargetSlotIndex = slotIndex;
}
else
{
//-- There was no more room in the pool, so grow it. Create a new
// target and append it to the target pool
HotSpotTarget newTarget = new HotSpotTarget();
newTarget.TargetEntityID = collider.GetID();
newTarget.AffectationCount = 0;
newTarget.Active = true;
//-- Add new slot to target pool
m_TargetPool.Add( newTarget );
newTargetSlotIndex = m_TargetPool.Count - 1;
}
//-- Register the new target to our lookup dictionary
m_TargetLookup[collider.GetID()] = newTargetSlotIndex;
//-- Immediately schedule the target to be affected
ScheduleTarget( newTargetSlotIndex, GameSystem.GetTime() + m_InitialDelay );
}
}
示例6: PrintEntity
/// <summary>
/// Prints the description for an individual entity on its own line.
/// </summary>
/// <param name="entity"></param>
private static void PrintEntity( Entity entity )
{
Console.Out.WriteLine( entity.GetID() + " - " + entity.ToString() + " [" + entity.m_Type.ToString() + "]" );
}
示例7: RemoveEntity
/// <summary>
/// Removes a specified entity from the game. This private function assumes that its parameter
/// is a valid entity currently present in the game world.
/// </summary>
/// <param name="entity"></param>
private static void RemoveEntity( Entity entity )
{
//-- Remove any collision that this entity may be involved with
RemoveCollision( entity );
//-- Remove the entity from the world
entity.ExitWorld();
s_GameEntities.Remove( entity.GetID() );
//-- Print
Console.Out.Write( "Removed entity: " );
PrintEntity( entity );
Console.Out.WriteLine();
PrintEntities();
}
示例8: AddEntity
/// <summary>
/// Adds a specified entity to the game world.
/// </summary>
private static void AddEntity( Entity entity )
{
//-- Print new entity
Console.Out.Write( "Created entity: " );
PrintEntity( entity );
//-- Add the entity to the world
s_GameEntities.Add( entity.GetID(), entity );
entity.EnterWorld();
//-- Print list
Console.Out.WriteLine();
PrintEntities();
}
示例9: GetCollision
/// <summary>
/// Returns an active collision involving two specified entities or null if
/// no such collision exists.
/// </summary>
private static Tuple<InstanceID, InstanceID> GetCollision( Entity entity1, Entity entity2 )
{
foreach( Tuple<InstanceID, InstanceID> collision in s_Collisions )
{
bool colliding = false;
colliding = colliding || ((collision.Item1 == entity1.GetID()) && (collision.Item2 == entity2.GetID()));
colliding = colliding || ((collision.Item2 == entity1.GetID()) && (collision.Item1 == entity2.GetID()));
if( colliding )
{
//-- Both members of the collision match the specified entities
return collision;
}
}
return null;
}
示例10: RemoveCollision
/// <summary>
/// Removes all active collisions involving a specified entity or does nothing
/// if no such collisions exist.
/// </summary>
private static void RemoveCollision( Entity entity )
{
LinkedListNode<Tuple<InstanceID, InstanceID>> collisionIter = s_Collisions.First;
while( null != collisionIter )
{
//-- Cache next collision
LinkedListNode<Tuple<InstanceID, InstanceID>> nextCollisionIter = collisionIter.Next;
//-- Remove this collision if one of its colliders is the entity
Tuple<InstanceID, InstanceID> collision = collisionIter.Value;
if( (collision.Item1 == entity.GetID()) || (collision.Item2 == entity.GetID()) )
{
//-- Send collision end events
Entity collider1 = GetEntity( collision.Item1 );
Entity collider2 = GetEntity( collision.Item2 );
if( null != collider1 )
{
collider1.HandleCollisionEnd( collider2 );
}
if( null != collider2 )
{
collider2.HandleCollisionEnd( collider1 );
}
//-- Remove the collision
s_Collisions.Remove( collisionIter );
}
//-- Next collision
collisionIter = nextCollisionIter;
}
}
示例11: AddCollision
/// <summary>
/// Adds a collision between two specified entities
/// </summary>
private static void AddCollision( Entity entity1, Entity entity2 )
{
//-- Only add a collision if the pair aren't already colliding
if( GetCollision( entity1, entity2 ) == null )
{
//-- Send collision events
entity1.HandleCollision( entity2 );
entity2.HandleCollision( entity1 );
//-- Add new collision
s_Collisions.AddLast( new Tuple<InstanceID, InstanceID>( entity1.GetID(), entity2.GetID() ) );
}
}
示例12: HandleCollisionEnd
public override void HandleCollisionEnd( Entity collider )
{
if( null == collider )
{
//-- Ignore null targets
return;
}
//-- Track colliding entity
m_CollidingEntities.Remove( collider.GetID() );
if( IsAffectedTarget( collider ) )
{
//-- Remove the target from any jobs it might be in
RemoveTargetFromJobs( collider.GetID() );
}
}
示例13: HandleCollision
/// <summary>
/// The implementation of this method code assumes that this function does
/// not get called twice for the same entity unless there is a 'HandleCollisionEnd'
/// call for that entity in between.
/// </summary>
public override void HandleCollision( Entity collider )
{
if( (null == collider) || (collider.GetID() == InstanceID.Invalid_IID) )
{
//-- Don't accept null or invalid targets
return;
}
if( !m_Active )
{
//-- Don't accept targets when inactive
return;
}
//-- Track the colliding entity
m_CollidingEntities.Add( collider.GetID() );
if( IsAffectedTarget( collider ) )
{
//-- Create a new target to schedule to be affected
HotSpotTarget newTarget = new HotSpotTarget();
newTarget.TargetEntityID = collider.GetID();
newTarget.AffectationCount = 0;
//-- Schedule the new target
ScheduleTarget( newTarget, GameSystem.GetTime() + m_InitialDelay );
}
}
示例14: SendMessage
/*
* Create a new speech bubble and add to list
*/
public void SendMessage(string[] messages, Entity sendingEntity, int messageType)
{
// choose what message to use
int randomMessageIndex = Random.Range(0, messages.Length);
string message = messages[randomMessageIndex];
// create speech bubble, set parameters
SpeechBubble speechBubble = new SpeechBubble(message, messageType, sendingEntity);
speechBubbles.Add(sendingEntity.GetID(), speechBubble);
// THIS IS TEMPORARY - this should be managed by looking at the list
// for now, send to panel to create new speech bubble panel
if (ShouldCreateSpeechBubble(messageType, sendingEntity.transform.position) &&
!speechBubbles[sendingEntity.GetID()].bubbleCreated) {
//print("creating speech bubble! size = " + speechBubbles.Count + " entity ID = " + sendingEntity.GetID());
speechBubbles[sendingEntity.GetID()].panel = speechBubblePanel.CreateNewSpeechBubblePanel(sendingEntity.transform,
message,
sendingEntity,
this);
} else
RemoveMessageDelayed(sendingEntity);
}
示例15: SendMessageContinuous
public void SendMessageContinuous(string[] messages, Entity sendingEntity, int messageType)
{
if (speechBubbles.ContainsKey(sendingEntity.GetID()))
return;
else
SendMessage(messages, sendingEntity, messageType);
}