updating movement and added a bucket, still some clean up to do on movement. TODO: if enemy becomes stuck, reclculate path.
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://m1mlr1s38on8"
|
||||
path="res://.godot/imported/bucket.png-4311011eff24918ebca7b2ac543f4bea.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Art/bucket.png"
|
||||
dest_files=["res://.godot/imported/bucket.png-4311011eff24918ebca7b2ac543f4bea.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 334 B |
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dpwvh7kwkyfqi"
|
||||
path="res://.godot/imported/bucket_bottom.png-5ddd021ef89e7830e28acc827066d67c.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Art/bucket_bottom.png"
|
||||
dest_files=["res://.godot/imported/bucket_bottom.png-5ddd021ef89e7830e28acc827066d67c.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://baukn3uw3c3c3"
|
||||
path="res://.godot/imported/bucket_top.png-99768a6b7a98df6d51966e9a1d3b56d2.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Art/bucket_top.png"
|
||||
dest_files=["res://.godot/imported/bucket_top.png-99768a6b7a98df6d51966e9a1d3b56d2.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.7 KiB |
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bekb6ulekgb0b"
|
||||
path="res://.godot/imported/tile_set_hex.png-4e21f3d721b662d063b200f1e5a89a7d.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Art/tile_set_hex.png"
|
||||
dest_files=["res://.godot/imported/tile_set_hex.png-4e21f3d721b662d063b200f1e5a89a7d.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
@@ -5,6 +5,8 @@ public partial class Attack : RigidBody2D
|
||||
{
|
||||
[Signal]
|
||||
public delegate void HitEventHandler(Node NODE);
|
||||
[Signal]
|
||||
public delegate void BucketEnteredEventHandler();
|
||||
|
||||
public bool _hovered = false;
|
||||
public int _damage = 1;
|
||||
@@ -15,6 +17,7 @@ public partial class Attack : RigidBody2D
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
|
||||
_predictionPath = GetNode<Path2D>("PredictedPath");
|
||||
}
|
||||
|
||||
@@ -35,10 +38,14 @@ public partial class Attack : RigidBody2D
|
||||
_predictionPath.Curve.AddPoint(POINTS[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void EnteredBucket()
|
||||
{
|
||||
EmitSignal(SignalName.BucketEntered);
|
||||
}
|
||||
|
||||
public void Shoot(Vector2 FORCE){
|
||||
_speed = FORCE;
|
||||
// Set("velocity", FORCE);
|
||||
GravityScale = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class Bucket : Node2D
|
||||
{
|
||||
|
||||
[Signal]
|
||||
public delegate void AttackEnteredEventHandler(Attack ATTACK);
|
||||
public int _minX = -500, _maxX = 500, _movementSign = 1, _movementSpeed = 3;
|
||||
|
||||
public void Move()
|
||||
{
|
||||
Position += new Vector2(_movementSign * _movementSpeed, 0);
|
||||
if (Position.X >= _maxX || Position.X <= _minX)
|
||||
{
|
||||
_movementSign *= -1;
|
||||
}
|
||||
}
|
||||
public void OnBodyEntered(Node2D BODY)
|
||||
{
|
||||
if (BODY is Attack attack)
|
||||
{
|
||||
EmitSignal(SignalName.AttackEntered, attack);
|
||||
attack.EnteredBucket();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://cn8hskwnfxc8f
|
||||
+10
-1
@@ -21,11 +21,19 @@ public partial class Commander : Sprite2D
|
||||
{
|
||||
_attack.QueueFree();
|
||||
_attack = null;
|
||||
EmitSignal(SignalName.ActionsUp);
|
||||
if (_actions <= 0)
|
||||
{
|
||||
EmitSignal(SignalName.ActionsUp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AttackEnteredBucket()
|
||||
{
|
||||
_actions += (_actions + 1) > _actionsMax ? 0 : 1;
|
||||
}
|
||||
|
||||
public void LoadAttack(Vector2 OFFSET)
|
||||
{
|
||||
if (_attack == null)
|
||||
@@ -34,6 +42,7 @@ public partial class Commander : Sprite2D
|
||||
_attack.Position = OFFSET;
|
||||
_attack._commanderOwner = this;
|
||||
_attack.GravityScale = 0;
|
||||
_attack.BucketEntered += AttackEnteredBucket;
|
||||
AddChild(_attack);
|
||||
}
|
||||
}
|
||||
|
||||
+49
-11
@@ -27,10 +27,29 @@ public partial class EnemyController : TurnController
|
||||
AddChild(newEnemy);
|
||||
}
|
||||
}
|
||||
public void AddEnemies(List<Vector2I> POSITIONS)
|
||||
{
|
||||
for (int i = 0; i < POSITIONS.Count; i++)
|
||||
{
|
||||
Enemy newEnemy = _enemyScene.Instantiate<Enemy>();
|
||||
newEnemy.Death += RemoveEnemy;
|
||||
|
||||
newEnemy._speed = Globals._rng.Next(2,4+1);
|
||||
newEnemy.Modulate = new Color(newEnemy._speed == 2 ? "#FF0000" : newEnemy._speed == 3 ? "#00FF00" : "#0000FF");
|
||||
newEnemy._enemyController = this;
|
||||
|
||||
WarpEnemy(newEnemy, POSITIONS[i]);
|
||||
_enemies.Add(newEnemy);
|
||||
AddChild(newEnemy);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Initiate()
|
||||
{
|
||||
AddEnemies(3);
|
||||
List<Vector2I> positions = [.. _playArea.GetNode<TileMapLayer>("InitialPositions").GetUsedCells()];
|
||||
|
||||
AddEnemies(positions);
|
||||
}
|
||||
|
||||
public void MoveEnemies()
|
||||
@@ -38,36 +57,51 @@ public partial class EnemyController : TurnController
|
||||
Tween tween = CreateTween();
|
||||
tween.SetParallel();
|
||||
Dictionary<Enemy, List<Vector2I>> enemyPaths = new();
|
||||
Dictionary<Enemy, int> enemyOffsets = new();
|
||||
_enemies = [.. _enemies.OrderBy(e => e._address.Y).ThenBy(e => e._address.X)];
|
||||
for (int i = 0; i < _enemies.Count; i++)
|
||||
{
|
||||
Enemy enemy = _enemies[i];
|
||||
List<Vector2I> path = _playArea._map.GetPath(enemy._address, new Vector2I(enemy._address.X, _playArea._map._minY));
|
||||
enemyPaths[enemy] = path;
|
||||
enemyOffsets[enemy] = 0;
|
||||
}
|
||||
|
||||
int maxSpeed = _enemies.Max(e => e._speed);
|
||||
|
||||
for (int i = 0; i < maxSpeed; i++)
|
||||
{
|
||||
for (int j = 0; j < enemyPaths.Count; j++)
|
||||
for (int j = 0; j < _enemies.Count; j++)
|
||||
{
|
||||
Enemy enemy = enemyPaths.ElementAt(j).Key;
|
||||
if (i >= enemy._speed)
|
||||
Enemy enemy = _enemies[j];
|
||||
int offset = enemyOffsets[enemy];
|
||||
if (i >= enemy._speed - offset)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
List<Vector2I> path = enemyPaths.ElementAt(j).Value;
|
||||
Vector2I cell = path[i];
|
||||
enemy._address = cell;
|
||||
if (j == 0)
|
||||
List<Vector2I> path = enemyPaths[enemy];
|
||||
Vector2I cell = path[i - offset];
|
||||
|
||||
if (_playArea._map.GetOccupant(cell) == null)
|
||||
{
|
||||
tween.Chain();
|
||||
_playArea._map.SetCellEnemy(enemy._address, null);
|
||||
enemy._address = cell;
|
||||
_playArea._map.SetCellEnemy(enemy._address, enemy);
|
||||
if (j == 0)
|
||||
{
|
||||
tween.Chain();
|
||||
}
|
||||
else
|
||||
{
|
||||
tween.Parallel();
|
||||
}
|
||||
tween.TweenProperty(enemy, "global_position", _playArea._map.GetCellPositionFromAddress(enemy._address), .2f);
|
||||
}
|
||||
else
|
||||
{
|
||||
tween.Parallel();
|
||||
enemyOffsets[enemy]++;
|
||||
}
|
||||
tween.TweenProperty(enemy, "global_position", _playArea._map.GetCellPositionFromAddress(enemy._address), .2f);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +124,11 @@ public partial class EnemyController : TurnController
|
||||
|
||||
public void WarpEnemy(Enemy ENEMY, Vector2I CELL)
|
||||
{
|
||||
|
||||
_playArea._map.SetCellEnemy(ENEMY._address, null);
|
||||
ENEMY._address = CELL;
|
||||
|
||||
_playArea._map.SetCellEnemy(ENEMY._address, ENEMY);
|
||||
ENEMY.GlobalPosition = _playArea._map.GetCellPositionFromAddress(CELL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ public partial class Map : TileMapLayer
|
||||
public Vector2I _pathTakenAtlasCoordinates = new Vector2I(4, 0);
|
||||
public List<Vector2I> _leftmostColumn, _rightmostColumn, _topRow, _bottomRow;
|
||||
public AStarGrid2D _astar = new();
|
||||
public Dictionary<Vector2I, Enemy> _addressOccupants = new();
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
@@ -25,21 +26,35 @@ public partial class Map : TileMapLayer
|
||||
_rightmostColumn = [.. cells.Where(c => c.X == _maxX)];
|
||||
_topRow = [.. cells.Where(c => c.Y == _minY)];
|
||||
_bottomRow = [.. cells.Where(c => c.Y == _maxY)];
|
||||
|
||||
cells.ForEach(c => SetCellEnemy(c, null));
|
||||
_sizeInCells = new Vector2(_topRow.Count, _leftmostColumn.Count);
|
||||
_sizeInPixels = _sizeInCells * _cellSize;
|
||||
|
||||
SetupAstar();
|
||||
}
|
||||
|
||||
|
||||
public Vector2 GetCellPositionFromAddress(Vector2I CELL_ADDRESS)
|
||||
{
|
||||
return GlobalPosition + CELL_ADDRESS * _cellSize + _cellSize / 2;
|
||||
}
|
||||
|
||||
public Enemy GetOccupant(Vector2I CELL_TO_CHECK)
|
||||
{
|
||||
return _addressOccupants[CELL_TO_CHECK];
|
||||
}
|
||||
|
||||
public bool IsCellSolid(Vector2I CELL_TO_CHECK)
|
||||
{
|
||||
return (bool)GetCellTileData(CELL_TO_CHECK).GetCustomData(_isSolidString);
|
||||
bool hasOccupant = GetOccupant(CELL_TO_CHECK) != null;
|
||||
bool isSolid = (bool)GetCellTileData(CELL_TO_CHECK).GetCustomData(_isSolidString);
|
||||
return hasOccupant || isSolid;
|
||||
}
|
||||
|
||||
public void SetCellEnemy(Vector2I ADDRESS, Enemy ENEMY)
|
||||
{
|
||||
_addressOccupants[ADDRESS] = ENEMY;
|
||||
IsCellSolid(ADDRESS);
|
||||
}
|
||||
|
||||
public void SetupAstar()
|
||||
|
||||
@@ -8,10 +8,12 @@ public partial class PlayArea : Node2D
|
||||
public Node2D _leftEdge, _rightEdge;
|
||||
public Area2D _region;
|
||||
public Map _map;
|
||||
public Bucket _bucket;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
_bucket = GetNode<Bucket>("Bucket");
|
||||
_region = GetNode<Area2D>("Region");
|
||||
|
||||
_leftEdge = GetNode<Node2D>("LeftEdge");
|
||||
@@ -21,5 +23,11 @@ public partial class PlayArea : Node2D
|
||||
|
||||
_map = GetNode<Map>("Map");
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
base._Process(delta);
|
||||
_bucket.Move();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+55
-28
File diff suppressed because one or more lines are too long
+1
-2
@@ -22,7 +22,7 @@ public partial class PlayerController : TurnController
|
||||
}
|
||||
}
|
||||
|
||||
public void SetUpTowers(int TOWER_COUNT = 8)
|
||||
public void SetUpTowers(int TOWER_COUNT = 5)
|
||||
{
|
||||
Tower tower = GetNode<Tower>("Tower1");
|
||||
Vector2 towerPositionCorrection = tower._offset.Position;
|
||||
@@ -48,7 +48,6 @@ public partial class PlayerController : TurnController
|
||||
public override void StartTurn()
|
||||
{
|
||||
_towers.ForEach(t => t.StartTurn());
|
||||
// _towers.Where(t=> t._commander != null).ToList().ForEach(t=>t._commander._actions = t._commander._actionsMax);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -116,7 +116,6 @@ public partial class Tower : Sprite2D
|
||||
{
|
||||
path.Curve.AddPoint(_arc[i]);
|
||||
}
|
||||
GD.Print(path.Curve.PointCount);
|
||||
}
|
||||
|
||||
private float EvaluateSimulationError(float ANGLE, Vector2 START, Vector2 TARGET)
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
[gd_scene format=3 uid="uid://b2mb7mimdu5ad"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cn8hskwnfxc8f" path="res://Bucket.cs" id="2_caem6"]
|
||||
[ext_resource type="Texture2D" uid="uid://dpwvh7kwkyfqi" path="res://Art/bucket_bottom.png" id="2_m1vr3"]
|
||||
[ext_resource type="Texture2D" uid="uid://baukn3uw3c3c3" path="res://Art/bucket_top.png" id="3_ghrs3"]
|
||||
|
||||
[node name="Bucket" type="Node2D" unique_id=1168722558]
|
||||
script = ExtResource("2_caem6")
|
||||
|
||||
[node name="Bottom" type="Sprite2D" parent="." unique_id=150417931]
|
||||
texture = ExtResource("2_m1vr3")
|
||||
|
||||
[node name="Top" type="Sprite2D" parent="." unique_id=201162499]
|
||||
texture = ExtResource("3_ghrs3")
|
||||
|
||||
[node name="Top2" type="Sprite2D" parent="." unique_id=203916174]
|
||||
texture = ExtResource("3_ghrs3")
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="." unique_id=1275030855]
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Area2D" unique_id=1086458018]
|
||||
polygon = PackedVector2Array(-30, -39, -30, -38, -43, -38, -43, -37, -52, -37, -52, -36, -59, -36, -59, -35, -66, -35, -66, -34, -71, -34, -71, -33, -76, -33, -76, -32, -80, -32, -80, -31, -83, -31, -83, -30, -86, -30, -86, -29, -89, -29, -89, -28, -92, -28, -92, -27, -93, -27, -93, -26, -95, -26, -95, -25, -96, -25, -96, -24, -97, -24, -97, -23, -98, -23, -98, -22, -99, -22, -99, -18, -98, -18, -98, -17, -97, -17, -97, -16, -96, -16, -96, -15, -95, -15, -95, -14, -93, -14, -93, -13, -92, -13, -92, -12, -89, -12, -89, -11, -86, -11, -86, -10, -83, -10, -83, -9, -80, -9, -80, -8, -76, -8, -76, -7, -71, -7, -71, -6, -66, -6, -66, -5, -59, -5, -59, -4, -52, -4, -52, -3, -43, -3, -43, -2, -30, -2, -30, -1, 30, -1, 30, -2, 43, -2, 43, -3, 52, -3, 52, -4, 59, -4, 59, -5, 66, -5, 66, -6, 71, -6, 71, -7, 76, -7, 76, -8, 80, -8, 80, -9, 83, -9, 83, -10, 86, -10, 86, -11, 89, -11, 89, -12, 92, -12, 92, -13, 93, -13, 93, -14, 95, -14, 95, -15, 96, -15, 96, -16, 97, -16, 97, -17, 98, -17, 98, -18, 99, -18, 99, -22, 98, -22, 98, -23, 97, -23, 97, -24, 96, -24, 96, -25, 95, -25, 95, -26, 93, -26, 93, -27, 92, -27, 92, -28, 89, -28, 89, -29, 86, -29, 86, -30, 83, -30, 83, -31, 80, -31, 80, -32, 76, -32, 76, -33, 71, -33, 71, -34, 66, -34, 66, -35, 59, -35, 59, -36, 52, -36, 52, -37, 43, -37, 43, -38, 30, -38, 30, -39)
|
||||
|
||||
[connection signal="body_entered" from="Area2D" to="." method="OnBodyEntered"]
|
||||
Reference in New Issue
Block a user