Exemple #1
0
        protected void CreateMap(DeathmatchMap Map, MapLayer Owner, int LayerIndex)
        {
            Map2D GroundLayer = Owner.LayerGrid;

            for (int X = Map.MapSize.X - 1; X >= 0; --X)
            {
                for (int Y = Map.MapSize.Y - 1; Y >= 0; --Y)
                {
                    DrawableTile ActiveTerrain   = GroundLayer.GetTile(X, Y);
                    Terrain3D    ActiveTerrain3D = ActiveTerrain.Terrain3DInfo;
                    if (ActiveTerrain3D.TerrainStyle == Terrain3D.TerrainStyles.Invisible)
                    {
                        continue;
                    }

                    float Z      = Owner.ArrayTerrain[X, Y].Position.Z * 32 + (LayerIndex * 32);
                    float ZFront = Z;
                    float ZBack  = Z;
                    float ZRight = Z;
                    float ZLeft  = Z;
                    if (Y + 1 < Map.MapSize.Y)
                    {
                        ZFront = Owner.ArrayTerrain[X, Y + 1].Position.Z * 32 + (LayerIndex * 32);
                    }
                    if (Y - 1 >= 0)
                    {
                        ZBack = Owner.ArrayTerrain[X, Y - 1].Position.Z * 32 + (LayerIndex * 32);
                    }
                    if (X - 1 >= 0)
                    {
                        ZLeft = Owner.ArrayTerrain[X - 1, Y].Position.Z * 32 + (LayerIndex * 32);
                    }
                    if (X + 1 < Map.MapSize.X)
                    {
                        ZRight = Owner.ArrayTerrain[X + 1, Y].Position.Z * 32 + (LayerIndex * 32);
                    }

                    List <Tile3D> ListNew3DTile = ActiveTerrain3D.CreateTile3D(ActiveTerrain.TilesetIndex, ActiveTerrain.Origin.Location,
                                                                               X * Map.TileSize.X, Y * Map.TileSize.Y, Z, LayerIndex * 32, Map.TileSize, Map.ListTileSet, ZFront, ZBack, ZLeft, ZRight, 0);

                    foreach (Tile3D ActiveTile in ListNew3DTile)
                    {
                        if (!DicTile3DByTileset.ContainsKey(ActiveTile.TilesetIndex))
                        {
                            DicTile3DByTileset.Add(ActiveTile.TilesetIndex, new Tile3DHolder(effect, Map.ListTileSet[ActiveTile.TilesetIndex]));
                        }
                        DicTile3DByTileset[ActiveTile.TilesetIndex].AddTile(ActiveTile);
                    }
                }
            }

            for (int L = 0; L < Owner.ListSubLayer.Count; L++)
            {
                CreateMap(Map, Owner.ListSubLayer[L], LayerIndex);
            }
        }
Exemple #2
0
        public void GivenNoHeuristic_ShouldBuildBigGraph()
        {
            var map2D        = new Map2D(14, 14);
            var goalPosition = map2D.Tiles[11, 12];
            var pathFinder   = new PathFinder <Tile>(delegate { return(0); }, 14 * 14, map2D.IndexMap(), map2D.NeighboursManhattan());

            var graph = pathFinder.BuildGraph(map2D.Tiles[0, 2], goalPosition);

            Assert.AreEqual(192, graph.Count(x => x != null));
        }
Exemple #3
0
 public DungeonMap(int width,
                   int height,
                   IDungeonGameRules rules)
 {
     Width           = width;
     Height          = height;
     FloorLayer      = new Map2D <IFloorType>(width, height, (_, _) => rules.FloorTypes.DefaultValue);
     WallLayer       = new Map2D <IWallType>(width, height, (_, _) => rules.WallTypes.DefaultValue);
     DecorationLayer = new Map2D <IDecorationType>(width, height, (_, _) => rules.DecorationTypes.DefaultValue);
 }
