예제 #1
0
 public PlaceTileAction(int x, int y, MapLayers layer, int tileid)
 {
     this.x = x;
     this.y = y;
     this.tileid = tileid;
     this.layer = layer;
 }
 public ReadOnlyCollection<IRenderer> GetItems(MapLayers layer)
 {
     lock (this.renderers)
     {
         return new ReadOnlyCollection<IRenderer>(this.renderers.SelectMany(p => p.Value).ToList());
     }
 }
예제 #3
0
        private void btnSwitch_Click(object sender, RoutedEventArgs e)
        {
            Button btnSwitch = (Button)sender;

            switch (btnSwitch.Name)
            {
            case "On":
                btnSwitch.Style = App.Current.Resources["btnOff"] as Style;
                MapLayers.ShowHideFeatureLayerByID(btnSwitch.Tag.ToString(), false);
                btnSwitch.Name = "Off";
                MapMethods.SendSwitchFeatureLayerByID(btnSwitch.Tag.ToString(), "0");
                //MapMethods.CloseInfoWin();
                //MapMethods.SendCloseInfoWindow();
                break;

            case "Off":
                btnSwitch.Style = App.Current.Resources["btnOn"] as Style;
                MapLayers.ShowHideFeatureLayerByID(btnSwitch.Tag.ToString(), true);
                btnSwitch.Name = "On";
                MapMethods.SendSwitchFeatureLayerByID(btnSwitch.Tag.ToString(), "1");
                break;

            default:
                break;
            }
        }
예제 #4
0
 public void RefreshTilesAround(Vector2Int position, MapLayers layer)
 {
     RefreshTile(position + Vector2Int.up, layer);
     RefreshTile(position + Vector2Int.down, layer);
     RefreshTile(position + Vector2Int.left, layer);
     RefreshTile(position + Vector2Int.right, layer);
 }
 public void AddItem(IRenderer renderer, MapLayers layer)
 {
     lock (this.renderers)
     {
         this.renderers[layer].Add(renderer);
     }
 }
예제 #6
0
        private void AddPushpin(string deviceID, Windows.Devices.Geolocation.BasicGeoposition position)
        {
            var mapDevices = new List <MapElement>();

            Windows.Devices.Geolocation.BasicGeoposition snPosition = new Windows.Devices.Geolocation.BasicGeoposition {
                Latitude = position.Latitude, Longitude = position.Longitude
            };

            var pushpin = new MapIcon
            {
                Location = new Geopoint(snPosition),
                NormalizedAnchorPoint = new Point(0.5, 1),
                ZIndex = 1000,
                Tag    = "NEW",
                Title  = deviceID,
                Image  = RandomAccessStreamReference.CreateFromUri(new Uri(resourceLoader.GetString("Map_Pushpin_New"))),
            };

            mapDevices.Add(pushpin);

            var mapDevicesLayer = new MapElementsLayer
            {
                ZIndex      = 1,
                MapElements = mapDevices
            };

            MapLayers.Add(mapDevicesLayer);
            CTRL_Map_Main.Layers.Add(mapDevicesLayer);
        }
예제 #7
0
        public void SetBitmask(int x, int y, byte mask, MapLayers layer, bool callEvent = true)
        {
            int cX = x / chunkWidth;
            int cY = y / chunkHeight;

            SetBitmask(cX, cY, x - (cX * chunkWidth), y - (cY * chunkHeight), mask, layer, callEvent);
        }
예제 #8
0
        public byte GetBitmask(int x, int y, MapLayers layer)
        {
            int cX = x / chunkWidth;
            int cY = y / chunkHeight;

            return(map.chunks[cX, cY].tileLayers[layer][x - (cX * chunkWidth), y - (cY * chunkHeight)].bitmask);
        }
예제 #9
0
    public void ResizeLayerMap(MapLayers layer)
    {
        GameObject[,] mapLayer = m_worldMap[layer];

        int oldCols = mapLayer.GetLength(0);
        int oldRows = mapLayer.GetLength(1);

        if ((oldRows > rows) || (oldCols > columns))
        {
            for (int c = columns; c < oldCols; c++)
            {
                for (int r = 0; r < oldRows; r++)
                {
                    DeleteTile(new Vector2(c, r), layer);
                }
            }
            for (int r = rows; r < oldRows; r++)
            {
                for (int c = 0; c < oldCols; c++)
                {
                    DeleteTile(new Vector2(c, r), layer);
                }
            }
        }

        m_worldMap[layer] = ResizeMatrix(mapLayer, columns, rows);
    }
