예제 #1
0
        public void Draw(SpriteBatch Target)
        {
            Br.Draw(Target);
            Vs.Draw(Target);
            Cardchoose.Draw(Target);
            ChooseText.Draw(Target);
            ChooseConfirm.Draw(Target);
            ChooseOrderText.Draw(Target);

            UI_Bottom.Draw(Target);
            UI_BottomLeft.Draw(Target);
            UI_Up.Draw(Target);
            UI_UpRight.Draw(Target);
            UI_UpLeft.Draw(Target);

            EnemyTurnSprite.Draw(Target);
            EnemyTurnText.Draw(Target);
            NewTurnText.Draw(Target);

            PlayerIcon.Draw(Target);
            OpponentIcon.Draw(Target);
            PlayerName.Draw(Target);
            OpponentName.Draw(Target);
            PlayerPoints.Draw(Target);
            OpponentPoints.Draw(Target);
            PlayerMoney.Draw(Target);
            RoundTime.Draw(Target);

            foreach (var cp in CPInfos)
            {
                cp.Draw(Target);
            }

            TileName.Draw(Target);
            Btn_Move.Draw(Target);
            Btn_Attack.Draw(Target);
            Btn_EndTurn.Draw(Target);
            Btn_Stats.Draw(Target);
            Btn_GameMenu.Draw(Target);
            Btn_Chat.Draw(Target);
            Inf.Draw(Target);

            EndGame.Draw(Target);
        }
예제 #2
0
        /// <summary>
        /// Gets, if it is loaded, the tile for the specified coordinates.
        /// </summary>
        /// <param name="tileX">MSTS TileX coordinate</param>
        /// <param name="tileZ">MSTS TileZ coordinate</param>
        /// <returns>The <c>Tile</c> covering the specified coordinates, if one exists and is loaded. It may be a single tile or quad tile.</returns>
        public Tile GetTile(int tileX, int tileZ)
        {
            var  tiles = Tiles;
            Tile tile;

            // Check for 1x1 (or 8x8) tiles.
            TileName.Snap(ref tileX, ref tileZ, Zoom);
            if (tiles.ByXZ.TryGetValue(((uint)tileX << 16) + (uint)tileZ, out tile) && tile.Size == (1 << (15 - (int)Zoom)))
            {
                return(tile);
            }

            // Check for 2x2 (or 16x16) tiles.
            TileName.Snap(ref tileX, ref tileZ, Zoom - 1);
            if (tiles.ByXZ.TryGetValue(((uint)tileX << 16) + (uint)tileZ, out tile) && tile.Size == (1 << (15 - (int)Zoom + 1)))
            {
                return(tile);
            }

            return(null);
        }
예제 #3
0
 protected string CalculateQuadKey(TileName name)
 {
     var quadKey = new System.Text.StringBuilder();
     var tileX = name.X;
     var tileY = name.Y;
     for (int i = name.Zoom; i > 0; i--)
     {
         char digit = '0';
         int mask = 1 << (i - 1);
         if ((tileX & mask) != 0)
         {
             digit++;
         }
         if ((tileY & mask) != 0)
         {
             digit++;
             digit++;
         }
         quadKey.Append(digit);
     }
     return quadKey.ToString();
 }
예제 #4
0
        protected string CalculateQuadKey(TileName name)
        {
            var quadKey = new System.Text.StringBuilder();
            var tileX   = name.X;
            var tileY   = name.Y;

            for (int i = name.Zoom; i > 0; i--)
            {
                char digit = '0';
                int  mask  = 1 << (i - 1);
                if ((tileX & mask) != 0)
                {
                    digit++;
                }
                if ((tileY & mask) != 0)
                {
                    digit++;
                    digit++;
                }
                quadKey.Append(digit);
            }
            return(quadKey.ToString());
        }
