Skip to content

Commit

Permalink
Energia dla Normy
Browse files Browse the repository at this point in the history
  • Loading branch information
ktos committed Jan 29, 2022
1 parent 8de9e0f commit 0c90ace
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 27 deletions.
8 changes: 7 additions & 1 deletion Rex2/DialogueManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private void EmptyDialogue(int elapsedTime)
dialogueShowTime = elapsedTime;
}

public void UpdateDialogue(LevelBase level, LevelDefinition def, Player player)
public void UpdateDialogue(LevelBase level, LevelDefinition def, Player player, Norma norma)
{
if (def.LevelTime - level.ElapsedTime < 30 && currentSequence != outOfTime)
{
Expand All @@ -204,6 +204,12 @@ public void UpdateDialogue(LevelBase level, LevelDefinition def, Player player)
return;
}

if (norma.Energy < 2 && currentSequence != takeShiny)
{
UpdateDialogueOnSituation(Situation.LowNormaEnergy);
return;
}

if (level.ElapsedTime - dialogueShowTime >= DisplayedDialogue.Time)
{
if (dialogueIndex + 1 < currentSequence.Count)
Expand Down
10 changes: 7 additions & 3 deletions Rex2/Norma.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace Rex2
{
internal class Norma
public class Norma
{
public Match3GameManager Board { get; set; }
public int Energy { get; set; } = 0;
public int Energy { get; set; } = 10;

public Action<TileType, int> GiveBuff { get; set; }

Expand Down Expand Up @@ -187,8 +187,11 @@ private bool Fall(int x, int y)
public Vector2? FirstActive { get; set; }
public Vector2? SecondActive { get; set; }

public void MarkActive(int x, int y)
public void MarkActive(int x, int y, Norma parent)
{
if (parent.Energy <= 0)
return;

if (FirstActive == null)
{
FirstActive = new Vector2(x, y);
Expand All @@ -207,6 +210,7 @@ public void MarkActive(int x, int y)
if (l == 1)
{
SwapTiles((int)FirstActive.Value.X, (int)FirstActive.Value.Y, (int)SecondActive.Value.X, (int)SecondActive.Value.Y);
parent.Energy--;
Check();
}

Expand Down
30 changes: 7 additions & 23 deletions Rex2/levels/TestLevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private void BuffPlayer(TileType t, int count)
private void UpdateTime(object? state)
{
ElapsedTime++;
dialogueManager.UpdateDialogue(this, level, player);
dialogueManager.UpdateDialogue(this, level, player, norma);
}

public override void Update(float deltaTime)
Expand Down Expand Up @@ -258,11 +258,13 @@ private void Draw()
EndTextureMode();
}

private void RenderPlayerStats()
private void DrawResources()
{
DrawText($"{player.HP}", 60, 15, 20, RED);
DrawText($"{player.Shield}", 265, 15, 20, GREEN);
DrawText($"{player.Ammo}", 470, 15, 20, BLUE);

DrawText($"{norma.Energy}", 770, 15, 20, GOLD);
}

private void RenderBullets()
Expand All @@ -275,16 +277,8 @@ private void RenderBullets()

private void RenderPlayer2()
{
//DrawRot13AnimatedText("Wake up, Rex!", 10, 0, 220, 14, MAGENTA);
//DrawCenteredText("Zażółć gęślą jaźń", 50, 18, GREEN);
//DrawRectangledTextEx(new Rectangle(20, 20, 120, 120), "This is a longer text with wrapping.", 14, DARKGREEN, GRAY);

//DrawRectangle(0, 0, 319, 10, RED);

Vector2 virtualMouse = GetVirtualMouse();

//DrawText($"{virtualMouse.X}, {virtualMouse.Y}", 0, 0, 10, GOLD);

for (int i = 0; i < norma.Board.sizeX; i++)
{
for (int j = 0; j < norma.Board.sizeY; j++)
Expand All @@ -294,7 +288,7 @@ private void RenderPlayer2()
if (g == null)
continue;

if (CheckCollisionPointRec(virtualMouse, g.Rect))
if (CheckCollisionPointRec(virtualMouse, g.Rect) && norma.Energy > 0)
{
if (!g.Hover)
{
Expand All @@ -303,22 +297,14 @@ private void RenderPlayer2()

if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON) && !g.Active)
{
norma.Board.MarkActive(i, j);
norma.Board.MarkActive(i, j, norma);
}
}
else if (g.Hover)
{
g.Hover = false;
}

//if (IsMouseButtonDown(MouseButton.MOUSE_LEFT_BUTTON))
//{
// if (g.Hover)
// {
// g.Active = true;
// }
//}

Color c = WHITE;

if (g.type == TileType.RED)
Expand All @@ -339,8 +325,6 @@ private void RenderPlayer2()
c = BLACK;

DrawTexture(jewel, (int)g.Rect.x, (int)g.Rect.y, c);

//DrawRectangle((int)g.Rect.x, (int)g.Rect.y, (int)g.Rect.width, (int)g.Rect.height, c);
}
}
}
Expand Down Expand Up @@ -378,7 +362,7 @@ internal override void DrawMain()
{
base.DrawMain();

RenderPlayerStats();
DrawResources();
DrawDialogueText(dialogueManager.DisplayedDialogue.Text, dialogueManager.DisplayedDialogue.IsNorma ? BLUE : RED);
DrawRemainingTime(level.LevelTime - ElapsedTime);
}
Expand Down

0 comments on commit 0c90ace

Please sign in to comment.