optimized enemy code
This commit is contained in:
@@ -100,16 +100,21 @@ public partial class IQEnemy : CharacterBody2D
|
||||
// Add gravity.
|
||||
if (GroundDetected == false){Velocity = new Vector2(Velocity[0],Velocity[1] + 10);}
|
||||
|
||||
#region 20IQ
|
||||
if (IQ >= 0 && IQ <= 20){ // Goomba ahh diddy blud
|
||||
if (GroundDetected && LedgeDetected == false){Flip();}
|
||||
if (WallDetected){Flip();}
|
||||
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){Velocity = new Vector2(Velocity[0], JumpHeight);} // Jump
|
||||
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)
|
||||
if (GroundDetected){Velocity = new Vector2(WalkSpeed * VAH.Scale[0], Velocity[1]);} // Walk on ground
|
||||
else{Velocity = new Vector2(WalkSpeed * VAH.Scale[0] * 2, Velocity[1]);} // Walk on air
|
||||
@@ -118,6 +123,27 @@ public partial class IQEnemy : CharacterBody2D
|
||||
if (GroundDetected && LedgeDetected == false && Velocity[1] == 0){Velocity = new Vector2(Velocity[0], JumpHeight);} // Jump at ledge
|
||||
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
|
||||
}
|
||||
#endregion
|
||||
#region 80IQ
|
||||
if (IQ > 60 && IQ <= 80){ // Maintan 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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user