예제 #5
0
        /// <summary>
        /// Translate a tile location given by tileX and tileZ, together with a zoomSize, into a single uint index
        /// </summary>
        /// <param name="tileX">The cornerIndexX-value of the tile number</param>
        /// <param name="tileZ">The cornerIndexZ-value of the tile number</param>
        /// <param name="zoomSize">The zoom size (1, 2, 8, or 16) </param>
        public uint TileIndex(int tileX, int tileZ, int zoomSize)
        {
            // tileX,Z raw data can be up to 15 bit, possibly 16. But we do not need that for a single route.
            // We also need room for zoom size, which can be 1, 2, 8, 16. To make things easy, we use 6 bits for this.
            // This leaves (32-6)/2 = 13 bits to encode the tileX,Z, each
            // To make sure they are never negative, we add 2^12 = 4096, so they are never negative.
            // Basically, this means routes that can have relative tiles ranging from about -4000 to + 4000, or 8000 * 2km = 16000 km. More than enough.

            // We also snap the tileX and tileZ to multiples of the size.
            TileName.Snap(ref tileX, ref tileZ, zoomFromInt[zoomSize]);

            uint index = ((uint)zoomSize << 26) + ((uint)(tileX - referenceTileX + 4096) << 13) + (uint)(tileZ - this.referenceTileZ + 4096);

            //debug (I guess a unit test would have been better)
            //uint indexX = (uint)(tileX - referenceTileX + 4096);
            //uint indexZ = (uint)(tileZ - referenceTileZ + 4096);
            //string debugX = Convert.ToString(indexX, 2);
            //string debugZ = Convert.ToString(indexZ, 2);
            //string debugString = Convert.ToString(index, 2);
            //if (tileX > referenceTileX)

            return(index);
        }
예제 #6
0
 public override string GetTileUrl(TileName name)
 {
     return string.Format("http://tah.openstreetmap.org/Tiles/tile/{0}/{1}/{2}.png",
                          name.Zoom,
                          name.X, name.Y);
 }
예제 #7
0
 public override string GetTileUrl(TileName name)
 {
     return(string.Format("http://khm1.google.com/kh/v=60&x={1}&s=&y={2}&z={0}&s=Gali",
                          name.Zoom,
                          name.X, name.Y));
 }
예제 #8
0
 public MapObject(TileName name, float x, float y)
 {
     Name = name;
     X    = x;
     Y    = y;
 }
예제 #9
0
		void DrawTile(TileName tile, float alpha) {
			var texture = _textures.GetTile(tile);
			
			var geo = GetGeometry(tile);
			
			if (texture == 0) {
				texture = MissingTileTexture;
			}
			GL.Color4(1.0f, 1.0f, 1.0f, alpha);
			GL.BindTexture(All.Texture2D, texture);
			GL.VertexPointer(3, All.Float, 0, geo.Verts);
			GL.TexCoordPointer(2, All.Float, 0, geo.TexVerts);
			GL.NormalPointer(All.Float, 0, geo.Norms);
			GL.DrawArrays(All.TriangleStrip, 0, geo.Verts.Length);
		}
예제 #10
0
 public override string GetTileUrl(TileName name)
 {
     return(string.Format("http://mt1.google.com/vt/lyrs=m@126&hl=en&x={1}&s=&y={2}&z={0}&s=Gali",
                          name.Zoom,
                          name.X, name.Y));
 }
예제 #11
0
 public override string GetTileUrl(TileName name)
 {
     return(string.Format("http://tah.openstreetmap.org/Tiles/tile/{0}/{1}/{2}.png",
                          name.Zoom,
                          name.X, name.Y));
 }
예제 #12
0
 public abstract string GetTileUrl(TileName name);
예제 #13
0
 public override string GetTileUrl(TileName name)
 {
     return(string.Format("http://ecn.t6.tiles.virtualearth.net/tiles/h{0}.png?g={1}&mkt=en-us&shading=hill&n=z",
                          CalculateQuadKey(name),
                          "452"));
 }
