Ejemplo n.º 1
0
 internal AStar2D()
 {
     UseHeuristic = true;
     fieldWidth = 0;
     fieldHeight = 0;
     field = null;
 }
	public void worldGenWorld() {


		// Generates the chunk map for the world

		wg = new World_ChunkGenerator (numChunks, terrainType, chunkSize);
		wg.generate ();

		chunkTerrain = wg.getChunkTerrain ();

	}
Ejemplo n.º 3
0
        internal void Destroy()
        {
            Array.Clear(SqState, 0, SqState.Length);
            Array.Clear(SqFloorHeight, 0, SqFloorHeight.Length);
            Array.Clear(SqSeatRot, 0, SqSeatRot.Length);

            staticModel = null;
            Heightmap = null;
            SqState = null;
            SqFloorHeight = null;
            SqSeatRot = null;
        }
Ejemplo n.º 4
0
        void OnInitComplete()
        {
            engine.CameraInput.Camera.FarZ = 10000;

            heightMap = ReadHgtFile();
            landscape.Scale = new SlimDX.Vector3(10, 1, 10);
            landscape.FrameVariance = initialFrameVariance;
            landscape.desiredTris = NumPatches*NumPatches*8;
            landscape.NUM_PATCHES_PER_SIDE = NumPatches;
            landscape.MAP_SIZE = MapSize;
            landscape.FetchFunction = MapFetchFunction;
            //landscape.VisibleFunction = IsTriVisible;
            landscape.SplitFunction = SplitByScreenArea;
            landscape.BindToPass(engine.D3DDevice, engine.Effect, "Terrain");
            engine.Geometry.Add(landscape);
        }
Ejemplo n.º 5
0
        public void TestStrm30()
        {
            w = 50;
            h = 20;
            latLongRegion = new RectangleF(lng - w * 0.5f, lat - h * 0.5f, w, h);
            long t0 = System.Environment.TickCount;
            long t1 = System.Environment.TickCount;
            TerrainHeightTextureFetcher fetcher = new Srtm30TextureFetcher();
            latLongRegion = new RectangleF(lng - w * 0.5f, lat - h * 0.5f, w, h);
            terrain = fetcher.FetchTerrain(latLongRegion);

            t0 = t1; t1 = System.Environment.TickCount;
            Console.WriteLine("Load: " + ((t1 - t0) / 10));
            DisplayTerrain(terrain, "terrainFetch30.png");
            t0 = t1; t1 = System.Environment.TickCount;
            Console.WriteLine("Save and show: " + ((t1 - t0) / 10));
        }
Ejemplo n.º 6
0
        public void TestStrm3()
        {
            latLongRegion = new RectangleF(lng - w * 0.5f, lat - h * 0.5f, w, h);
            long t0 = System.Environment.TickCount;
            long t1 = System.Environment.TickCount;
            TerrainHeightTextureFetcher fetcher = new Srtm3TextureFetcher();

            terrain = fetcher.FetchTerrain(latLongRegion);

            t0 = t1; t1 = System.Environment.TickCount;
            Console.WriteLine("Load: "+((t1-t0)/10));
            Image img = ImagingFunctions.CreateImageFromArray(terrain, ImagingFunctions.HsvColourMap(256));
            t0 = t1; t1 = System.Environment.TickCount;
            Console.WriteLine("Copy Image: " + ((t1 - t0) / 10));
            ImagingFunctions.SaveAndDisplayImage(img, "terrainFetch.png");
            t0 = t1; t1 = System.Environment.TickCount;
            Console.WriteLine("Save and show: " + ((t1 - t0) / 10));
        }
Ejemplo n.º 7
0
    public void Render()
    {
        var landId = GameData.LevelMetaData[GameData.level].LandType;

        var sprites  = GameData.TileSprites[landId];
        var iconsMap = GameData.Icons;

        short[,] tiles = GameData.LevelData.GetTiles(ActiveLevel);

        var baseTileId = GameData.Tilesets[landId].base_tile_id - 1;

        Tile m_Tile = ScriptableObject.CreateInstance <Tile>();
        Tile s_Tile = ScriptableObject.CreateInstance <Tile>();

        groundTilemap.ClearAllTiles();
        specialTilemap.ClearAllTiles();

        int tileId;

        for (int y = 0; y < 90; y++)
        {
            for (int x = 0; x < 90; x++)
            {
                tileId = (tiles[y, x] % 1000) - 1;
                Vector3Int p = new Vector3Int(x, -y, 0);
                if (tileId > 200 || tileId < 0) // special tile
                {
                    var name = (tileId + 1).ToString("D5");
                    s_Tile.sprite = iconsMap[name];
                    specialTilemap.SetTile(p, s_Tile);

                    m_Tile.sprite = sprites[baseTileId];
                }
                else // normal tile
                {
                    m_Tile.sprite = sprites[tileId];
                }

                groundTilemap.SetTile(p, m_Tile);
            }
        }
    }
Ejemplo n.º 8
0
        public Wall(Board a_board, ref char[,] a_cBoard, ref Random a_generator, bool a_bIsVertical = true, short a_16SizeofWall = 4, float a_fProbalityOfMovement = 0.5f, float a_fProbalityOfChangingDirection = 0.01f)
        {
            m_board                         = a_board;
            m_16Direction                   = 1;
            m_bIsVertical                   = a_bIsVertical;
            m_cBoard                        = a_cBoard;
            m_16WallPosition                = new short[a_16SizeofWall, 2];
            m_fProbalityOfMovement          = a_fProbalityOfMovement;
            m_fProbalityOfChangingDirection = a_fProbalityOfChangingDirection;
            generator                       = a_generator;

            if (a_bIsVertical)
            {
                do
                {
                    m_16WallPosition[0, 0] = Convert.ToInt16(generator.Next(1, 18));
                    m_16WallPosition[0, 1] = Convert.ToInt16(generator.Next(1, 18));
                }while (a_cBoard[m_16WallPosition[0, 0], m_16WallPosition[0, 1]] != '0' && a_cBoard[m_16WallPosition[0, 0], m_16WallPosition[0, 1] + 1] != '0' && a_cBoard[m_16WallPosition[0, 0], m_16WallPosition[0, 1] + 2] != '0' && a_cBoard[m_16WallPosition[0, 0], m_16WallPosition[0, 1] + 3] != '0');
                a_cBoard[m_16WallPosition[0, 0], m_16WallPosition[0, 1]] = 'W';
                for (short i = 1; i < a_16SizeofWall; ++i)
                {
                    m_16WallPosition[i, 0] = m_16WallPosition[0, 0];
                    m_16WallPosition[i, 1] = Convert.ToInt16(m_16WallPosition[0, 1] + i);
                    a_cBoard[m_16WallPosition[i, 0], m_16WallPosition[i, 1]] = 'W';
                }
            }
            else
            {
                do
                {
                    m_16WallPosition[0, 0] = Convert.ToInt16(generator.Next(1, 18));
                    m_16WallPosition[0, 1] = Convert.ToInt16(generator.Next(1, 18));
                }while (a_cBoard[m_16WallPosition[0, 0], m_16WallPosition[0, 1]] != '0' && a_cBoard[m_16WallPosition[0, 0] + 1, m_16WallPosition[0, 1]] != '0' && a_cBoard[m_16WallPosition[0, 0] + 2, m_16WallPosition[0, 1]] != '0' && a_cBoard[m_16WallPosition[0, 0] + 3, m_16WallPosition[0, 1]] != '0');
                a_cBoard[m_16WallPosition[0, 0], m_16WallPosition[0, 1]] = 'W';
                for (short i = 1; i < a_16SizeofWall; ++i)
                {
                    m_16WallPosition[i, 0] = Convert.ToInt16(m_16WallPosition[0, 0] + i);
                    m_16WallPosition[i, 1] = m_16WallPosition[0, 1];
                    a_cBoard[m_16WallPosition[i, 0], m_16WallPosition[i, 1]] = 'W';
                }
            }
        }
