コード例 #1
0
        public static bool CanMove(Entity mover, OrderedPair destination)
        {
            // returns true if any entites at the destination position are solid

            List <Entity> entitesAtDestination = Zone.GetEntitiesAtPosition(destination);

            foreach (Entity potentialObstacle in entitesAtDestination)
            {
                if (potentialObstacle.HasComponent <Solid>())
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Draws the entity. If the entity cannot/should not be rendered, it won't be.
        /// </summary>
        /// <param name="entity"></param>
        private static void DrawEntity(Entity entity)
        {
            if (!entity.HasComponent <Display>() || !entity.HasComponent <Position>())
            {
                return;
            }

            Display     display = entity.GetComponent <Display>();
            OrderedPair pos     = entity.GetComponent <Position>().Pos;

            if (!display.ShouldRender)
            {
                return;
            }

            GameManager.DrawSprite(display.TextureName, pos.X, pos.Y, display.Color);
        }
コード例 #3
0
 public static void Move(Entity mover, OrderedPair destination)
 {
     mover.GetComponent <Position>().Pos = destination;
 }