✨ Switchable tiles
This commit is contained in:
		| @@ -18,7 +18,8 @@ | ||||
| 	"durability": 200, | ||||
| 	"buildTime": 3.0, | ||||
| 	"allowedRotations": [0], | ||||
| 	"layer": 1 | ||||
| 	"layer": 1, | ||||
| 	"size": [3, 3] | ||||
|   }, | ||||
|   "ground": { | ||||
| 	"scene": "res://Scenes/Tiles/GroundTile.tscn", | ||||
|   | ||||
| @@ -23,3 +23,4 @@ offset_left = -27.0 | ||||
| offset_top = -27.0 | ||||
| offset_right = 27.0 | ||||
| offset_bottom = 27.0 | ||||
| metadata/_edit_use_anchors_ = true | ||||
|   | ||||
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 438 KiB After Width: | Height: | Size: 506 KiB | 
| @@ -2,7 +2,7 @@ | ||||
|  | ||||
| importer="texture" | ||||
| type="CompressedTexture2D" | ||||
| uid="uid://bn80thu20eaia" | ||||
| uid="uid://bt6xmcgrbb078" | ||||
| path="res://.godot/imported/MinerTile.png-a6c5eba73cdda5685afda8ced0234fec.ctex" | ||||
| metadata={ | ||||
| "vram_texture": false | ||||
|   | ||||
| @@ -1,12 +1,13 @@ | ||||
| [gd_scene load_steps=4 format=3 uid="uid://cbu81slklwq3u"] | ||||
|  | ||||
| [ext_resource type="Script" uid="uid://dyubkyqtpcg3a" path="res://Scripts/Tiles/MinerTile.cs" id="1_mecoy"] | ||||
| [ext_resource type="Texture2D" uid="uid://bn80thu20eaia" path="res://Scenes/Tiles/MinerTile.png" id="2_mecoy"] | ||||
| [ext_resource type="Texture2D" uid="uid://bt6xmcgrbb078" path="res://Scenes/Tiles/MinerTile.png" id="2_mecoy"] | ||||
|  | ||||
| [sub_resource type="RectangleShape2D" id="RectangleShape2D_8o613"] | ||||
| size = Vector2(54, 54) | ||||
|  | ||||
| [node name="MinerTile" type="StaticBody2D"] | ||||
| scale = Vector2(3, 3) | ||||
| script = ExtResource("1_mecoy") | ||||
| TileId = "miner" | ||||
|  | ||||
|   | ||||
| @@ -1,4 +1,5 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using AceFieldNewHorizon.Scripts.Tiles; | ||||
| using Godot; | ||||
| using System.Linq; | ||||
| @@ -10,6 +11,8 @@ public partial class PlacementManager : Node2D | ||||
|     [Export] public GridManager Grid { get; set; } | ||||
|     [Export] public BuildingRegistry Registry { get; set; } | ||||
|  | ||||
|     private static readonly List<string> BuildableTiles = ["wall", "miner"]; | ||||
|  | ||||
|     private string _currentBuildingId = "wall"; | ||||
|     private Vector2I _hoveredCell; | ||||
|     private BaseTile _ghostBuilding; | ||||
| @@ -144,6 +147,13 @@ public partial class PlacementManager : Node2D | ||||
|             building.QueueFree(); | ||||
|             Grid.FreeArea(buildingInfo.Value.Position, buildingInfo.Value.Size, buildingInfo.Value.Rotation); | ||||
|         } | ||||
|  | ||||
|         if (Input.IsActionJustPressed("switch_tile")) | ||||
|         { | ||||
|             var currentIdx = BuildableTiles.IndexOf(_currentBuildingId); | ||||
|             var nextIdx = (currentIdx + 1) % BuildableTiles.Count; | ||||
|             SetCurrentBuilding(BuildableTiles[nextIdx]); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private bool CanPlaceBuilding() | ||||
|   | ||||
| @@ -70,18 +70,13 @@ move_sprint={ | ||||
| "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194325,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) | ||||
| ] | ||||
| } | ||||
| camera_zoom_in={ | ||||
| switch_tile={ | ||||
| "deadzone": 0.2, | ||||
| "events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":8,"position":Vector2(437, 34),"global_position":Vector2(456, 130),"factor":0.0300018,"button_index":4,"canceled":false,"pressed":true,"double_click":false,"script":null) | ||||
| ] | ||||
| } | ||||
| camera_zoom_out={ | ||||
| "deadzone": 0.2, | ||||
| "events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":16,"position":Vector2(583, 50),"global_position":Vector2(602, 146),"factor":0.437677,"button_index":5,"canceled":false,"pressed":true,"double_click":false,"script":null) | ||||
| "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":93,"key_label":0,"unicode":93,"location":0,"echo":false,"script":null) | ||||
| ] | ||||
| } | ||||
|  | ||||
| [rendering] | ||||
|  | ||||
| renderer/rendering_method="gl_compatibility" | ||||
| renderer/rendering_method.mobile="gl_compatibility" | ||||
| anti_aliasing/quality/msaa_2d=3 | ||||
| anti_aliasing/quality/use_taa=true | ||||
|   | ||||
		Reference in New Issue
	
	Block a user