Ejemplo n.º 9
0
    /// <summary>
    /// Spawns tiles to their positions
    /// </summary>
    /// <param name="leveldata"> This needs a leveldata map to read out of to get the data of the tiles </param>
    private void SpawnTiles(Map leveldata)
    {
        foreach (Layer _layer in leveldata.Layers)
        {
            if (leveldata.Layers == null || leveldata.Layers.Length == 0)
            {
                continue;
            }

            short[,] _tileNumbers = _layer.GetTileArray();

            for (int row = 0; row < _layer.Height; row++)
            {
                for (int col = 0; col < _layer.Width; col++)
                {
                    bool _isBackgroundTile = _layer.GetBoolProperty("Background");

                    int     _tileNumber = _tileNumbers[col, row];
                    TileSet _tiles      = leveldata.GetTileSet(_tileNumber);

                    string _filenameTiles = _tiles.Image.FileName;
                    _filenameTiles = _filenameTiles.Remove(0, 3);
                    if (_tileNumber > 0 && _isBackgroundTile == false)
                    {
                        CollisionTile _tile = new CollisionTile(_filenameTiles, _tiles.Columns, _tiles.Rows);
                        _tile.SetFrame(_tileNumber - _tiles.FirstGId);
                        _tile.x = col * _tile.width;
                        _tile.y = row * _tile.height;
                        AddChild(_tile);
                    }
                    else if (_tileNumber > 0 && _isBackgroundTile == true)
                    {
                        BackgroundTile _backgroundTile = new BackgroundTile(_filenameTiles, _tiles.Columns, _tiles.Rows);
                        _backgroundTile.SetFrame(_tileNumber - _tiles.FirstGId);
                        _backgroundTile.x = col * _backgroundTile.width;
                        _backgroundTile.y = row * _backgroundTile.height;
                        AddChild(_backgroundTile);
                    }
                }
            }
        }
    }
Ejemplo n.º 10
0
        internal unsafe float SlopesForHillshade(int x, int y, short[,] dem, int width, int height, float cellsize)
        {
            var xp = Math.Min(x + 1, width - 1);
            var xm = Math.Max(x - 1, 0);
            var yp = Math.Min(y + 1, height - 1);
            var ym = Math.Max(y - 1, 0);

            var max_slope = 0f;
            var ary       = stackalloc int[4];
            var center    = dem[y, x];

            ary[0] = dem[ym, x];
            ary[1] = dem[y, xm];
            ary[2] = dem[y, xp];
            ary[3] = dem[yp, x];
            var scale = 0.5f / cellsize;  //2f / cellsize;

            for (var i = 0; i < 4; i++)
            {
                var slope = Math.Abs(ary[i] - center) * scale;
                if (slope > max_slope)
                {
                    max_slope = slope;
                }
            }

            ary[0] = dem[ym, xm];
            ary[1] = dem[ym, xp];
            ary[2] = dem[yp, xm];
            ary[3] = dem[yp, xp];
            scale /= 1.414214f;
            for (var i = 0; i < 4; i++)
            {
                var slope = Math.Abs(ary[i] - center) * scale;
                if (slope > max_slope)
                {
                    max_slope = slope;
                }
            }

            return(max_slope);
        }
Ejemplo n.º 11
0
Archivo: Map.cs Proyecto: lizgw/Pacman
        public Map(Game1 aGame)
        {
            // setup map with default map to start with
            map         = initMap;
            game        = aGame;
            tempTexture = game.Content.Load <Texture2D>("white");
            pointCount  = 0;

            // figure out how many points are on the map
            for (int r = 0; r < map.GetLength(0); r++)
            {
                for (int c = 0; c < map.GetLength(1); c++)
                {
                    if (map[r, c] == POINT)
                    {
                        pointCount++;
                    }
                }
            }
        }
Ejemplo n.º 12
0
    static uint M4(C0 arg0, C1 arg1, ulong arg2, bool arg3, S0 arg4, char arg5, bool[] arg6, C1 arg7, C1 arg8, S0 arg9)
    {
        if (true)
        {
            S0 var0 = arg7.F4.F5;
            arg1.F3.F5.F4 = arg7.F4.F5.F4;
            s_1           = s_1;
            arg1.F1       = arg1.F9;
            arg7.F3.F5.F1 = var0.F1;
        }
        else
        {
            arg1.F2       = arg8.F2++;
            arg9          = arg0.F5;
            arg8.F3.F5    = new S0(38776295U, 205, 140, 65535, 0);
            arg1.F3.F5.F3 = 1;
        }

        return(3178297303U);
    }
Ejemplo n.º 13
0
            //todo fix
            public void Animate(List <Sprite> animation, int interval_animation, int interval_frames)
            {
                int old_GameTick = 0;
                int i            = 0;

                if (GameTick - old_GameTick == interval_animation)
                {
                    if (i == animation.Count)
                    {
                        i = 0;
                    }

                    sprite_chars      = animation[i].sprite_chars;
                    sprite_attributes = animation[i].sprite_attributes;
                    sprite_bytes      = CharSpriteToByteSprite(sprite_chars);
                    i++;

                    old_GameTick = GameTick;
                }
            }
Ejemplo n.º 14
0
 /// <summary>
 /// 旋转一个二维数组
 /// </summary>
 /// <param name="a">要旋转的数组</param>
 /// <param name="rotNum">顺时针旋转圈数</param>
 /// <returns>旋转后的数组</returns>
 public static short[,] SquareRot90(short[,] a, int rotNum)
 {
     while (rotNum < 0)
     {
         rotNum += 4;
     }
     for (int rot_i = 0; rot_i < rotNum; rot_i++)
     {
         short[,] b = new short[4, 4];
         for (int i = 0; i < a.GetLength(0); i++)
         {
             for (int j = 0; j < a.GetLength(1); j++)
             {
                 b[j, a.GetLength(0) - i - 1] = a[i, j];
             }
         }
         a = b;
     }
     return(a);
 }