예제 #14
0
 public override string GetTileUrl(TileName name)
 {
     return(string.Format("http://c.andy.sandbox.cloudmade.com/tiles/cycle/{0}/{1}/{2}.png",
                          name.Zoom,
                          name.X, name.Y));
 }
예제 #15
0
 public abstract string GetTileUrl(TileName name);
예제 #16
0
 public override string GetTileUrl(TileName name)
 {
     return string.Format("http://ecn.t6.tiles.virtualearth.net/tiles/r{0}.png?g={1}&mkt=en-us&shading=hill&n=z",
                          CalculateQuadKey(name),
                          "452");
 }
예제 #17
0
 public override string GetTileUrl(TileName name)
 {
     return(string.Format("http://mw1.google.com/mw-planetary/lunar/lunarmaps_v1/clem_bw/{0}/{1}/{2}.jpg",
                          name.Zoom,
                          name.X, name.Y));
 }
예제 #18
0
        public bool DoConversion(DataConversion conversion)
        {
            // We can convert from .t or .w files.
            if (Path.GetExtension(conversion.Input) != ".t" && Path.GetExtension(conversion.Input) != ".w")
            {
                return(false);
            }
            // We can convert to .dae files.
            if (conversion.Output.Any(output => Path.GetExtension(output) != ".dae"))
            {
                return(false);
            }
            if (!File.Exists(conversion.Input))
            {
                throw new FileNotFoundException("", conversion.Input);
            }

            if (Path.GetExtension(conversion.Input) == ".w")
            {
                // Convert from world file to tile file, by parsing the X, Z coordinates from filename.
                var filename = Path.GetFileNameWithoutExtension(conversion.Input);
                int tileX, tileZ;
                if (filename.Length != 15 ||
                    filename[0] != 'w' ||
                    (filename[1] != '+' && filename[1] != '-') ||
                    (filename[8] != '+' && filename[8] != '-') ||
                    !int.TryParse(filename.Substring(1, 7), out tileX) ||
                    !int.TryParse(filename.Substring(8, 7), out tileZ))
                {
                    throw new InvalidCommandLineException("Unable to parse tile coordinates from world filename: " + filename);
                }
                var tilesDirectory = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(conversion.Input)), "Tiles");
                var tileName       = TileName.FromTileXZ(tileX, tileZ, TileName.Zoom.Small);
                conversion.SetInput(Path.Combine(tilesDirectory, tileName + ".t"));
            }

            var baseFileName = Path.Combine(Path.GetDirectoryName(conversion.Input), Path.GetFileNameWithoutExtension(conversion.Input));

            var tFile = new TerrainFile(baseFileName + ".t");

            var sampleCount = tFile.terrain.terrain_samples.terrain_nsamples;
            var yFile       = new TerrainAltitudeFile(baseFileName + "_y.raw", sampleCount);
            TerrainFlagsFile fFile;

            if (File.Exists(baseFileName + "_f.raw"))
            {
                fFile = new TerrainFlagsFile(baseFileName + "_f.raw", sampleCount);
            }

            var patchCount = tFile.terrain.terrain_patchsets[0].terrain_patchset_npatches;

            for (var x = 0; x < patchCount; x++)
            {
                for (var z = 0; z < patchCount; z++)
                {
                    var patch = new TerrainConverterPatch(tFile, yFile, x, z);

                    XNamespace cNS             = "http://www.collada.org/2005/11/COLLADASchema";
                    var        colladaDocument = new XDocument(
                        new XDeclaration("1.0", "UTF-8", "false"),
                        new XElement(cNS + "COLLADA",
                                     new XAttribute("version", "1.4.1"),
                                     new XElement(cNS + "asset",
                                                  new XElement(cNS + "created", DateTime.UtcNow.ToString("o")),
                                                  new XElement(cNS + "modified", DateTime.UtcNow.ToString("o"))
                                                  ),
                                     new XElement(cNS + "library_effects",
                                                  new XElement(cNS + "effect",
                                                               new XAttribute("id", "Library-Effect-GreenPhong"),
                                                               new XElement(cNS + "profile_COMMON",
                                                                            new XElement(cNS + "technique",
                                                                                         new XAttribute("sid", "phong"),
                                                                                         new XElement(cNS + "phong",
                                                                                                      new XElement(cNS + "emission",
                                                                                                                   new XElement(cNS + "color", "1.0 1.0 1.0 1.0")
                                                                                                                   ),
                                                                                                      new XElement(cNS + "ambient",
                                                                                                                   new XElement(cNS + "color", "1.0 1.0 1.0 1.0")
                                                                                                                   ),
                                                                                                      new XElement(cNS + "diffuse",
                                                                                                                   new XElement(cNS + "color", "0.0 1.0 0.0 1.0")
                                                                                                                   ),
                                                                                                      new XElement(cNS + "specular",
                                                                                                                   new XElement(cNS + "color", "1.0 1.0 1.0 1.0")
                                                                                                                   ),
                                                                                                      new XElement(cNS + "shininess",
                                                                                                                   new XElement(cNS + "float", "20.0")
                                                                                                                   ),
                                                                                                      new XElement(cNS + "reflective",
                                                                                                                   new XElement(cNS + "color", "1.0 1.0 1.0 1.0")
                                                                                                                   ),
                                                                                                      new XElement(cNS + "reflectivity",
                                                                                                                   new XElement(cNS + "float", "0.5")
                                                                                                                   ),
                                                                                                      new XElement(cNS + "transparent",
                                                                                                                   new XElement(cNS + "color", "1.0 1.0 1.0 1.0")
                                                                                                                   ),
                                                                                                      new XElement(cNS + "transparency",
                                                                                                                   new XElement(cNS + "float", "1.0")
                                                                                                                   )
                                                                                                      )
                                                                                         )
                                                                            )
                                                               )
                                                  ),
                                     new XElement(cNS + "library_materials",
                                                  new XElement(cNS + "material",
                                                               new XAttribute("id", "Library-Material-Terrain"),
                                                               new XAttribute("name", "Terrain material"),
                                                               new XElement(cNS + "instance_effect",
                                                                            new XAttribute("url", "#Library-Effect-GreenPhong")
                                                                            )
                                                               )
                                                  ),
                                     new XElement(cNS + "library_geometries",
                                                  new XElement(cNS + "geometry",
                                                               new XAttribute("id", "Library-Geometry-Terrain"),
                                                               new XAttribute("name", "Terrain geometry"),
                                                               new XElement(cNS + "mesh",
                                                                            new XElement(cNS + "source",
                                                                                         new XAttribute("id", "Library-Geometry-Terrain-Position"),
                                                                                         new XElement(cNS + "float_array",
                                                                                                      new XAttribute("id", "Library-Geometry-Terrain-Position-Array"),
                                                                                                      new XAttribute("count", patch.GetVertexArrayLength()),
                                                                                                      patch.GetVertexArray()
                                                                                                      ),
                                                                                         new XElement(cNS + "technique_common",
                                                                                                      new XElement(cNS + "accessor",
                                                                                                                   new XAttribute("source", "#Library-Geometry-Terrain-Position-Array"),
                                                                                                                   new XAttribute("count", patch.GetVertexLength()),
                                                                                                                   new XAttribute("stride", 3),
                                                                                                                   new XElement(cNS + "param",
                                                                                                                                new XAttribute("name", "X"),
                                                                                                                                new XAttribute("type", "float")
                                                                                                                                ),
                                                                                                                   new XElement(cNS + "param",
                                                                                                                                new XAttribute("name", "Y"),
                                                                                                                                new XAttribute("type", "float")
                                                                                                                                ),
                                                                                                                   new XElement(cNS + "param",
                                                                                                                                new XAttribute("name", "Z"),
                                                                                                                                new XAttribute("type", "float")
                                                                                                                                )
                                                                                                                   )
                                                                                                      )
                                                                                         ),
                                                                            new XElement(cNS + "vertices",
                                                                                         new XAttribute("id", "Library-Geometry-Terrain-Vertex"),
                                                                                         new XElement(cNS + "input",
                                                                                                      new XAttribute("semantic", "POSITION"),
                                                                                                      new XAttribute("source", "#Library-Geometry-Terrain-Position")
                                                                                                      )
                                                                                         ),
                                                                            new XElement(cNS + "polygons",
                                                                                         new XObject[] {
                        new XAttribute("count", patch.GetPolygonLength()),
                        new XAttribute("material", "MATERIAL"),
                        new XElement(cNS + "input",
                                     new XAttribute("semantic", "VERTEX"),
                                     new XAttribute("source", "#Library-Geometry-Terrain-Vertex"),
                                     new XAttribute("offset", 0)
                                     )
                    }.Concat(patch.GetPolygonArray().Select(polygon => (XObject) new XElement(cNS + "p", polygon)))
                                                                                         )
                                                                            )
                                                               )
                                                  ),
                                     // Move nodes into <library_nodes/> to make them individual components in SketchUp.
                                     //new XElement(cNS + "library_nodes",
                                     //),
                                     new XElement(cNS + "library_visual_scenes",
                                                  new XElement(cNS + "visual_scene",
                                                               new XAttribute("id", "VisualScene-Default"),
                                                               new XElement(cNS + "node",
                                                                            new XAttribute("id", "Node-Terrain"),
                                                                            new XAttribute("name", "Terrain"),
                                                                            new XElement(cNS + "instance_geometry",
                                                                                         new XAttribute("url", "#Library-Geometry-Terrain"),
                                                                                         new XElement(cNS + "bind_material",
                                                                                                      new XElement(cNS + "technique_common",
                                                                                                                   new XElement(cNS + "instance_material",
                                                                                                                                new XAttribute("symbol", "MATERIAL"),
                                                                                                                                new XAttribute("target", "#Library-Material-Terrain")
                                                                                                                                )
                                                                                                                   )
                                                                                                      )
                                                                                         )
                                                                            )
                                                               )
                                                  ),
                                     new XElement(cNS + "scene",
                                                  new XElement(cNS + "instance_visual_scene",
                                                               new XAttribute("url", "#VisualScene-Default")
                                                               )
                                                  )
                                     )
                        );

                    foreach (var output in conversion.Output)
                    {
                        var fileName = Path.ChangeExtension(output, string.Format("{0:00}-{1:00}.dae", x, z));
                        colladaDocument.Save(fileName);
                    }
                }
            }

            return(true);
        }
