✨ Defeated enemygroups now drop a beet_seed
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
[gd_scene load_steps=2 format=3 uid="uid://n5cj71bxxjkk"]
|
[gd_scene load_steps=3 format=3 uid="uid://n5cj71bxxjkk"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://dqe1i2qmpttwf" path="res://scripts/CSharp/Common/Fight/FightWorld.cs" id="1_tnyce"]
|
[ext_resource type="Script" uid="uid://dqe1i2qmpttwf" path="res://scripts/CSharp/Common/Fight/FightWorld.cs" id="1_tnyce"]
|
||||||
|
[ext_resource type="Resource" uid="uid://duq7tshxv6uhp" path="res://resources/items/beet_seed.tres" id="2_lxs0o"]
|
||||||
|
|
||||||
[node name="FightWorldAutoload" type="Node2D"]
|
[node name="FightWorldAutoload" type="Node2D"]
|
||||||
script = ExtResource("1_tnyce")
|
script = ExtResource("1_tnyce")
|
||||||
|
_itemToDropByEnemyGroup = ExtResource("2_lxs0o")
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
[ext_resource type="Script" uid="uid://dbu8afaiohpdh" path="res://scripts/CSharp/Common/Fight/FightRoomSceneSetup.cs" id="40_cvg1r"]
|
[ext_resource type="Script" uid="uid://dbu8afaiohpdh" path="res://scripts/CSharp/Common/Fight/FightRoomSceneSetup.cs" id="40_cvg1r"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bcld43daavmrn" path="res://prefabs/fight/fight_scene_switcher.tscn" id="40_elhbh"]
|
[ext_resource type="PackedScene" uid="uid://bcld43daavmrn" path="res://prefabs/fight/fight_scene_switcher.tscn" id="40_elhbh"]
|
||||||
[ext_resource type="PackedScene" uid="uid://qfdiudt3vpai" path="res://prefabs/fight/roaming_enemy_group.tscn" id="41_cvg1r"]
|
[ext_resource type="PackedScene" uid="uid://qfdiudt3vpai" path="res://prefabs/fight/roaming_enemy_group.tscn" id="41_cvg1r"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dpbbroif2tnil" path="res://prefabs/interactions/generic_item_on_ground_2d.tscn" id="41_x3yi1"]
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ruj2u"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ruj2u"]
|
||||||
shader = ExtResource("16_0fard")
|
shader = ExtResource("16_0fard")
|
||||||
@@ -2175,6 +2176,7 @@ _sceneRoot = NodePath("..")
|
|||||||
script = ExtResource("40_cvg1r")
|
script = ExtResource("40_cvg1r")
|
||||||
_enemyGroupSpawns = [NodePath("../YSorted/EnemyGroupSpawns/Spawn1"), NodePath("../YSorted/EnemyGroupSpawns/Spawn2"), NodePath("../YSorted/EnemyGroupSpawns/Spawn3"), NodePath("../YSorted/EnemyGroupSpawns/Spawn4")]
|
_enemyGroupSpawns = [NodePath("../YSorted/EnemyGroupSpawns/Spawn1"), NodePath("../YSorted/EnemyGroupSpawns/Spawn2"), NodePath("../YSorted/EnemyGroupSpawns/Spawn3"), NodePath("../YSorted/EnemyGroupSpawns/Spawn4")]
|
||||||
_roamingEnemyGroupPrefab = ExtResource("41_cvg1r")
|
_roamingEnemyGroupPrefab = ExtResource("41_cvg1r")
|
||||||
|
_itemOnGroundPrefab = ExtResource("41_x3yi1")
|
||||||
_fightSceneSwitcher = NodePath("../FightSceneSwitcher")
|
_fightSceneSwitcher = NodePath("../FightSceneSwitcher")
|
||||||
|
|
||||||
[editable path="YSorted/Vesna"]
|
[editable path="YSorted/Vesna"]
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Babushka.scripts.CSharp.Common.Util;
|
using Babushka.scripts.CSharp.Common.Inventory;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
namespace Babushka.scripts.CSharp.Common.Fight;
|
namespace Babushka.scripts.CSharp.Common.Fight;
|
||||||
|
|
||||||
public partial class FightRoomSceneSetup : Node
|
public partial class FightRoomSceneSetup : Node
|
||||||
{
|
{
|
||||||
[Export(PropertyHint.ArrayType)] private Node2D[] _enemyGroupSpawns;
|
[Export(PropertyHint.ArrayType)] private Node2D[] _enemyGroupSpawns = null!;
|
||||||
[Export] private PackedScene _roamingEnemyGroupPrefab;
|
[Export] private PackedScene _roamingEnemyGroupPrefab = null!;
|
||||||
[Export] private FightSceneSwitcher _fightSceneSwitcher;
|
[Export] private PackedScene _itemOnGroundPrefab = null!;
|
||||||
|
[Export] private FightSceneSwitcher _fightSceneSwitcher = null!;
|
||||||
|
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
@@ -19,11 +20,30 @@ public partial class FightRoomSceneSetup : Node
|
|||||||
foreach (var (parent, group) in _enemyGroupSpawns.Zip(room.enemyGroups))
|
foreach (var (parent, group) in _enemyGroupSpawns.Zip(room.enemyGroups))
|
||||||
{
|
{
|
||||||
if (group.AreAllDead())
|
if (group.AreAllDead())
|
||||||
continue;
|
{
|
||||||
|
SpawnLoot(group, parent);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SpawnEnemies(group, parent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SpawnEnemies(FightWorld.FighterGroup group, Node2D parent)
|
||||||
|
{
|
||||||
var roamingEnemyGroup = _roamingEnemyGroupPrefab.Instantiate<RoamingEnemyGroup>();
|
var roamingEnemyGroup = _roamingEnemyGroupPrefab.Instantiate<RoamingEnemyGroup>();
|
||||||
roamingEnemyGroup.Initialize(group, _fightSceneSwitcher);
|
roamingEnemyGroup.Initialize(group, _fightSceneSwitcher);
|
||||||
parent.AddChild(roamingEnemyGroup);
|
parent.AddChild(roamingEnemyGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SpawnLoot(FightWorld.FighterGroup group, Node2D parent)
|
||||||
|
{
|
||||||
|
if (group.lootToDrop == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var onGroundInstance = _itemOnGroundPrefab.Instantiate<ItemOnGround2D>();
|
||||||
|
onGroundInstance.itemInstance = group.lootToDrop;
|
||||||
|
parent.AddChild(onGroundInstance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Babushka.scripts.CSharp.Common.Fight.Actions;
|
using Babushka.scripts.CSharp.Common.Fight.Actions;
|
||||||
|
using Babushka.scripts.CSharp.Common.Inventory;
|
||||||
using Babushka.scripts.CSharp.Common.Util;
|
using Babushka.scripts.CSharp.Common.Util;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
@@ -19,6 +20,7 @@ public partial class FightWorld : Node
|
|||||||
None,
|
None,
|
||||||
EndOfNight
|
EndOfNight
|
||||||
}
|
}
|
||||||
|
|
||||||
public required Dictionary<int, Room> paths;
|
public required Dictionary<int, Room> paths;
|
||||||
public required List<FighterGroup> enemyGroups;
|
public required List<FighterGroup> enemyGroups;
|
||||||
public Special specialRoom = Special.None;
|
public Special specialRoom = Special.None;
|
||||||
@@ -27,6 +29,7 @@ public partial class FightWorld : Node
|
|||||||
public class FighterGroup
|
public class FighterGroup
|
||||||
{
|
{
|
||||||
public required List<Fighter> fighters;
|
public required List<Fighter> fighters;
|
||||||
|
public ItemInstance? lootToDrop = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FightHappeningData
|
public class FightHappeningData
|
||||||
@@ -81,6 +84,9 @@ public partial class FightWorld : Node
|
|||||||
public FightHappeningData? fightHappeningData = null;
|
public FightHappeningData? fightHappeningData = null;
|
||||||
public AllyFighters allyFighters = new();
|
public AllyFighters allyFighters = new();
|
||||||
|
|
||||||
|
// settings
|
||||||
|
[Export] private ItemResource? _itemToDropByEnemyGroup;
|
||||||
|
|
||||||
public void ResetFightWorld()
|
public void ResetFightWorld()
|
||||||
{
|
{
|
||||||
Generate();
|
Generate();
|
||||||
@@ -89,10 +95,10 @@ public partial class FightWorld : Node
|
|||||||
|
|
||||||
public void Generate()
|
public void Generate()
|
||||||
{
|
{
|
||||||
world = new Generator().GenerateWorld();
|
world = new Generator(this).GenerateWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Generator
|
private class Generator(FightWorld fightWorld)
|
||||||
{
|
{
|
||||||
public World GenerateWorld()
|
public World GenerateWorld()
|
||||||
{
|
{
|
||||||
@@ -162,6 +168,11 @@ public partial class FightWorld : Node
|
|||||||
fighters = []
|
fighters = []
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (fightWorld._itemToDropByEnemyGroup != null)
|
||||||
|
{
|
||||||
|
enemyGroup.lootToDrop = new ItemInstance { blueprint = fightWorld._itemToDropByEnemyGroup };
|
||||||
|
}
|
||||||
|
|
||||||
var enemyCount = GD.RandRange(2, 3);
|
var enemyCount = GD.RandRange(2, 3);
|
||||||
|
|
||||||
for (var i = 0; i < enemyCount; i++)
|
for (var i = 0; i < enemyCount; i++)
|
||||||
|
|||||||
Reference in New Issue
Block a user