Ejemplo n.º 15
0
        internal void SlopesForHillshade(int x, int y, short[,] dem, int width, int height, float cellsize, out float dzdx, out float dzdy)
        {
            var xp = Math.Min(x + 1, width - 1);
            var xm = Math.Max(x - 1, 0);
            var yp = Math.Min(y + 1, height - 1);
            var ym = Math.Max(y - 1, 0);

            var a = dem[ym, xm];
            var b = dem[ym, x];
            var c = dem[ym, xp];
            var d = dem[y, xm];
            var e = dem[y, x];
            var f = dem[y, xp];
            var g = dem[yp, xm];
            var h = dem[yp, x];
            var i = dem[yp, xp];

            dzdx = ((c + f + f + i) - (a + d + d + g)) / (8f * cellsize);
            dzdy = ((g + h + h + i) - (a + b + b + c)) / (8f * cellsize);
        }
Ejemplo n.º 16
0
    public override void SetElevationData(short[,] data)
    {
        elevationData       = data;
        elevationX1         = elevationRequestX1;
        elevationY1         = elevationRequestY1;
        elevationW          = elevationRequestW;
        elevationH          = elevationRequestH;
        elevationDataWidth  = data.GetLength(0);
        elevationDataHeight = data.GetLength(1);

        UpdateMinMax();

        waitSetElevationData = false;

        if (OnElevationUpdated != null)
        {
            OnElevationUpdated();
        }
        map.Redraw();
    }
Ejemplo n.º 17
0
        void RestoreBlock(short[,] block, int n)
        {
            int row = 8;

            for (int col = 1; col < 8; ++col)
            {
                block[n, col] += block[n, col - 1];
                block[n, row] += block[n, row - 8];
                row           += 8;
            }
            row = 8;
            for (int y = 1; y < 8; ++y)
            {
                for (int x = 1; x < 8; ++x)
                {
                    block[n, row + x] += block[n, row + x - 9];
                }
                row += 8;
            }
        }
Ejemplo n.º 18
0
    // Warning: the first cells element should be the center position
    private short[,] UpdateDangerMap(short[,] dangerMap, List <Vector2Int> cells, short dangerLevel, bool force = false)
    {
        short currentDangerLevel = dangerMap[cells[0].x, cells[0].y];

        if (!force && currentDangerLevel > dangerLevel)
        {
            dangerLevel = currentDangerLevel;
        }

        foreach (var cell in cells)
        {
            if (!force && dangerMap[cell.x, cell.y] >= dangerLevel)
            {
                continue;
            }

            if (cell != cells[0])
            {
                var foundBomb = _bombs.Find(b => Equals(CellPosition(b.transform.position), cell));

                if (foundBomb != null)
                {
                    var impactedCells = Bomb.FindImpactedCells(this, CellPosition(foundBomb.transform.position), foundBomb.Power);
                    UpdateDangerMap(dangerMap, impactedCells, dangerLevel);
                }
            }

            dangerMap[cell.x, cell.y] = dangerLevel;
        }

        if (force)
        {
            foreach (var bomb in _bombs)
            {
                var impactedCells = Bomb.FindImpactedCells(this, CellPosition(bomb.transform.position), bomb.Power);
                UpdateDangerMap(dangerMap, impactedCells, bomb.DangerLevel);
            }
        }

        return(dangerMap);
    }
Ejemplo n.º 19
0
        private void CreateMaskedVolumeView(short theIsoValueInHounsfield, byte[][,] mask, CTSliceInfo[] slices)
        {
            // shall be used only once, because original slice data will be altered
            // require data reloading
            for (int k = 0; k != slices.Length; ++k)
            {
                CTSliceInfo ct = slices[k];
                short[,] buffer = ct.HounsfieldPixelBuffer;
                byte[,] maska   = mask[k];

                for (int r = 0; r != ct.RowCount; ++r)
                {
                    for (int c = 0; c != ct.ColumnCount; ++c)
                    {
                        if (maska[r, c] > 0)
                        {
                            buffer[r, c] = theIsoValueInHounsfield;
                        }
                    }
                }
            }

            if (slices.Length > 2)
            {
                VolumeView aVolumeViewWindow = new VolumeView();

                Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;

                // Create the Volume for the specified IOD list / IsoValue.
                aVolumeViewWindow.CreateVolume(slices, theIsoValueInHounsfield);
                aVolumeViewWindow.Title = string.Format("DICOM Viewer - Volume View (IsoValue = {0} in Hounsfield Units)", theIsoValueInHounsfield.ToString());

                Mouse.OverrideCursor = null;

                aVolumeViewWindow.ShowDialog();
            }
            else
            {
                System.Windows.MessageBox.Show("The series does not have suffcient CT Slices in order to generate a Volume View!");
            }
        }
Ejemplo n.º 20
0
        public PCMFile(byte[] data)
        {
            if (!Encoding.ASCII.GetString(data, 0, 12).Equals("Puzzle V2.0 "))
            {
                throw new Exception("bad file");
            }
            Unk1 = BitConverter.ToInt16(data, 12);
            Unk2 = BitConverter.ToInt16(data, 14);
            Unk3 = BitConverter.ToInt16(data, 16);
            Unk4 = BitConverter.ToInt16(data, 18);
            int widthBytes = BitConverter.ToInt16(data, 20);
            int height     = BitConverter.ToInt16(data, 22);

            if (!Encoding.ASCII.GetString(data, 24, 4).Equals("MAP "))
            {
                throw new Exception("bad file");
            }

            Unk5 = BitConverter.ToInt16(data, 28);
            Unk6 = BitConverter.ToInt16(data, 30);

            Width        = widthBytes / 2;
            Height       = height;
            TilesIndices = new short[Height, Width];
            int ptr = data.Length - widthBytes * Height;

            for (int y = 0; y < Height; ++y)
            {
                for (int x = 0; x < Width; ++x)
                {
                    int v     = BitConverter.ToInt16(data, ptr);
                    int index = v >> 2;
                    if (index >= 1000)
                    {
                        index = 0;
                    }
                    TilesIndices[y, x] = (short)index;
                    ptr += 2;
                }
            }
        }
Ejemplo n.º 21
0
        private bool isEqualLastPixels(ref short[,] pixels)
        {
            bool equal = true;

            if (pixels == null)
            {
                return(false);
            }
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    if (pixels[i, j] != lastPixelData[i, j])
                    {
                        equal = false;
                        lastPixelData[i, j] = pixels[i, j];
                    }
                }
            }
            return(equal);
        }
Ejemplo n.º 22
0
        public Tilemap(int width, int height, int tileWidth, Bitmap bmp)
        {
            tileset = new Bitmap[bmp.Width / tileWidth];

            this.tileWidth = tileWidth;
            tileHeight     = bmp.Height;

            for (int i = 0; i < tileset.Length; i++)
            {
                tileset[i] = bmp.Clone(new Rectangle(i * tileWidth, 0, tileWidth, tileHeight), bmp.PixelFormat);
            }

            map = new short[width, height];
            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    map[i, j] = -1;
                }
            }
        }