예제 #19
0
파일: Content.cs 프로젝트: Fobur/RPG
        public static Content GetGameObject(TileName name, Zones zone)
        {
            var ret = new Content();

            switch (name)
            {
            case TileName.Hub:
                ret.Image      = Hub;
                ret.Background = Grass;
                ret.Cost       = 1;
                break;

            case TileName.Mountain:
                ret.Image      = Mountain;
                ret.Background = Grass;
                ret.Cost       = 5;
                break;

            case TileName.River:
                ret.Image      = Empty;
                ret.Background = River;
                ret.Cost       = 2;
                break;

            case TileName.Meadow:
                ret.Image      = Empty;
                ret.Background = Grass;
                ret.Cost       = 1;
                break;

            case TileName.Desert:
                ret.Image      = Empty;
                ret.Background = Desert;
                ret.Cost       = 2;
                break;

            case TileName.Forest:
                ret.Image      = Forest;
                ret.Background = Grass;
                ret.Cost       = 2;
                break;

            case TileName.Swamp:
                ret.Image      = Empty;
                ret.Background = Swamp;
                ret.Cost       = 3;
                break;

            case TileName.Tundra:
                ret.Image      = SnowForest;
                ret.Background = Snow;
                ret.Cost       = 2;
                break;

            case TileName.TropicalForest:
                ret.Image      = Jungle;
                ret.Background = Grass;
                ret.Cost       = 2;
                break;

            default:
                ret.Image      = NoTexture;
                ret.Background = Empty;
                break;
            }

            ret.Difficulty = zone switch
            {
                Zones.HubZone => 0,
                Zones.GreenZone => 1,
                Zones.FrointerZone => 2,
                Zones.UnknownZone => 3,
                _ => ret.Difficulty
            };
            return(ret);
        }
