/// <summary>
    /// Заменяет имеющиеся наборы текстур в массиве Textures на свежесгенерированные
    /// </summary>
    public void ChangeSets()
    {
        // Освободить старые ресурсы
        if (_nextSetEmpty) {
            Debug.Log("Заказано обновление текстур когда они еще не готовы! Стоит проверять \"NextSetReady\"");
            return;
        }
        //Stopwatch stopwatch = Stopwatch.StartNew();
        // Освобождаю ресурсы от еще в прошлый раз устаревших текстур
        if (tempTextures != null) {
            int nSets = tempTextures.GetLength(1);
            for (int i = 0; i < tempTextures.GetLength(0); i++) {
                for (int j = 0; j < nSets; j++) {
                    DestroyImmediate(tempTextures[i, j], true);
                }
            }
        }
        //Resources.UnloadUnusedAssets();
        // сохраняю устаревшие текстуры, чтобы объекты на сцена не испортить.
        tempTextures = textures;
        // копирую новые
        _nextSetEmpty = true;
        textures = reserveTextures;
        reserveTextures = new Texture2D[_countSizes, _countEachTexture];
        //DebugF.Log("Старый набор текстур был удален и заменен резервным за {0}мс", stopwatch.ElapsedMilliseconds);

        // Запускаю расчет резервного набора текстур
        StartCoroutine(UpdateTetures(_countSizes, _countEachTexture, _minSizeTexture));
    }
        public Joueur(string path, Texture2D[,] texture_usp, Texture2D[,] texture_ak47, Texture2D[,] texture_mp5, Texture2D[,] texture_m3, ContentManager Content, int height, int width)
        {
            Load(path, Content);
            this.height = height;
            this.width = width;

            this.texture_usp = texture_usp;
            this.texture_ak47 = texture_ak47;
            this.texture_mp5 = texture_mp5;
            this.texture_m3 = texture_m3;

            this.position = new Vector2(width / 2  - texture_ak47[1,1].Width / 6, height / 2 - texture_ak47[1,1].Height / 6 );
            this.init_position = this.position;

            this.health = 100;

            reloading = false;

            current_weapon = 0;
            dist_marche = 0;
            pas = 0;

            SetSpeed(2);
            SetRectangle();
        }
Example #3
0
        public Wall(string name, string price, string desc, Bitmap[,] rotsByLods, GraphicsDevice gd, string spriteName)
        {
            myWallName = name;
            myWallDesc = desc;
            myWallPrice = price;
            mySpriteName = spriteName;
            myWallRotsS1 = new Texture2D[3,4];
            myGD = gd;

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    MemoryStream ms = new MemoryStream();
                    Microsoft.Xna.Framework.Graphics.Color[] pixels = new Microsoft.Xna.Framework.Graphics.Color[rotsByLods[i, j].Height * rotsByLods[i, j].Width];
                    for (int k = 0; k < rotsByLods[i, j].Height; k++)
                    {
                        for (int l = 0; l < rotsByLods[i, j].Width; l++)
                        {
                            System.Drawing.Color currentColor = rotsByLods[i, j].GetPixel(l, k);
                            pixels[k * rotsByLods[i, j].Width + l] = new Microsoft.Xna.Framework.Graphics.Color(currentColor.R, currentColor.G, currentColor.B, currentColor.A);
                        }
                    }

                    myWallRotsS1[i, j] = new Texture2D(gd, rotsByLods[i, j].Width, rotsByLods[i, j].Height);
                    myWallRotsS1[i, j].SetData<Microsoft.Xna.Framework.Graphics.Color>(pixels);
                }
            }
            myWallRotsS2 = myWallRotsS1;
        }
Example #4
0
 //default map constructor, makes a concrete bitmap with nothing on it
 public Map(ContentManager content, int screenWidth, int screenHeight) {
     tileSize = screenWidth / 20;
     tileMap = new Texture2D[20, 100];
     objectMap = new MapObject[tileMap.GetLength(0), tileMap.GetLength(1)];
     tileRot = new int[tileMap.GetLength(0), tileMap.GetLength(1)];
     objRot = new int[tileMap.GetLength(0), tileMap.GetLength(1)];
     //loops through entire tileMap array and sets each value to concrete
     for (int i = 0; i < tileMap.GetLength(0); i++) {
         for (int j = 0; j < tileMap.GetLength(1); j++) {
             tileMap[i, j] = content.Load<Texture2D>("ConcreteCorner");
         }
     }
     //loops through objectMap array and sets edges to noTexture
     for (int i = 0; i < objectMap.GetLength(0); i++) {
         for (int j = 0; j < objectMap.GetLength(1); j++) {
             objectMap[i, j] = new MapObject(content, true, "NoTexture", i, j);
         }
     }
     for (int i = 1; i < objectMap.GetLength(0) - 1; i++) {
         for (int j = 1; j < objectMap.GetLength(1) - 1; j++) {
             objectMap[i, j] = null;
         }
     }
     for (int i = 1; i < objectMap.GetLength(0); i += 6) {
         for (int j = 0; j < objectMap.GetLength(1) - 3; j++) {
             objectMap[i, j] = new MapObject(content, true, "NoTexture", i, j);
         }
     }
 }
 public Zombie(Vector2 position, float speed, Texture2D[,] textures)
 {
     this.textures = textures;
     this.position = position;
     this.speed = speed;
     this.health = 100;
     this.dead = false;
     SetRectangle();
     SetTarget();
 }
Example #6
0
 public Wall(string name, string price, string desc, Texture2D[,] side1, Texture2D[,] side2, GraphicsDevice gd, string spriteName)
 {
     myWallName = name;
     myWallDesc = desc;
     myWallPrice = price;
     mySpriteName = spriteName;
     myWallRotsS1 = side1;
     myWallRotsS2 = side2;
     myGD = gd;
 }
Example #7
0
        public void LoadContent(MyGame game)
        {
            PowerTextures = LoadPowerTextures(game);
            PowerLocations = LoadPowerLocations();
            spriteBatch = new SpriteBatch(game.GraphicsDevice);

            player.LoadContent(game);
            map.LoadContent(game);
            background.LoadContent(game);
        }
Example #8
0
 public TankBattle(Game game,Map map)
     : base(game)
 {
     Battle  = map;
        // feild = new Rectangle[length, length];
     tanks  = new Texture2D[count, 4];
     length = Battle.getLength();
     w = 600 / length;
        // isPlayerThere = new Boolean[length, length];
     // TODO: Construct any child components here
 }
 private void Initialize()
 {
     txt = new Texture2D[(int)_dimensions.X, (int)_dimensions.Y];
     for(int i = 0; i < (int)_dimensions.X; i++)
     {
         for (int j = 0; j < (int)_dimensions.Y; j++)
         {
             txt[i,j] = new Texture2D(Master.GetGame().GraphicsDevice, _tileSide, _tileSide);
         }
     }
 }
 public void LoadData(int tW, int tH, int tO, int tX, int tY, string tM)
 {
     tile_width = tW;
     tile_height = tH;
     tile_offset = tO;
     tile_X = tX;
     tile_Y = tY;
     tile_num_dict = new int[tX,tY];
     tile_tex_dict = new Texture2D[tX,tY];
     tile_map = (Texture2D) Resources.Load(tM);
 }
Example #11
0
 public switch_map(GamePlayer Player, gamemain Main)
 {
     player = Player;
     main = Main;
     liste_map = new Texture2D[5, 5];
     liste_map[1, 2] = ressource.map_1;
     liste_map[2, 1] = ressource.map_2;
     liste_map[2, 2] = ressource.map_0;
     x = 2;
     y = 2;
     active_map = liste_map[2, 2];
 }
