Compare commits
11 Commits
f647f5ed08
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9382d3f3a5 | ||
|
|
30f564323a | ||
|
|
1c4f90fa96 | ||
|
|
b58f4412f2 | ||
|
|
4392367ef6 | ||
|
|
6a00e320b3 | ||
|
|
88ecd78c4e | ||
|
|
47a1e88b5f | ||
|
|
4ca341f416 | ||
|
|
0506824cf1 | ||
|
|
318397ee29 |
File diff suppressed because one or more lines are too long
@@ -1,124 +0,0 @@
|
|||||||
using Godot;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
public partial class IQEnemy : CharacterBody2D
|
|
||||||
{
|
|
||||||
// Misc
|
|
||||||
float GlobalTimer;
|
|
||||||
|
|
||||||
// Enemy Stats
|
|
||||||
public int IQ;
|
|
||||||
public float HP;
|
|
||||||
public float MaxHP;
|
|
||||||
float RegenerationAmmount;
|
|
||||||
float RegenerationInterval;
|
|
||||||
float WalkSpeed;
|
|
||||||
float JumpHeight;
|
|
||||||
|
|
||||||
// Enemy Conditions
|
|
||||||
float CurrentYVelocity;
|
|
||||||
float PreviousYVelocity;
|
|
||||||
bool GroundDetected;
|
|
||||||
bool LedgeDetected;
|
|
||||||
|
|
||||||
// Enemy Abilities
|
|
||||||
bool AbilityJump = false;
|
|
||||||
bool AbilityMove = false;
|
|
||||||
bool AbilityAttack = false;
|
|
||||||
bool AbilityDash = false;
|
|
||||||
bool AbilityCloak = false;
|
|
||||||
bool AbilityTeleport = false;
|
|
||||||
bool AbilityRegenerate = false;
|
|
||||||
|
|
||||||
public override void _Ready()
|
|
||||||
{
|
|
||||||
// Read & Set Abilities
|
|
||||||
if (HasMeta("AbilityJump")) AbilityJump = (bool)GetMeta("AbilityJump");
|
|
||||||
if (HasMeta("AbilityMove")) AbilityMove = (bool)GetMeta("AbilityMove");
|
|
||||||
if (HasMeta("AbilityAttack")) AbilityAttack = (bool)GetMeta("AbilityAttack");
|
|
||||||
if (HasMeta("AbilityDash")) AbilityDash = (bool)GetMeta("AbilityDash");
|
|
||||||
if (HasMeta("AbilityCloak")) AbilityCloak = (bool)GetMeta("AbilityCloak");
|
|
||||||
if (HasMeta("AbilityTeleport")) AbilityTeleport = (bool)GetMeta("AbilityTeleport");
|
|
||||||
if (HasMeta("AbilityRegenerate")) AbilityRegenerate = (bool)GetMeta("AbilityRegenerate");
|
|
||||||
if (HasMeta("RegenerationAmmount")) RegenerationAmmount = (float)GetMeta("RegenerationAmmount");
|
|
||||||
else RegenerationAmmount = 1.0f;
|
|
||||||
if (HasMeta("RegenerationInterval")) RegenerationInterval = (float)GetMeta("RegenerationInterval");
|
|
||||||
else RegenerationInterval = 1.0f;
|
|
||||||
if (HasMeta("WalkSpeed")) WalkSpeed = (float)GetMeta("WalkSpeed");
|
|
||||||
else WalkSpeed = 10.0f;
|
|
||||||
if (HasMeta("JumpHeight")) JumpHeight = (float)GetMeta("JumpHeight");
|
|
||||||
else JumpHeight = 10.0f;
|
|
||||||
|
|
||||||
// Read and set stats
|
|
||||||
if (HasMeta("MaxHP")) MaxHP = (float)GetMeta("MaxHP");
|
|
||||||
|
|
||||||
// Set up ground detection
|
|
||||||
GetNode<Area2D>("GroundDetector").AreaEntered += OnGroundEntered;
|
|
||||||
GetNode<Area2D>("GroundDetector").AreaExited += OnGroundExited;
|
|
||||||
|
|
||||||
GetNode<Area2D>("LedgeDetector").AreaEntered += OnLedgeEntered;
|
|
||||||
GetNode<Area2D>("LedgeDetector").AreaExited += OnLedgeExited;
|
|
||||||
|
|
||||||
GroundDetected = true;
|
|
||||||
LedgeDetected = true;
|
|
||||||
|
|
||||||
// Apply IQ based permenant modifiers
|
|
||||||
IQ = (int)GetMeta("IQ"); // Read IQ
|
|
||||||
|
|
||||||
if (IQ >= 100) MaxHP += 20;
|
|
||||||
HP = MaxHP;
|
|
||||||
if (IQ >= 100 && HasMeta("RegenerationInterval")) RegenerationInterval *= 0.9f;
|
|
||||||
if (IQ >= 100 && HasMeta("RegenerationAmmount")) RegenerationAmmount *= 1.05f; // 5% increase
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void _Process(double delta)
|
|
||||||
{
|
|
||||||
// Update Timer
|
|
||||||
GlobalTimer = GetTree().Root.GetNode<CommonData>("CommonData").GlobalTimer;
|
|
||||||
|
|
||||||
// Show current hp for testing purposes
|
|
||||||
if (HasMeta("CurrentHP")) SetMeta("CurrentHP", HP);
|
|
||||||
|
|
||||||
// Regenerate Health
|
|
||||||
if (AbilityRegenerate){
|
|
||||||
if (GlobalTimer % RegenerationInterval == 0){Regenerate(RegenerationAmmount);}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Movement
|
|
||||||
// Add gravity.
|
|
||||||
if (GroundDetected == false){Velocity = new Vector2(Velocity[0],-1);}
|
|
||||||
if (IQ <= 20){ // Goomba ahh diddy blud
|
|
||||||
if (GroundDetected && LedgeDetected == false) {Flip("ANY");}
|
|
||||||
if (Scale[0] > 0){Velocity = new Vector2(WalkSpeed, Velocity[1]);} // Facing right
|
|
||||||
if (Scale[0] < 0){Velocity = new Vector2(-1 * WalkSpeed, Velocity[1]);} // Facing left
|
|
||||||
}
|
|
||||||
MoveAndSlide();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Flip(string facing){
|
|
||||||
if (facing == "ANY") Scale = new Vector2(Scale[0] * -1,1);
|
|
||||||
if (facing == "RIGHT") Scale = new Vector2(1,1);
|
|
||||||
if (facing =="LEFT") Scale = new Vector2(-1,1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Regenerate(float ammount){
|
|
||||||
if (HP < MaxHP) HP += ammount;
|
|
||||||
if (HP > MaxHP) HP = MaxHP; // Catch errors
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Damage(float ammount){
|
|
||||||
HP -= ammount;
|
|
||||||
if (HP <= 0) Kill();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Kill(){
|
|
||||||
QueueFree(); // Change to proper death w/ corpse
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ground Detection
|
|
||||||
public void OnGroundEntered(Area2D area){if (area.CollisionLayer == 0) GroundDetected = true;}
|
|
||||||
public void OnGroundExited(Area2D area){if (area.CollisionLayer == 0) GroundDetected = false;}
|
|
||||||
// Ledge Detection
|
|
||||||
public void OnLedgeEntered(Area2D area){if (area.CollisionLayer == 0) LedgeDetected = true;}
|
|
||||||
public void OnLedgeExited(Area2D area){if (area.CollisionLayer == 0) LedgeDetected = false;}
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
[gd_scene load_steps=22 format=3 uid="uid://eknn66u8gt26"]
|
[gd_scene format=3 uid="uid://eknn66u8gt26"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://cy22d14qd0f48" path="res://Assets/Scenes/DEVSCENES/IQEnemy.cs" id="1_p53ib"]
|
[ext_resource type="Script" uid="uid://cy22d14qd0f48" path="res://Assets/Scripts/EnemyScripts/IQEnemy.cs" id="1_p53ib"]
|
||||||
[ext_resource type="Texture2D" uid="uid://c0pno0ac25r7i" path="res://Assets/Sprites/knight.png" id="2_o0b1e"]
|
[ext_resource type="Texture2D" uid="uid://c0pno0ac25r7i" path="res://Assets/Sprites/knight.png" id="2_o0b1e"]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_bc7hl"]
|
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_41iyt"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_41iyt"]
|
||||||
|
size = Vector2(14, 16)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_a1e3t"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_a1e3t"]
|
||||||
atlas = ExtResource("2_o0b1e")
|
atlas = ExtResource("2_o0b1e")
|
||||||
@@ -127,42 +126,53 @@ animations = [{
|
|||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
}]
|
}]
|
||||||
|
|
||||||
[node name="IQEnemy" type="CharacterBody2D"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_bc7hl"]
|
||||||
|
|
||||||
|
[node name="IQEnemy" type="CharacterBody2D" unique_id=240625765]
|
||||||
collision_layer = 8
|
collision_layer = 8
|
||||||
collision_mask = 3
|
collision_mask = 3
|
||||||
script = ExtResource("1_p53ib")
|
script = ExtResource("1_p53ib")
|
||||||
metadata/IQ = 20
|
metadata/IQ = 20
|
||||||
metadata/AbilityRegenerate = true
|
metadata/AbilityRegenerate = true
|
||||||
|
metadata/_edit_vertical_guides_ = [-36.0]
|
||||||
|
metadata/AbilityLunge = true
|
||||||
|
|
||||||
[node name="GroundDetector" type="Area2D" parent="."]
|
[node name="Hitbox" type="CollisionShape2D" parent="." unique_id=2143062555]
|
||||||
position = Vector2(1.1368684e-13, 10.999999)
|
position = Vector2(0, 2)
|
||||||
scale = Vector2(0.099999994, 0.099999994)
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="GroundDetector"]
|
|
||||||
scale = Vector2(0.99999994, 0.99999994)
|
|
||||||
shape = SubResource("RectangleShape2D_bc7hl")
|
|
||||||
|
|
||||||
[node name="LedgeDetector" type="Area2D" parent="."]
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="LedgeDetector"]
|
|
||||||
position = Vector2(12, 12)
|
|
||||||
scale = Vector2(0.1, 0.1)
|
|
||||||
shape = SubResource("RectangleShape2D_bc7hl")
|
|
||||||
|
|
||||||
[node name="WallDetector" type="Area2D" parent="."]
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="WallDetector"]
|
|
||||||
position = Vector2(12, 9.536743e-07)
|
|
||||||
scale = Vector2(0.1, 0.1)
|
|
||||||
shape = SubResource("RectangleShape2D_bc7hl")
|
|
||||||
|
|
||||||
[node name="Hitbox" type="CollisionShape2D" parent="."]
|
|
||||||
shape = SubResource("RectangleShape2D_41iyt")
|
shape = SubResource("RectangleShape2D_41iyt")
|
||||||
|
|
||||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
[node name="VisualsAndHitboxes" type="Node2D" parent="." unique_id=1894404141]
|
||||||
|
|
||||||
|
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="VisualsAndHitboxes" unique_id=1301527955]
|
||||||
position = Vector2(9.536743e-07, -1.9999999)
|
position = Vector2(9.536743e-07, -1.9999999)
|
||||||
scale = Vector2(0.99999994, 0.99999994)
|
scale = Vector2(0.99999994, 0.99999994)
|
||||||
sprite_frames = SubResource("SpriteFrames_rqn21")
|
sprite_frames = SubResource("SpriteFrames_rqn21")
|
||||||
autoplay = "default"
|
autoplay = "default"
|
||||||
frame = 1
|
frame = 1
|
||||||
frame_progress = 0.9866207
|
frame_progress = 0.9866207
|
||||||
|
|
||||||
|
[node name="GroundDetector" type="Area2D" parent="VisualsAndHitboxes" unique_id=1709439423]
|
||||||
|
position = Vector2(1.1368684e-13, 11.000001)
|
||||||
|
scale = Vector2(0.099999994, 0.099999994)
|
||||||
|
collision_layer = 0
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="VisualsAndHitboxes/GroundDetector" unique_id=1429561812]
|
||||||
|
position = Vector2(0, 19.999992)
|
||||||
|
scale = Vector2(0.99999994, 0.99999994)
|
||||||
|
shape = SubResource("RectangleShape2D_bc7hl")
|
||||||
|
|
||||||
|
[node name="LedgeDetector" type="Area2D" parent="VisualsAndHitboxes" unique_id=1421687086]
|
||||||
|
collision_layer = 0
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="VisualsAndHitboxes/LedgeDetector" unique_id=1073584572]
|
||||||
|
position = Vector2(11, 13)
|
||||||
|
scale = Vector2(0.1, 0.1)
|
||||||
|
shape = SubResource("RectangleShape2D_bc7hl")
|
||||||
|
|
||||||
|
[node name="WallDetector" type="Area2D" parent="VisualsAndHitboxes" unique_id=1085104067]
|
||||||
|
collision_layer = 0
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="VisualsAndHitboxes/WallDetector" unique_id=1699607778]
|
||||||
|
position = Vector2(11, 9.536743e-07)
|
||||||
|
scale = Vector2(0.1, 0.1)
|
||||||
|
shape = SubResource("RectangleShape2D_bc7hl")
|
||||||
|
|||||||
@@ -130,7 +130,8 @@ animations = [{
|
|||||||
size = Vector2(12, 28)
|
size = Vector2(12, 28)
|
||||||
|
|
||||||
[node name="Player" type="CharacterBody2D"]
|
[node name="Player" type="CharacterBody2D"]
|
||||||
collision_layer = 2
|
collision_layer = 4
|
||||||
|
collision_mask = 3
|
||||||
script = ExtResource("1_b2ifw")
|
script = ExtResource("1_b2ifw")
|
||||||
|
|
||||||
[node name="AreaDetector" type="Area2D" parent="."]
|
[node name="AreaDetector" type="Area2D" parent="."]
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public partial class CommonData : Node
|
|||||||
// Level information
|
// Level information
|
||||||
public string CurrentLevel;
|
public string CurrentLevel;
|
||||||
|
|
||||||
// Player information
|
// Player stats
|
||||||
public float CurrentHealth;
|
public float CurrentHealth;
|
||||||
public float MaxHealth = 100;
|
public float MaxHealth = 100;
|
||||||
|
|
||||||
@@ -40,6 +40,7 @@ public partial class CommonData : Node
|
|||||||
PlayMusic("MainMenu");
|
PlayMusic("MainMenu");
|
||||||
|
|
||||||
// Load in saved data
|
// Load in saved data
|
||||||
|
//....?
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
@@ -49,28 +50,18 @@ public partial class CommonData : Node
|
|||||||
GlobalTimer = NumFramesElapsed / FPS;
|
GlobalTimer = NumFramesElapsed / FPS;
|
||||||
GlobalTimer = (float)Convert.ToDouble(GlobalTimer.ToString("0.##")); // Truncates seconds elapsed to hundreds place (0.00)
|
GlobalTimer = (float)Convert.ToDouble(GlobalTimer.ToString("0.##")); // Truncates seconds elapsed to hundreds place (0.00)
|
||||||
//GD.Print(GlobalTimer);
|
//GD.Print(GlobalTimer);
|
||||||
if (Input.IsActionJustPressed("quit_game")){GetTree().Quit();}
|
if (Input.IsActionJustPressed("quit_game")) GetTree().Quit();
|
||||||
|
|
||||||
if (Input.IsActionJustPressed("mute"))
|
if (Input.IsActionJustPressed("mute")){
|
||||||
{
|
Muted = ! Muted;
|
||||||
if (Muted)
|
GetNode<AudioStreamPlayer>("AudioStreamPlayer").VolumeDb = (Muted) ? -80 : 0;
|
||||||
{
|
|
||||||
Muted = false;
|
|
||||||
GetNode<AudioStreamPlayer>("AudioStreamPlayer").VolumeDb = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Muted = true;
|
|
||||||
GetNode<AudioStreamPlayer>("AudioStreamPlayer").VolumeDb = -80;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// BG Audio Management
|
// BG Audio Management
|
||||||
public void StopMusic(){GetNode<AudioStreamPlayer>("AudioStreamPlayer").Stop();}// Stop whatever audio is playing\
|
public void StopMusic(){GetNode<AudioStreamPlayer>("AudioStreamPlayer").Stop();}// Stop whatever audio is playing\
|
||||||
|
|
||||||
public void PlayMusic(string AudioName)
|
public void PlayMusic(string AudioName){
|
||||||
{
|
|
||||||
// Load target audio and play the audio
|
// Load target audio and play the audio
|
||||||
GetNode<AudioStreamPlayer>("AudioStreamPlayer").Stream = (Godot.AudioStream)GD.Load($"res://Assets/Audio/Music/{AudioName}.mp3");
|
GetNode<AudioStreamPlayer>("AudioStreamPlayer").Stream = (Godot.AudioStream)GD.Load($"res://Assets/Audio/Music/{AudioName}.mp3");
|
||||||
GetNode<AudioStreamPlayer>("AudioStreamPlayer").Play();
|
GetNode<AudioStreamPlayer>("AudioStreamPlayer").Play();
|
||||||
|
|||||||
222
Assets/Scripts/EnemyScripts/IQEnemy.cs
Normal file
222
Assets/Scripts/EnemyScripts/IQEnemy.cs
Normal file
@@ -0,0 +1,222 @@
|
|||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public partial class IQEnemy : CharacterBody2D
|
||||||
|
{
|
||||||
|
// Misc
|
||||||
|
float GlobalTimer;
|
||||||
|
Node2D VAH; // Shorthand refrence
|
||||||
|
|
||||||
|
// Enemy Stats
|
||||||
|
public int IQ;
|
||||||
|
public float HP;
|
||||||
|
float MaxHP, RegenerationAmmount, RegenerationInterval, WalkSpeed, JumpHeight, JumpInterval, LungeInterval, DetectionRange;
|
||||||
|
|
||||||
|
// Enemy Conditions
|
||||||
|
bool GroundDetected, LedgeDetected, WallDetected, CanJump, CanLunge;
|
||||||
|
String FacingDirection;
|
||||||
|
|
||||||
|
// Enemy Abilities
|
||||||
|
bool AbilityJump, AbilityMove, AbilityAttack, AbilityDash, AbilityLunge, AbilityCloak, AbilityTeleport, AbilityRegenerate;
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
// Read & Set Abilities
|
||||||
|
if (HasMeta("AbilityJump")) AbilityJump = (bool)GetMeta("AbilityJump");
|
||||||
|
else AbilityJump = true;
|
||||||
|
if (HasMeta("AbilityMove")) AbilityMove = (bool)GetMeta("AbilityMove");
|
||||||
|
else AbilityMove = true;
|
||||||
|
if (HasMeta("AbilityAttack")) AbilityAttack = (bool)GetMeta("AbilityAttack");
|
||||||
|
else AbilityAttack = true;
|
||||||
|
if (HasMeta("AbilityDash")) AbilityDash = (bool)GetMeta("AbilityDash");
|
||||||
|
else AbilityDash = false;
|
||||||
|
if (HasMeta("AbilityLunge")) AbilityLunge = (bool)GetMeta("AbilityLunge");
|
||||||
|
else AbilityLunge = false;
|
||||||
|
if (HasMeta("AbilityCloak")) AbilityCloak = (bool)GetMeta("AbilityCloak");
|
||||||
|
else AbilityCloak = false;
|
||||||
|
if (HasMeta("AbilityTeleport")) AbilityTeleport = (bool)GetMeta("AbilityTeleport");
|
||||||
|
else AbilityTeleport = false;
|
||||||
|
if (HasMeta("AbilityRegenerate")) AbilityRegenerate = (bool)GetMeta("AbilityRegenerate");
|
||||||
|
else AbilityRegenerate = true;
|
||||||
|
if (HasMeta("RegenerationAmmount")) RegenerationAmmount = (float)GetMeta("RegenerationAmmount");
|
||||||
|
else RegenerationAmmount = 1.0f;
|
||||||
|
if (HasMeta("RegenerationInterval")) RegenerationInterval = (float)GetMeta("RegenerationInterval");
|
||||||
|
else RegenerationInterval = 1.0f;
|
||||||
|
if (HasMeta("WalkSpeed")) WalkSpeed = (float)GetMeta("WalkSpeed");
|
||||||
|
else WalkSpeed = 20.0f;
|
||||||
|
if (HasMeta("JumpHeight")) JumpHeight = (float)GetMeta("JumpHeight");
|
||||||
|
else JumpHeight = 250.0f;
|
||||||
|
if (HasMeta("JumpInterval")) JumpInterval = (float)GetMeta("JumpInterval");
|
||||||
|
else JumpInterval = 1.0f;
|
||||||
|
if (HasMeta("LungeInterval")) LungeInterval = (float)GetMeta("LungeInterval");
|
||||||
|
else LungeInterval = 1.0f;
|
||||||
|
if (HasMeta("DetectionRange")) DetectionRange = (float)GetMeta("DetectionRange");
|
||||||
|
else DetectionRange = 100.0f;
|
||||||
|
JumpHeight *= -1;
|
||||||
|
|
||||||
|
// Read and set stats
|
||||||
|
if (HasMeta("MaxHP")) MaxHP = (float)GetMeta("MaxHP");
|
||||||
|
|
||||||
|
FacingDirection = "RIGHT";
|
||||||
|
VAH = GetNode<Node2D>("VisualsAndHitboxes");
|
||||||
|
|
||||||
|
// Set up collision detection
|
||||||
|
VAH.GetNode<Area2D>("GroundDetector").BodyEntered += OnGroundEntered; // Ground
|
||||||
|
VAH.GetNode<Area2D>("GroundDetector").BodyExited += OnGroundExited;
|
||||||
|
VAH.GetNode<Area2D>("LedgeDetector").BodyEntered += OnLedgeEntered; // Ledge
|
||||||
|
VAH.GetNode<Area2D>("LedgeDetector").BodyExited += OnLedgeExited;
|
||||||
|
VAH.GetNode<Area2D>("WallDetector").BodyEntered += OnWallEntered; // Wall
|
||||||
|
VAH.GetNode<Area2D>("WallDetector").BodyExited += OnWallExited;
|
||||||
|
|
||||||
|
GroundDetected = false;
|
||||||
|
LedgeDetected = false;
|
||||||
|
WallDetected = false;
|
||||||
|
CanJump = AbilityJump;
|
||||||
|
CanLunge = AbilityLunge;
|
||||||
|
|
||||||
|
// Apply IQ based permenant modifiers
|
||||||
|
IQ = (int)GetMeta("IQ"); // Read IQ
|
||||||
|
|
||||||
|
if (IQ >= 100) MaxHP += 20;
|
||||||
|
HP = MaxHP;
|
||||||
|
if (IQ >= 100 && HasMeta("RegenerationInterval")) RegenerationInterval *= 0.9f;
|
||||||
|
if (IQ >= 100 && HasMeta("RegenerationAmmount")) RegenerationAmmount *= 1.05f; // 5% increase
|
||||||
|
|
||||||
|
WalkSpeed += IQ / 10;
|
||||||
|
JumpHeight += IQ / 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _PhysicsProcess(double delta)
|
||||||
|
{
|
||||||
|
// Update Timer
|
||||||
|
GlobalTimer = GetTree().Root.GetNode<CommonData>("CommonData").GlobalTimer;
|
||||||
|
|
||||||
|
// Show current hp for testing purposes
|
||||||
|
if (HasMeta("CurrentHP")) SetMeta("CurrentHP", HP);
|
||||||
|
|
||||||
|
// Cooldowns
|
||||||
|
// Regenerate Health
|
||||||
|
if (AbilityRegenerate){
|
||||||
|
if (GlobalTimer % RegenerationInterval == 0) Regenerate(RegenerationAmmount);
|
||||||
|
}
|
||||||
|
// Jump Cooldown
|
||||||
|
if (AbilityJump){
|
||||||
|
if (GlobalTimer % JumpInterval == 0) CanJump = true;
|
||||||
|
}
|
||||||
|
// Lunge Cooldown
|
||||||
|
if (AbilityLunge){
|
||||||
|
if (GlobalTimer % LungeInterval == 0) CanLunge = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Movement
|
||||||
|
// Add gravity.
|
||||||
|
if (GroundDetected == false) Velocity = new Vector2(Velocity[0],Velocity[1] + 10);
|
||||||
|
|
||||||
|
#region 20IQ
|
||||||
|
if (AbilityMove){
|
||||||
|
if (IQ >= 0 && IQ <= 20){ // Goomba ahh diddy blud
|
||||||
|
if (GroundDetected && LedgeDetected == false) Flip(); // Flip when presented with a ledge
|
||||||
|
if (WallDetected) Flip(); // Flip when comeing in contact with a wall
|
||||||
|
if (GroundDetected) Velocity = new Vector2(WalkSpeed * VAH.Scale[0], Velocity[1]); // Walk
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region 30IQ
|
||||||
|
if (IQ > 20 && IQ <= 30){ // Goomba w/ hopps (no judy)
|
||||||
|
Velocity = new Vector2(WalkSpeed * VAH.Scale[0], Velocity[1]); // Walk
|
||||||
|
if (WallDetected && GroundDetected && Velocity[1] == 0) Jump(0.0f);
|
||||||
|
if (WallDetected && GroundDetected && Velocity[1] > 0) Flip(); // Wall too high
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region 40IQ
|
||||||
|
if (IQ > 30 && IQ <= 40){ // Adds jumping when reaching edge as feature (also adding directional x force)
|
||||||
|
Velocity = (GroundDetected) ? new Vector2(WalkSpeed * VAH.Scale[0], Velocity[1]) : new Vector2 (Velocity[0] + 0.05f, Velocity[1]); // Walk on ground : air
|
||||||
|
if (WallDetected && GroundDetected) Jump(0.0f);
|
||||||
|
if (GroundDetected && LedgeDetected == false) Jump(50.0f * VAH.Scale[0]); // Jump at ledge with x motion
|
||||||
|
if (WallDetected && GroundDetected && Velocity[1] > 0) Flip(); // Wall too high
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region 60IQ
|
||||||
|
if (IQ > 40 && IQ <= 60){ // Concious of what side of the enemy the player is on
|
||||||
|
if (DetectsPlayer()){ // Pursuing Player
|
||||||
|
var CurrentLevel = GetTree().Root.GetChildren();
|
||||||
|
float DistanceFromPlayerX = GlobalPosition[0] - CurrentLevel[2].GetNode<Node2D>("Player").GlobalPosition[0];
|
||||||
|
if (DistanceFromPlayerX > (30.0f / (IQ / 4))) if (VAH.Scale[0] > 0)Flip(); // left of player
|
||||||
|
if (DistanceFromPlayerX < (-30.0f / (IQ / 4))) if (VAH.Scale[0] < 0)Flip(); // right of player
|
||||||
|
if (DistanceFromPlayerX < (-30.0f / (IQ / 4)) && GroundDetected && GlobalPosition[1] > CurrentLevel[2].GetNode<Node2D>("Player").GlobalPosition[1]) Jump(0.0f); // Jump when player is overhead
|
||||||
|
if (DistanceFromPlayerX > DetectionRange / 2.0f) Lunge(100.0f * VAH.Scale[0]);
|
||||||
|
} else{ // Patrol
|
||||||
|
if (WallDetected && GroundDetected && Velocity[1] > 0)Flip(); // Wall too high (flips when it lands on the ground in front of a wall)
|
||||||
|
}
|
||||||
|
// Common Behaviors
|
||||||
|
Velocity = (GroundDetected) ? new Vector2(WalkSpeed * VAH.Scale[0], Velocity[1]) : new Vector2 (Velocity[0] + 0.05f, Velocity[1]); // Walk on ground : air
|
||||||
|
if (WallDetected && GroundDetected) Jump(0.0f); // Jump when touching a wall
|
||||||
|
if (GroundDetected && LedgeDetected == false) Jump(50.0f * VAH.Scale[0]); // Jump at ledge with x motion
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region 80IQ
|
||||||
|
if (IQ > 60 && IQ <= 80){ // Maintain distance to avoid melee attacks and optimise ranged attacks
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region 1000IQ
|
||||||
|
if (IQ > 80 && IQ <= 100){ // Basic Pathfinding
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region 120IQ
|
||||||
|
if (IQ > 100 && IQ <= 120){ // Advanced Pathfindinhg
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region 140IQ
|
||||||
|
if (IQ > 120 && IQ <= 140){ // Advanced movement options
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
MoveAndSlide(); // Updates physics applied this frame
|
||||||
|
}
|
||||||
|
|
||||||
|
void Flip(){
|
||||||
|
VAH.Scale = new Vector2(-1 * VAH.Scale[0],1);
|
||||||
|
WallDetected = false;
|
||||||
|
LedgeDetected = true;
|
||||||
|
if (FacingDirection == "RIGHT"){FacingDirection = "LEFT";}
|
||||||
|
else if (FacingDirection == "LEFT"){FacingDirection = "RIGHT";}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Jump(float xMagnitude){
|
||||||
|
if (GroundDetected && CanJump) {Velocity = new Vector2(Velocity[0] + xMagnitude, JumpHeight);
|
||||||
|
CanJump = false;}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Lunge(float xMagnitude){
|
||||||
|
if (GroundDetected && CanLunge) {Velocity = new Vector2(Velocity[0] + xMagnitude, JumpHeight / 2.0f);
|
||||||
|
CanLunge = false;}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DetectsPlayer(){
|
||||||
|
var CurrentLevel = GetTree().Root.GetChildren();
|
||||||
|
return (GlobalPosition.DistanceTo(CurrentLevel[2].GetNode<Node2D>("Player").GlobalPosition) <= DetectionRange) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Regenerate(float ammount){
|
||||||
|
if (HP < MaxHP) HP += ammount;
|
||||||
|
if (HP > MaxHP) HP = MaxHP; // Catch errors
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Damage(float ammount){
|
||||||
|
HP -= ammount;
|
||||||
|
if (HP <= 0) Kill();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Kill(){
|
||||||
|
QueueFree(); // Change to proper death w/ corpse
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ground Detection
|
||||||
|
public void OnGroundEntered(Node2D body){if (body is TileMapLayer tileLayer) GroundDetected = true;}
|
||||||
|
public void OnGroundExited(Node2D body){if (body is TileMapLayer tileLayer) GroundDetected = false;}
|
||||||
|
// Ledge Detection
|
||||||
|
public void OnLedgeEntered(Node2D body){if (body is TileMapLayer tileLayer) LedgeDetected = true;}
|
||||||
|
public void OnLedgeExited(Node2D body){if (body is TileMapLayer tileLayer) LedgeDetected = false;}
|
||||||
|
// Wall Detection
|
||||||
|
public void OnWallEntered(Node2D body){if (body is TileMapLayer tileLayer) WallDetected = true;}
|
||||||
|
public void OnWallExited(Node2D body){if (body is TileMapLayer tileLayer) WallDetected = false;}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Godot.NET.Sdk/4.5.1">
|
<Project Sdk="Godot.NET.Sdk/4.6.0">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net9.0</TargetFramework>
|
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net9.0</TargetFramework>
|
||||||
|
|||||||
7
fracturepoint.csproj.old
Normal file
7
fracturepoint.csproj.old
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<Project Sdk="Godot.NET.Sdk/4.5.1">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net9.0</TargetFramework>
|
||||||
|
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
@@ -8,11 +8,15 @@
|
|||||||
|
|
||||||
config_version=5
|
config_version=5
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
|
||||||
|
compatibility/default_parent_skeleton_in_mesh_instance_3d=true
|
||||||
|
|
||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="fracturepoint"
|
config/name="fracturepoint"
|
||||||
run/main_scene="uid://bn5opy6atakg"
|
run/main_scene="uid://bn5opy6atakg"
|
||||||
config/features=PackedStringArray("4.5", "C#", "GL Compatibility")
|
config/features=PackedStringArray("4.6", "C#", "GL Compatibility")
|
||||||
run/max_fps=90
|
run/max_fps=90
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user