예제 #20
0
		void DrawTiles(Camera cam, TileName centerTile, float alpha) {
			//
			// Determine the number of tiles to show
			//
			int minX=99999999, minY=99999999, maxX=0, maxY=0;
			for (var i = 0; i < cam.ScreenLocations.Length; i++) {
				var loc = cam.ScreenLocations[i];
				if (loc != null) {
					var c = TileName.FromLocation(loc, centerTile.Zoom);
					minX = Math.Min(c.X, minX);
					minY = Math.Min(c.Y, minY);
					maxX = Math.Max(c.X, maxX);
					maxY = Math.Max(c.Y, maxY);
				}
			}
			minX = Math.Min(centerTile.X, minX);
			minY = Math.Min(centerTile.Y, minY);
					maxX = Math.Max(centerTile.X, maxX);
					maxY = Math.Max(centerTile.Y, maxY);
			minX-=1;
			minY-=1;
			maxX+=1;
			maxY+=1;
			
			//
			// Draw them
			//
			var nd = 0;
			var tile = new TileName() { Zoom = centerTile.Zoom };
			
			var n = (int)Math.Pow(2, tile.Zoom);
			
			foreach (var p in RenderOrder) {
				tile.X = centerTile.X + p.X;
				tile.Y = centerTile.Y + p.Y;
				
				while (tile.X < 0) tile.X += n;
				while (tile.Y < 0) tile.Y += n;
				while (tile.X >= n) tile.X -= n;
				while (tile.Y >= n) tile.Y -= n;

				if (tile.X < minX || tile.Y < minY) continue;
				if (tile.X > maxX || tile.Y > maxY) continue;
				
				DrawTile(tile, alpha);
				nd ++;
			}
		}