Exemple #4
0
        public void SparseCreation()
        {
            var map = new Map2D <float>(16, 16);

            map[-8, -8]      = 4.0f;
            map[-1024, -887] = 8.0f;

            // With only two areas in memory, we only have (16*16)*2 blocks.
            Assert.AreEqual(512, map.Count);
        }
        public MapLayer(SorcererStreetMap Map, List <AnimationBackground> ListBackgrounds, List <AnimationBackground> ListForegrounds, BinaryReader BR)
        {
            this.Map = Map;

            ListSubLayer = new List <SubMapLayer>();

            StartupDelay   = BR.ReadInt32();
            ToggleDelayOn  = BR.ReadInt32();
            ToggleDelayOff = BR.ReadInt32();
            Depth          = BR.ReadSingle();

            if (StartupDelay == 0)
            {
                IsVisible   = true;
                ToggleTimer = ToggleDelayOn;
            }
            else
            {
                IsVisible   = false;
                ToggleTimer = StartupDelay;
            }

            ArrayTerrain = new TerrainSorcererStreet[Map.MapSize.X, Map.MapSize.Y];
            for (int Y = 0; Y < Map.MapSize.Y; Y++)
            {
                for (int X = 0; X < Map.MapSize.X; X++)
                {
                    int TerrainTypeIndex = BR.ReadInt32();

                    switch (Map.ListTerrainType[TerrainTypeIndex])
                    {
                    case TerrainSorcererStreet.FireElement:
                    case TerrainSorcererStreet.WaterElement:
                    case TerrainSorcererStreet.EarthElement:
                    case TerrainSorcererStreet.AirElement:
                        ArrayTerrain[X, Y] = new ElementalTerrain(X, Y, TerrainTypeIndex);
                        break;

                    case TerrainSorcererStreet.EastGate:
                    case TerrainSorcererStreet.WestGate:
                    case TerrainSorcererStreet.SouthGate:
                    case TerrainSorcererStreet.NorthGate:
                        ArrayTerrain[X, Y] = new GateTerrain(X, Y, TerrainTypeIndex);
                        break;

                    default:
                        ArrayTerrain[X, Y] = new TerrainSorcererStreet(X, Y, TerrainTypeIndex);
                        break;
                    }
                }
            }

            OriginalLayerGrid = new SorcererStreetMap2D(Map, BR);
            LayerGrid         = new Map3D(Map, this, OriginalLayerGrid, GameScreen.GraphicsDevice);
        }
Exemple #6
0
        public void GivenValidHeuristic_ShouldBuildSmallerGraph()
        {
            var map2D        = new Map2D(14, 14);
            var goalPosition = map2D.Tiles[11, 12];
            var pathFinder   = new PathFinder <Tile>(_heuristic, 14 * 14, map2D.IndexMap(), map2D.NeighboursManhattan());

            var graph = pathFinder.BuildGraph(map2D.Tiles[0, 2], goalPosition);
            var test  = graph.Where(x => x != null).Select(x => x.Heuristic).ToList();

            Assert.AreEqual(63, graph.Count(x => x != null));
        }
Exemple #7
0
        public void CanAccessRandomly()
        {
            var map = new Map2D <float>();

            map[-8, -8]     = 4.0f;
            map[-240, -778] = 8.0f;
            map[8, 8]       = 16.0f;
            map[240, 778]   = 32.0f;

            Assert.That(Math.Abs(map[-240, -778] - 8) < 0.001);
            Assert.That(Math.Abs(map[240, 778] - 32.0f) < 0.001);
        }