Ejemplo n.º 23
0
        public static byte[] GetBytes(short[,] values)
        {
            int rows = values.GetLength(0);
            int cols = values.GetLength(1);

            byte[] buf = new byte[rows * cols * short_size];
            byte[] tmp;
            int    offset;

            for (int r = 0; r < rows; r++)
            {
                for (int c = 0; c < cols; c++)
                {
                    offset = (c * rows + r) * short_size;
                    tmp    = BitConverter.GetBytes(values[r, c]);
                    Buffer.BlockCopy(tmp, 0, buf, offset, short_size);
                }
            }

            return(buf);
        }
Ejemplo n.º 24
0
        public PuzzleLogic(int numRows)
        {
            _numRows = numRows;
            _cells   = new short[_numRows, _numRows];

            _cells[0, 0] = 1;
            _cells[0, 1] = 2;
            _cells[0, 2] = 3;

            _cells[1, 0] = 8;
            _cells[1, 1] = 9;
            _cells[1, 2] = 4;

            _cells[2, 0] = 5;
            _cells[2, 1] = 6;
            _cells[2, 2] = 7;

            _emptyCol = _numRows - 2;                   //find the column of the empty cell
            _emptyRow = _numRows - 2;                   //find the row of the empty cell
            _cells[_emptyRow, _emptyCol] = EmptyCellId; //overwrite the last cell with the empty cell ID
        }
Ejemplo n.º 25
0
        /// <summary>
        /// 判断两个数组是否相等
        /// </summary>
        /// <param name="a">第一个数组</param>
        /// <param name="b">第二个数组</param>
        /// <returns>是否相等</returns>
        public static bool IsEquals(short[,] a, short[,] b)
        {
            bool res = true;

            for (int i = 0; i < a.GetLength(0); i++)
            {
                for (int j = 0; j < a.GetLength(1); j++)
                {
                    if (b[i, j] != a[i, j])
                    {
                        res = false;
                        break;
                    }
                }
                if (!res)
                {
                    break;
                }
            }
            return(res);
        }
Ejemplo n.º 26
0
        private static int CalculateSum(short[,] matrix)
        {
            var maxSum = int.MinValue;

            for (int row = 0; row < matrix.GetLength(0) - 2; row++)
            {
                for (int col = 0; col < matrix.GetLength(1) - 2; col++)
                {
                    var currentSum = matrix[row, col] + matrix[row + 1, col] + matrix[row + 2, col]
                                     + matrix[row, col + 1] + matrix[row + 1, col + 1] + matrix[row + 2, col + 1]
                                     + matrix[row, col + 2] + matrix[row + 1, col + 2] + matrix[row + 2, col + 2];

                    if (currentSum > maxSum)
                    {
                        maxSum = currentSum;
                    }
                }
            }

            return(maxSum);
        }
Ejemplo n.º 27
0
 public void SetFrameData(Bitmap bmp)
 {
     GetFrameDelay(bmp);
     Width      = bmp.Width;
     Height     = bmp.Height;
     ColorTable = GetColorTable(bmp);
     if (ColorTable.Length > 16)
     {
         var compressed = CompressColors(bmp);
         ColorTable = GetColorTable(compressed);
     }
     TGE.Color[,] Colors = GetColors(bmp);
     Pixels = new short[Width, Height];
     for (int y = 0; y < Height; y++)
     {
         for (int x = 0; x < Width; x++)
         {
             Pixels[x, y] = GetClosestColorIndex(Colors[x, y]);
         }
     }
 }
Ejemplo n.º 28
0
        private bool WriteHeightmapFromNBT(short[,] hm, int localChunkX, int localChunkZ, HeightmapType type)
        {
            if (sourceNBT == null)
            {
                return(false);
            }
            var chunkHM = sourceNBT.GetHeightmapFromChunkNBT(type);

            if (chunkHM == null)
            {
                return(false);
            }
            for (int x = 0; x < 16; x++)
            {
                for (int z = 0; z < 16; z++)
                {
                    hm[localChunkX * 16 + x, localChunkZ * 16 + z] = chunkHM[x, z];
                }
            }
            return(true);
        }
Ejemplo n.º 29
0
        private static void initialize(Bitmap bm)
        {
            xsize = (short)bm.Width;
            ysize = (short)bm.Height;
            Console.WriteLine("Initialize(), width:" + xsize + " ysize: " + ysize);
            //all black pixels get marked as "1" in the array, white are "0"
            var kmmLevels = new short[bm.Width, bm.Height]; //filled with 0

            for (int i = 1; i < bm.Width - 1; i++)
            {
                for (int j = 1; j < bm.Height - 1; j++)
                {
                    var black = Color.FromArgb(255, 0, 0, 0);
                    if (bm.GetPixel(i, j) == black)
                    {
                        kmmLevels[i, j] = 1;
                    }
                }
            }
            kmmArray = kmmLevels;
        }
Ejemplo n.º 30
0
        public Bitmap FinalProcess(short[,] edgesX, short[,] edgesY)
        {
            Bitmap outputImg = new Bitmap(edgesX.GetLength(0), edgesX.GetLength(1));

            for (int i = 0; i < edgesX.GetLength(0); i++)
            {
                for (int j = 0; j < edgesX.GetLength(1); j++)
                {
                    short final = (short)Math.Sqrt(Math.Pow(edgesX[i, j], 2) + Math.Pow(edgesY[i, j], 2));

                    if (final > 255)
                    {
                        final = 255;
                    }

                    outputImg.SetPixel(i, j, Color.FromArgb(final, final, final));
                }
            }

            return(outputImg);
        }
