예제 #1
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            texture = Content.Load<Texture2D>("texture");
            textureAtlas = Content.Load<TextureAtlas>("atlasJSON");
            textureRegion = textureAtlas.GetRegion("Enemy Bug");
        }
예제 #2
0
파일: PlayScreen.cs 프로젝트: Choochoo/Ship
        public PlayScreen(GameScreenManager gameScreenManager, Texture2D interfaceTexture, TextureAtlas interfaceAtlas)
            : base(gameScreenManager)
        {
            SpawnX = 214;
            SpawnY = 250;
            _cam = new Camera2D(MainGame.GraphicD.Viewport);
            Seeds.CreateNewSeeds();
            Spritebatch = new SpriteBatch(MainGame.GraphicD);

            DecorationTexture = MainGame.ContentLoader.Load<Texture2D>("Screens/Play/Sheets/decorations");
            DecorationAtlas = MainGame.ContentLoader.Load<TextureAtlas>("Screens/Play/Sheets/decorationsJSON");

            CharacterTexture = MainGame.ContentLoader.Load<Texture2D>("Screens/Play/Sheets/characters");
            CharacterAtlas = MainGame.ContentLoader.Load<TextureAtlas>("Screens/Play/Sheets/charactersJSON");

            InterfaceTexture = interfaceTexture;
            InterfaceAtlas = interfaceAtlas;

            var worlditems = new TextureRegion[WorldItemKey.AllItems.Count];
            for (var i = 0; i < WorldItemKey.AllItems.Count; i++)
                worlditems[i] = DecorationAtlas.GetRegion(WorldItemKey.AllItems[i]);
            WorldItemKey.ItemRegions = worlditems;

            #if DEBUG
            if (ShowMap)
            {
                WorldData.MyWorldData = new WorldData();
                _cw = new CreateWorld(true, false);
                //_tb = new TestBox();
            }
            else
            {
                var az = Enumerable.Range(0, 64*64).Select(i => Color.Red).ToArray();
                ErrorBox = new Texture2D(MainGame.GraphicD, 64, 64, false, SurfaceFormat.Color);
                ErrorBox.SetData(az);
            #endif
                // Create a new SpriteBatch, which can be used to draw textures.

                // showMap = new CreateWorld(GraphicsDevice);
                if (WorldData.MyWorldData == null)
                {
                    //look for file
                    //Utility.RemoveSave();
                    WorldData.MyWorldData = Utility.LoadGameData();
                    if (WorldData.MyWorldData == null)
                    {
                        WorldData.MyWorldData = new WorldData();
                        _cw = new CreateWorld(false, true);
                    }
                }
                _managers = new Manager();
                _myInputs = new Inputs();
            #if DEBUG
            }
            #endif

            GC.Collect();
        }
예제 #3
0
파일: Decoration.cs 프로젝트: Choochoo/Ship
 public Decoration(DecorManager dm, ref TextureRegion[] tileRegions)
 {
     _dm = dm;
     _hitRect = new Rectangle(0, 0, 50, 50);
     _tileRegions = tileRegions;
     _numberOfElementsAllTogether = DecorHelper.BushCount + DecorHelper.RockCount + DecorHelper.TreeCount;
     _spriteBatch = PlayScreen.Spritebatch;
     _myTexture = PlayScreen.DecorationTexture;
     _treeDestroyAnimation = new DestroyTreeAnim("treefalling");
 }
예제 #4
0
        public TileCollection(TextureRegion[] tileRegions, int vectorx, int vectory, int width, int height)
        {
            _tileRegions = tileRegions;

            MyVectorSpotX = vectorx;
            MyVectorSpotY = vectory;

            _topVectorY = MyVectorSpotY - 1 < 0 ? height - 1 : MyVectorSpotY - 1;
            _bottomVectorY = MyVectorSpotY + 1 < height ? MyVectorSpotY + 1 : 0;
            _leftVectorX = MyVectorSpotX - 1 < 0 ? width - 1 : MyVectorSpotX - 1;
            _rightVectorX = MyVectorSpotX + 1 < width ? MyVectorSpotX + 1 : 0;
            //minus 25 for width of hitbox of hero
            _hitRect = new Rectangle((vectorx*TileManager.Sprite2XWidth), (vectory*TileManager.Sprite2XWidth),
                                     TileManager.Sprite2XWidth - 14, TileManager.Sprite2XWidth - 12);
        }
예제 #5
0
        public Sprite(Beatup game, string atlas_name, string sheet_name, string sprite_name)
        {
            atlas = game.Content.Load<TextureAtlas>(atlas_name);
            region = atlas.GetRegion(sprite_name);

            sheet = game.Content.Load<Texture2D>(sheet_name);

            this.position.X = 0;
            this.position.Y = 0;

            flippedX = false;
            rotation = 0;

            scale_x = 4.0f;
            scale_y = 4.0f;
        }
예제 #6
0
파일: TestBox.cs 프로젝트: Choochoo/Ship
        public void TileTesting(GraphicsDevice graphicsDevice)
        {
            textureRegion = _mainAtlas.GetRegion("decor_hot_tree1");
            var xspot = 1;
            var yspot = 1;
            showPosition = new Vector2(((xspot*PlayScreen.SectorTileSize)*Zoom) - (textureRegion.Bounds.Width/2.0f),
                                       ((yspot*PlayScreen.SectorTileSize)*Zoom) - (textureRegion.Bounds.Height*3) +
                                       ((PlayScreen.SectorTileSize*Zoom)/2));
            //TerrainTesting(graphicsDevice);
            var black = new[] {Color.Black};
            var red = new[] {Color.Red};
            for (var x = 0; x < _texture.GetLength(0); x++)
            {
                for (var y = 0; y < _texture.GetLength(0); y++)
                {
                    _texture[x, y] = new Texture2D(graphicsDevice, PlayScreen.SectorTileSize, PlayScreen.SectorTileSize);
                    _texturePos[x, y] = new Vector2((x*PlayScreen.SectorTileSize)*Zoom,
                                                    (y*PlayScreen.SectorTileSize)*Zoom);

                    for (var i = 0; i < PlayScreen.SectorTileSize; i++)
                    {
                        for (var j = 0; j < PlayScreen.SectorTileSize; j++)
                        {
                            if (i == 0 || j == 0)
                                _texture[x, y].SetData(0, new Rectangle(i, j, 1, 1), red, 0, 1);
                            else
                                _texture[x, y].SetData(0, new Rectangle(i, j, 1, 1), black, 0, 1);
                        }
                    }
                }
            }
        }
예제 #7
0
파일: TestBox.cs 프로젝트: Choochoo/Ship
 public void TextureTesting(GraphicsDevice graphicsDevice)
 {
     startTime = Environment.TickCount;
     textureRegion = _mainAtlas.GetRegion("grass");
 }
예제 #8
0
파일: WorldItem.cs 프로젝트: Choochoo/Ship
 public void SetType(ref TileCollection myTile, byte type, float positionX, float positionY)
 {
     MyType = type;
     Count = 1;
     _myRegion = WorldItemKey.ItemRegions[type];
     _hitRect.Width = _myRegion.Bounds.Width;
     _hitRect.Height = _myRegion.Bounds.Height;
     PutOnGround(positionX, positionY);
     SetTile(ref myTile);
 }