예제 #21
0
 public override string GetTileUrl(TileName name)
 {
     return string.Format("http://c.andy.sandbox.cloudmade.com/tiles/cycle/{0}/{1}/{2}.png",
                          name.Zoom,
                          name.X, name.Y);
 }
예제 #22
0
		Geometry GetGeometry(TileName tile) {
			
			var g = _geometries[tile];
			
			if (g == null) {
				g = new Geometry();
				
				var locs = tile.GetCornerLocations();
				
				g.Verts = new OpenTK.Vector3[locs.Length];
				g.Norms = new OpenTK.Vector3[locs.Length];
				for (var i = 0; i < locs.Length; i++) {
					var p = locs[i].ToPositionAboveSeaLevel(0);
					g.Verts[i] = p;
					p.Normalize();
					g.Norms[i] = p;
					//Console.WriteLine (g.Verts[i]);
				}
				
				g.TexVerts = new Vector2[locs.Length];
				var up = Source.FlipVertical ? 0.0f : 1.0f;
				var down = 1.0f - up;
				g.TexVerts[0] = new Vector2(1.0f, up);
				g.TexVerts[1] = new Vector2(0, up);
				g.TexVerts[2] = new Vector2(1.0f, down);
				g.TexVerts[3] = new Vector2(0, down);
				
				_geometries[tile] = g;
			}
			
			return g;
		}
예제 #23
0
 public override string GetTileUrl(TileName name)
 {
     return string.Format("http://mw1.google.com/mw-planetary/lunar/lunarmaps_v1/clem_bw/{0}/{1}/{2}.jpg",
                          name.Zoom,
                          name.X, name.Y);
 }
