public MapTileCollection Get_MapTiles(string iMapTile) { MapTileCollection mapTileCollection = new MapTileCollection(); string str = iMapTile; if (StringType.StrCmp(str, "Outer Top Left", false) == 0) { mapTileCollection = this.Get_MapTile(this.iMapOuterTopLeft.Nodes); } else if (StringType.StrCmp(str, "Outer Top Right", false) == 0) { mapTileCollection = this.Get_MapTile(this.iMapOuterTopRight.Nodes); } else if (StringType.StrCmp(str, "Outer Bottom Left", false) == 0) { mapTileCollection = this.Get_MapTile(this.iMapOuterBottomLeft.Nodes); } else if (StringType.StrCmp(str, "Outer Bottom Right", false) == 0) { mapTileCollection = this.Get_MapTile(this.iMapOuterBottomRight.Nodes); } else if (StringType.StrCmp(str, "Inner Top Left", false) == 0) { mapTileCollection = this.Get_MapTile(this.iMapInnerTopLeft.Nodes); } else if (StringType.StrCmp(str, "Inner Top", false) == 0) { mapTileCollection = this.Get_MapTile(this.iMapInnerTop.Nodes); } else if (StringType.StrCmp(str, "Inner Top Right", false) == 0) { mapTileCollection = this.Get_MapTile(this.iMapInnerTopRight.Nodes); } else if (StringType.StrCmp(str, "Inner Left", false) == 0) { mapTileCollection = this.Get_MapTile(this.iMapInnerLeft.Nodes); } else if (StringType.StrCmp(str, "Inner Right", false) == 0) { mapTileCollection = this.Get_MapTile(this.iMapInnerRight.Nodes); } else if (StringType.StrCmp(str, "Inner Bottom Left", false) == 0) { mapTileCollection = this.Get_MapTile(this.iMapInnerBottomLeft.Nodes); } else if (StringType.StrCmp(str, "Inner Bottom", false) == 0) { mapTileCollection = this.Get_MapTile(this.iMapInnerBottom.Nodes); } else if (StringType.StrCmp(str, "Inner Bottom Right", false) == 0) { mapTileCollection = this.Get_MapTile(this.iMapInnerBottomRight.Nodes); } else if (StringType.StrCmp(str, "Autocorrect", false) == 0) { mapTileCollection = this.Get_MapTile(((ClsTerrain)this.Select_Group_B.SelectedItem).TileID); } return(mapTileCollection); }
public MapTileCollection Get_MapTile(short iTileID) { MapTileCollection mapTileCollection = new MapTileCollection(); mapTileCollection.Clear(); mapTileCollection.Add(new MapTile(iTileID, 0)); return(mapTileCollection); }
private void ActivateTileUnderMouse() { MouseState mm = Mouse.GetState(); Vector2 cameraPostition = worldCharacter.CameraPosition; Point positionOffset = worldCharacter.PositionOffset; Vector2 mouseWorldPosition = new Vector2(cameraPostition.X + mm.X, cameraPostition.Y + mm.Y); DebugConsole.WriteLine($"Mouse global tile X:{mouseWorldPosition.X} Y:{mouseWorldPosition.Y}"); DebugConsole.WriteLine($"Mouse onscreen position X:{mm.X} Y:{mm.Y}"); var x = mm.X / EngineSettings.TileSize; var y = mm.Y / EngineSettings.TileSize; int finalX = (x * EngineSettings.TileSize) - positionOffset.X +; int finalY = (y * EngineSettings.TileSize) - positionOffset.Y; DebugConsole.WriteLine($"positionOffset X:{positionOffset.X} Y:{positionOffset.Y}"); DebugConsole.WriteLine($"Mouse onscreen tile X:{finalX} Y:{finalY}"); GSS.SpriteBatch.Draw(MapTileCollection.GetTexture(), new Rectangle(new Point(finalX, finalY), TileSize), Color.Black); }
public MapTileCollection Get_MapTile(TreeNodeCollection iTreeNode) { IEnumerator enumerator = null; MapTileCollection mapTileCollection = new MapTileCollection(); mapTileCollection.Clear(); try { enumerator = iTreeNode.GetEnumerator(); while (enumerator.MoveNext()) { TreeNode current = (TreeNode)enumerator.Current; mapTileCollection.Add(new MapTile(ShortType.FromObject(current.Tag), 0)); } } finally { if (enumerator is IDisposable) { ((IDisposable)enumerator).Dispose(); } } return(mapTileCollection); }
private void DrawWorldMap() { Vector2 cameraPostition = worldCharacter.CameraPosition; Point positionOffset = worldCharacter.PositionOffset + new Point(EngineSettings.TileSize, EngineSettings.TileSize); int worldmapLength = _worldMapSpriteSet[0].Length; for (int yOffset = ((int)cameraPostition.Y * WorldInformation.mapWidth) - 1, TileY = -positionOffset.Y; yOffset < (int)(cameraPostition.Y + _halfWidthPlus) * WorldInformation.mapWidth; yOffset += WorldInformation.mapWidth, TileY += EngineSettings.TileSize) { for (int x = (int)cameraPostition.X + yOffset, TileX = -positionOffset.X; x < (int)cameraPostition.X + _halfHeightPlus + yOffset + 1; x++, TileX += EngineSettings.TileSize) { int ColorIndex = x; while (ColorIndex < yOffset) { ColorIndex += WorldInformation.mapWidth; } while (ColorIndex > yOffset + WorldInformation.mapWidth) { ColorIndex -= WorldInformation.mapWidth; } while (ColorIndex < 0) { ColorIndex += worldmapLength; } while (ColorIndex >= worldmapLength) { ColorIndex -= worldmapLength; } Color TileColor = _worldmapAnimator.Get()[ColorIndex]; Point location = new Point(TileX, TileY); if (MapTileCollection.ContainsTile(TileColor)) { if (MapTileCollection.HasSubTexture(TileColor)) { GSS.SpriteBatch.Draw(MapTileCollection.GetSubTexture(TileColor), new Rectangle(location, TileSize), _sunColor); } if (GSS.DebugMapX0Y0) { Point t = GetCoordinate(ColorIndex); GSS.SpriteBatch.Draw(MapTileCollection.GetTexture(TileColor), new Rectangle(location, TileSize), t.X == 0 || t.Y == 0 ? new Color(0, 0, 0) : _sunColor); } else { GSS.SpriteBatch.Draw(MapTileCollection.GetTexture(TileColor), new Rectangle(location, TileSize), _sunColor); } } else { GSS.SpriteBatch.Draw(MapTileCollection.GetTexture(), new Rectangle(location, TileSize), Color.Black); } } } }