Example #12
0
 private void LoadImages()
 {
     characterImages = new Texture2D[genderItems.Length, classItems.Length];
     for (int i = 0; i < genderItems.Length - 1; i++)
     {
         for (int j = 0; j < classItems.Length; j++)
         {
             characterImages[i, j] = Game.Content.Load <Texture2D>(@"PlayerSprites\" +
                                                                   genderItems[i] + classItems[j]);
         }
     }
 }
Example #13
0
        /*
         * Constructor
         */
        public Tank(Texture2D[,] texture, Rectangle tankAreaRectangle)
        {
            this.texture = texture;
            currentThreshold = 1.0f;
            this.tankAreaRectangle = tankAreaRectangle;

            // Position reflects the center of the tank area rectangle.
            position.X = (tankAreaRectangle.Width - texture[0, 0].Width) / 2;
            position.X += tankAreaRectangle.X;
            position.Y = (tankAreaRectangle.Height - texture[0, 0].Height) / 2;
            position.Y += tankAreaRectangle.Y;
        }
Example #14
0
    //블럭 배열 생성----------------------------------------------
    void CreateBlock()
    {
        shuffleB = new EventBlock[blockLine, blockLine];
        //초기 번호 배열
        targetArray = gameObject.AddComponent <NumArray>();
        targetArray.MakeLine(blockLine);
        for (int y = 0; y < blockLine; y++)
        {
            for (int x = 0; x < blockLine; x++)
            {
                int myNum = x + (blockLine * y) + 1;
                targetArray.MakeArray(x, y, myNum);
            }
        }
        numArray = gameObject.AddComponent <NumArray>();
        numArray.MakeLine(blockLine);

        //분할 이미지
        Texture2D[,] Image = SetImage.ImageBlock(myImage, blockLine);

        for (int y = 0; y < blockLine; y++)
        {
            for (int x = 0; x < blockLine; x++)
            {
                //Quad로 블럭 생성
                GameObject myBlock = GameObject.CreatePrimitive(PrimitiveType.Quad);
                myBlock.transform.localPosition = new Vector2(-0.5f * (blockLine - 1), -0.5f * (blockLine - 1) - 1) + new Vector2(x, y);

                //이벤트 설정
                eventBlock = myBlock.AddComponent <EventBlock>();
                //좌표, 이미지 설정
                eventBlock.Init(new Vector2(x, y), Image[x, y]);
                //셔플 배열에 블럭 넣기
                shuffleB[x, y] = eventBlock;

                //번호 배열 정보
                int myNum = x + (blockLine * y) + 1;
                //변화하는 번호 배열
                numArray.MakeArray(x, y, myNum);

                //초기 비어있는 블럭
                if (x == blockLine - 1 && y == 0)
                {
                    myBlock.SetActive(false);
                    emptyBlock = eventBlock;
                }

                //마우스 입력이 일어나면
                eventBlock.BlockPressed += MoveBlock;
            }
        }
    }
Example #15
0
        public void AddFilePos(int filePos)
        {
            if (this.filePos == null)
            {
                this.filePos        = new int[this.Tiles.Y, this.Tiles.X];
                this.textureMap     = new Texture2D[this.Tiles.Y, this.Tiles.X];
                this.textureUsedMap = new uint[this.Tiles.Y, this.Tiles.X];
            }
            var pos = this.ConvertFilePosNumToSlot(this.addedTiles);

            this.filePos[pos.Y, pos.X] = filePos;
            this.addedTiles++;
        }
        public SpriteSheet(Texture2D[] sprites)
        {
            //Same amount of columns as sprites, 1 row
            cols = sprites.Length;
            rows = 1;

            //Save the sprites
            this.sprites = new Texture2D[cols, rows];
            for (int i = 0; i < cols; i++)
            {
                this.sprites[i, 0] = sprites[i];
            }
        }
Example #17
0
        // public Board(SpriteBatch spritebatch, Texture2D tileTexture,Texture2D monsterBulletTexture, Texture2D tileTexture2, Texture2D tileTexture3, Texture2D tileTexture4, Texture2D tileTexture5, Texture2D tileTexture6, Texture2D tileTexture7, Texture2D chestTexture,Texture2D chestTexture2, Texture2D monsterTexture,Texture2D[,] MapTextures,Texture2D TraderTexture, Texture2D preacherTexture, Texture2D bossTexture, int columns, int rows, Player player, GameState gameState, List<Texture2D> itemTexture,SpriteFont debugFont,Texture2D lvluptexture)
        public Board(SpriteBatch spritebatch, Texture2D tileTexture, Texture2D monsterBulletTexture, Texture2D tileTexture2, Texture2D tileTexture3, Texture2D tileTexture4, Texture2D tileTexture5, Texture2D tileTexture6, Texture2D tileTexture7, Texture2D chestTexture, Texture2D chestTexture2, Texture2D monsterTexture, Texture2D[,] MapTextures, Texture2D TraderTexture, Texture2D preacherTexture, Texture2D bossTexture, int columns, int rows, Player player, GameState gameState, List <Texture2D> itemTexture, SpriteFont debugFont, Texture2D lvluptexture, Texture2D Tilebis, Texture2D tileroof, List <Texture2D> invTexture)
        {
            _monsterBulletTexture = monsterBulletTexture;
            totalSeconds          = 20;
            _tilebis     = Tilebis;
            LvlUpTexture = lvluptexture;
            Columns      = columns;
            Rows         = rows;
            TileTexture  = tileTexture;
            TileTexture2 = tileTexture2;
            TileTexture3 = tileTexture3;
            TileTexture4 = tileTexture4;
            TileTexture5 = tileTexture5;
            TileTexture6 = tileTexture6;
            TileTexture7 = tileTexture7;
            TileRoof     = tileroof;

            ChestTexture    = chestTexture;
            ChestTexture2   = chestTexture2;
            BossTexture     = bossTexture;
            MonsterTexture  = monsterTexture;
            PreacherTexture = preacherTexture;
            _traderTexture  = TraderTexture;
            _time           = 15;
            _chestState     = false;
            ItemTexture     = itemTexture;
            SpriteBatch     = spritebatch;
            Preacher        = new List <Preacher>();

            _debugFont         = debugFont;
            mapTextures        = MapTextures;
            _tileFloor         = new Tile[Columns, Rows];
            _tiles             = new Tile[Columns, Rows];
            _tile2             = new Tile[Columns, Rows];
            _tile3             = new Tile[Columns, Rows];
            _tile4             = new Tile[Columns, Rows];
            _tile5             = new Tile[Columns, Rows];
            _tile6             = new Tile[Columns, Rows];
            _tile7             = new Tile[Columns, Rows];
            Board.CurrentBoard = this;
            InvTexture         = invTexture;
            _boss = new Boss(BossTexture, _monsterBulletTexture, _bossPosition, SpriteBatch, false, itemTexture, _debugFont);

            Bullets    = new List <Bullet>();
            _player    = player;
            Inventory  = _player.Inventory;
            _gameState = gameState;
            Stage1();
            _monsterDead = 0;
            Shop         = Special == _roomNumber && SpecialType == 4;
        }
Example #18
0
        //
        public Person(string imgsrc) : base()
        {
            gameMain    = GameMain.getInstance();
            taskManager = TaskManager.getInstance();
            content     = gameMain.Content;

            characterTexture = content.Load <Texture2D>(imgsrc);
            int col = (int)characterTexture.Width / spriteWidth;
            int row = (int)characterTexture.Height / spriteHeight;

            textureStorage = new Texture2D[col, row];
            width          = spriteWidth;
            height         = spriteHeight;
        }
        private Texture2D ConcatTexture(Texture2D[,] textures, int ColumnCount, int RowCount)
        {
            Texture2D finalTexture = new Texture2D(ColumnCount * tileSize, RowCount * tileSize);

            for (int i = 0; i < RowCount; i++)
            {
                for (int j = 0; j < ColumnCount; j++)
                {
                    finalTexture.SetPixels(j * tileSize, (RowCount - i - 1) * tileSize, tileSize, tileSize, textures[i, j].GetPixels());
                }
            }

            return(finalTexture);
        }