Exemple #8
0
        public void CanEnumerateRanges()
        {
            var map = new Map2D <float>();

            map[1, 2] = 4.0f;

            var begin = new WorldSpace2D(0, 0);
            var end   = new WorldSpace2D(4, 4);

            Assert.That(map.Within(begin, end).Any());
            Assert.That(map.Within(begin, end).Any(i => Math.Abs(i - 4.0f) < 0.001));
        }
        private int CalcConvexHull(Map2D <int> mapOwnClone)
        {
            var vis = new Map2D <bool>(size);

            for (int i = 1; i <= size; i++)
            {
                var pois = new List <Point>()
                {
                    new Point(1, i), new Point(size, i),
                    new Point(i, 1), new Point(i, size)
                };
                foreach (var p in pois)
                {
                    int x = p.X, y = p.Y;
                    if (vis[x, y] || IsOutOfMap(x, y) ||
                        mapOwnClone[x, y] == beforeGame.TeamID)
                    {
                        continue;
                    }
                    vis[x, y] = true;
                    var q = new Queue <Point>();
                    q.Enqueue(p);
                    while (q.Count > 0)
                    {
                        var t = q.Dequeue();
                        foreach (var j in new int[] { 0, 2, 4, 6 })
                        {
                            int nx = t.X + dx[j], ny = t.Y + dy[j];
                            if (vis[nx, ny] || IsOutOfMap(nx, ny) ||
                                mapOwnClone[nx, ny] == beforeGame.TeamID)
                            {
                                continue;
                            }
                            vis[nx, ny] = true;
                            q.Enqueue(new Point(nx, ny));
                        }
                    }
                }
            }
            int res = 0;

            for (int i = 1; i <= size; i++)
            {
                for (int j = 1; j <= size; j++)
                {
                    if (vis[i, j] == false && mapOwnClone[i, j] != beforeGame.TeamID)
                    {
                        res += Math.Abs(mapScores[i, j]);
                    }
                }
            }
            return(res);
        }
        public void TwoDimensionalTest()
        {
            _map2D = new Map2D(4, 4);
            var pathFinder = new PathFinder <Tile>(_heuristic, 4 * 4, _map2D.IndexMap(), _map2D.NeighboursManhattan());

            _map2D.Tiles[0, 1].IsBlocking = true;
            _map2D.Tiles[2, 0].IsBlocking = true;

            var path = pathFinder.Path(_map2D.Tiles[0, 0], _map2D.Tiles[3, 3]);

            Assert.AreEqual(6, path.Length);
        }
Exemple #11
0
        public void SupportsAddingEntities()
        {
            var map = new Map2D <float>(16, 16);

            var oldBoot = new Entity {
                Name = "Old Boot"
            };

            map.PutEntity(1, 1, oldBoot);

            Assert.That(map.GetEntitiesAt(1, 1).Any());
            Assert.That(oldBoot.X == 1 && oldBoot.Y == 1);
        }
Exemple #12
0
    void Awake()
    {
        MeshFilter   meshFilter   = gameObject.AddComponent <MeshFilter>();
        MeshRenderer meshRenderer = gameObject.AddComponent <MeshRenderer>();

        meshRenderer.material = material;
        MeshMaker2D meshMaker    = new MeshMaker2D(Map2D.getWidth(), Map2D.getHeight(), alightment == Alignment.Centered);
        Mesh        mesh         = meshMaker.getMesh();
        Bitmask     mapConverter = new Bitmask(Map2D.map);

        mesh.uv         = meshMaker.getUVmap((int)atlasSize.x, (int)atlasSize.y, mapConverter.convertMap(), buffer);
        meshFilter.mesh = mesh;
    }
Exemple #13
0
        protected override void Initialize()
        {
            camera      = new Camera.Camera2DControlled();
            camera.Zoom = 1f;

            map    = new Map2D(Content, 16);
            engine = new ECS.Engine(map);

            mouseState  = Mouse.GetState();
            cursor_rect = new Rectangle(mouseState.X, mouseState.Y, 1, 1);

            base.Initialize();
        }
Exemple #14
0
    public static void DrawGizmos(Map2D physicsMap2D)
    {
        float es = physicsMap2D.ElementSize;

        for (int x = 0; x < physicsMap2D.Width; x++)
        {
            for (int y = 0; y < physicsMap2D.Height; y++)
            {
                Gizmos.color = colors[Math.Min(colors.Length - 1, physicsMap2D.Data[x][y].Count)];
                Vector3 pos = new Vector3(x * es + es / 2, y * es + es / 2);
                Gizmos.DrawCube(pos, new Vector3(es * 0.9f, es * 0.9f, es * 0.1f));
            }
        }
    }
