Started work on new enemy system
This commit is contained in:
154
Assets/Scenes/DEVSCENES/20IQEnemy.tscn
Normal file
154
Assets/Scenes/DEVSCENES/20IQEnemy.tscn
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
[gd_scene load_steps=22 format=3 uid="uid://eknn66u8gt26"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://cy22d14qd0f48" path="res://Assets/Scenes/DEVSCENES/IQBasedEnemy.cs" id="1_a638n"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://c0pno0ac25r7i" path="res://Assets/Sprites/knight.png" id="2_xbll0"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_a1e3t"]
|
||||||
|
atlas = ExtResource("2_xbll0")
|
||||||
|
region = Rect2(0, 64, 32, 32)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_ef81u"]
|
||||||
|
atlas = ExtResource("2_xbll0")
|
||||||
|
region = Rect2(32, 64, 32, 32)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_4c3ag"]
|
||||||
|
atlas = ExtResource("2_xbll0")
|
||||||
|
region = Rect2(64, 64, 32, 32)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_1uahc"]
|
||||||
|
atlas = ExtResource("2_xbll0")
|
||||||
|
region = Rect2(96, 64, 32, 32)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_e5qiv"]
|
||||||
|
atlas = ExtResource("2_xbll0")
|
||||||
|
region = Rect2(128, 64, 32, 32)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_3xcl8"]
|
||||||
|
atlas = ExtResource("2_xbll0")
|
||||||
|
region = Rect2(160, 64, 32, 32)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_55x3b"]
|
||||||
|
atlas = ExtResource("2_xbll0")
|
||||||
|
region = Rect2(192, 64, 32, 32)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_f81eh"]
|
||||||
|
atlas = ExtResource("2_xbll0")
|
||||||
|
region = Rect2(224, 64, 32, 32)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_2ehdo"]
|
||||||
|
atlas = ExtResource("2_xbll0")
|
||||||
|
region = Rect2(0, 96, 32, 32)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_4wgw3"]
|
||||||
|
atlas = ExtResource("2_xbll0")
|
||||||
|
region = Rect2(32, 96, 32, 32)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_7bxlo"]
|
||||||
|
atlas = ExtResource("2_xbll0")
|
||||||
|
region = Rect2(64, 96, 32, 32)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_kwup2"]
|
||||||
|
atlas = ExtResource("2_xbll0")
|
||||||
|
region = Rect2(96, 96, 32, 32)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_p5lub"]
|
||||||
|
atlas = ExtResource("2_xbll0")
|
||||||
|
region = Rect2(128, 96, 32, 32)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_v4h3h"]
|
||||||
|
atlas = ExtResource("2_xbll0")
|
||||||
|
region = Rect2(160, 96, 32, 32)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_fpk85"]
|
||||||
|
atlas = ExtResource("2_xbll0")
|
||||||
|
region = Rect2(192, 96, 32, 32)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_hylxp"]
|
||||||
|
atlas = ExtResource("2_xbll0")
|
||||||
|
region = Rect2(224, 96, 32, 32)
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id="SpriteFrames_rqn21"]
|
||||||
|
animations = [{
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_a1e3t")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_ef81u")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_4c3ag")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_1uahc")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_e5qiv")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_3xcl8")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_55x3b")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_f81eh")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_2ehdo")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_4wgw3")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_7bxlo")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_kwup2")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_p5lub")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_v4h3h")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_fpk85")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_hylxp")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"default",
|
||||||
|
"speed": 5.0
|
||||||
|
}]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_41iyt"]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_bc7hl"]
|
||||||
|
|
||||||
|
[node name="Enemy20IQ" type="RigidBody2D"]
|
||||||
|
script = ExtResource("1_a638n")
|
||||||
|
metadata/IQ = 20
|
||||||
|
metadata/MaxHP = 100.0
|
||||||
|
|
||||||
|
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||||
|
position = Vector2(9.536743e-07, 5.684342e-14)
|
||||||
|
scale = Vector2(0.99999994, 0.99999994)
|
||||||
|
sprite_frames = SubResource("SpriteFrames_rqn21")
|
||||||
|
autoplay = "default"
|
||||||
|
frame = 1
|
||||||
|
frame_progress = 0.9866207
|
||||||
|
|
||||||
|
[node name="Hitbox" type="CollisionShape2D" parent="."]
|
||||||
|
shape = SubResource("RectangleShape2D_41iyt")
|
||||||
|
|
||||||
|
[node name="LedgeDetector" type="CollisionShape2D" parent="."]
|
||||||
|
position = Vector2(12, 12)
|
||||||
|
scale = Vector2(0.1, 0.1)
|
||||||
|
shape = SubResource("RectangleShape2D_bc7hl")
|
||||||
|
|
||||||
|
[node name="WallDetector" type="CollisionShape2D" parent="."]
|
||||||
|
position = Vector2(12, 9.536743e-07)
|
||||||
|
scale = Vector2(0.1, 0.1)
|
||||||
|
shape = SubResource("RectangleShape2D_bc7hl")
|
||||||
45
Assets/Scenes/DEVSCENES/IQBasedEnemy.cs
Normal file
45
Assets/Scenes/DEVSCENES/IQBasedEnemy.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public partial class IQBasedEnemy : RigidBody2D
|
||||||
|
{
|
||||||
|
// Enemy Stats
|
||||||
|
public int IQ;
|
||||||
|
public float HP;
|
||||||
|
public float MaxHP;
|
||||||
|
|
||||||
|
// Enemy Conditions
|
||||||
|
float CurrentYVelocity;
|
||||||
|
float PreviousYVelocity;
|
||||||
|
public bool IsGrounded;
|
||||||
|
|
||||||
|
// Enemy Abilities
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
IQ = (int)GetMeta("IQ"); // Read IQ
|
||||||
|
|
||||||
|
MaxHP = (float)GetMeta("MaxHP"); // Get Max HP
|
||||||
|
if (IQ >= 100)
|
||||||
|
MaxHP += 20;
|
||||||
|
HP = MaxHP;
|
||||||
|
|
||||||
|
CurrentYVelocity = 0f;
|
||||||
|
PreviousYVelocity = 0f;
|
||||||
|
IsGrounded = true;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _Process(double delta)
|
||||||
|
{
|
||||||
|
// Ground Detection
|
||||||
|
CurrentYVelocity = LinearVelocity[1];
|
||||||
|
if (CurrentYVelocity == 0 && PreviousYVelocity == 0)
|
||||||
|
IsGrounded = true;
|
||||||
|
else
|
||||||
|
IsGrounded = false;
|
||||||
|
PreviousYVelocity = CurrentYVelocity;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
1
Assets/Scenes/DEVSCENES/IQBasedEnemy.cs.uid
Normal file
1
Assets/Scenes/DEVSCENES/IQBasedEnemy.cs.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://cy22d14qd0f48
|
||||||
Reference in New Issue
Block a user