예제 #10
0
    private void Paint(GameObject[,] worldMap, Tile tile, Sprite lastTile, MapLayers layer, int x, int y)
    {
        if (x < 0 || y < 0 || x >= worldMap.GetLength(0) || y >= worldMap.GetLength(1))
        {
            return;
        }

        if (lastTile == null)
        {
            if (worldMap[x, y] != null)
            {
                return;
            }
        }
        else
        {
            GameObject currentTile = worldMap[x, y];
            if (currentTile == null)
            {
                return;
            }

            if (currentTile.GetComponentInChildren <SpriteRenderer>().sprite != lastTile)
            {
                return;
            }
        }

        CreateTile(tile, new Vector2(x, y), layer);
        Paint(worldMap, tile, lastTile, layer, x + 1, y);
        Paint(worldMap, tile, lastTile, layer, x, y + 1);
        Paint(worldMap, tile, lastTile, layer, x - 1, y);
        Paint(worldMap, tile, lastTile, layer, x, y - 1);
    }
예제 #11
0
        //private Task threadListenToServerByTCP = null;
        public MainWindow()
        {
            InitializeComponent();
            //SetFullScreen();//设置本程序全屏显示
            LoadVectorMap(); //加载矢量地图
            LoadImageMap();  //加载影像地图-------考虑异步加载,节省程序加载时间
            PublicParams.pubMainMap    = mainMap;
            PublicParams.pubLayoutRoot = LayoutRoot;
            PublicParams.pubInfoWin    = mainInfoWindow;
            //PublicParams.pubCanvasChild1 = canvasChild1;

            Task listenToClient = new Task(ListenToClientByTCP, TaskCreationOptions.LongRunning); //长时间监听

            listenToClient.Start();                                                               //建立监听,等待客户端连接大屏

            Thread threadRefreshMainMap = new Thread(MapMethods.RefreshMainMapThread)
            {
                IsBackground = true
            };

            threadRefreshMainMap.Start();

            if (PublicParams.IsInitLayers != "0") //暂时没有图层服务器,不显示图层
            {
                MapLayers.InitMapLayers();        //初始化地图所需的图层,静态方法
            }
            //ShowOneCrimePoint();//添加一个案件点

            PadHelper.InitPads();
            PoliceCarGPS gps     = new PoliceCarGPS(); //MQ相关,接收警车GPS信号
            Traffic      traffic = new Traffic();      //红绿灯和道路

            ParamsHelper.ReloadModularsFromXML();
        }
예제 #12
0
 public byte GetBitmask(Vector2Int location, MapLayers layer)
 {
     if (ReferenceEquals(MapManager.instance.GetTile(location.x, location.y, layer), null))
     {
         return(0);
     }
     return(1);
 }
예제 #13
0
        private async Task <bool> SetUpForecastAsync(SimpleLocation location, bool showLoading = true)
        {
            if (showLoading)
            {
                ShowLoadingPanel(Common.GetLocalizedText("LoadingWeatherInfoText"));
            }

            try
            {
                CurrentLocation = location.Name;

                // Set the map center
                MapCenter = new Geopoint(location.Position);

                // Add pin
                MapLayers.Clear();
                AddPinToMap(new SimpleLocation(Common.GetLocalizedText("WeatherMapPinLabel"), location.Position.Latitude, location.Position.Longitude));

                // Retrieve weather information about location
                var weather = await WeatherProvider.Instance.GetGenericWeatherAsync(location.Position.Latitude, location.Position.Longitude);

                // Update the UI if weather is available
                if (weather != null)
                {
                    // Only set weather if it's not null
                    _weather = weather;

                    // Update weather-related UI
                    RefreshWeatherUI(_weather);

                    // Try to get sensor data
                    try
                    {
                        SensorTemperatureAndHumidity = await GetSensorTemperatureAndHumidityString();
                    }
                    catch (Exception ex)
                    {
                        LogService.WriteException(ex);
                    }

                    // Show proper weather panel
                    WeatherErrorPageVisibility = false;
                    WeatherControlVisibility   = true;
                    return(true);
                }
                else
                {
                    // Something went wrong so show the error panel
                    WeatherErrorPageVisibility = true;
                    WeatherControlVisibility   = false;
                }
            }
            finally
            {
                HideLoadingPanel();
            }
            return(false);
        }
        // Update is called once per frame
        void Update()
        {
            if (Input.GetKeyDown(KeyCode.Alpha1))
            {
                ml = MapLayers.FG;
            }
            if (Input.GetKeyDown(KeyCode.Alpha2))
            {
                ml = MapLayers.BG;
            }
            if (Input.GetKeyDown(KeyCode.M))
            {
                minimap.SetActive(!minimap.activeSelf);
            }
            curspeed = Input.GetKey(KeyCode.LeftShift) ? fastSpeed : moveSpeed;
            Vector2 moveVec = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));

            moveVelo = moveVec * curspeed;

            if (Input.GetKeyDown(KeyCode.Z))
            {
                Vector2Int po = MapManager.instance.WorldToBlock(cam.ScreenToWorldPoint(Input.mousePosition));
                TileString s  = MapManager.instance.GetTile(po.x, po.y, MapLayers.FG);
                blockName.text    = s != null ? $"{s.nspace}:{s.tile}" : "";
                blockBitmask.text = MapManager.instance.GetBitmask(po.x, po.y, MapLayers.FG).ToString();
            }


            Vector2    pos;
            Vector2Int blockPos;

            if (Input.GetMouseButton(0))
            {
                pos      = cam.ScreenToWorldPoint(Input.mousePosition);
                blockPos = mm.WorldToBlock(pos);
                for (int i = -destroyRadius; i < destroyRadius; i++)
                {
                    for (int j = -destroyRadius; j < destroyRadius; j++)
                    {
                        mm.SetTile(blockPos.x + i, blockPos.y + j, blockToPlace, ml);
                    }
                }
            }

            if (Input.GetMouseButton(1))
            {
                pos      = cam.ScreenToWorldPoint(Input.mousePosition);
                blockPos = mm.WorldToBlock(pos);
                for (int i = -destroyRadius; i < destroyRadius; i++)
                {
                    for (int j = -destroyRadius; j < destroyRadius; j++)
                    {
                        mm.SetTile(blockPos.x + i, blockPos.y + j, null, ml, true, true, true);
                    }
                }
            }
        }
