Refactor and reorganize scripts for improved structure and functionality
- Removed obsolete scripts: Chest, BreakableWall, Door, DoorInteract, and UiManager. - Moved Chest and BreakableWall scripts to EnvironmentObjects folder. - Introduced HammerThrower class to manage hammer throwing mechanics. - Updated PlayerController to utilize new InputManager and HammerThrower. - Refactored PlayerState to manage player state and item collection. - Enhanced UI management in UiManager to reflect player item collection. - Updated EnemyAI to remove unused movement logic. - Adjusted KeyChest to interact with PlayerState instead of Player. - Cleaned up code and improved event handling for item collection.
This commit is contained in:
+27
-27
@@ -13,39 +13,39 @@ public class EnemyAI : Character
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float horizontal = 0;
|
||||
float vertical = 0;
|
||||
// float horizontal = 0;
|
||||
// float vertical = 0;
|
||||
|
||||
Vector2 directionToPlayer = Player.Instance.transform.position - transform.position;
|
||||
directionToPlayer.Normalize();
|
||||
// Vector2 directionToPlayer = Player.Instance.transform.position - transform.position;
|
||||
// directionToPlayer.Normalize();
|
||||
|
||||
float verticalDistance = Player.Instance.transform.position.y - transform.position.y;
|
||||
// float verticalDistance = Player.Instance.transform.position.y - transform.position.y;
|
||||
|
||||
if (Mathf.Abs(verticalDistance) > 0.1f && (isCanClimbUp || isCanGoDown))
|
||||
{
|
||||
vertical = Mathf.Sign(verticalDistance);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Mathf.Abs(Player.Instance.transform.position.x - transform.position.x) < 0.1f)
|
||||
{
|
||||
horizontal = 0;
|
||||
}
|
||||
else if (directionToPlayer.x < 0)
|
||||
{ horizontal = -1; }
|
||||
else if (directionToPlayer.x > 0)
|
||||
{ horizontal = 1; }
|
||||
}
|
||||
// if (Mathf.Abs(verticalDistance) > 0.1f && (isCanClimbUp || isCanGoDown))
|
||||
// {
|
||||
// vertical = Mathf.Sign(verticalDistance);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (Mathf.Abs(Player.Instance.transform.position.x - transform.position.x) < 0.1f)
|
||||
// {
|
||||
// horizontal = 0;
|
||||
// }
|
||||
// else if (directionToPlayer.x < 0)
|
||||
// { horizontal = -1; }
|
||||
// else if (directionToPlayer.x > 0)
|
||||
// { horizontal = 1; }
|
||||
// }
|
||||
|
||||
if (Input.GetKey(KeyCode.T))
|
||||
{ vertical = 1; }
|
||||
if (Input.GetKey(KeyCode.G))
|
||||
{ vertical = -1; }
|
||||
// if (Input.GetKey(KeyCode.T))
|
||||
// { vertical = 1; }
|
||||
// if (Input.GetKey(KeyCode.G))
|
||||
// { vertical = -1; }
|
||||
|
||||
Debug.Log($"Enemy Position: {transform.position}, Player Position: {Player.Instance.transform.position}");
|
||||
Debug.Log($"Vertical Distance: {verticalDistance}, Vertical Movement: {vertical}");
|
||||
// Debug.Log($"Enemy Position: {transform.position}, Player Position: {Player.Instance.transform.position}");
|
||||
// Debug.Log($"Vertical Distance: {verticalDistance}, Vertical Movement: {vertical}");
|
||||
|
||||
base.MoveTo(horizontal, vertical);
|
||||
// base.MoveTo(horizontal, vertical);
|
||||
}
|
||||
|
||||
private float VerticalMove(float verticalDistance)
|
||||
|
||||
Reference in New Issue
Block a user