public override void ProcessingOfClicks(GameTime gameTime) { if (!IsActive) { return; } if (InputManager.MouseStates.LeftButton == ButtonState.Pressed && InputManager.LastMouseStates.LeftButton == ButtonState.Released && InputManager.MouseStates.X >= Position.X && InputManager.MouseStates.Y >= Position.Y && InputManager.MouseStates.X <= (Position.X + buildingStocksArea.Width) && InputManager.MouseStates.Y <= (Position.Y + buildingStocksArea.Height)) { foreach (UITextureDemo tdemo in TexturesDemo) { tdemo.ProcessingOfClicks(gameTime); if (tdemo.Clicked) { Clicked = true; MapEntryTextureType tmp; Enum.TryParse(tdemo.TextureTypeName, out tmp); currentTextureType = tmp; } } } else if (InputManager.IsNewPressedAnyMouseButton()) { IsActive = false; } base.ProcessingOfClicks(gameTime); }
/// <summary> /// Изменение типа текстуры /// </summary> /// <param name="type">Тип текстуры</param> /// <param name="countTileTypes">Количество тайлов в один ряд (кол-во столбцов). Для рандомности выбора однотипной текстуры</param> public void ChangeType(MapEntryTextureType type, int countTileTypes = 5) { cntTileTypes = Math.Max(0, countTileTypes); switch (type) { //None (стираем всё) case MapEntryTextureType.None: default: CollidingTexture = null; CollideTextureType = MapEntryTextureType.None; NonCollidingTexture = null; NonCollideTextureType = MapEntryTextureType.None; DecorateTexture = null; DecorateTextureType = MapEntryTextureType.None; break; //CollideTexture case MapEntryTextureType.Dirt: case MapEntryTextureType.Gold: case MapEntryTextureType.Grass: case MapEntryTextureType.Silver: case MapEntryTextureType.Stone: if (CollideTextureType != type) { CollideTextureType = type; TileStartPoint = new Point(rnd.Next(0, cntTileTypes), 0); TilesRow = 0; WatchNearbyCells = false; CollidingTexture = TextureManager.GetTexture(TextureType.Tilesets, CollideTextureType.ToString()); } break; //NonCollideTexture case MapEntryTextureType.BackDirt: case MapEntryTextureType.BackWall: if (NonCollideTextureType != type || CollidingTexture != null) { NonCollideTextureType = type; TileStartPoint = new Point(rnd.Next(0, cntTileTypes), 0); TilesRow = 0; WatchNearbyCells = true; NonCollidingTexture = TextureManager.GetTexture(TextureType.Tilesets, NonCollideTextureType.ToString()); CollideTextureType = MapEntryTextureType.None; CollidingTexture = null; } break; } }
/// <summary> /// Устанавливаем текстуру в ячейку карты /// </summary> /// <param name="mapEntryTexture">Тип текстуры</param> /// <param name="x">Адрес ячейки. Столбец</param> /// <param name="y">Адрес ячейки. Строка</param> public void SetTexture(MapEntryTextureType mapEntryTexture, int x, int y) { map[y, x].ChangeType(mapEntryTexture); map[y, x].Refresh = true; }