예제 #15
0
        private void ClearMapLayers()
        {
            foreach (var item in MapLayers)
            {
                CTRL_Map_Main.Layers.Remove(item);
            }

            MapLayers.Clear();
        }
예제 #16
0
        public void ChangeLayerOpacity(double opacity)
        {
            if (!MapLayers.Any(x => x.IsVisible))
            {
                return;
            }

            MapLayers.Where(x => x.IsVisible)?.ForEach(x => x.Layer.Opacity = opacity);
        }
예제 #17
0
        public MainWindow()
        {
            InitializeComponent();

            LogHelper.WriteLog("<-------加载开始了!");
            LoadVectorMap(); //加载矢量地图
            LoadImageMap();  //加载影像地图-------考虑异步加载,节省程序加载时间

            PublicParams.pubMainMap      = mainMap;
            PublicParams.pubLayoutRoot   = LayoutRoot;
            PublicParams.pubInfoWin      = mainInfoWindow;
            PublicParams.pubCanvasChild1 = canvasChild1;

            if (PublicParams.IsInitLayers != "0")
            {
                MapLayers.InitMapLayers();//初始化地图所需的图层,静态方法
            }

            //ShowOneCrimePoint();//添加一个模拟的案件点

            //Task taskConnectDVCSServer = new Task(ConnectDVCSServerInTask);//DVCS服务器连接相关
            //taskConnectDVCSServer.Start();
            PublicParams.dvcsServerMain = new DVCSServer()
            {
                dvcsServerIP = PublicParams.DVCSIP, dvcsServerPort = PublicParams.DVCSPort, dvcsName = PublicParams.dvcsServerMainName
            };
            ConnectDVCSServerInTask(PublicParams.dvcsServerMain);
            PublicParams.dvcsServer2 = new DVCSServer()
            {
                dvcsServerIP = PublicParams.DVCSIP2, dvcsServerPort = PublicParams.DVCSPort2, dvcsName = PublicParams.dvcsServer2Name
            };
            ConnectDVCSServerInTask(PublicParams.dvcsServer2);

            PadHelper.InitPads();                //初始化信息窗
            WallVideosHelper.InitOpenedVideos(); //初始化已打开视频列表


            PoliceCarGPS gpsPoliceCar = new PoliceCarGPS(); //MQ相关,接收警车GPS信号
            Cases        cases        = new Cases();        //MQ相关,接收案件信息
            Traffic      traffic      = new Traffic();

            drawBuffer = new Draw(mainMap)
            {
                LineSymbol = App.Current.Resources["DrawLineSymbol"] as LineSymbol,
                FillSymbol = App.Current.Resources["DrawFillSymbol"] as FillSymbol
            };
            drawBuffer.DrawComplete += drawBuffer_DrawComplete;

            drawLenOrArea = new Draw(PublicParams.pubMainMap)
            {
                LineSymbol = App.Current.Resources["DrawLineSymbol"] as LineSymbol,
                FillSymbol = App.Current.Resources["DrawFillSymbol"] as FillSymbol
            };
            drawLenOrArea.DrawComplete += drawLenOrArea_DrawComplete;
            LogHelper.WriteLog("<-------加载完成了!");
        }