Exemple #15
0
    private void RecretaeMap()
    {
        HashSet <IAabb> all = new HashSet <IAabb>();

        if (map2D != null)
        {
            all = map2D.GetIntersections(new FloatRect(0, 0, map2D.Width * map2D.ElementSize, map2D.Height * map2D.ElementSize));
        }
        map2D = new Map2D(width, height, elementSize);
        foreach (var a in all)
        {
            map2D.Put(a);
        }
    }
        private Tile3D CreateTile(DeathmatchMap Map, Texture2D ActiveTileset, Vector3[] ArrayVertexPosition, int X, int Y)
        {
            //Add and remove a half pixel offset to avoid texture bleeding.
            VertexPositionColorTexture[] ArrayVertex = new VertexPositionColorTexture[4];
            Map2D        GroundLayer   = Map.ListLayer[0].OriginalLayerGrid;
            DrawableTile ActiveTerrain = GroundLayer.GetTile(X, Y);
            float        UVXValue      = ActiveTerrain.Origin.X + 0.5f;
            float        UVYValue      = ActiveTerrain.Origin.Y + 0.5f;
            Vector2      TextureSize   = new Vector2(ActiveTileset.Width, ActiveTileset.Height);

            ArrayVertex[0]                   = new VertexPositionColorTexture();
            ArrayVertex[0].Position          = ArrayVertexPosition[0];
            ArrayVertex[0].TextureCoordinate = new Vector2(UVXValue / TextureSize.X, UVYValue / TextureSize.Y);
            ArrayVertex[0].Color             = Color.White;

            UVXValue                         = ActiveTerrain.Origin.X + Map.TileSize.X - 0.5f;
            UVYValue                         = ActiveTerrain.Origin.Y + 0.5f;
            ArrayVertex[1]                   = new VertexPositionColorTexture();
            ArrayVertex[1].Position          = ArrayVertexPosition[1];
            ArrayVertex[1].TextureCoordinate = new Vector2(UVXValue / TextureSize.X, UVYValue / TextureSize.Y);
            ArrayVertex[1].Color             = Color.White;

            UVXValue                         = ActiveTerrain.Origin.X + 0.5f;
            UVYValue                         = ActiveTerrain.Origin.Y + Map.TileSize.Y - 0.5f;
            ArrayVertex[2]                   = new VertexPositionColorTexture();
            ArrayVertex[2].Position          = ArrayVertexPosition[2];
            ArrayVertex[2].TextureCoordinate = new Vector2(UVXValue / TextureSize.X, UVYValue / TextureSize.Y);
            ArrayVertex[2].Color             = Color.White;

            UVXValue                         = ActiveTerrain.Origin.X + Map.TileSize.X - 0.5f;
            UVYValue                         = ActiveTerrain.Origin.Y + Map.TileSize.Y - 0.5f;
            ArrayVertex[3]                   = new VertexPositionColorTexture();
            ArrayVertex[3].Position          = ArrayVertexPosition[3];
            ArrayVertex[3].TextureCoordinate = new Vector2(UVXValue / TextureSize.X, UVYValue / TextureSize.Y);
            ArrayVertex[3].Color             = Color.White;

            short[] ArrayIndex = new short[6];
            ArrayIndex[0] = 0;
            ArrayIndex[1] = 1;
            ArrayIndex[2] = 3;
            ArrayIndex[3] = 0;
            ArrayIndex[4] = 3;
            ArrayIndex[5] = 2;

            Tile3D NewTile = new Tile3D(ArrayVertex, ArrayIndex);

            return(NewTile);
        }
Exemple #17
0
        public void SupportsUnloading()
        {
            var map = new Map2D <float>();

            map[0, 0]   = 2.0f;
            map[16, 16] = 2.0f;
            map[33, 33] = 4.0f;

            Assert.AreEqual((16 * 16) * 3, map.Count);

            var begin = new WorldSpace2D(0, 0);
            var end   = new WorldSpace2D(33, 33);

            map.UnloadArea(begin, end);

            Assert.AreEqual(0, map.Count);
        }
Exemple #18
0
        public void InitBRAIN(BeforeGame beforeGame, OnGame onGame)
        {
            size        = int.Parse(onGame.Height);
            isObs       = new Map2D <bool>(size);
            scores      = new Map2D <int>(size);
            owns        = new Map2D <int>(size);
            myAgents    = new List <MyAgent>();
            enemyAgents = new List <MyAgent>();

            foreach (var obs in onGame.Obstacles)
            {
                isObs[obs.Y, obs.X] = true;
            }
            foreach (var tre in onGame.Treasure)
            {
                if (tre.Status == 0)
                {
                    scores[tre.Y, tre.X] = tre.Point;
                }
            }
            for (int i = 1; i <= size; i++)
            {
                for (int j = 1; j <= size; j++)
                {
                    scores[i, j] += onGame.Points[i - 1][j - 1];
                    owns[i, j]    = onGame.Tiled[i - 1][j - 1];
                }
            }
            foreach (var tea in onGame.Teams)
            {
                if (tea.TeamID == beforeGame.TeamID)
                {
                    foreach (var age in tea.Agents)
                    {
                        myAgents.Add(new MyAgent(age.Y, age.X, age.AgentID));
                    }
                }
                else
                {
                    foreach (var age in tea.Agents)
                    {
                        enemyAgents.Add(new MyAgent(age.Y, age.X, age.AgentID));
                    }
                }
            }
        }