Ejemplo n.º 31
0
        public short [] ZigzagScanning(short [,] arr)
        {
            list.Clear();

            foreach (Point p in zigzagPosition)
            {
                list.Add(arr [p.X, p.Y]);
            }

            /**/ int index;

            while ((index = list.LastIndexOf(0)) != -1)
            {
                if (index == list.Count - 1)
                {
                    list.RemoveAt(index);
                }
                else
                {
                    break;                 /**/
                }
Ejemplo n.º 32
0
        // Selection changed in size combo
        private void sizeCombo_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (se != null)
            {
                int size    = sizes[this.sizeCombo.SelectedIndex];
                int oldSize = se.GetLength(0);
                int d       = (size - oldSize) >> 1;
                short[,] array = new short[size, size];

                // copy old kernel into new
                for (int i = 0; i < oldSize; i++)
                {
                    if (i + d < 0)
                    {
                        continue;
                    }
                    if (i + d >= size)
                    {
                        break;
                    }

                    for (int j = 0; j < oldSize; j++)
                    {
                        if (j + d < 0)
                        {
                            continue;
                        }
                        if (j + d >= size)
                        {
                            break;
                        }
                        array[i + d, j + d] = se[i, j];
                    }
                }

                se = array;
                grid.LoadData(se);
                UpdateFilter( );
            }
        }
Ejemplo n.º 33
0
        public static short[,] Apply(CTSliceInfo ct, GaussBlur gb)
        {
            short[,] hmap = ct.HounsfieldPixelBuffer;

            int nr = ct.RowCount;
            int nc = ct.ColumnCount;

            int br = gb.br;
            int bc = gb.bc;

            float[,] blur = gb.blur;

            short[,] bm = new short[nr, nc];
            int l = bm.Length;

            Array.Clear(bm, 0, bm.Length);

            for (int r = br; r != nr - br; ++r)
            {
                for (int c = bc; c != nc - bc; ++c)
                {
                    float s = 0.0f;

                    for (int ir = -br; ir <= br; ++ir)
                    {
                        int sr = r + ir;
                        for (int ic = -bc; ic <= bc; ++ic)
                        {
                            int sc = c + ic;

                            s += (float)hmap[sr, sc] * blur[ir + br, ic + bc];
                        }
                    }

                    bm[r, c] = (short)(s + 0.5f);
                }
            }

            return(bm);
        }
Ejemplo n.º 34
0
        public unsafe void ProcessImage(UnmanagedImage image)
        {
            if (image.PixelFormat != PixelFormat.Format8bppIndexed)
            {
                throw new UnsupportedImageFormatException("Unsupported pixel format of the source image.");
            }
            width  = image.Width;
            height = image.Height;
            int num = image.Stride - width;

            houghMap = new short[height, width];
            byte *ptr = (byte *)image.ImageData.ToPointer();

            for (int i = 0; i < height; i++)
            {
                int num2 = 0;
                while (num2 < width)
                {
                    if (*ptr != 0)
                    {
                        DrawHoughCircle(num2, i);
                    }
                    num2++;
                    ptr++;
                }
                ptr += num;
            }
            maxMapIntensity = 0;
            for (int j = 0; j < height; j++)
            {
                for (int k = 0; k < width; k++)
                {
                    if (houghMap[j, k] > maxMapIntensity)
                    {
                        maxMapIntensity = houghMap[j, k];
                    }
                }
            }
            CollectCircles();
        }
Ejemplo n.º 35
0
    public FrameStructure GetShema(short[,] map, TileInfoStructure info)
    {
        FrameStructure rez = new FrameStructure();

        currentTileInfo = info;


        // GetTop();
        if (mapTop == null)
        {
            mapTop = new short[, ] {
                { -2, -1, -2 },
                { -2, -2, -2 },
                { -2, -2, -2 }
            }
        }
        ;
        if (ChackMap(mapTop, map, info))
        {
            return(GetTop());
        }

        // GetBottom();
        if (mapBottom == null)
        {
            mapBottom = new short[, ] {
                { -2, -2, -2 },
                { -2, -2, -2 },
                { -2, -1, -2 }
            }
        }
        ;
        if (ChackMap(mapBottom, map, info))
        {
            return(GetBottom());
        }

        return(rez);
    }
}
Ejemplo n.º 36
0
        private static void SetupLargestHouse(Point origin, int forestSize, IEnumerable <Point> trees)
        {
            _largestHouse = new short[forestSize, forestSize];

            // fill in left edge
            for (var i = 0; i < forestSize; i++)
            {
                _largestHouse[i, 0] = 1;
            }

            // fill in top edge
            for (var j = 0; j < forestSize; j++)
            {
                _largestHouse[0, j] = 1;
            }

            // fill in trees
            foreach (var tree in trees)
            {
                var newtree = Translate(tree, origin);
                if (newtree.Y > 0 && newtree.Y < forestSize && newtree.X > 0 && newtree.X < forestSize)
                {
                    _largestHouse[newtree.Y, newtree.X] = 1;
                }
            }

            // fill in all other cells, left to right then top to bottom
            for (var i = 1; i < forestSize; i++)
            {
                for (var j = 1; j < forestSize; j++)
                {
                    if (_largestHouse[i, j] == 0) // only if we don't already know there's a tree
                    {
                        _largestHouse[i, j] = (short)(1 + Min(_largestHouse[i - 1, j],
                                                              _largestHouse[i - 1, j - 1],
                                                              _largestHouse[i, j - 1]));
                    }
                }
            }
        }
Ejemplo n.º 37
0
        internal void refreshArrays()
        {
            SquareState[,] newSqState = new SquareState[MapSizeX + 1, MapSizeY + 1];
            short[,] newSqFloorHeight = new short[MapSizeX + 1, MapSizeY + 1];
            byte[,] newSqSeatRot = new byte[MapSizeX + 1, MapSizeY + 1];

            for (int y = 0; y < MapSizeY; y++)
            {
                for (int x = 0; x < MapSizeX; x++)
                {
                    if (x > (staticModel.MapSizeX - 1) || y > (staticModel.MapSizeY - 1))
                    {
                        newSqState[x, y] = SquareState.BLOCKED;
                    }
                    else
                    {
                        newSqState[x, y] = SqState[x, y];
                        newSqFloorHeight[x, y] = SqFloorHeight[x, y];
                        newSqSeatRot[x, y] = SqSeatRot[x, y];

                    }
                }
            }

            SqState = newSqState;
            SqFloorHeight = newSqFloorHeight;
            SqSeatRot = newSqSeatRot;

            RelativeSerialized = false;
            HeightmapSerialized = false;
        }
        void FetchLoresTerrain()
        {
            TerrainHeightTextureFetcher fetcher = new Srtm30TextureFetcher();
            Vector2 terrainLocation = new Vector2((float)MathExtensions.Round(initialTerrainLocation.X, 1), (float)MathExtensions.Round(initialTerrainLocation.Y, 1));

            loresTerrain = fetcher.FetchTerrain(GetCentredSquareRectangle(terrainLocation, DegreesToWorldUnits(9.999) / 1200.0f));
            TerrainEffect.WriteLoresTexture(loresTerrain);
            TerrainEffect.LoresTerrainCentreLocation = new Vector2(); //DegreesToWorldUnits(initialCameraLocation);
        }
 private void FetchHiresTerrain()
 {
     TerrainHeightTextureFetcher fetcher = new Srtm3TextureFetcher();
     Vector2 terrainLocation = new Vector2((float)MathExtensions.Round(initialTerrainLocation.X, 0.125), (float)MathExtensions.Round(initialTerrainLocation.Y, 0.125));
     hiresTerrain = fetcher.FetchTerrain(GetCentredSquareRectangle(terrainLocation, DegreesToWorldUnits(0.5) / 1200.0f));
     TerrainEffect.WriteHiresTexture(hiresTerrain);
     TerrainEffect.TerrainCentreLocation = new Vector2();// DegreesToWorldUnits(initialCameraLocation);
 }