예제 #18
0
        private void _afterRoomChange()
        {
            roomInfoLabelName.Text            = Manager.Project.Room.name;
            roomInfoLabelWidth.Text           = Manager.Project.Room.width.ToString() + "px";
            roomInfoLabelHeight.Text          = Manager.Project.Room.height.ToString() + "px";
            roomInfoLabelInstancesNumber.Text = Manager.Project.Room.instances.Count.ToString();

            Manager.Project.Room.reorderInstances();

            int total = Manager.Project.GmsResourceRoomList.Sum(r => r.instances.Count);

            int totalObjects = Manager.Project.GmsResourceObjectList.Count;

            roomInfoLabelOthers.Text =
                "Total rooms: " + Manager.Project.GmsResourceRoomList.Count.ToString() + Environment.NewLine +
                "Total instnaces in rooms: " + total.ToString() + Environment.NewLine +
                "Total objects: " + totalObjects.ToString();


            Manager.Project.RoomLayers = new ObservableCollection <MapLayers>();

            {
                MapLayers layer = new MapLayers()
                {
                    LayerName = "_DEFAULT", LayerDepth = 0
                };
                Manager.Project.RoomLayers.Add(layer);
            }

            foreach (GmsRoomInstance inst in Manager.Project.Room.instances)
            {
                if (Manager.Project.RoomLayers.Where(n => n.LayerName == inst.instance_of.name).Count() == 0)
                {
                    MapLayers layer = new MapLayers()
                    {
                        LayerName = inst.instance_of.name, LayerDepth = inst.instance_of.depth
                    };
                    Manager.Project.RoomLayers.Add(layer);
                }
            }

            foreach (GmsObject obj in Manager.Project.GmsResourceObjectList)
            {
                string _name = "DEPTH " + obj.depth.ToString();
                if (Manager.Project.RoomLayers.Where(n => n.LayerName == _name).Count() == 0)
                {
                    MapLayers layer = new MapLayers()
                    {
                        LayerName = _name, LayerDepth = obj.depth
                    };
                    Manager.Project.RoomLayers.Add(layer);
                }
            }

            Manager.Project.regenerateLayerList();
        }
예제 #19
0
 //Update the chunk where the tile was placed.
 void OnTilePlaced(Vector2Int chunk, Vector2Int pos, TileBase tb, MapLayers layer)
 {
     if (this.layer == layer)
     {
         if (chunks[chunk.x, chunk.y])
         {
             chunks[chunk.x, chunk.y].update = true;
         }
     }
 }
예제 #20
0
        public void RefreshTile(Vector2Int position, MapLayers layer)
        {
            TileString t = GetTile(position.x, position.y, layer);

            if (!ReferenceEquals(t, null))
            {
                TileBase tb = GetTileFromCollection(t);
                tb.RefreshTile(position, layer);
            }
        }
예제 #21
0
        public static void CreateMap(MenuCommand menuCommand)
        {
            var gameObject = new GameObject("Map", typeof(Reactics.Core.Map.Authoring.Map));

            GameObjectUtility.SetParentAndAlign(gameObject, menuCommand.context as GameObject);
            Undo.RegisterCreatedObjectUndo(gameObject, "Create " + gameObject.name);
            Selection.activeObject = gameObject;
            var map = gameObject.GetComponent <Reactics.Core.Map.Authoring.Map>();

            map.layerColors = MapLayers.CreateDefaultColorMap();
        }
예제 #22
0
        public TileString GetTile(int x, int y, MapLayers layer)
        {
            if (x >= mapWidth || x < 0 || y >= mapHeight || y < 0)
            {
                return(null);
            }
            int cX = x / chunkWidth;
            int cY = y / chunkHeight;

            return(map.chunks[cX, cY].GetTile(x - (cX * chunkWidth), y - (cY * chunkHeight), layer));
        }
예제 #23
0
    public void DeleteTile(Vector2 gridPosition, MapLayers layer)
    {
        GameObject tile = m_worldMap[layer][(int)gridPosition.x, (int)gridPosition.y];

        if (tile == null)
        {
            return;
        }
        DestroyImmediate(tile);
        m_worldMap[layer][(int)gridPosition.x, (int)gridPosition.y] = null;
    }
