Beeg checkin
This commit is contained in:
10
Enemies/Attacks/EnemyBullet.cs
Normal file
10
Enemies/Attacks/EnemyBullet.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Godot;
|
||||
|
||||
public partial class EnemyBullet : Projectile
|
||||
{
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
TranslateObjectLocal(new Vector3(0, 0, -Speed * (float)delta));
|
||||
}
|
||||
}
|
||||
48
Enemies/Attacks/EnemyBullet.tscn
Normal file
48
Enemies/Attacks/EnemyBullet.tscn
Normal file
@@ -0,0 +1,48 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://rlxnnw4yay7e"]
|
||||
|
||||
[ext_resource type="Script" path="res://Enemies/Attacks/EnemyBullet.cs" id="1_rv13r"]
|
||||
[ext_resource type="Texture2D" uid="uid://dd71tdgrgic46" path="res://Textures/Projectiles/LB ORB.png" id="2_6l2aj"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_phgri"]
|
||||
albedo_color = Color(0.584314, 0.0352941, 0.141176, 1)
|
||||
|
||||
[sub_resource type="SphereMesh" id="SphereMesh_wuk0e"]
|
||||
material = SubResource("StandardMaterial3D_phgri")
|
||||
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_e4v7f"]
|
||||
radius = 0.4
|
||||
|
||||
[node name="TestBullet" type="Node3D"]
|
||||
script = ExtResource("1_rv13r")
|
||||
_projectileSpeed = 3.0
|
||||
|
||||
[node name="RigidBody3D" type="RigidBody3D" parent="."]
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
gravity_scale = 0.0
|
||||
custom_integrator = true
|
||||
continuous_cd = true
|
||||
max_contacts_reported = 10
|
||||
contact_monitor = true
|
||||
can_sleep = false
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="RigidBody3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.02602, 0)
|
||||
visible = false
|
||||
mesh = SubResource("SphereMesh_wuk0e")
|
||||
skeleton = NodePath("../..")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="RigidBody3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0111055, 1.02602, 0)
|
||||
shape = SubResource("CylinderShape3D_e4v7f")
|
||||
|
||||
[node name="Sprite3D" type="Sprite3D" parent="RigidBody3D"]
|
||||
transform = Transform3D(0.08, 0, 0, 0, 0.08, 0, 0, 0, 0.08, -0.379318, 1.02602, 0.436329)
|
||||
centered = false
|
||||
axis = 1
|
||||
texture = ExtResource("2_6l2aj")
|
||||
|
||||
[node name="TTL" type="Timer" parent="."]
|
||||
process_callback = 0
|
||||
wait_time = 0.8
|
||||
autostart = true
|
||||
29
Enemies/Attacks/FireAtPlayer.cs
Normal file
29
Enemies/Attacks/FireAtPlayer.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Godot;
|
||||
using System.Linq;
|
||||
|
||||
public partial class FireAtPlayer : Timer
|
||||
{
|
||||
[Export]
|
||||
private Area3D _enemy;
|
||||
[Export]
|
||||
private PackedScene _fireProjectile;
|
||||
|
||||
public void OnFireAtPlayer()
|
||||
{
|
||||
var players = GetTree().GetNodesInGroup("Player");
|
||||
if (players.Any())
|
||||
{
|
||||
var convertedPlayers = players.Select(x => (Node3D)x);
|
||||
var target = convertedPlayers.OrderBy(x => _enemy.Position.DistanceTo(x.Position)).FirstOrDefault();
|
||||
var projectile = _fireProjectile.Instantiate<Projectile>() as EnemyBullet;
|
||||
projectile.Rotation = _enemy.Rotation;
|
||||
projectile.Position = _enemy.Position;
|
||||
GetParent().AddChild(projectile);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDied()
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user