Exemple #19
0
        public Worker(bool map2d = true, bool map3d = true, bool viewer2d = true)
        {
            Map2D    = map2d;
            Map3D    = map3D;
            Viewer2D = viewer2d;

            _LV                    = new LViewer();
            _map2d                 = new Map2D();
            _map2d_win             = new LaserViewer2D();
            _map2d_win.DataContext = _map2d;
            _map3d                 = new LaserViewer3D();

            if (map3d)
            {
                _map3d.Show();
            }
        }
Exemple #20
0
        public GameForm(GameBackground back, Ether eth, Map2D <int> map2D)
        {
            this.map2D = map2D;
            this.back  = back;

            format.Alignment     = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;



            ClientSize = new Size(800, 600);
            Timer t = new Timer();

            t.Interval = 10;
            t.Tick    += new EventHandler(t_Tick);
            t.Start();
        }
        protected override void CreateMap(DeathmatchMap Map)
        {
            DicTile3D.Clear();

            for (int X = Map.MapSize.X - 1; X >= 0; --X)
            {
                for (int Y = Map.MapSize.Y - 1; Y >= 0; --Y)
                {
                    Vector3[] ArrayVertexPosition = new Vector3[4];
                    ArrayVertexPosition[0] = new Vector3(X * Map.TileSize.X, 0, Y * Map.TileSize.Y);
                    ArrayVertexPosition[1] = new Vector3(X * Map.TileSize.X + Map.TileSize.X, 0, Y * Map.TileSize.Y);
                    ArrayVertexPosition[2] = new Vector3(X * Map.TileSize.X, 0, Y * Map.TileSize.Y + Map.TileSize.Y);
                    ArrayVertexPosition[3] = new Vector3(X * Map.TileSize.X + Map.TileSize.X, 0, Y * Map.TileSize.Y + Map.TileSize.Y);

                    Vector3[] ArrayTransformedVertexPosition = new Vector3[ArrayVertexPosition.Length];

                    Matrix TranslationToOriginMatrix = Matrix.CreateTranslation(-Radius, Radius, -Radius);
                    Vector3.Transform(ArrayVertexPosition, ref TranslationToOriginMatrix, ArrayTransformedVertexPosition);
                    for (int V = ArrayVertexPosition.Length - 1; V >= 0; --V)
                    {
                        ArrayVertexPosition[V] = ArrayTransformedVertexPosition[V];
                    }

                    Map2D        GroundLayer   = Map.ListLayer[0].OriginalLayerGrid;
                    DrawableTile ActiveTerrain = GroundLayer.GetTile(X, Y);
                    Texture2D    ActiveTileset = Map.ListTileSet[ActiveTerrain.Tileset];
                    if (!DicTile3D.ContainsKey(ActiveTileset))
                    {
                        DicTile3D.Add(ActiveTileset, new List <Tile3D>());
                    }
                    Tile3D NewTile = CreateTile(Map, ActiveTileset, ArrayVertexPosition, X, Y);

                    if (Spherical)
                    {
                        MoveToSphericalCoordinates(NewTile, Radius);
                        CreateSphericalElevation(Map, ActiveTileset, NewTile, X, Y);
                    }
                    else
                    {
                        CreateFlatElevation(Map, ActiveTileset, NewTile, X, Y);
                    }
                    CreateCubicTile(Map, ActiveTileset, NewTile);
                }
            }
        }
Exemple #22
0
    /// <summary>
    /// Initialises variables, called before Start().
    /// </summary>
    private void Awake()
    {
        // Initialise tax timer
        _gameTimer = new CountdownTimer {
            Seconds = 10f
        };
        _gameTimer.Begin();

        // Initialise map
        _map = gameObject.GetComponent <Map2D>();

        // Get audio sources
        _musicSource = transform.FindChild("Music").GetComponent <AudioSource>();
        _sfxSource   = transform.FindChild("SFX").GetComponent <AudioSource>();

        // Initialise the game
        InitGame();
    }
        public SeamTracking()
        {
            InitializeComponent();
            //Dispatcher.Invoke(()=> {
            //    Worker w = new Worker();
            //    w.RobotStart();
            //    w.LaserStart();
            //});
            Map2D    = false;
            Map3D    = true;
            Viewer2D = true;

            test = false;
            l1   = false;
            l2   = false;
            l3   = false;
            l4   = false;
            cal  = false;
            one  = false;

            _LV                    = new LViewer();
            _map2d                 = new Map2D();
            _map2d_win             = new LaserViewer2D();
            _map2d_win.DataContext = _map2d;
            _map3d                 = new LaserViewer3D();
            s = Singleton.GetInstance();

            if (Map2D)
            {
                _map2d_win.Show();
            }
            if (Map3D)
            {
                _map3d.Show();
            }
            if (Viewer2D)
            {
                _LV.Show();
            }

            // Start();
        }