예제 #24
0
    public void PaintTile(Tile tile, Vector2 gridPosition, MapLayers layer)
    {
        Sprite     lastSprite = null;
        GameObject go         = m_worldMap[layer][(int)gridPosition.x, (int)gridPosition.y];

        if (go != null)
        {
            lastSprite = go.GetComponentInChildren <SpriteRenderer>().sprite;
        }

        Paint(m_worldMap[layer], tile, lastSprite, layer, (int)gridPosition.x, (int)gridPosition.y);
    }
예제 #25
0
        public void SetTile(int x, int y, TileString blockID, MapLayers layer,
                            bool callEvent = true, bool refreshSurronding = true, bool ignoreSameTile = false)
        {
            if (x < 0 || y < 0)
            {
                return;
            }
            int cX = x / chunkWidth;
            int cY = y / chunkHeight;

            SetTile(cX, cY, x, y, blockID, layer, callEvent, refreshSurronding, ignoreSameTile);
        }
예제 #26
0
        /*private void addOrEditPlaceable(bool edit)
         * {
         *  string defName = "Undefined Placeable " + lbPlaceables.Items.Count.ToString();
         *
         *  if (edit)
         *  {
         *      if (lbPlaceables.Items.Count < 1 || lbPlaceables.SelectedIndex < 0) return;
         *  }
         *
         *  using (PlaceableForm form = new PlaceableForm())
         *  {
         *      PlaceableElement elem;
         *      if (edit)
         *      {
         *          elem = Manager.Project.PlaceableList[lbPlaceables.SelectedIndex];
         *          form.Element = elem;
         *          form.Text = "Edit Placeable Definition: " + elem.Name;
         *      }
         *      else
         *      {
         *          elem = new PlaceableElement() { Name = defName };
         *          form.Element = elem;
         *          form.Text = "Create new Placeable Definition: " + defName;
         *      }
         *
         *      if (form.ShowDialog() == DialogResult.OK)
         *      {
         *          if (edit)
         *          {
         *              //TODO: since elem is referenced, it shouldn't be changed that way
         *              //elem = form.Element;
         *          }
         *          else
         *          {
         *              Manager.Project.PlaceableList.Add(form.Element);
         *          }
         *          Manager.Project.regenerateEnvDefList();
         *      }
         *  }
         *
         *  statusLabelPlaceables.Text = Manager.Project.PlaceableList.Count.ToString();
         * }*/

        private void addOrEditLayer(bool edit)
        {
            string defName = "Undefined Layer " + lbLayers.Items.Count.ToString();

            if (edit)
            {
                if (lbLayers.Items.Count < 1 || lbLayers.SelectedIndex < 0)
                {
                    return;
                }
            }

            using (LayerForm form = new LayerForm())
            {
                MapLayers elem;
                if (edit)
                {
                    elem         = Manager.Project.Room.Layers[lbLayers.SelectedIndex];
                    form.Element = elem;
                    form.Text    = "Edit Layer Definition: " + elem.LayerName;
                }
                else
                {
                    int depth = 0;
                    if (lbLayers.Items.Count > 0)
                    {
                        depth = Manager.Project.Room.Layers[lbLayers.Items.Count - 1].LayerDepth + 1;
                    }
                    elem = new MapLayers()
                    {
                        LayerName = defName, LayerDepth = 1
                    };
                    form.Text = "Create new Layer Definition: " + defName;
                }

                form.Element = elem;

                if (form.ShowDialog() == DialogResult.OK)
                {
                    if (edit)
                    {
                        //TODO: since elem is referenced, it shouldn't be changed that way
                        //elem = form.Element;
                    }
                    else
                    {
                        Manager.Project.Room.Layers.Add(form.Element);
                    }
                    Manager.Project.regenerateLayerList();
                }
            }
        }
예제 #27
0
        public void AddLayer(ILayer layer)
        {
            MapLayer mapLayer = layer as MapLayer;

            if (mapLayer != null)
            {
                if (mapLayer.Width != mapWidth || mapLayer.Height != mapHeight)
                {
                    throw new Exception("Map layer size exception");
                }

                MapLayers.Add(layer);
            }
        }