Example #20
0
        /// <summary> Draws the corners of an element onto the RenderTarget. </summary>
        /// <param name="sprite"> The spritebatch to draw with. </param>
        /// <param name="components"> The texture components of the element. </param>
        /// <param name="bounds"> The bounds of the element. </param>
        /// <param name="borderColour"> The colour to tint the texture. </param>
        private void drawCorners(SpriteBatch sprite, Texture2D[,] components, Rectangle bounds, Color borderColour)
        {
            //Draw the top-left corner
            sprite.Draw(components[0, 0], Vector2.Zero, borderColour);

            //Draw the top-right corner
            sprite.Draw(components[2, 0], new Vector2(bounds.Width - components[2, 0].Width, 0), borderColour);

            //Draw the bottom-left corner
            sprite.Draw(components[0, 2], new Vector2(0, bounds.Height - components[0, 2].Height), borderColour);

            //Draw the bottom-right corner
            sprite.Draw(components[2, 2], new Vector2(bounds.Width - components[2, 2].Width, bounds.Height - components[2, 2].Height), borderColour);
        }
Example #21
0
    void CreatePuzzle()
    {
        blocks = new Block[blocksPerLine, blocksPerColumn];   // creation blocklist
        Texture2D[,] imageSlices = ImageSlicer.GetSlices(brailleWord, blocksPerLine);
        for (int y = 0; y < blocksPerColumn; y++)
        {
            for (int x = 0; x < blocksPerLine; x++)
            {
                GameObject blockObject = GameObject.CreatePrimitive(PrimitiveType.Quad);                                                                                                            // create block = Quad
                blockObject.transform.position = new Vector2(-Vector2.one.x * (blocksPerLine - 1) * .5f + new Vector2(x, y).x, -Vector2.one.y * (blocksPerColumn - 1) * .5f + new Vector2(x, y).y); // symetrical to camera
                blockObject.transform.parent   = transform;

                Block block = blockObject.AddComponent <Block>();
                block.OnBlockPressed   += PlayerMoveBlockInput;
                block.OnFinishedMoving += OnBlockFinishedMoving;
                block.Init(new Vector2Int(x, y), imageSlices[x, y]);
                blocks[x, y] = block;

                blockObject.tag = letterAndPos(x, y); // apply a tag for each kind of letter and if it's top or bottom part

                if (y == blocksPerColumn - 1 && x == blocksPerLine - 1)
                {
                    blockObject.SetActive(false); // disable block bottom right
                    emptyBlock = block;
                }
            }
        }

        for (int i = 0; i < nombrePermutation; i++)   //shuffling
        {
            int a = Random.Range(0, blocksPerLine);   // y
            int b = Random.Range(0, blocksPerColumn); // x

            int c = Random.Range(0, blocksPerLine);
            int d = Random.Range(0, blocksPerColumn);

            Vector2Int targetCoord = blocks[a, b].coord;
            blocks[a, b].coord = blocks[c, d].coord;
            blocks[c, d].coord = targetCoord;

            Vector2 targetPosition = blocks[a, b].transform.position;
            blocks[a, b].transform.position = blocks[c, d].transform.position;
            blocks[c, d].transform.position = targetPosition;
        }


        Camera.main.orthographicSize = Mathf.Max(blocksPerLine, blocksPerColumn) * .55f; // adapt camera to game
        inputs = new Queue <Block>();
        state  = PuzzleState.InPlay;
    }
Example #22
0
    public void RotateRight() //zet de array op zijn kant
    {
        int x = array.GetLength(1);

        Texture2D[,] tempArray = new Texture2D[x, x];
        for (int i = 0; i < x; i++)
        {
            for (int j = 0; j < x; j++)
            {
                tempArray[i, j] = array[x - j - 1, i];
            }
        }
        array = tempArray;
    }
Example #23
0
        /// <summary> Creates a texture for the given element. </summary>
        /// <param name="elementStyle"> The style of the element. </param>
        /// <param name="bounds"> The bounds of the element. </param>
        /// <returns> The element texture. </returns>
        public Texture2D CreateElementTexture(ElementStyle elementStyle, Rectangle bounds)
        {
            //The graphics device to load the textures onto
            GraphicsDevice graphicsDevice = textures.First().Value.GraphicsDevice;

            //A 3x3 array of the corners, edges, and fill of the texture. Imagine the texture being split into 3s based on the edges and corners
            //Calculates the borders and fills in the edges of the array with the relevant textures
            Texture2D[,] textureComponents = calculateBorder(elementStyle, graphicsDevice);

            //Sets the centre of the texture to the background texture
            textureComponents[1, 1] = calculateBackground(elementStyle, graphicsDevice);

            //Create the full texture from the components and return it
            return(constructElementTexture(elementStyle, graphicsDevice, textureComponents, bounds));
        }
Example #24
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            map             = new Texture2D[3, 3];
            dunOne          = new Texture2D[3, 3];
            mobs            = new List <Mob>();
            activeMobs      = new List <Mob>();
            buildings       = new List <Building>();
            activeBuildings = new List <Building>();
            areaLoad        = false;

            screenIntX = 1;
            screenIntY = 1;
            base.Initialize();
        }
 public void LoadData(int[,] nD, Texture2D[,] tD)
 {
     tiles = new GameObject[15*15];
     tile_num_dict = nD;
     tile_tex_dict = tD;
     tile_tex_table = new Hashtable();
     map_text = "";
     map_file = "Maps/test";
     selectormap_file = "Maps/selectormap";
     map_data = new TextAsset();
     file_sep = ',';
     for (int i = 0; i < tile_num_dict.GetLength(0); i++)
         for (int j = 0; j < tile_num_dict.GetLength(1); j++)
             tile_tex_table.Add(tile_num_dict[i,j],tile_tex_dict[i,j]);
 }
Example #26
0
    /// <summary>
    ///
    /// </summary>
    public void LoadTileTextures()
    {
        this.textureArray = new Texture2D[5, 5];
        int xIndex = (int)centerTileNumbers.x - 2;
        int yIndex = (int)centerTileNumbers.y - 2;

        for (int x = 0; x < 5; x++)
        {
            for (int y = 0; y < 5; y++)
            {
                this.textureArray[y, x] = GetTileTexture(xIndex + x, yIndex + y, this.zoomLevel);
            }
        }

        changed = false;
    }
Example #27
0
        public static Texture2D GetTextureRectangleFromTable(Texture2D[,] Textures, int x1, int y1, int x2, int y2)
        {
            int       width  = (x2 - x1 + 1) * 32;
            int       height = (y2 - y1 + 1) * 32;
            Texture2D result = new Texture2D(ContentManager.game.GraphicsDevice, (int)width, (int)height);

            for (int i = x1; i <= x2; i++)
            {
                for (int j = y1; j <= y2; j++)
                {
                    result.SetTexture(Textures[i, j], new Rectangle((i - x1) * 32, (j - y1) * 32, 32, 32));
                }
            }

            return(result);
        }
Example #28
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);

            Content.RootDirectory = "Content";


            #region Map Size
            graphics.PreferredBackBufferWidth  = GAME_BOARD_WIDTH * TILE_SIZE;  // set this value to the desired width of your window
            graphics.PreferredBackBufferHeight = GAME_BOARD_LENGTH * TILE_SIZE; // set this value to the desired height of your window
            graphics.ApplyChanges();
            groundTexture         = new Texture2D[GAME_BOARD_WIDTH, GAME_BOARD_LENGTH];
            groundTextureType     = new int[GAME_BOARD_WIDTH, GAME_BOARD_LENGTH];
            groundTextureCollider = new Rectangle[GAME_BOARD_WIDTH, GAME_BOARD_LENGTH];
            #endregion
        }
