コード例 #1
0
        public T Get <T>(GameEntityId id)
            where T : GameEntityBase
        {
            GameEntityBase result = this.Get(id);

            return((T)result);
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
    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);
    }
コード例 #5
0
        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();
            }
        }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PrecisionMovingEntity"/> class.
 /// </summary>
 /// <param name="entity">
 /// The entity.
 /// </param>
 public PrecisionMovingEntity(GameEntityBase entity) : base(entity)
 {
 }
コード例 #7
0
 /// <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);
 }
コード例 #8
0
 /// <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);
 }
コード例 #9
0
 /// <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;
 }
コード例 #10
0
 /// <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)
 {
 }
コード例 #11
0
ファイル: GameEntityController.cs プロジェクト: sea0731/ATM
 public void EntityDestroy(GameEntityBase @base)
 {
     GameEntities.Remove(@base);
     Destroy(@base.gameObject);
 }
コード例 #12
0
ファイル: GameEntityController.cs プロジェクト: sea0731/ATM
 public void EntityBuild(GameEntityBase @base)
 {
     GameEntities.Add(@base);
 }
コード例 #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WorkerAntIntelligence"/> class.
 /// </summary>
 /// <param name="entity">
 /// The entity.
 /// </param>
 public WorkerAntIntelligence(GameEntityBase entity) : base(entity)
 {
 }
コード例 #14
0
 public void RegisterEntity(GameEntityBase data)
 {
     this.entityRegister.Add(data.Id, data);
     this.updateEntityCache = true;
 }