Exemple #24
0
 public bool Equals(Map2D <TKey1, TKey2, TValue> x, Map2D <TKey1, TKey2, TValue> y)
 {
     if (ReferenceEquals(x, y))
     {
         return(true);
     }
     if (ReferenceEquals(x, null))
     {
         return(false);
     }
     if (ReferenceEquals(y, null))
     {
         return(false);
     }
     if (x.GetType() != y.GetType())
     {
         return(false);
     }
     return(Equals(x.map, y.map));
 }
Exemple #25
0
        public void SupportsUnloadingWithPersistance()
        {
            var map = new Map2D <float>();

            map[0, 0]   = 2.0f;
            map[16, 16] = 2.0f;
            map[33, 33] = 4.0f;

            Assert.AreEqual((16 * 16) * 3, map.Count);

            map.MakePersistant((1, 1));

            var begin = new WorldSpace2D(0, 0);
            var end   = new WorldSpace2D(33, 33);

            map.UnloadArea(begin, end);

            // One chunk left
            Assert.AreEqual((16 * 16), map.Count);
        }
Exemple #26
0
        public void SupportsQuantumEntanglementPrevention()
        {
            var map = new Map2D <float>(16, 16);

            var oldBoot = new Entity {
                Name = "Old Boot"
            };

            map.PutEntity(1, 1, oldBoot);

            Assert.That(map.GetEntitiesAt(1, 1).Any());
            Assert.That(oldBoot.X == 1 && oldBoot.Y == 1);

            // Put the boot somewhere else, moving it.
            map.PutEntity(17, 17, oldBoot);
            oldBoot.Name = "Spooky Old Boot";

            Assert.That(map.GetEntitiesAt(1, 1).Any() == false);
            Assert.That(map.GetEntitiesAt(17, 17).Any());
        }
Exemple #27
0
        public async Task <Immutable <Map2D <TExport> > > RenderFrame(RenderingOptions options, Complex center, double scale, GrainCancellationToken cancellationToken = null)
        {
            // Prepare a frame to return
            var frame = new Map2D <TExport>(options.FrameWidth, options.FrameHeight);

            // Load initial values
            var initialSet = PrepareInitialValues(options.FrameWidth, options.FrameHeight, center, scale);

            // Compute in batches
            var batchCount = (int)Math.Ceiling(frame.Raw.Length / (double)options.BatchSize);
            var batchTasks = new Task <Immutable <TExport[]> > [batchCount];

            for (int i = 0; i < batchCount; i++)
            {
                var newBatch = GrainFactory.GetGrain <IRenderBatch <TExport> >(Guid.NewGuid());

                var startPoint = i * options.BatchSize;
                var count      = Math.Min(options.BatchSize, frame.Raw.Length - startPoint);

                var buffer = new Span <Complex>(initialSet, startPoint, count).ToArray();

                batchTasks[i] = newBatch.Compute(options, buffer, cancellationToken);
            }

            // Wait for the workers to finish
            var   combinedTask = Task.WhenAll(batchTasks); // TODO: exception handling
            await combinedTask;

            cancellationToken?.CancellationToken.ThrowIfCancellationRequested();

            // Import the results...
            for (int i = 0; i < batchCount; i++)
            {
                var startPoint = i * options.BatchSize;

                batchTasks[i].Result.Value.CopyTo(frame.Raw, startPoint);
            }

            // ... and send them back to the requestor.
            return(new Immutable <Map2D <TExport> >(frame));
        }
        public MapLayer(SorcererStreetMap Map)
        {
            this.Map = Map;

            ListSubLayer = new List <SubMapLayer>();
            ToggleTimer  = StartupDelay;
            IsVisible    = StartupDelay > 0;

            //Tiles
            ArrayTerrain = new TerrainSorcererStreet[Map.MapSize.X, Map.MapSize.Y];
            for (int Y = 0; Y < Map.MapSize.Y; Y++)
            {
                for (int X = 0; X < Map.MapSize.X; X++)
                {
                    ArrayTerrain[X, Y] = new TerrainSorcererStreet(X, Y);
                }
            }

            OriginalLayerGrid = new SorcererStreetMap2D(Map);
            LayerGrid         = new Map3D(Map, this, OriginalLayerGrid, GameScreen.GraphicsDevice);
        }