Example #29
0
        internal void SetPixelIgnoringStacks(ref PassData passData, ref Texture2D[,] tileTexs)
        {
            Texture2D tex = tileTexs[passData.col, passData.row];             //CPU

            int tx = passData.x % passData.width;
            int ty = passData.y % passData.height;

            Color cs = tex.GetPixel(tx, ty);             //CPU

            if (cs == passData.color)
            {
                return;
            }

            tex.SetPixel(tx, ty, passData.color);      //这是调用了mono里边的更改纹理API     //CPU
        }
Example #30
0
        public override void LoadTexture()
        {
            // split texture into 3x4 sprites
            _sprites = new Texture2D[SPRITES_X, SPRITES_Y];
            var texture    = Controller.Content.LoadDirect <Texture2D>("Textures/World/Characters/" + _data.textureFile + ".png");
            var spriteSize = new Point(texture.Width / SPRITES_X, texture.Height / SPRITES_Y);

            for (var y = 0; y < SPRITES_Y; y++)
            {
                for (var x = 0; x < SPRITES_X; x++)
                {
                    var sprite = texture.Slice(new Rectangle(x * spriteSize.X, y * spriteSize.Y, spriteSize.X, spriteSize.Y));
                    _sprites[x, y] = sprite;
                }
            }
        }
Example #31
0
    void Start()
    {
        m_texPlayers    = new Texture2D[4, 4];
        m_iCurAnimation = 0;
        m_sFps          = m_fFps.ToString();
        //加载图片资源
        LoadTexture();

        for (int i = 0; i < m_iMinPicColumnCount; ++i)
        {
            for (int j = 0; j < m_iMinPicRowCount; ++j)
            {
                DePackTexture(i, j);
            }
        }
    }
Example #32
0
    void Start()
    {
        anim            = Resources.LoadAll("frameimg");
        m_texPlayers    = new Texture2D[4, 5];
        m_iCurAnimation = 0;
        m_sFps          = m_fFps.ToString();
        //加载图片资源
        LoadTexture();

        for (int i = 0; i < m_iMinPicColumnCount; ++i)
        {
            for (int j = 0; j < m_iMinPicRowCount; ++j)
            {
                DePackTexture(i, j);
            }
        }
    }
        public MapManager(GameManager _gameManager, List <Texture2D> _mapTextures)
        {
            map     = _mapTextures[0];
            terrain = _mapTextures[1];
            path    = _mapTextures[2];

            trackRects      = new List <Rectangle>();
            towerRects      = new List <Rectangle>();
            builtTowerRects = new List <Rectangle>();
            tileRects       = new Rectangle[map.Width, map.Height];
            tileTex         = new Texture2D[map.Width, map.Height];
            colours2D       = new Color[map.Width, map.Height];

            openNodes   = new List <Vector2>();
            trackList   = new List <Vector2>();
            gameManager = _gameManager;
        }
Example #34
0
        /// <summary>
        /// Cette fonction s'assure que les textures contenues dans le tableau de
        /// textures fourni en argument (paramètre tex) aient toutes les mêmes
        /// dimensions. Si ce n'est pas le cas, une exception est lancée.
        /// </summary>
        /// <param name="tex">Tableau des textures à valider.</param>
        private static void ValiderDimensionsDeTextures(Texture2D[,] tex)
        {
            // On s'assure que toutes les images ont les mêmes dimensions.
            int largeur = tex[0, 0].Width;
            int hauteur = tex[0, 0].Height;

            for (int row = 0; row < tex.GetLength(0); row++)
            {
                for (int col = 0; col < tex.GetLength(1); col++)
                {
                    if (tex[row, col].Width != largeur || tex[row, col].Height != hauteur)
                    {
                        throw new System.Exception("les images doivent être de dimensions uniformes");
                    }
                }
            }
        }
 void unloadPictureIcons()
 {
     Texture2D[,] texs = PropertiesSingleton.instance.albumsIcons;
     for (int i = 0; i < texs.GetLength(0); i++)
     {
         if (texs[i, 0] != null)
         {
             int j = 0;
             while (texs[i, j] != null && j < texs.GetLength(1))
             {
                 Resources.UnloadAsset(texs[i, j]);
                 texs[i, j] = null;
                 j++;
             }
         }
     }
 }
Example #36
0
        }                                  // Empty constructor to avoid crashes

        // Constructor which loads image and works out the new gamewidth & gameheight. Also set the size of the main background rectangle and the size of the part2draw rectangle
        public scrollingbackground2(ContentManager content, string spritename, float sizeratio, int colnum, int rownum)
        {
            columns   = colnum;
            rows      = rownum;
            image     = new Texture2D[colnum, rownum];
            imagemain = content.Load <Texture2D>(spritename);
            for (int x = 0; x < colnum; x++)
            {
                for (int y = 0; y < rownum; y++)
                {
                    image[x, y] = content.Load <Texture2D>(spritename);
                }
            }
            scale      = sizeratio;
            gamewidth  = (int)(image[0, 0].Width * columns * scale);
            gameheight = (int)(image[0, 0].Height * rows * scale);
        }
Example #37
0
    public void Slice()
    {
        _horizontalSlices = _fromGUIHorizontalSlices;
        _verticalSlices   = _fromGUIHorizontalSlices;

        _slicedHeightMap = new Texture2D[_horizontalSlices, _verticalSlices];

        int heightmapWidth  = _terrainData.heightmapWidth;
        int heightmapHeight = _terrainData.heightmapHeight;

        horizontalSize = heightmapWidth / _horizontalSlices;
        verticallSize  = heightmapHeight / _verticalSlices;


        for (int i = 0; i < _horizontalSlices; i++)
        {
            for (int j = 0; j < _verticalSlices; j++)
            {
                _slicedHeightMap[i, j] = new Texture2D(horizontalSize, verticallSize);
            }
        }

        int sliceHorizontal = 0;
        int sliceVertical   = 0;

        for (int i = _horizontalSlices - 1; i >= 0; i--)
        {
            for (int j = 0; j < _verticalSlices; j++)
            {
                Color[] color = _heightMap.GetPixels(sliceHorizontal, sliceVertical, horizontalSize, verticallSize);
                _slicedHeightMap[i, j].SetPixels(0, 0, horizontalSize, verticallSize, color);

                sliceHorizontal += horizontalSize;
            }
            sliceVertical  += verticallSize;
            sliceHorizontal = 0;
        }

        for (int i = 0; i < _horizontalSlices; i++)
        {
            for (int j = 0; j < _verticalSlices; j++)
            {
                _slicedHeightMap[i, j].Apply();
            }
        }
    }
Example #38
0
    public void Reset() //zet alle waardes weer op 0 en maakt een nieuw grid en vorm aan
    {
        gameState  = GameState.Playing;
        levelTime  = 0;
        score      = 90;
        level      = 0;
        speed      = 1;
        totalscore = 0;
        grid       = new TetrisGrid();
        NewShape();
        currentShape         = nextShape;
        currentShape.gridpos = new Point(4, 0);
        NewShape();
        int arraySize = currentShape.array.Length;

        Texture2D[,] array = currentShape.array;
    }