Ejemplo n.º 40
0
        //===========================================================================
        // NewStage
        //===========================================================================
        public static void NewStage()
        {
            switch( nStageNum )
            {
                case 0: stage = (short[,])Place.PlaceData0.Clone(); break;
                case 1: stage = (short[,])Place.PlaceData1.Clone(); break;
                case 2: stage = (short[,])Place.PlaceData2.Clone(); break;
                case 3: stage = (short[,])Place.PlaceData3.Clone(); break;
                case 4: stage = (short[,])Place.PlaceData4.Clone(); break;
                case 5: stage = (short[,])Place.PlaceData5.Clone(); break;
                case 6: stage = (short[,])Place.PlaceData6.Clone(); break;
                case 7: stage = (short[,])Place.PlaceData7.Clone(); break;
                case 8: stage = (short[,])Place.PlaceData8.Clone(); break;
                case 9: stage = (short[,])Place.PlaceData9.Clone(); break;
                case 10: stage = (short[,])Place.PlaceData10.Clone(); break;
                case 11: stage = (short[,])Place.PlaceData11.Clone(); break;
                case 12: stage = (short[,])Place.PlaceData12.Clone(); break;
                case 13: stage = (short[,])Place.PlaceData13.Clone(); break;
                case 14: stage = (short[,])Place.PlaceData14.Clone(); break;
                case 15: stage = (short[,])Place.PlaceData15.Clone(); break;
                case 16: stage = (short[,])Place.PlaceData16.Clone(); break;
                case 17: stage = (short[,])Place.PlaceData17.Clone(); break;
                case 18: stage = (short[,])Place.PlaceData18.Clone(); break;
                case 19: stage = (short[,])Place.PlaceData19.Clone(); break;
                case 20: stage = (short[,])Place.PlaceData20.Clone(); break;
                case 21: stage = (short[,])Place.PlaceData21.Clone(); break;
            }

            callStageInit();

            Countdown = 60;
            bCleared = false;
        }
Ejemplo n.º 41
0
        // Selection changed in size combo
        private void sizeCombo_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (se != null)
            {
                int			size = sizes[this.sizeCombo.SelectedIndex];
                int			oldSize = se.GetLength(0);
                int			d = (size - oldSize) >> 1;
                short[,]	array = new short[size, size];

                // copy old kernel into new
                for (int i = 0; i < oldSize; i++)
                {
                    if (i + d < 0)
                        continue;
                    if (i + d >= size)
                        break;

                    for (int j = 0; j < oldSize; j++)
                    {
                        if (j + d < 0)
                            continue;
                        if (j + d >= size)
                            break;
                        array[i + d, j + d] = se[i, j];
                    }
                }

                se = array;
                grid.LoadData(se);
                UpdateFilter();
            }
        }
Ejemplo n.º 42
0
	void Start() {

		// Setting up stuff

		terrainHolderObj = GameObject.Find ("WorldTerrainHolder");
		terrainHolder = (World_TerrainHolder)terrainHolderObj.GetComponent<World_TerrainHolder>();

		playerHolder = GameObject.Find ("PlayerHolder");
		ph = (PlayerHolder)playerHolder.GetComponent<PlayerHolder> ();

		terrainChunkMap = terrainHolder.getChunkTerrain ();
		terrainCostMap = terrainHolder.getTerrainCost ();
		reloadTerrain ();
		wcs.initialize (terrainChunkMap, tilesToUse, terrainHolder.getChunkSize());
		chunkSize = terrainHolder.getChunkSize ();

		isChunkLoad = new bool[terrainChunkMap.GetLength (0), terrainChunkMap.GetLength (1)];

		// Calculating XBound

		xBound = chunkSize * terrainChunkMap.GetLength (0) * tileSize;
		xBound = xBound / 2.0f;
			
		yBound = chunkSize * terrainChunkMap.GetLength (1) * tileSize;
		yBound = yBound/2.0f;

		Debug.Log ("Calculated XBound to :" + xBound + ", YBound to :" + yBound);

		// Generating cornucopia chunks...

		short centerChunk = (short)(terrainChunkMap.GetLength (0) / 2);

		for (int i = centerChunk-2; i < centerChunk+3; i++) {
			for (int j = centerChunk-2; j < centerChunk+3; j++) {

				short[,] tmpChunk = wcs.spawnChunk ((short)i, (short)j);
				terrainHolder.copyInChunk (i,j,tmpChunk);

			}
		}

		// Spawning in cornucopia chunks

		for (int i = centerChunk-2; i < centerChunk+3; i++) {
			for (int j = centerChunk-2; j < centerChunk+3; j++) {

				short[,] tmpChunk = terrainHolder.copyOutChunk(i, j);
				loadInChunk (tmpChunk, i, j);
			}
		}

		reloadTerrain ();







		// Instantiating in players

		int numPlayers = ph.getNumPlayers ();
		float rads = 360 / numPlayers;
		rads = (rads * 3.14159f / 180.0f);

		for (int i = 0; i < numPlayers; i++) {

			float currentAngle = rads * i;

			//Debug.Log ("Angle : " + (180.0f*currentAngle/3.14159f));

			float xCord = (Mathf.Cos (currentAngle));
			float yCord = (Mathf.Sin (currentAngle));

			//Debug.Log ("X:" + xCord + ", Y:" + yCord);

			xCord *= (8.0f * 0.4f);
			yCord *= (8.0f * 0.4f);

			//Debug.Log ("X:" + xCord + ", Y:" + yCord);

			int xRemaind = (int)(xCord / 0.4f);
			int yRemaind = (int)(yCord / 0.4f);

			xCord = xRemaind * 0.4f;
			yCord = yRemaind * 0.4f;

			GameObject player = ph.getPlayer (i);
			player.SetActive (true);

			Debug.Log ("Putting player " + i + " at " + xCord + "," + yCord);
			player.transform.Translate (xCord,yCord,0);
		}

		currentPlayer = ph.getPlayer (0);
		pi = (PlayerInfo)currentPlayer.GetComponent<PlayerInfo> ();
		pi.isCurrentPlayer = true;

		UpdateCamera ();
	}
Ejemplo n.º 43
0
 public MapLayer(short[,] map)
 {
     this.map = (short[,])map.Clone();
 }
    private void InitMapMesh()
    {
        _useElevation = useElevation;

        Shader tileShader = tilesetShader;

        MeshFilter meshFilter;
        BoxCollider boxCollider = null;

        if (tilesetMesh == null)
        {
            meshFilter = gameObject.AddComponent<MeshFilter>();
            gameObject.AddComponent<MeshRenderer>();

            if (colliderType == OnlineMapsColliderType.mesh) meshCollider = gameObject.AddComponent<MeshCollider>();
            else if (colliderType == OnlineMapsColliderType.box) boxCollider = gameObject.AddComponent<BoxCollider>();

            tilesetMesh = new Mesh {name = "Tileset"};
        }
        else
        {
            meshFilter = GetComponent<MeshFilter>();
            tilesetMesh.Clear();
            elevationData = null;
            elevationRequest = null;
            if (useElevation)
            {
                ignoreGetElevation = false;
            }
        }

        int w1 = api.tilesetWidth / OnlineMapsUtils.tileSize;
        int h1 = api.tilesetHeight / OnlineMapsUtils.tileSize;

        int subMeshVX = 1;
        int subMeshVZ = 1;

        if (useElevation)
        {
            if (w1 < 32) subMeshVX = 32 % w1 == 0 ? 32 / w1 : 32 / w1 + 1;
            if (h1 < 32) subMeshVZ = 32 % h1 == 0 ? 32 / h1 : 32 / h1 + 1;
        }

        Vector2 subMeshSize = new Vector2(api.tilesetSize.x / w1, api.tilesetSize.y / h1);

        int w = w1 + 2;
        int h = h1 + 2;

        vertices = new Vector3[w * h * subMeshVX * subMeshVZ * 4];
        uv = new Vector2[w * h * subMeshVX * subMeshVZ * 4];
        Vector3[] normals = new Vector3[w * h * subMeshVX * subMeshVZ * 4];
        Material[] materials = new Material[w * h];
        tilesetMesh.subMeshCount = w * h;

        for (int y = 0; y < h; y++)
        {
            for (int x = 0; x < w; x++)
            {
                InitMapSubMesh(ref normals, x, y, w, h, subMeshSize, subMeshVX, subMeshVZ);
            }
        }

        tilesetMesh.vertices = vertices;
        tilesetMesh.uv = uv;
        tilesetMesh.normals = normals;

        for (int y = 0; y < h; y++)
        {
            for (int x = 0; x < w; x++)
            {
                InitMapSubMeshTriangles(ref materials, x, y, w, h, subMeshVX, subMeshVZ, tileShader);
            }
        }

        triangles = null;

        gameObject.GetComponent<Renderer>().materials = materials;

        tilesetMesh.MarkDynamic();
        tilesetMesh.RecalculateBounds();
        meshFilter.sharedMesh = tilesetMesh;

        if (meshCollider != null) meshCollider.sharedMesh = Instantiate(tilesetMesh) as Mesh;
        else if (boxCollider != null)
        {
            boxCollider.center = new Vector3(-api.tilesetSize.x / 2, 0, api.tilesetSize.y / 2);
            boxCollider.size = new Vector3(api.tilesetSize.x, 0, api.tilesetSize.y);
        }

        UpdateMapMesh();
    }