예제 #28
0
    private static void CreateVisualisations()
    {
        MapLayers.Add(new MapVisualisation(
                          world,
                          Keyboard.Key.F,
                          true,
                          Updaters.FitnessImage
                          ));
        MapLayers.Add(new MapVisualisation(
                          world,
                          Keyboard.Key.F,
                          true,
                          Updaters.HeightShadeImage
                          ));
        MapLayers.Add(new MapVisualisation(
                          world,
                          Keyboard.Key.B,
                          true,
                          Updaters.IsolineImage
                          ));

        MapLayers.Add(new MapVisualisation(
                          world,
                          Keyboard.Key.T,
                          false,
                          Updaters.TempImage
                          ));

        MapLayers.Add(new MapVisualisation(
                          world,
                          Keyboard.Key.M,
                          false,
                          Updaters.MoistureImage
                          ));

        MapLayers.Add(new MapVisualisation(
                          world,
                          Keyboard.Key.I,
                          false,
                          Updaters.IslandImage
                          ));

        MapLayers.Add(new MapVisualisation(
                          world,
                          Keyboard.Key.P,
                          false,
                          Updaters.PressureImage
                          ));
    }
예제 #29
0
 private void AddPinToMap(SimpleLocation location)
 {
     MapLayers.Add(new MapElementsLayer
     {
         ZIndex      = 1,
         MapElements = new List <MapElement>
         {
             new MapIcon
             {
                 Location = new Geopoint(location.Position),
                 Title    = location.Name
             }
         }
     });
 }
예제 #30
0
        public override void RefreshTile(Vector2Int position, MapLayers layer)
        {
            byte top         = GetBitmask(position + Vector2Int.up, layer);
            byte left        = GetBitmask(position + Vector2Int.left, layer);
            byte right       = GetBitmask(position + Vector2Int.right, layer);
            byte bottom      = GetBitmask(position + Vector2Int.down, layer);
            byte topLeft     = (byte)(GetBitmask(position + ul, layer) & top & left);
            byte topRight    = (byte)(GetBitmask(position + ur, layer) & top & right);
            byte bottomRight = (byte)(GetBitmask(position + dr, layer) & bottom & right);
            byte bottomLeft  = (byte)(GetBitmask(position + dl, layer) & bottom & left);
            byte mask        = (byte)((1 * topLeft) + (2 * top) + (4 * topRight) + (8 * left) + (16 * right) +
                                      (32 * bottomLeft) + (64 * bottom) + (128 * bottomRight));

            MapManager.instance.SetBitmask(position.x, position.y, mask, layer);
        }
예제 #31
0
 void consumer_Listener(IMessage message)
 {
     ITextMessage msg = (ITextMessage)message;
     PublicParams.pubMainMap.Dispatcher.Invoke(new Action(delegate{
         //tbTest.Text = msg.Text;
         JObject json = JObject.Parse(msg.Text);
         if (json["JJDBH"].ToString() == "00000")//演示用的程序会推送一些编号为00000的数据
         {
             MapLayers.ClearGLayerByID(PublicParams.gLayerCrimePoint);
             return;
         }
         Case newcase = new Case(json);
         DrawCase(json);
         LoopQueue(newcase);
         UpdateNewest(newcase);
     }));
 }
예제 #32
0
 public TileString GetTile(int x, int y, MapLayers layer)
 {
     if (chunkPallete.Count == 0)
     {
         return(null);
     }
     td = tileLayers[layer][x, y];
     if (td == null)
     {
         return(null);
     }
     if (td.tile == 0)
     {
         return(null);
     }
     return(chunkPallete[td.tile - 1]);
 }
예제 #33
0
        public override void Init()
        {
            Events.Init();
            MapLayers.Init(Server.CurrentMap);
            MapCollision.Init(MapLayers);
            Players = new BasePlayer[Server.MaxClients];

            GameController = Server.GameController(Config["SvGametype"]);
            GameController.Init();

            Server.PlayerReady        += ServerOnPlayerReady;
            Server.PlayerEnter        += ServerOnPlayerEnter;
            Server.PlayerDisconnected += ServerOnPlayerDisconnected;

            HandleGameLayer();
            CheckPureTuning();
        }
 public void DrawLayer(BaseCharacter character, SpriteBatch spriteBatch, BaseCamera camera, MapLayers layer)
 {
     switch (layer)
     {
         case MapLayers.UnderLayer:
             this.DrawUnder (character, spriteBatch, camera);
             break;
         case MapLayers.BaseLayer:
             this.DrawBase (character, spriteBatch, camera);
             break;
         case MapLayers.MiddleLayer:
             this.DrawMiddle (character, spriteBatch, camera);
             break;
         case MapLayers.TopLayer:
             this.DrawTop (character, spriteBatch, camera);
             break;
     }
 }