예제 #24
0
        public void Update()
        {
            fileNameBox.position = new Vector2(0 * elemWidth + 1 * offset, bannedY / 2 - elemHeight / 2);
            camera.offset        = new Vector2(Raylib.GetScreenWidth(), Raylib.GetScreenHeight()) / 2;

            //side buttons for tile selecting
            for (var i = 0; i < tileButtons.Count; i++)
            {
                var b = tileButtons[i].button;
                tileButtons[i].button.position = new Vector2(Raylib.GetScreenWidth() - bannedX / 2 - b.size.X / 2, i * 70 + bannedY + 10);
                tileButtons[i].tint            = i == (int)selectedObject ? Color.WHITE : Color.GRAY;
                if (b.Active())
                {
                    selectedObject = (TileName)i;
                }
            }

            //camera movement with middle button
            if (Raylib.IsMouseButtonPressed(MouseButton.MOUSE_MIDDLE_BUTTON))
            {
                cameraFollowMouse = true;
                clickMousePos     = Raylib.GetMousePosition();
                clickCameraPos    = camera.target;
            }
            if (Raylib.IsMouseButtonReleased(MouseButton.MOUSE_MIDDLE_BUTTON))
            {
                cameraFollowMouse = false;
            }

            if (cameraFollowMouse)
            {
                camera.target = clickCameraPos + (clickMousePos - Raylib.GetMousePosition()) / camera.zoom;
            }


            var mouse = Raylib.GetMousePosition();

            if (mouse.X < Raylib.GetScreenWidth() - bannedX && mouse.Y > bannedY)
            {
                //add tile on mouse left pressed
                if ((Raylib.IsMouseButtonDown(MouseButton.MOUSE_LEFT_BUTTON) && showGrid) || Raylib.IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON))
                {
                    var p         = camera.target + (mouse - camera.offset) / camera.zoom;
                    var texture   = Texture.Tile[selectedObject].texture;
                    var pos       = showGrid ? PointToTile(p) : p - new Vector2(texture.width, texture.height) / 2;
                    var mapObject = new MapObject(selectedObject, pos.X, pos.Y);
                    var contains  = false;
                    foreach (var o in objects)
                    {
                        if (o.X == mapObject.X && o.Y == mapObject.Y)
                        {
                            contains = true;
                        }
                    }
                    if (!contains)
                    {
                        objects.Add(mapObject);
                    }
                }

                //remove tile on mouse right pressed
                if (Raylib.IsMouseButtonDown(MouseButton.MOUSE_RIGHT_BUTTON))
                {
                    var p = camera.target + (mouse - camera.offset) / camera.zoom;
                    for (var i = objects.Count - 1; i >= 0; i--)
                    {
                        var o = objects[i];
                        var t = Texture.Tile[o.Name].texture;
                        if (p.X > o.X && p.Y > o.Y && p.X < o.X + t.width && p.Y < o.Y + t.height)
                        {
                            objects.RemoveAt(i);
                        }
                    }
                }

                //camera zoom
                camera.zoom += Raylib.GetMouseWheelMove() / 10;
                camera.zoom  = Math.Clamp(camera.zoom, 0.1f, 5);
            }


            //shortcut keys
            if (Raylib.IsKeyDown(KeyboardKey.KEY_LEFT_CONTROL))
            {
                if (Raylib.IsKeyPressed(KeyboardKey.KEY_G))
                {
                    showGrid = !showGrid;
                }

                if (Raylib.IsKeyPressed(KeyboardKey.KEY_S))
                {
                    Save();
                }

                if (Raylib.IsKeyPressed(KeyboardKey.KEY_L))
                {
                    objects = Load(fileNameBox.text);
                }

                if (Raylib.IsKeyPressed(KeyboardKey.KEY_P))
                {
                    Program.scene = new World();
                }
            }
        }
예제 #25
0
 public override string GetTileUrl(TileName name)
 {
     return string.Format("http://khm1.google.com/kh/v=60&x={1}&s=&y={2}&z={0}&s=Gali",
                          name.Zoom,
                          name.X, name.Y);
 }