Example #39
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);

            // TODO: use this.Content to load your game content here
            map[0, 0] = Content.Load <Texture2D>("MapTopLeftPNG");
            map[0, 1] = Content.Load <Texture2D>("MapTopPNG");
            map[0, 2] = Content.Load <Texture2D>("MapTopRightPNG");
            map[1, 0] = Content.Load <Texture2D>("MapLeftPNG");
            map[1, 1] = Content.Load <Texture2D>("MapCentrePNG");
            map[1, 2] = Content.Load <Texture2D>("MapRightPNG");
            map[2, 0] = Content.Load <Texture2D>("MapBottomLeftPNG");
            map[2, 1] = Content.Load <Texture2D>("MapBottomPNG");
            map[2, 2] = Content.Load <Texture2D>("MapBottomRightPNG");


            area = map;

            dunOne[0, 0] = Content.Load <Texture2D>("MapTopLeftPNG");
            dunOne[0, 1] = Content.Load <Texture2D>("MapTopPNG");
            dunOne[0, 2] = Content.Load <Texture2D>("MapTopRightPNG");
            dunOne[1, 0] = Content.Load <Texture2D>("MapLeftPNG");
            dunOne[1, 1] = Content.Load <Texture2D>("MapCentrePNG");
            dunOne[1, 2] = Content.Load <Texture2D>("MapRightPNG");
            dunOne[2, 0] = Content.Load <Texture2D>("MapBottomLeftPNG");
            dunOne[2, 1] = Content.Load <Texture2D>("Room1");
            dunOne[2, 2] = Content.Load <Texture2D>("MapBottomRightPNG");

            playerOne = new Hero(Content.Load <Texture2D>("white"), new Rectangle(400, 250, 32, 32), Content.Load <Texture2D>("Sword"), Content.Load <Texture2D>("walkForwards"), Content.Load <Texture2D>("walkBack"));

            white = Content.Load <Texture2D>("white");

            mobs.Add(new Mob(white, new Rectangle(400, 250, 20, 20), 0, Color.Red, map));
            mobs.Add(new Mob(white, new Rectangle(350, 200, 20, 20), 0, Color.Blue, map));
            mobs.Add(new Mob(white, new Rectangle(400, 250, 20, 20), 1, Color.Red, map));
            mobs.Add(new Mob(white, new Rectangle(400, 250, 20, 20), 3, Color.Red, map));
            mobs.Add(new Mob(white, new Rectangle(400, 250, 20, 20), 6, Color.Blue, map));
            mobs.Add(new Mob(white, new Rectangle(400, 250, 20, 20), 5, Color.Red, map));
            mobs.Add(new Mob(white, new Rectangle(400, 250, 20, 20), 8, Color.Red, map));
            mobs.Add(new Mob(white, new Rectangle(400, 250, 20, 20), 2, Color.Blue, map));
            mobs.Add(new Mob(white, new Rectangle(350, 200, 20, 20), 2, Color.Red, map));


            buildings.Add(new Building(white, new Rectangle(0, 0, 300, 200), 0, map));
        }
Example #40
0
        public MapEditorPage()
        {
            for (int i = 0; i < 3; i++)
            {
                layers[i] = new EditorLayer();
            }
            ActiveLayer = layers[0];
            #region Buttons

            for (int i = 0; i < 3; i++)
            {
                buttons.Add(new SmallButton("Layer " + (i + 1)));
                buttons[i].Position = new Vector2(95 * i, 10);
            }
            buttons[0].selected  = true;
            TileSelector         = new TileSelection();
            colorButton          = new SmallButton("Color");
            colorButton.Position = new Vector2(Game1.WindowWidth / 2 - colorButton.Width / 2, Game1.WindowHeight - colorButton.Height - 10);
            buttons.Add(colorButton);

            tileSetBounds = new Rectangle(0, 0, 32 * EditorLayer.numberOfTiles, 32 * EditorLayer.numberOfTiles);
            #endregion

            #region Graphics

            tileset = new System.Drawing.Bitmap(path + "Content/terrain.png");
            Texture2D gridtexture = Game1.Content.Load <Texture2D>(path + "Content/grid");
            cameraspeed = 10;

            // Initialisation de la grille de base
            grid = new Texture2D[HauteurEnTiles, LargeurEnTiles];
            for (int i = 0; i < HauteurEnTiles; i++)
            {
                for (int j = 0; j < LargeurEnTiles; j++)
                {
                    grid[j, i] = gridtexture;
                }
            }

            InitializeTiles();
            tiles_by_closest_color_list = new Dictionary <System.Drawing.Color, List <int> >();
            InitializeMostClosestColorsList();

            #endregion
        }
Example #41
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);

            // Assign contentManager
            contentManager = Content;

            // Load content
            blankTexture = Content.Load <Texture2D>("textures/blank");
            wallTextures = Content.Load <Texture2D>("textures/" + texturePackage + "/walls-common").SplitTileset(new Point(16, 16));
            wallpapers   = Content.Load <Texture2D>("textures/" + texturePackage + "/wallpapers").SplitTileset(new Point(16, 16));
            doorTextures = Content.Load <Texture2D>("textures/" + texturePackage + "/doors").SplitTileset(new Point(16, 16));
            charTexture  = Content.Load <Texture2D>("textures/" + texturePackage + "/char");
            floors       = Content.Load <Texture2D>("textures/" + texturePackage + "/floors").SplitTileset(new Point(16, 16));
            string docPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Content\rooms.xml");

            roomsDocument.Load(docPath);
            docPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Content\furniture.xml");
            furnitureDocument.Load(docPath);
            font = Content.Load <SpriteFont>("font");
            LoadFurnitureTextures();

            // Initialize map
            Map currentMap = new Map(roomsDocument, furnitureDocument);
            int bestScore  = 0;

            Console.WriteLine("Generating houses.");
            for (int h = 0; h < 25; h++)
            {
                Console.WriteLine(h / 25f * 100 + "%; h = " + h);
                currentMap.GenerateHouse(15, out int currentBranches, out int currentRooms);
                if (currentBranches + currentRooms > bestScore)
                {
                    mainMap   = currentMap; // Asign the generated map to the main variable
                    bestScore = currentRooms * currentBranches;
                }
            }

            Console.WriteLine("Placing doors.");
            mainMap.PlaceDoorsBetweenAllRooms();

            Console.WriteLine("Placing furniture.");
            mainMap.GenerateFurniture();
        }
Example #42
0
    void CreatePuzzle()
    {
        id     = (blocksPerLine * blocksPerLine) - (blocksPerLine - 1);
        blocks = new Block[blocksPerLine, blocksPerLine];
        Texture2D[,] imageSlices = ImageSlicer.GetSlices(image, blocksPerLine);
        solver.initialPos        = new Vector2Int[(blocksPerLine * blocksPerLine)];
        solver.currentPos        = new Vector2Int[(blocksPerLine * blocksPerLine)];
        solver.idOrder           = new int[(blocksPerLine * blocksPerLine)];
        solver.correctidOrder    = new int[(blocksPerLine * blocksPerLine)];

        for (int y = 0; y < blocksPerLine; y++)
        {
            for (int x = 0; x < blocksPerLine; x++)
            {
                blockObject = GameObject.CreatePrimitive(PrimitiveType.Quad);
                blockObject.transform.position = -Vector2.one * (blocksPerLine - 1) * .5f + new Vector2(x, y);
                blockObject.transform.parent   = transform;

                block = blockObject.AddComponent <Block>();
                block.OnBlockPressed   += PlayerMoveBlockInput;
                block.OnFinishedMoving += OnBlockFinishedMoving;
                block.Init(new Vector2Int(x, y), imageSlices[x, y]);
                block.id     = id;
                blocks[x, y] = block;
                if (isDivisible(id, blocksPerLine))
                {
                    id = id - (blocksPerLine * 2);
                }
                id++;

                if (y == 0 && x == blocksPerLine - 1)
                {
                    emptyBlock = block;
                    block.id   = 0;
                }
                solver.initialPos[block.id]     = block.coord;
                solver.currentPos[block.id]     = block.coord;
                solver.idOrder[block.id]        = block.id;
                solver.correctidOrder[block.id] = block.id;
            }
        }

        Camera.main.orthographicSize = blocksPerLine * .55f;
        inputs = new Queue <Block>();
    }
 public void CreateChunck(Mesh[,] meshs, Texture2D[,] texrures)
 {
     for (int y = 0; y < gfxsMap.GetLength(0); y++)
     {
         for (int x = 0; x < gfxsMap.GetLength(0); x++)
         {
             gfxsMap[x, y] = Instantiate(gfxMapPrefab, Vector3.zero, Quaternion.identity, GameObject.Find("Chunks").transform);
             gfxsMap[x, y].GetComponent <MeshFilter>().mesh         = meshs[x, y];
             gfxsMap[x, y].GetComponent <MeshCollider>().sharedMesh = meshs[x, y];
             gfxsMap[x, y].GetComponent <Renderer>().sharedMaterial = new Material(Shader.Find("Standard"))
             {
                 mainTexture = texrures[x, y]
             };
             map.chunkNeedMeshUpdate[x, y]    = false;
             map.chunkNeedTextureUpdate[x, y] = false;
         }
     }
 }