예제 #35
0
        /// <summary>
        /// Performs a flood fill beginning on the target square
        /// </summary>
        /// <param name="map">The map to perform the operation on</param>
        /// <param name="layer">The layer to perform on</param>
        /// <param name="x">The x location to begin filling</param>
        /// <param name="y">The y location to begin filling</param>
        /// <param name="oldtileid">The ID of the tile to begin replacing.</param>
        /// <param name="newtileid">The ID of the replacement tile.</param>
        private void FloodFill(Map map, MapLayers layer, int x, int y, int oldtileid, int newtileid)
        {
            int value = map.GetLayerValue(new MapPoint(x, y), layer);

            if (value != oldtileid || value == newtileid)
                return;

            var action = new PlaceTileAction(x, y, layer, newtileid);
            action.Do(context);
            tmpactions.Add(action);

            if (x + 1 < MapEditorManager.CurrentMap.MapSize.X)
                this.FloodFill(map, layer, x + 1, y, oldtileid, newtileid);

            if (x - 1 >= 0)
                this.FloodFill(map, layer, x - 1, y, oldtileid, newtileid);

            if (y + 1 < MapEditorManager.CurrentMap.MapSize.Y)
                this.FloodFill(map, layer, x, y + 1, oldtileid, newtileid);

            if (y - 1 >= 0)
                this.FloodFill(map, layer, x, y - 1, oldtileid, newtileid);
        }
 public ReadOnlyCollection<IRenderer> this[MapLayers layer]
 {
     get { return this.GetItems(layer); }
 }
예제 #37
0
        public int GetGlobalLayerValue(string WorldName, MapPoint globalpoint, MapLayers layer)
        {
            foreach(var header in this.WorldsList[WorldName].MapList.Values)
            {
                if(header.MapLocation.ToRect(header.Map.MapSize.ToPoint()).Contains(globalpoint.ToPoint()))
                {
                    return header.Map.GetLayerValue(header.MapLocation - globalpoint, layer);
                }
            }

            return 0;
        }
예제 #38
0
파일: Map.cs 프로젝트: NullSoldier/Valkyrie
        public Rectangle GetLayerSourceRect(MapPoint point, MapLayers layer)
        {
            if (point.X < 0 || point.X > this.MapSize.X || point.Y < 0 || point.Y >= this.MapSize.Y)
                throw new ArgumentOutOfRangeException("point");

            int LayerValue = this.GetLayerValue(point, layer);
            if (LayerValue < 0)
                return Rectangle.Empty;

            if (this.AnimatedTiles.ContainsKey(LayerValue))
                return this.AnimatedTiles[LayerValue].FrameRectangle;
            else
                return new Rectangle(
                    (LayerValue % this.TilesPerRow) * TileSize,
                    (LayerValue / this.TilesPerRow) * TileSize,
                    TileSize - 1, TileSize - 1);
        }
예제 #39
0
        public static void DrawLayerMapLocal(SpriteBatch spriteBatch, MapHeader header, MapLayers layer)
        {
            Check.NullArgument (spriteBatch, "spriteBatch");
            Check.NullArgument (header, "header");

            Map currentMap = header.Map;
            ScreenPoint camOffset = TileEngine.Camera.Offset();
            ScreenPoint tileSize = currentMap.TileSize;

            for (int y = 0; y < currentMap.MapSize.Y; y++)
            {
                for (int x = 0; x < currentMap.MapSize.X; x++)
                {
                    ScreenPoint pos = new MapPoint(x, y).ToScreenPoint();
                    Rectangle des = pos.ToRect(tileSize.ToPoint());

                    Rectangle sourceRectangle = currentMap.GetLayerSourceRect(new MapPoint(x, y), layer);

                    if (sourceRectangle.IsEmpty)
                        continue;

                    spriteBatch.Draw(currentMap.Texture, des, sourceRectangle, Color.White);
                }
            }
        }
예제 #40
0
        public static void DrawLayerMap(SpriteBatch spriteBatch, MapHeader header, MapLayers layer)
        {
            Check.NullArgument (spriteBatch, "spriteBatch");

            DrawLayerMap(spriteBatch, header, layer, Color.White);
        }
예제 #41
0
        public static void DrawLayerMap(SpriteBatch spriteBatch, MapLayers layer, Color tint)
        {
            Check.NullArgument (spriteBatch, "spriteBatch");

            foreach (var header in TileEngine.WorldManager.CurrentWorld.MapList.Values)
            {
                if (!header.IsVisableToPlayer(TileEngine.Camera))
                    continue;

                TileEngine.DrawLayerMap(spriteBatch, header, layer);
            }
        }
예제 #42
0
파일: Map.cs 프로젝트: NullSoldier/Valkyrie
 public int GetLayerValue(MapPoint point, MapLayers layer)
 {
     return this.GetLayerValue (point.IntX, point.IntY, layer);
 }