예제 #26
0
 public override string GetTileUrl(TileName name)
 {
     return string.Format("http://mt1.google.com/vt/lyrs=m@126&hl=en&x={1}&s=&y={2}&z={0}&s=Gali",
                          name.Zoom,
                          name.X, name.Y);
 }
예제 #27
0
        public void LoadTiles()
        {
            string[,] map = { { null,         null,        null,                    null,                   "LeaveCaveRoom" },
                              { null,         null,        "FindGoldRoom",          "EmptyRoom",            "DragonRoom"    },
                              { null,         null,        "EmptyRoom",             null,                   "FindGoldRoom"  },
                              { null,         null,        "EmptyRoom",             null,                   null            },
                              { "GoblinRoom", "EmptyRoom", "StartingRoom",          "FindDaggerRoom",       null            },
                              { null,         null,        "EmptyRoom",             null,                   null            },
                              { null,         null,        "OgreRoom",              "FindHealthPotionRoom", null            },
                              { null,         null,        "FindUltimateSwordRoom", null,                   null            }, };
            //string PathFile = "C:\\Users\\bunchmattsource\\repos\\TextAdventure\\TextAdventure\\resources\\map.txt";
            //StreamReader streamReader = new StreamReader(PathFile);
            // open resource file
            //int counter = NumOfLines(PathFile);
            //string[] rows = new string[counter];

            //for (int i = 0; i < counter; i++)
            //{
            //    rows[i] = streamReader.ReadLine();
            //}

            for (int y = 0; y < map.GetLength(1); y++)
            {
                for (int x = 0; x < map.GetLength(0); x++)
                {
                    string TileName;
                    if (map[x, y] != null)
                    {
                        TileName = map[x, y].Replace("\n", "");
                    }
                    else
                    {
                        TileName = null;
                    }

                    if (TileName != null)
                    {
                        if (TileName.Equals("StartingRoom"))
                        {
                            StartingPosition[0] = x;
                            StartingPosition[1] = y;
                        }
                    }

                    int[] position = { x, y };
                    //Console.WriteLine(TileName + " position: x:" + position[0] + ", y:" + position[1]);


                    if (TileName == null)
                    {
                        _world.Add(position, null);
                    }
                    else if (TileName.Equals("StartingRoom"))
                    {
                        _world.Add(position, new StartingRoom(x, y));
                    }
                    else if (TileName.Equals("LeaveCaveRoom"))
                    {
                        _world.Add(position, new LeaveCaveRoom(x, y));
                    }
                    else if (TileName.Equals("EmptyRoom"))
                    {
                        _world.Add(position, new EmptyRoom(x, y));
                    }
                    else if (TileName.Equals("GoblinRoom"))
                    {
                        _world.Add(position, new GoblinRoom(x, y));
                    }
                    else if (TileName.Equals("OgreRoom"))
                    {
                        _world.Add(position, new OgreRoom(x, y));
                    }
                    else if (TileName.Equals("DragonRoom"))
                    {
                        _world.Add(position, new DragonRoom(x, y));
                    }
                    else if (TileName.Equals("FindDaggerRoom"))
                    {
                        _world.Add(position, new FindDaggerRoom(x, y));
                    }
                    else if (TileName.Equals("FindGoldRoom"))
                    {
                        _world.Add(position, new FindGoldRoom(x, y));
                    }
                    else if (TileName.Equals("FindHealthPotionRoom"))
                    {
                        _world.Add(position, new FindHealthPotionRoom(x, y));
                    }
                    else if (TileName.Equals("FindUltimateSwordRoom"))
                    {
                        _world.Add(position, new FindUltimateSwordRoom(x, y));
                    }

                    // debugging
                    //Console.WriteLine("x: " + x);
                    //Console.WriteLine("y: " + y);
                }
            }
            //Print_World();
        }