Example #44
0
    private void OnEnable()
    {
      currentPalletes = new SpriteColorRampPalettes[3];

      valuePalletes = System.Enum.GetValues(typeof(SpriteColorRampPalettes));
      currentPalletes[0] = (SpriteColorRampPalettes)Random.Range(0, valuePalletes.Length);
      currentPalletes[1] = (SpriteColorRampPalettes)Random.Range(0, valuePalletes.Length);
      currentPalletes[2] = (SpriteColorRampPalettes)Random.Range(0, valuePalletes.Length);

      spriteColorMaskFX = gameObject.GetComponent<SpriteColorRampMask>();

      textureRamp = Resources.Load<Texture2D>("Textures/SpriteColorRamps");

      texturePalletes = new Texture2D[3, 5];
      for (int i = 0; i < 5; ++i)
        for (int j = 0; j < 3; ++j)
          texturePalletes[j, i] = MakeTexture(14, 14, textureRamp.GetPixel((textureRamp.width / 5) * (i + 1), (int)currentPalletes[j]));
    }
Example #45
0
        public static void Initialize()
        {
            //Инициализация массива текстур
            BuildingsTexture = new Texture2D[Constants.QUANTITY_BUILDINGS][];

            BuildingsTexture[(int)BuildingType.Church] = new Texture2D[9];
            BuildingsTexture[(int)BuildingType.DrawWell] = new Texture2D[1];
            BuildingsTexture[(int)BuildingType.Fair] = new Texture2D[1];
            BuildingsTexture[(int)BuildingType.Government] = new Texture2D[3];
            BuildingsTexture[(int)BuildingType.Hotel] = new Texture2D[1];
            BuildingsTexture[(int)BuildingType.House] = new Texture2D[4];
            BuildingsTexture[(int)BuildingType.Shop] = new Texture2D[1];
            BuildingsTexture[(int)BuildingType.SmallTotem] = new Texture2D[4];
            BuildingsTexture[(int)BuildingType.Totem] = new Texture2D[4];
            BuildingsTexture[(int)BuildingType.WorkShop] = new Texture2D[4];

            ClaimTexture = new Texture2D[4, 5];
        }
 void CutAssets()
 {
     frames = new Texture2D[(cols-1),(rows-1)];
     for(int i = 0; i < rows - 1; i++) {
         for(int j = 0; j < cols - 1; j++) {
             Texture2D newFrame = new Texture2D(cellwidth, cellheight);
             for(int x = 0; x < cellwidth; x++) {
                 for(int y = 0; y < cellheight; y++) {
                     newFrame.SetPixel(x, cellheight - y, spriteSheet.GetPixel(x + (i*cellwidth) + xoffset, (spriteSheet.height - yoffset - (y + (j*cellheight)))));
                 }
             }
             newFrame.Apply();
             frames[j,i] = newFrame;
         }
     }
     gridOverlay = null;
     spriteSheet = null;
 }
Example #47
0
        public Level(ContentManager Content)
        {
            currentLevel = 0;
            levelLoaded = false;

            levelRec = new List<Rectangle>();
            eventRec = new List<Rectangle>();
            damageRec = new List<Rectangle>();
            objectRec = new List<Rectangle>();

            int maxAantalLagen = 0;
            int maxAantalVlakken = 0;

            aantalLevels = Directory.GetDirectories(@"Content/Levels/").Length;
            aantalLagen = new int[aantalLevels];

            for (int i = 0; i < aantalLevels; i++)
            {
                aantalLagen[i] = Directory.GetDirectories(@"Content/Levels/Level" + Convert.ToString(i)).Length;
                if (maxAantalLagen < aantalLagen[i])
                {
                    maxAantalLagen = aantalLagen[i];
                }
            }
            aantalVlakken = new int[aantalLevels, maxAantalLagen];

            for (int i = 0; i < aantalLevels; i++)
            {
                for (int y = 0; y < aantalLagen[i]; y++)
                {
                    aantalVlakken[i, y] = Directory.GetFiles(@"Content/Levels/Level" + Convert.ToString(i) + "/" + "Laag" + Convert.ToString(y)).Length;
                    if (maxAantalVlakken < aantalVlakken[i, y])
                    {
                        maxAantalVlakken = aantalVlakken[i, y];
                    }
                }
            }

            objecten = new Texture2D[Directory.GetFiles(@"Content/Objecten").Length];
            levelSegment = new Texture2D[maxAantalLagen, maxAantalVlakken];
            levelSegmentPos = new Vector2[maxAantalLagen, maxAantalVlakken];
            levelSegmentSpeed = new int[maxAantalLagen];
            LoadLevel(Content);
        }
Example #48
0
 /// <summary>
 /// Constructs a background based off the current level and stage.
 /// </summary>
 public Background(ContentManager content, int levelIndex, int stageIndex)
 {
     List<string> lines = new List<string>();
     using (StreamReader reader = new StreamReader(string.Format("Content/Levels/Level{0}/Stage{1}/background.txt", levelIndex, stageIndex)))
     {
         string line = reader.ReadLine();
         width = line.Length;
         while (line != null)
         {
             lines.Add(line);
             if (line.Length != width)
                 throw new Exception(String.Format("The length of line {0} is different from all preceeding lines.", lines.Count));
             line = reader.ReadLine();
         }
         height = lines.Count;
     }
     background = new Texture2D[width, height];
     for (int y = 0; y < height; ++y)
         for (int x = 0; x < width; ++x)
             background[x, y] = content.Load<Texture2D>(String.Format("Backgrounds/Levels/Level{0}/{1}", levelIndex, lines[y][x]));
 }
Example #49
0
        public TerrainTexture(
            Texture2D alphaMap, 
            string[,,] detailTextureNames, 
            Vector2[, ,] detailTextureUVOffset, 
            Vector2[, ,] detailTextureUVScale, 
            int numChunksHorizontal, 
            int numChunksVertical, 
            GraphicsDevice device)
        {
            mDevice = device;

            mHeight = alphaMap.Height;
            mWidth = alphaMap.Width;

            mNumChunksVertical = numChunksVertical;
            mNumChunksHorizontal = numChunksHorizontal;

            mChunkHeight = mHeight / mNumChunksVertical;
            mChunkWidth = mWidth / mNumChunksHorizontal;

            InitializeTexels(alphaMap);

            mTextureBuffers = new Texture2D[mNumChunksVertical, mNumChunksHorizontal];

            mDetailTextureNames    = detailTextureNames;
            mDetailTextureUVOffset = detailTextureUVOffset;
            mDetailTextureUVScale  = detailTextureUVScale;

            mDirtyChunks = new bool[mNumChunksVertical, mNumChunksHorizontal];
            for (int row = 0; row < mNumChunksVertical; ++row)
            {
                for (int col = 0; col < mNumChunksHorizontal; ++col)
                {
                    mDirtyChunks[row, col] = true;
                }
            }

            UpdateTextureBuffers();
        }