예제 #43
0
파일: Map.cs 프로젝트: NullSoldier/Valkyrie
        public int GetLayerValue(int x, int y, MapLayers layer)
        {
            if (x < 0 || (x >= this.MapSize.X) || y < 0 || (y >= this.MapSize.Y))
                return -2; // throw new ArgumentOutOfRangeException("point");

            switch (layer)
            {
                default:
                case MapLayers.UnderLayer:
                    return this.UnderLayer[(int)(y * this.MapSize.X + x)];

                case MapLayers.BaseLayer:
                    return this.BaseLayer[(int)(y * this.MapSize.X + x)];

                case MapLayers.MiddleLayer:
                    return this.MiddleLayer[(int)(y * this.MapSize.X + x)];

                case MapLayers.TopLayer:
                    return this.TopLayer[(int)(y * this.MapSize.X + x)];

                case MapLayers.CollisionLayer:
                    return this.CollisionLayer[(int)(y * this.MapSize.X + x)];

                case MapLayers.OpaqueLayer:
                    return this.OpaqueLayer[(int)(y * this.MapSize.X + x)];
            }
        }
예제 #44
0
파일: Map.cs 프로젝트: NullSoldier/Valkyrie
 public void SetLayerValue(MapPoint point, MapLayers layer, int value)
 {
     this.SetLayerValue(point.IntX, point.IntY, layer, value);
 }
예제 #45
0
파일: Map.cs 프로젝트: NullSoldier/Valkyrie
        public void SetLayerValue(int x, int y,  MapLayers layer, int value)
        {
            if (x < 0 || (x > this.MapSize.X) || y < 0 || (y > this.MapSize.Y))
                throw new ArgumentOutOfRangeException("point");

            switch (layer)
            {
                default:
                case MapLayers.UnderLayer:
                    this.UnderLayer[(int)(y * this.MapSize.X + x)] = value; break;

                case MapLayers.BaseLayer:
                    this.BaseLayer[(int)(y * this.MapSize.X + x)] = value; break;

                case MapLayers.MiddleLayer:
                    this.MiddleLayer[(int)(y * this.MapSize.X + x)] = value; break;

                case MapLayers.TopLayer:
                    this.TopLayer[(int)(y * this.MapSize.X + x)] = value; break;

                case MapLayers.CollisionLayer:
                    this.CollisionLayer[(int)(y * this.MapSize.X + x)] = value; break;

                case MapLayers.OpaqueLayer:
                    this.OpaqueLayer[(int)(y * this.MapSize.X + x)] = value; break;
            }
        }
예제 #46
0
 public void DrawLayer(MapLayers layer)
 {
     this.DrawLayerMap (spritebatch, currentcamera, layer);
 }
예제 #47
0
        private void DrawLayerMap(SpriteBatch spriteBatch, BaseCamera camera, MapLayers layer)
        {
            if(camera.CurrentMap == null)
                ResolvePositionableCurrentMap(camera);

            this.DrawLayerMap(spriteBatch, camera, layer, camera.CurrentMap, Color.White);
        }
예제 #48
0
        private void DrawLayerMap(SpriteBatch spriteBatch, BaseCamera camera, MapLayers layer, MapHeader header, Color tint)
        {
            Check.NullArgument(spriteBatch, "spriteBatch");
            Check.NullArgument(header, "header");

            Map currentMap = header.Map;
            ScreenPoint camOffset = ScreenPoint.Zero;// camera.Offset;
            int tileSize = currentMap.TileSize;

            for (int y = 0; y < currentMap.MapSize.Y; y++)
            {
                for (int x = 0; x < currentMap.MapSize.X; x++)
                {
                    ScreenPoint pos = new MapPoint(x, y).ToScreenPoint() + camOffset + header.MapLocation.ToScreenPoint();
                    Rectangle des = new Rectangle(pos.IntX, pos.IntY, tileSize, tileSize);
                    MapPoint point = new MapPoint(x, y);

                    if (!camera.CheckIsVisible(des))
                        continue;

                    // Opaque only and not opaque
                    var opacity = currentMap.GetLayerValue(point, MapLayers.OpaqueLayer);

                    if (opacity >= 1)
                    {
                        var info = new Rectangle()
                        {
                            X = pos.IntX,
                            Y = pos.IntY,
                            Width = tileSize,
                            Height = tileSize
                        };

                        if(!this.lastfoginfos.Contains(info))
                            this.lastfoginfos.Add(info);
                    }

                    Rectangle sourceRectangle = currentMap.GetLayerSourceRect(point, layer);

                    if (sourceRectangle.IsEmpty)
                        continue;

                    spriteBatch.Draw(currentMap.Texture, des, sourceRectangle, tint);
                }
            }
        }