Exemple #29
0
        public void SupportsAddingAndRemovingEntities()
        {
            var map = new Map2D <float>(16, 16);

            var oldBoot = new Entity {
                Name = "Old Boot"
            };

            map.PutEntity(1, 1, oldBoot);

            Assert.That(map.GetEntitiesAt(1, 1).Any());
            Assert.That(oldBoot.X == 1 && oldBoot.Y == 1);

            map.RemoveEntity(oldBoot);
            Assert.That(map.GetEntitiesAt(1, 1).Any() == false);

            // After removing, items have null coordinates.
            Assert.That(oldBoot.X == null);
            Assert.That(oldBoot.Y == null);
            Assert.That(oldBoot.Z == null);
        }
Exemple #30
0
        public void AddDrawablePoints(List <MovementAlgorithmTile> ListPoint, Color PointColor)
        {
            List <Tile3D> ListDrawablePoint3D = new List <Tile3D>(ListPoint.Count);

            foreach (MovementAlgorithmTile ActivePoint in ListPoint)
            {
                int          X               = (int)ActivePoint.Position.X;
                int          Y               = (int)ActivePoint.Position.Y;
                float        Z               = Map.LayerManager.ListLayer[ActivePoint.LayerIndex].ArrayTerrain[X, Y].Position.Z * 32 + (ActivePoint.LayerIndex * 32) + 0.1f;
                Map2D        GroundLayer     = Map.LayerManager.ListLayer[ActivePoint.LayerIndex].LayerGrid;
                DrawableTile ActiveTerrain   = GroundLayer.GetTile(X, Y);
                Terrain3D    ActiveTerrain3D = ActiveTerrain.Terrain3DInfo;

                ListDrawablePoint3D.Add(ActiveTerrain3D.CreateTile3D(0, Point.Zero,
                                                                     X * Map.TileSize.X, Y * Map.TileSize.Y, Z, Z + 0.1f, Map.TileSize, new List <Texture2D>()
                {
                    sprCursor
                }, Z, Z, Z, Z, 0)[0]);
            }

            DicDrawablePointPerColor.Add(PointColor, ListDrawablePoint3D);
        }
        void mWebMapCommon_OnVisibleEdgesChange(object sender, Map2D.VisibleEdgesArgs e)
        {
            IEnumerable<RadiomapBackend.Edge> edges = e.VisibleEdges;
            if (edges == null)
                return;

            foreach (RadiomapBackend.Edge curEdge in edges)
            {
                AbsoluteLocation origin = null, destination = null;
                bool first = true;
                foreach (Vertex v in curEdge.Vertices)
                {
                    if (first)
                    {
                        origin = v.AbsoluteLocations.First();
                        first = false;
                    }
                    else
                    {
                        destination = v.AbsoluteLocations.First();
                        break;
                    }
                }
                if (origin != null && destination != null)
                {
                    AddEdgeLine((double)origin.latitude, (double)origin.longitude, (double)destination.latitude, (double)destination.longitude);
                }
            }
        }
        void mWebMapCommon_OnVisibleVerticesChange(object sender, Map2D.VisibleVerticesArgs e)
        {
            IEnumerable<Vertex> vertices = e.VisibleVertices;
            if (vertices == null)
                return;

            foreach (Vertex v in vertices)
            {
                AddVertexPin(v);
            }
        }
 void mWebMapCommon_OnCenterChange(object sender, Map2D.CoordinateArgs e)
 {
     graphMap.Center = new GeoCoordinate(e.Latitude, e.Longitude);
 }
 void mWebMapCommon_OnTitleChange(object sender, Map2D.TitleArgs e)
 {
     this.ApplicationTitle.Text = e.Title;
 }