Example #50
0
        /*
         * boardSize contains the x and y length and width of the whole gameboard.
         * boardSize.X = 25 and boardSize.Y = 25 would translate to a 25 X 25 board
         * windowSize contains the x and y length and width of the game's window's size.
         * windowSize.X = 900 and windowSize.Y = 600 would translate to a 900 X 600 window size in pixels
         */
        public GameBoard(Vector2 boardSize, Vector2 windowSize)
        {
            squareLength = (int)(windowSize.Y / boardSize.Y);
            squareWidth = (int)(windowSize.X / boardSize.X);

            gridLength = (int)boardSize.Y;
            gridWidth = (int)boardSize.X;

            grid = new Rectangle[(int)boardSize.X, (int)boardSize.Y];
            hasObject = new Boolean[(int)boardSize.X, (int)boardSize.Y];
            background = new Texture2D[(int)boardSize.X, (int)boardSize.Y];

            for (int i = 0; i < boardSize.X; i++)
            {
                for (int j = 0; j < boardSize.Y; j++)
                {
                    grid[i,j] = new Rectangle(i * squareWidth, j * squareLength, squareWidth, squareLength);
                    hasObject[i,j] = false;
                    background[i, j] = null;
                }
            }
        }
 public MenuOptions()
 {
     sheet = SheetHandler.getSheet("menu/options/main");
     MusicVolumeSheet = SheetHandler.getSheet("menu/options/opt_musicBar10-");
     MusicTitle = SheetHandler.getSheet("menu/options/opt_music+");
     MusicVolRect = new Rectangle(314, 260, 294, 44);
     EffectsVolumeSheet = SheetHandler.getSheet("menu/options/opt_soundfxBar10");
     EffectsTitle = SheetHandler.getSheet("menu/options/opt_soundfx+");
     EffectVolRect = new Rectangle(314, 409, 294, 44);
     FullscreenCheckbox = new Texture2D[,]{
         {SheetHandler.getSheet("menu/options/opt_fullCheck-"), SheetHandler.getSheet("menu/options/opt_fullCheck-+")},
         {SheetHandler.getSheet("menu/options/opt_fullCheck+-"), SheetHandler.getSheet("menu/options/opt_fullCheck++")}
     };
     FullScreenArea = new Rectangle(452,494,74,105);
     KeybindTexts = new Texture2D[,]{
         {SheetHandler.getSheet("menu/options/opt_left-"), SheetHandler.getSheet("menu/options/opt_left+")},
         {SheetHandler.getSheet("menu/options/opt_right-"), SheetHandler.getSheet("menu/options/opt_right+")},
         {SheetHandler.getSheet("menu/options/opt_jump-"), SheetHandler.getSheet("menu/options/opt_jump+")},
         {SheetHandler.getSheet("menu/options/opt_interact-"), SheetHandler.getSheet("menu/options/opt_interact+")},
         {SheetHandler.getSheet("menu/options/opt_melee-"), SheetHandler.getSheet("menu/options/opt_melee+")},
         {SheetHandler.getSheet("menu/options/opt_spell1-"), SheetHandler.getSheet("menu/options/opt_spell1+")},
         {SheetHandler.getSheet("menu/options/opt_spell2-"), SheetHandler.getSheet("menu/options/opt_spell2+")},
         {SheetHandler.getSheet("menu/options/opt_inventory-"), SheetHandler.getSheet("menu/options/opt_inventory+")}
     };
     KeybindAreas = new Rectangle[]{
         new Rectangle(733,173,82,25),
         new Rectangle(732,198,82,25),
         new Rectangle(733,223,82,23),
         new Rectangle(732,246,82,23),
         new Rectangle(733,269,82,24),
         new Rectangle(733,293,82,24),
         new Rectangle(733,319,82,26),
         new Rectangle(733,343,82,26)
     };
     font = SheetHandler.getSpriteFont();
     Mainmenu = SheetHandler.getSheet("menu/options/opt_main+");
     Mainrect = new Rectangle(806, 491, 140, 38);
     oldState = Keyboard.GetState();
 }
Example #52
0
        public Level(ContentManager Content, SpriteBatch Sprite)
        {
            content = Content;
            sprite = Sprite;
            currentLevel = 0;
            levelLoaded = false;

            int maxAantalLagen = 0;
            int maxAantalVlakken = 0;

            aantalLevels = Directory.GetDirectories(@"Content/Levels/").Length;
            aantalLagen = new int[aantalLevels];

            for (int i = 0; i < aantalLevels; i++)
            {
                aantalLagen[i] = Directory.GetDirectories(@"Content/Levels/Level" + Convert.ToString(i)).Length;
                if (maxAantalLagen < aantalLagen[i])
                {
                    maxAantalLagen = aantalLagen[i];
                }
            }
            aantalVlakken = new int[aantalLevels, maxAantalLagen];

            for (int i=  0; i < aantalLevels; i++)
            {
                for (int y = 0; y < aantalLagen[i]; y++)
                {
                    aantalVlakken[i,y] = Directory.GetFiles(@"Content/Levels/Level" + Convert.ToString(i) + "/" + "Laag" + Convert.ToString(y)).Length;
                    if (maxAantalVlakken < aantalVlakken[i,y])
                    {
                        maxAantalVlakken = aantalVlakken[i,y];
                    }
                }
            }
            levelSegment = new Texture2D[maxAantalLagen, maxAantalVlakken];
            levelSegmentPos = new Vector2[maxAantalLagen, maxAantalVlakken];
            levelSegmentSpeed = new int[maxAantalLagen];
        }
Example #53
0
        /// <summary>
        /// Charge les images d'affichage et de détection de collisions.
        /// </summary>
        /// <param name="content">Gestionnaire de contenu permettant de charger les images du vaisseau.</param>
        /// <param name="graphics">Gestionanire de périphérique d'affichage permettant d'extraire
        /// les caractéristiques de celui-ci (p.ex. l'écran).</param>
        public static void LoadContent(ContentManager content, GraphicsDeviceManager graphics)
        {
            // Créer les deux tableaux de textures.
            textures = new Texture2D[2, 2];
            texturesCollisions = new Texture2D[2, 2];

            // Charger les textures d'affichage, rangée par rangée
            textures[0, 0] = content.Load<Texture2D>("Monde\\map_1_3\\map200");
            textures[0, 1] = content.Load<Texture2D>("Monde\\map_1_3\\map201");

            textures[1, 0] = content.Load<Texture2D>("Monde\\map_1_3\\map210");
            textures[1, 1] = content.Load<Texture2D>("Monde\\map_1_3\\map211");

            // Charger les textures de collisions, rangée par rangée
            texturesCollisions[0, 0] = content.Load<Texture2D>("Monde\\map_1_3\\Map2Collision00");
            texturesCollisions[0, 1] = content.Load<Texture2D>("Monde\\map_1_3\\Map2Collision01");

            texturesCollisions[1, 0] = content.Load<Texture2D>("Monde\\map_1_3\\Map2Collision10");
            texturesCollisions[1, 1] = content.Load<Texture2D>("Monde\\map_1_3\\Map2Collision11");
        }
