Example #1
0
        public static Ship init(GameEntity world)
        {
            Debug.Assert(ship == null);

            ship = new Ship(world);

            return ship;
        }
Example #2
0
        private Ship(GameEntity world)
        {
            entity_ = new GameEntity();
            entity_.spatial = new Components.SpatialComponent(entity_, world.spatial);
            entity_.physic = new PhysicsComponent(entity_, Vector2.Zero, 0, Vector2.Zero);

            Locator.getComponentManager().addEntity(entity_);

            tiles = new Components.TileSystemComponent(entity_);
            tiles.addArea(new Point(16, 8), Point.Zero);
            tiles.addArea(new Point(16, 8), new Point(0, 10));
            tiles.addArea(new Point(16, 8), new Point(0, 20));
            tiles.addArea(new Point(6, 28), new Point(16, 0));
            tiles.addArea(new Point(10, 16), new Point(22, 6));
            tiles.addArea(new Point(10, 8), new Point(32, 10));
            tiles.addArea(new Point(6, 16), new Point(42, 6));

            tiles.generateTileEntities(entity_);
        }
Example #3
0
        public GameEntity deepCopy()
        {
            GameEntity entity = new GameEntity();

            if (render != null)
            {
                entity.render = (RenderComponent)render.deepCopy(entity);
            }
            if (spatial != null)
            {
                entity.spatial = (SpatialComponent)spatial.deepCopy(entity);
            }
            if (physic != null)
            {
                entity.physic = (PhysicsComponent)physic.deepCopy(entity);
            }
            if (controller != null)
            {
                entity.controller = (ControllerComponent)controller.deepCopy(entity);
            }
            if (tile != null)
            {
                entity.tile = (TileCoord)tile.deepCopy(entity);
            }
            if (info != null)
            {
                entity.info = (InfoComponent)info.deepCopy(entity);
            }
            if (inventory != null)
            {
                entity.inventory = (InventoryComponent)inventory.deepCopy(entity);
            }
            if (production != null)
            {
                entity.production = (ProductionComponent)production.deepCopy(entity);
            }
            if (item != null)
            {
                entity.item = (ItemInfo)item.deepCopy(entity);
            }

            return entity;
        }
Example #4
0
 private static void make(GameEntity e, int x, int y, Components.ObjectState state = Components.ObjectState.OK)
 {
     e.tile.coord_ = new Point(x, y);
     e.info.state = state;
     e.item.state_ = state;
     ship.tiles.build(e.tile.coord_, e.tile.size_);
     Locator.getComponentManager().addEntity_(e);
 }
Example #5
0
 public static void provideWorld(GameEntity world)
 {
     world_ = world;
 }
Example #6
0
 public static void providePlayer(GameEntity player)
 {
     player_ = player;
 }
Example #7
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            Locator.provide(ScreenPrinter.init(Content.Load<SpriteFont>("LargeFont"), Content.Load<SpriteFont>("SmallFont")));
            Locator.provide(TextureManager.init(GraphicsDevice, Content));
            Ship.loadTextures();

            bg_tex_id = Locator.getTextureManager().loadTexture("spacebg");

            world = new GameEntity();
            world.spatial = new SpatialComponent(world, new Vector2(400, 300), 0, Vector2.One);
            world.controller = new WorldController(world, screen);
            Locator.getComponentManager().addEntity(world);
            Locator.provideWorld(world);

            Locator.provide(Ship.init(world));

            ObjectFactory ob = new ObjectFactory();
            ob.init();
            Locator.provide(ob);

            Locator.getShip().populate();
            Locator.getControlManager().forceState(new ControlStates.Selector());

            player = new GameEntity();
            player.spatial = new Components.SpatialComponent(player, Locator.getShip().entity_.spatial, new Vector2(900, 416), 0, Vector2.One);
            player.render = new Components.RenderComponent(player, Locator.getTextureManager().loadTexture("person32"), 1, new Vector2(16), Color.White);
            player.inventory = new InventoryComponent(player, 10);
            player.controller = new Components.PlayerControllerComponent(player);
            Locator.getComponentManager().addEntity_(player);
            Locator.providePlayer(player);

            test = new GameEntity();
            test.spatial = new SpatialComponent(test, Locator.getShip().entity_.spatial, Vector2.Zero, 0, new Vector2(3));
            test.render = new RenderComponent(test, -1, 0, new Vector2(0.5f), Color.White);
            Locator.getComponentManager().addEntity(test);

            Locator.provide(new WindowFactory(screen));
            Locator.getControlManager().setInventory(Locator.getWindowFactory().inventoryWindow());

            Locator.getMessageBoard().postMessage(new Post(PostCategory.PLACED_OBJECT));
        }