Ejemplo n.º 45
0
	void reloadTerrain() {

		terrainMap = terrainHolder.getTerrain ();
	}
    protected override void OnDestroyLate()
    {
        base.OnDestroyLate();

        if (drawingsGameObject != null) DestroyImmediate(drawingsGameObject);
        drawingsGameObject = null;
        elevationData = null;
        elevationRequest = null;
        meshCollider = null;
        tilesetMesh = null;
        triangles = null;
        uv = null;
        vertices = null;
    }
Ejemplo n.º 47
0
 public Chunk(Chunk c)
 {
     data = (short[,])c.data.Clone();
 }
Ejemplo n.º 48
0
        void Start()
        {
            //Log.debug("ENTER SpriteBuilding.Start");

            map = GameObject.FindObjectOfType<Map>();
            dispatcher = map.transform.GetComponent<AsyncDispatchBehaviour>();
            mapData = dispatcher.mapData;
            nodeW = map.nodeW;
            nodeH = map.nodeH;

            //Log.debug("LEAVE SpriteBuilding.Start");
        }
Ejemplo n.º 49
0
        public void TestStrm3PixelRegion()
        {
            PointF longLat = new PointF(lng, lat);
            TerrainHeightTextureFetcher fetcher = new Srtm3TextureFetcher();
            Rectangle region = new Rectangle(0, 0, 1000, 1500);

            terrain = fetcher.FetchTerrain(longLat, region);

            Image img = ImagingFunctions.CreateImageFromArray(terrain, ImagingFunctions.HsvColourMap(256));
            ImagingFunctions.SaveAndDisplayImage(img, "terrainFetchPixel030.png");
            region = new Rectangle(0, 1500, 1000, 1500);

            terrain = fetcher.FetchTerrain(longLat, region);

            img = ImagingFunctions.CreateImageFromArray(terrain, ImagingFunctions.HsvColourMap(256));
            ImagingFunctions.SaveAndDisplayImage(img, "terrainFetchPixel032.png");
        }
Ejemplo n.º 50
0
 private static bool LoadPrunData()
 {
     if (File.Exists(PrunPath))
     {
         using (Stream stream = File.Open(PrunPath, FileMode.Open))
         {
             var bformatter = new BinaryFormatter();
             twistMove = (short[,]) bformatter.Deserialize(stream);
             flipMove = (short[,]) bformatter.Deserialize(stream);
             FRtoBR_Move = (short[,]) bformatter.Deserialize(stream);
             URFtoDLF_Move = (short[,]) bformatter.Deserialize(stream);
             URtoDF_Move = (short[,]) bformatter.Deserialize(stream);
             URtoUL_Move = (short[,]) bformatter.Deserialize(stream);
             UBtoDF_Move = (short[,]) bformatter.Deserialize(stream);
             MergeURtoULandUBtoDF = (short[,]) bformatter.Deserialize(stream);
             Slice_URFtoDLF_Parity_Prun = (sbyte[]) bformatter.Deserialize(stream);
             Slice_URtoDF_Parity_Prun = (sbyte[]) bformatter.Deserialize(stream);
             Slice_Twist_Prun = (sbyte[]) bformatter.Deserialize(stream);
             Slice_Flip_Prun = (sbyte[]) bformatter.Deserialize(stream);
         }
         return true;
     }
     return false;
 }
Ejemplo n.º 51
0
        public void refreshArrays()
        {
            var newSqState = new SquareState[MapSizeX + 1, MapSizeY + 1];
            var newSqFloorHeight = new short[MapSizeX + 1, MapSizeY + 1];
            var newSqSeatRot = new byte[MapSizeX + 1, MapSizeY + 1];

            for (int y = 0; y < MapSizeY; y++)
            {
                for (int x = 0; x < MapSizeX; x++)
                {
                    if (x > (staticModel.MapSizeX - 1) || y > (staticModel.MapSizeY - 1))
                    {
                        newSqState[x, y] = SquareState.BLOCKED;
                    }
                    else
                    {
                        newSqState[x, y] = SqState[x, y];
                        newSqFloorHeight[x, y] = SqFloorHeight[x, y];
                        newSqSeatRot[x, y] = SqSeatRot[x, y];
                    }
                }
            }

            SqState = newSqState;
            SqFloorHeight = newSqFloorHeight;
            SqSeatRot = newSqSeatRot;
        }
Ejemplo n.º 52
0
        public void TestStrm30PixelMap()
        {
            PointF longLat = new PointF(lng, lat);
            TerrainHeightTextureFetcher fetcher = new Srtm30TextureFetcher();
            int w = 2048;
            int h = 2048;
            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {

                    Rectangle region = new Rectangle(700 + i * w, 1800 - j * h, w, h);

                    terrain = fetcher.FetchTerrain(longLat, region);

                    Image img = ImagingFunctions.CreateImageFromArray(terrain, ImagingFunctions.HsvColourMap(256));
                    ImagingFunctions.SaveAndDisplayImage(img, "terrainFetchPixel04" + i + j + ".png");
                }
            }
        }
Ejemplo n.º 53
0
            protected internal Figure(short[,] currentPosition, short matrixSize)
            {
                this.currentPosition = currentPosition;

                newPosition = (short[,]) currentPosition.Clone();

                this.matrixSize = matrixSize;

                this.CurrentSum = CountSum();
            }