Example #54
0
        /// <summary>
        /// Creates all the regions for the level editor for easy placement within the Title Safe area
        /// </summary>
        private void CreateRegions()
        {
            mScreenRect = mGraphics.GraphicsDevice.Viewport.TitleSafeArea;

            mPadding = new Vector2(mScreenRect.Width / 100, mScreenRect.Height / 100);

            mLevelPanel = mTitleBar = new Rectangle();

            //Title bar, bottom bar, and level panel is 2/3 the x size of the title safe area
            mTitleBar.Width = mLevelPanel.Width = mScreenRect.Width;

            //Set the bottom and title bar to 1/8 of the title safe y area.
            //Set the level selection area to be 3/4 of the title safe y area
            mLevelPanel.Height = mScreenRect.Height - (mTitleBar.Height = mScreenRect.Height / 8);

            //Sets the x and y location of all the regions
            mLevelPanel.X = mTitleBar.X = mScreenRect.Left;
            mTitleBar.Y = mScreenRect.Top;
            mLevelPanel.Y = mTitleBar.Y + mTitleBar.Height;

            mLevelRegions = new Rectangle[49];

            mSelected = new Texture2D[6, 4];
            mUnselected = new Texture2D[6];

            //Create 6 regions for image icons. The x direction is split into 3rds, which that region is 2/3rds of that area
            for (int i = 0; i < mLevelRegions.Length; i++)
            {
                int width = mLevelPanel.Width / 7;
                int height = mLevelPanel.Height / 4;
                int xpadding = (i % 6) * width / 6;
                int ypadding = ((i / 6) + 1) * height / 5;

                mLevelRegions[i] = new Rectangle(mLevelPanel.Left + width * (i % 6) + xpadding, mLevelPanel.Top + height * (i / 6) + ypadding, width, height);
            }
        }
Example #55
0
        public override void LoadContent()
        {
            font1 = Content.Load<SpriteFont>("Fontey");
            PlayerYou = Content.Load<Texture2D>("spikey2");
            PlayerThem = Content.Load<Texture2D>("spikey");
            mouse = Content.Load<Texture2D>("crosshair");
            shottex = Content.Load<Texture2D>("spike");
            shottex2 = Content.Load<Texture2D>("spike2");
            BG = Content.Load<Texture2D>("BG");

            playersShot = new Texture2D[2, 30];
            beenShot = new int[2, 30];
            shotx = new float[2, 30];
            shoty = new float[2, 30];
            bullsangle = new double[30];
            bullsrot = new float[2, 30];
            rot = new float[2];
            x = new int[2];
            y = new int[2];

            for (int k = 0; k < 2; k++)
            {
                x[k] = 100;
                y[k] = 100;
                rot[k] = 0;
                for (int j = 0; j < 30; j++)
                {
                    if (k == 0)
                    {
                        playersShot[k, j] = shottex;
                        beenShot[k, j] = 0;
                        shotx[k, j] = 0;
                        shoty[k, j] = 0;
                        bullsangle[j] = 0;
                        bullsrot[k, j] = 0;
                    }
                    else
                    {
                        playersShot[k, j] = shottex2;
                        beenShot[k, j] = 0;
                        shotx[k, j] = 0;
                        shoty[k, j] = 0;
                        bullsrot[k, j] = 0;
                    }
                }
            }
            Game1.DataStuff.childthread2 = new Thread(new ThreadStart(runthrough));
            i = 0;
        }
Example #56
0
	void GetPanoramaImage(string pano_id, int width, int height)
	{
		print ("Get Panorama Image - ID : " + pano_id + " width : " + width + " height : " + height);

		panoramaTexture = new Texture2D(width, height);

		string output = "tile";
		int x = 0;
		int y = 0;
		count = 0;

		rowTilesNum = height/tileHeight;
		if((height % tileHeight) > 0)
			rowTilesNum += 1;

		colTilesNum = width/tileWidth;
		if((width % tileHeight) > 0)
			colTilesNum += 1;

		totalTilesNum = rowTilesNum * colTilesNum;

		tiles = new Texture2D[rowTilesNum, colTilesNum];
		
		for (y = 0; y < rowTilesNum; y++)
		{
			for (x = 0; x < colTilesNum; x++)
			{
				StartCoroutine(GoogleStreetViewTiled(output, panoramaID, zoom, x, y));
			}
		}
	}
Example #57
0
    // Step 3
    IEnumerator GetPanoramaImage(string pano_id, int width, int height)
    {
        string output = "tile";

        if (panoramaTexture != null)
        {
            DestroyImmediate(panoramaTexture);
            panoramaTexture = null;
            
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }

        // 파노라마 이미지의 크기만큼 담을 수 있는 빈 텍스쳐 공간을 메모리에 할당한다.
        panoramaTexture = new Texture2D(width, height);
        downloadedTilesCount = 0;

        rowTilesNum = height / tileHeight;
        if ((height % tileHeight) > 0)
            rowTilesNum += 1;

        colTilesNum = width / tileWidth;
        if ((width % tileHeight) > 0)
            colTilesNum += 1;

        totalTilesNum = rowTilesNum * colTilesNum;

        tiles = new Texture2D[rowTilesNum, colTilesNum];

        for (int y = 0; y < rowTilesNum; y++)
        {
            for (int x = 0; x < colTilesNum; x++)
            {
                yield return StartCoroutine(GoogleStreetViewTiled(output, panoramaID, zoom, x, y));
            }
        }

        if (downloadedTilesCount == totalTilesNum)
            Debug.Log("All tiles downloaded!");
        else
            Debug.LogWarning("Tiles downloaed loss");
    }
 /// <summary>
 /// Инициализатор вместо конструктора
 /// </summary>
 /// <param name="halfFlightWidth">половина ширины полетного пространства</param>
 /// <param name="textures">Массив текстур для запускаемых префабов</param>
 public void Init(float halfFlightWidth, Texture2D[,] textures) {
     _halfFlightWidth = halfFlightWidth;
     _textures = textures;
 }
        public scrollingbackground2() { }  // Empty constructor to avoid crashes

        // Constructor which loads image and works out the new gamewidth & gameheight. Also set the size of the main background rectangle and the size of the part2draw rectangle
        public scrollingbackground2(ContentManager content, string spritename, float sizeratio, int colnum, int rownum)
        {
            columns = colnum;
            rows = rownum;
            image = new Texture2D[colnum, rownum];
            imagemain = content.Load<Texture2D>(spritename);
            for (int x = 0; x < colnum; x++)
                for (int y = 0; y < rownum; y++)
                {
                    image[x, y] = content.Load<Texture2D>(spritename);
                }
            scale = sizeratio;
            gamewidth = (int)(image[0, 0].Width * columns * scale);
            gameheight = (int)(image[0, 0].Height * rows * scale);
        }
Example #60
0
        public void InitIcons()
        {
            Random rand = m_Puzzle.m_Rand;
            int[] iScatterArray = new int[8];

            Puzzle.RandomDistribution(rand, iScatterArray);
            Texture2D[] aAllIcons = new Texture2D[64];
            for (int i = 0; i < 8; i++)
            {
                aAllIcons[i] = Assets.Cars[iScatterArray[i]];
                aAllIcons[8 + i] = Assets.Cats[iScatterArray[i]];
                aAllIcons[16 + i] = Assets.Flowers[iScatterArray[i]];
                aAllIcons[24 + i] = Assets.Hubble[iScatterArray[i]];
                aAllIcons[32 + i] = Assets.Princesses[iScatterArray[i]];
                aAllIcons[40 + i] = Assets.Puppies[iScatterArray[i]];
                aAllIcons[48 + i] = Assets.Simpsons[iScatterArray[i]];
                aAllIcons[56 + i] = Assets.Superheros[iScatterArray[i]];
            }

            Puzzle.RandomDistribution(rand, iScatterArray);
            m_aIcons = new Texture2D[8, 8];
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    m_aIcons[i, j] = aAllIcons[(iScatterArray[i] * 8) + j];
                }
            }
        }