public T Get <T>(GameEntityId id) where T : GameEntityBase { GameEntityBase result = this.Get(id); return((T)result); }
/// <summary> /// Creates a new yellow ant entity. /// </summary> /// <param name="contentProvider"> /// The content provider. /// </param> /// <param name="position"> /// The position. /// </param> /// <returns> /// A yellow ant. /// </returns> public static GameEntityBase Create(ContentProvider contentProvider, Point position) { var animation = new Texture2D[2]; animation[0] = contentProvider.GetSpriteTexture(SpriteResource.YellowAntWalk1); animation[1] = contentProvider.GetSpriteTexture(SpriteResource.YellowAntWalk2); // apply interactive elements first var baseEntity = new GameEntityBase(EntityType.Ant, new Rectangle(position.X, position.Y, 1, 1), Player.Black); baseEntity = new PrecisionMovingEntity(baseEntity); baseEntity = new AnimationRenderEntity(baseEntity, animation); baseEntity = new CollisionBarrierEntity(baseEntity); return new InteractionEffectEntity(baseEntity); }
/// <summary> /// Creates soil-type terrain tile. /// </summary> /// <param name="texture"> /// The texture. /// </param> /// <param name="position"> /// The position. /// </param> /// <returns> /// A soil-type terrain tile. /// </returns> public static GameEntityBase CreateSoil(Texture2D texture, Point position) { var tint = Color.White; var depth = position.Y; if (depth > 0) { tint = Color.SaddleBrown; } var baseEntity = new GameEntityBase(EntityType.TerrainSurface, new Rectangle(position.X, position.Y, 1, 1)); baseEntity = new StaticRenderEntity(baseEntity, texture, tint); return new TransparentCollisionEntity(baseEntity); }
private Vector2 GetGunDirection() { Vector2 dir = m_direction; GameEntityBase entity = m_enemyDetector.GetCloestTarget(); if (entity != null) { dir = new Vector2(entity.transform.position.x - transform.position.x, entity.transform.position.y - transform.position.y); } return(dir); }
public override void Update() { base.Update(); if (this.updateEntityCache) { this.updateEntityCache = false; this.entityTickCache.Clear(); this.entityTickCache.AddRange(this.entityRegister.Keys); } foreach (GameEntityId id in this.entityTickCache) { GameEntityBase entity = this.entityRegister[id]; if (entity.IsDead) { continue; } entity.TickEntity(); } }
/// <summary> /// Initializes a new instance of the <see cref="PrecisionMovingEntity"/> class. /// </summary> /// <param name="entity"> /// The entity. /// </param> public PrecisionMovingEntity(GameEntityBase entity) : base(entity) { }
/// <summary> /// Creates an obstacle-type terrain. /// </summary> /// <param name="texture"> /// The texture. /// </param> /// <param name="position"> /// The position. /// </param> /// <param name="size"> /// The size of the obstacle. /// </param> /// <returns> /// An obstacle-type terrain. /// </returns> public static GameEntityBase CreateObstacle(Texture2D texture, Point position, int size) { var baseEntity = new GameEntityBase(EntityType.TerrainObstacle, new Rectangle(position.X, position.Y, size, size)); baseEntity = new StaticRenderEntity(baseEntity, texture); return new CollisionBarrierEntity(baseEntity); }
/// <summary> /// Creates a surface-type terrain tile. /// </summary> /// <param name="texture"> /// The texture. /// </param> /// <param name="position"> /// The position. /// </param> /// <returns> /// A surface-type terrain tile. /// </returns> public static GameEntityBase CreateSurface(Texture2D texture, Point position) { var baseEntity = new GameEntityBase(EntityType.TerrainSurface, new Rectangle(position.X, position.Y, 1, 1)); baseEntity = new StaticRenderEntity(baseEntity, texture); return new TransparentCollisionEntity(baseEntity); }
/// <summary> /// This policy does not allow the colliding entity to enter the collision zone. /// </summary> /// <param name="collidingEntity"> /// The colliding entity. /// </param> /// <returns> /// False always. /// </returns> public override bool CollideOn(GameEntityBase collidingEntity) { return false; }
/// <summary> /// Initializes a new instance of the <see cref="CollisionBarrierEntity"/> class. /// </summary> /// <param name="entity"> /// The entity to decorate. /// </param> public CollisionBarrierEntity(GameEntityBase entity) : base(entity) { }
public void EntityDestroy(GameEntityBase @base) { GameEntities.Remove(@base); Destroy(@base.gameObject); }
public void EntityBuild(GameEntityBase @base) { GameEntities.Add(@base); }
/// <summary> /// Initializes a new instance of the <see cref="WorkerAntIntelligence"/> class. /// </summary> /// <param name="entity"> /// The entity. /// </param> public WorkerAntIntelligence(GameEntityBase entity) : base(entity) { }
public void RegisterEntity(GameEntityBase data) { this.entityRegister.Add(data.Id, data); this.updateEntityCache = true; }