Ejemplo n.º 54
0
        void OnInitComplete()
        {
            engine.CameraInput.Camera.FarZ = 12000;

            heightMap = ReadHgtFile(hgtFile, MapSize);

            landscape = new Landscape();
            //landscape.SplitFunction = SplitFromHeight;
            landscape.VisibleFunction = IsTriVisible;
            landscape.FetchFunction = MapFetchFunction;
            landscape.MAP_SIZE = heightMap.GetLength(0)-1;
            landscape.NUM_PATCHES_PER_SIDE = NumPatches;
            landscape.Init();
            landscape.Scale = new Vector3(1, 0.0005f, 1);
            landscape.BindToPass(engine.D3DDevice, engine.Effect, "Terrain");
            engine.Geometry.Add(landscape);

            using (MeshFactory fact = new MeshFactory())
                person = fact.CreateSphere(0.5f, 20, 20);

            float h = GetHeightAtPoint(2.5f,2.5f);

            person.Translation = new Vector3(2.5f, h+1, 2.5f);
            person.BindToPass(engine.D3DDevice, engine.Effect, 2);
            engine.Geometry.Add(person);

            engine.D3DDevice.FillMode = SlimDX.Direct3D10.FillMode.Wireframe;

            engine.CameraInput.LookAt(new Vector3(MapSize/2, 100, 0), new Vector3(MapSize/2, 0, MapSize/2));
        }
Ejemplo n.º 55
0
        //===========================================================================
        // アプリ初期化
        //===========================================================================
        static void AppInit()
        {
            graphics = new GraphicsContext();

            stopwatch = new Stopwatch();
            stopwatch.Start();

            stage = (short[,])Place.PlaceData0.Clone ();

            //  load models&初期化
            player[0].idle  = new BasicModel( "/Application/mdx/player_idle.mdx", 0 );
            player[0].move  = new BasicModel( "/Application/mdx/player_move.mdx", 0 );
            player[0].clear = new BasicModel( "/Application/mdx/player_happy.mdx", 0 );
            player[0].mode = StateId.lookingDown;

            player[1].idle  = new BasicModel( "/Application/mdx/player2.mdx", 0 );
            player[1].move  = new BasicModel( "/Application/mdx/player2_move.mdx", 0 );
            player[1].clear = new BasicModel( "/Application/mdx/player2_happy.mdx", 0 );
            player[1].mode = StateId.lookingDown;

            mdl_wall		= new BasicModel( "/Application/mdx/box.mdx", 0 );
            mdl_floor		= new BasicModel( "/Application/mdx/floor.mdx", 0 );
            mdl_switch		= new BasicModel( "/Application/mdx/switch.mdx", 0 );

            SampleDraw.Init(graphics);
            /*
            soundClear = new Sound( "/Application/sound/clear.wav" );
            soundPlayerClear = soundClear.CreatePlayer();

            soundhitWall = new Sound( "/Application/sound/hitwall.wav" );
            soundPlayerhitWall =  soundhitWall.CreatePlayer();

            //@e Initialization of BGM
            //@j BGMの初期化
            bgm = new Bgm( "/Application/sound/GameBgm.wav" );
            bgmPlayer = bgm.CreatePlayer();
            bgmPlayer.Loop = true;
            bgmPlayer.Play();
            */
            program = new BasicProgram();

            menuCtrl = new MenuCtrl( graphics );

            rBlock.init();
        }
Ejemplo n.º 56
0
 public void Destroy()
 {
     Heightmap = null;
     SqState = null;
     SqFloorHeight = null;
     SqSeatRot = null;
 }
Ejemplo n.º 57
0
 public static void GenWorld(string named)
 {
     //Directory.CreateDirectory(Config.rootfolder + Config.savefolder + Config.worlddata + "/" + named);
     killed_kane = false;
     killed_loki = false;
     if (Settings.allow_painting)
     {
         //max_width /= 2;
         chunkcolor = new Color[max_width, max_height];
         Main.myPlayer.pos = new Vector2(max_width / 2, max_height / 2);
         Main.myPlayer.spawnpoint = Main.myPlayer.pos;
     }
     thickness = new byte[max_width, max_height];
     world = new short[max_width, max_height];
     matrix = world;
     wall = new short[max_width, max_height];
     alreadygen = new bool[max_width, max_height];
     //powered = new bool[max_width, max_height];
     //color = new Color[max_width, max_height];
     name = named;
     World.AddPlanets();
     GenChunk((int)(Main.myPlayer.pos.X - (Main.myPlayer.pos.X % chunksize)) / chunksize, (int)(Main.myPlayer.pos.Y - (Main.myPlayer.pos.Y % chunksize)) / chunksize, Main.rand.Next(2));
     //GenVillage((max_width / chunksize) / 2);
     GenHive(max_width / 2, 850);
     //planets.Add(0, new Planet());
     //World.SwitchDimensions(1);
     CheckChunks(Main.myPlayer);
     new Thread(new ThreadStart(SaveChunk)).Start();
     new Thread(new ThreadStart(CheckChunkThread)).Start();
 }
Ejemplo n.º 58
0
        // On "Load" button - load kernel
        private void loadButton_Click(object sender, System.EventArgs e)
        {
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    short[,]	array = (short[,]) Serialize2DimArray.Load(ofd.FileName, typeof(short));
                    int			size = array.GetLength(0);
                    int			i;

                    // check size
                    if (size != array.GetLength(1))
                        throw new ApplicationException();

                    for (i = 0; i < sizes.Length; i++)
                    {
                        if (size == sizes[i])
                        {
                            this.sizeCombo.SelectedIndex = i;
                            break;
                        }
                    }
                    if (i == sizes.Length)
                        throw new ApplicationException();

                    se = array;
                    grid.LoadData(se);
                    UpdateFilter();
                }
                catch (ApplicationException)
                {
                    MessageBox.Show(this, "Failed loading structuring element from specified file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 59
0
        private void Dispose(bool bDisposing)
        {
            if(!bDisposed)
            {
                sChars=null;
                oAddedTags=null;
                sStrings=null;
                bTagData=null;
            }

            bDisposed=true;
        }
Ejemplo n.º 60
0
        private void getImage()
        {
            try
            {
                if (this.connected == true)
                {
                    object data = null;

                    if(this.camara != null)
                        data = this.camara.GetImage(0);

                    if (data is short[,])
                        this.imgData = (short[,])data;
                    else
                    {
                        this.imgData = null;
                        if (data is short)
                        {
                            if ((short) data == 14)     //TIMEOUT
                            {
                                //Poner el Framerate más alto
                                object framesObject = this.camara.GetCameraProperty(75);
                                //Subir el timeout 100 ms
                                object actualTimeout = this.camara.GetCameraProperty(93);

                                short status;

                                if (actualTimeout is int)
                                {
                                    status = this.camara.SetCameraProperty(93, (int)actualTimeout + 100);
                                }

                                if (framesObject is double[])
                                {
                                    //CAMBIAR FRAMERATE
                                    double[] frames = (double[])framesObject;

                                    status = this.camara.SetCameraProperty(43, frames[0]);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex.ToString().Contains("No se puede utilizar un objeto COM que se ha separado de su RCW subyacente."))
                    return;

                procesarExcepcion(ex, "GetImage");
            }
        }