Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Clock #499

Merged
merged 3 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions CheatCodeClasses/GetClock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Microsoft.Xna.Framework;

namespace LegendOfZelda
{
public class GetClock : ICheatCode
{
Vector2 LinkPos;
public GetClock()
{
}

public void Execute()
{
LinkPos = GameState.Link.Pos;
Clock item = new(new Vector2(LinkPos.X + 10, LinkPos.Y - 70));
item.Show();
}
}
}
17 changes: 17 additions & 0 deletions Command/CheatCodes/GetClockCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace LegendOfZelda
{
public class GetClockCommand : ICommands
{
private GetClock cheatCode;
public GetClockCommand()
{
cheatCode = new GetClock();
}

public void Execute()
{
cheatCode.Execute();
}
}
}

8 changes: 8 additions & 0 deletions Controller/CheatCodeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class CheatCodeController : IController
private AddKeyCommand addKeyCommand;
private InvincibleCommand invincibleCommand;
private AddBombCommand addBombCommand;
private GetClockCommand getClockCommand;

public CheatCodeController()
{
Expand All @@ -21,6 +22,7 @@ public CheatCodeController()
addKeyCommand = new AddKeyCommand();
invincibleCommand = new InvincibleCommand();
addBombCommand = new AddBombCommand();
getClockCommand = new GetClockCommand();
}

public void Update()
Expand Down Expand Up @@ -61,6 +63,12 @@ public void Update()
ReleasedKey = false;
SoundFactory.PlaySound(SoundFactory.getInstance().GetItem);
}
else if (Keyboard.GetState().IsKeyDown(Keys.C) && Keyboard.GetState().IsKeyDown(Keys.G) && ReleasedKey)
{
getClockCommand.Execute();
ReleasedKey = false;
SoundFactory.PlaySound(SoundFactory.getInstance().GetItem);
}

if (Keyboard.GetState().IsKeyUp(Keys.C) && Keyboard.GetState().IsKeyUp(Keys.H) && Keyboard.GetState().IsKeyUp(Keys.P) && Keyboard.GetState().IsKeyUp(Keys.J) && Keyboard.GetState().IsKeyUp(Keys.T) && !ReleasedKey)
{
Expand Down
21 changes: 12 additions & 9 deletions Enemies/BlueGoriya.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,23 @@ public void ChangeDirection()
public void Update(GameTime gameTime)
{
CurrentCooldown -= (float)gameTime.ElapsedGameTime.TotalSeconds; // Decrement the cooldown timer
if (gameTime.TotalGameTime.TotalMilliseconds > LastSwitch + 1000)
if (!Frozen)
{
LastSwitch = gameTime.TotalGameTime.TotalMilliseconds;
UpdateCount++;
if (gameTime.TotalGameTime.TotalMilliseconds > LastSwitch + 1000)
{
LastSwitch = gameTime.TotalGameTime.TotalMilliseconds;
UpdateCount++;

ChangeDirection();
ChangeDirection();

if (UpdateCount % 2 == 0)
{
Attack();
if (UpdateCount % 2 == 0)
{
Attack();
}
}
ChangePosition();
Collider.Pos = Position;
}
ChangePosition();
Collider.Pos = Position;
}
public void OnCollision(List<CollisionInfo> collisions)
{
Expand Down
21 changes: 12 additions & 9 deletions Enemies/Goriya.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,23 @@ public void ChangeDirection()
public void Update(GameTime gameTime)
{
CurrentCooldown -= (float)gameTime.ElapsedGameTime.TotalSeconds; // Decrement the cooldown timer
if (gameTime.TotalGameTime.TotalMilliseconds > LastSwitch + 1000)
if (!Frozen)
{
LastSwitch = gameTime.TotalGameTime.TotalMilliseconds;
UpdateCount++;
if (gameTime.TotalGameTime.TotalMilliseconds > LastSwitch + 1000)
{
LastSwitch = gameTime.TotalGameTime.TotalMilliseconds;
UpdateCount++;

ChangeDirection();
ChangeDirection();

if (UpdateCount % 2 == 0)
{
Attack();
if (UpdateCount % 2 == 0)
{
Attack();
}
}
ChangePosition();
Collider.Pos = Position;
}
ChangePosition();
Collider.Pos = Position;
}
public void OnCollision(List<CollisionInfo> collisions)
{
Expand Down