Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
some updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Greiner committed Dec 5, 2016
1 parent 4ed122b commit 3fa7c92
Show file tree
Hide file tree
Showing 17 changed files with 434 additions and 57 deletions.
2 changes: 1 addition & 1 deletion FillItUp/AppData.dat
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<startScene dataType="Struct" type="Duality.ContentRef`1[[Duality.Resources.Scene]]">
<contentPath dataType="String">Data\Scenes\MainMenu.Scene.res</contentPath>
</startScene>
<version dataType="UInt">137</version>
<version dataType="UInt">279</version>
<websiteUrl dataType="String">http://www.adamslair.net</websiteUrl>
</root>
<!-- XmlFormatterBase Document Separator -->
12 changes: 12 additions & 0 deletions FillItUp/Data/Audio/ticking-clock.AudioData.res

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions FillItUp/Data/Audio/ticking-clock.Sound.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<root dataType="Struct" type="Duality.Resources.Sound" id="129723834">
<assetInfo />
<audioData dataType="Struct" type="System.Collections.Generic.List`1[[Duality.ContentRef`1[[Duality.Resources.AudioData]]]]" id="427169525">
<_items dataType="Array" type="Duality.ContentRef`1[[Duality.Resources.AudioData]][]" id="1100841590">
<item dataType="Struct" type="Duality.ContentRef`1[[Duality.Resources.AudioData]]">
<contentPath dataType="String">Data\Audio\ticking-clock.AudioData.res</contentPath>
</item>
</_items>
<_size dataType="Int">1</_size>
<_version dataType="Int">0</_version>
</audioData>
<fadeOutAt dataType="Float">0</fadeOutAt>
<fadeOutTime dataType="Float">0</fadeOutTime>
<lowpassFactor dataType="Float">1</lowpassFactor>
<maxDistFactor dataType="Float">1</maxDistFactor>
<maxInstances dataType="Int">5</maxInstances>
<minDistFactor dataType="Float">1</minDistFactor>
<pitchFactor dataType="Float">1</pitchFactor>
<type dataType="Enum" type="Duality.Audio.SoundType" name="World" value="0" />
<volFactor dataType="Float">2</volFactor>
</root>
<!-- XmlFormatterBase Document Separator -->
321 changes: 321 additions & 0 deletions FillItUp/Data/Scenes/HowToPlay.Scene.res

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion FillItUp/Data/Scenes/MainMenu.Scene.res
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
<_items dataType="Array" type="Duality.Component[]" id="3511591150" length="4">
<item dataType="Struct" type="FillItUp.MainMenuController" id="2057901380">
<_x003C_NextScene_x003E_k__BackingField dataType="Struct" type="Duality.ContentRef`1[[Duality.Resources.Scene]]">
<contentPath dataType="String">Data\Scenes\GameScene.Scene.res</contentPath>
<contentPath dataType="String">Data\Scenes\HowToPlay.Scene.res</contentPath>
</_x003C_NextScene_x003E_k__BackingField>
<active dataType="Bool">true</active>
<gameobj dataType="ObjectRef">2435526045</gameobj>
Expand Down
2 changes: 1 addition & 1 deletion FillItUp/DefaultUserData.dat
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<customData />
<gfxAAQuality dataType="Enum" type="Duality.AAQuality" name="High" value="0" />
<gfxHeight dataType="Int">720</gfxHeight>
<gfxMode dataType="Enum" type="Duality.ScreenMode" name="FullWindow" value="2" />
<gfxMode dataType="Enum" type="Duality.ScreenMode" name="FixedWindow" value="1" />
<gfxRefreshMode dataType="Enum" type="Duality.RefreshMode" name="VSync" value="2" />
<gfxWidth dataType="Int">1280</gfxWidth>
<sfxEffectVol dataType="Float">1</sfxEffectVol>
Expand Down
Binary file modified FillItUp/DualityEditor.exe
Binary file not shown.
4 changes: 2 additions & 2 deletions FillItUp/EditorUserData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!--DockPanel configuration file. Author: Weifen Luo, all rights reserved.-->
<!--!!! AUTOMATICALLY GENERATED FILE. DO NOT MODIFY !!!-->
<DockPanel FormatVersion="1.0" DockLeftPortion="0.169921875" DockRightPortion="0.222135416666667" DockTopPortion="0.25" DockBottomPortion="0.25" ActiveDocumentPane="6" ActivePane="6">
<DockPanel FormatVersion="1.0" DockLeftPortion="0.169921875" DockRightPortion="0.222135416666667" DockTopPortion="0.25" DockBottomPortion="0.166322314049587" ActiveDocumentPane="6" ActivePane="-1">
<Contents Count="6">
<Content ID="0" PersistString="Duality.Editor.Plugins.CamView.CamView" AutoHidePortion="0.25" IsHidden="False" IsFloat="False" />
<Content ID="1" PersistString="Duality.Editor.Plugins.ProjectView.ProjectFolderView" AutoHidePortion="0.169921875" IsHidden="False" IsFloat="False" />
<Content ID="2" PersistString="Duality.Editor.Plugins.SceneView.SceneView" AutoHidePortion="0.169921875" IsHidden="False" IsFloat="False" />
<Content ID="3" PersistString="Duality.Editor.Plugins.ObjectInspector.ObjectInspector" AutoHidePortion="0.222135416666667" IsHidden="False" IsFloat="False" />
<Content ID="4" PersistString="Duality.Editor.Plugins.LogView.LogView" AutoHidePortion="0.25" IsHidden="False" IsFloat="False" />
<Content ID="4" PersistString="Duality.Editor.Plugins.LogView.LogView" AutoHidePortion="0.166322314049587" IsHidden="False" IsFloat="False" />
<Content ID="5" PersistString="Duality.Editor.Plugins.CamView.CamView" AutoHidePortion="0.25" IsHidden="False" IsFloat="False" />
</Contents>
<Panes Count="8">
Expand Down
4 changes: 2 additions & 2 deletions FillItUp/PackageConfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
<Package id="AdamsLair.Duality.Plugins.Compatibility" version="2.0.2.0" />
<Package id="AdamsLair.Duality.Docs" version="2.0.1.0" />
<Package id="SnowyPeak.Duality.Plugins.YAUI.Core" version="1.0.0.0" />
<Package id="AdamsLair.Duality.Backend.DefaultOpenTK" version="2.0.11.0" />
<Package id="AdamsLair.Duality.Editor" version="2.7.9.0" />
<Package id="AdamsLair.Duality.Editor.Plugins.Base" version="2.2.4.0" />
<Package id="AdamsLair.Duality.Editor.Plugins.CamView" version="2.3.8.0" />
<Package id="AdamsLair.Duality.Editor.Plugins.HelpAdvisor" version="2.0.4.0" />
Expand All @@ -19,5 +17,7 @@
<Package id="AdamsLair.Duality.Editor.Plugins.SceneView" version="2.0.9.0" />
<Package id="AdamsLair.Duality.Editor.Plugins.PackageManagerFrontend" version="2.0.6.0" />
<Package id="AdamsLair.Duality.Editor.Backend.DefaultOpenTK" version="2.0.4.0" />
<Package id="AdamsLair.Duality.Backend.DefaultOpenTK" version="2.0.12.0" />
<Package id="AdamsLair.Duality.Editor" version="2.7.11.0" />
</Packages>
</PackageConfig>
Binary file modified FillItUp/Plugins/GamePlugin.core.dll
Binary file not shown.
Binary file modified FillItUp/Plugins/GamePlugin.core.pdb
Binary file not shown.
Binary file modified FillItUp/Source/Code/.vs/ProjectPlugins/v14/.suo
Binary file not shown.
53 changes: 35 additions & 18 deletions FillItUp/Source/Code/CorePlugin/Cup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,25 @@ public float FillSpeed
private float fillSpeed = 2f;
private readonly ContentRef<Sound> fillingSound = new ContentRef<Sound>(null, "Data/Audio/cup-fill.Sound.res");
private readonly ContentRef<Sound> successSound = new ContentRef<Sound>(null, "Data/Audio/success.Sound.res");
private readonly Random rnd = new Random();

private readonly ColorRgba waterColor = new ColorRgba(52, 152, 219);
private readonly ColorRgba coffeeColor = new ColorRgba(111, 78, 55);
private readonly ColorRgba sodaColor = new ColorRgba(241, 196, 15);
private readonly ColorRgba greenTeeColor = new ColorRgba(46, 204, 113);

private bool showLimit = true;
private bool showDebug = false;

[DontSerialize]
private SpriteRenderer spriteRenderer = null;
private ColorRgba currentLiquidColor = ColorRgba.White;

[DontSerialize]
private float waterFillHeight = 0f;

[DontSerialize]
private readonly Random rnd = new Random();

[DontSerialize]
private float waterLimitPosY = 0f;

[DontSerialize]
private int waterLimitY = 0;

[DontSerialize]
private int limitRange = 0;

Expand All @@ -86,7 +86,6 @@ public void OnInit(InitContext context)
{
if (context == InitContext.Activate)
{
spriteRenderer = GameObj.GetComponent<SpriteRenderer>();
gameManager = GameObj.ParentScene.FindComponent<GameManager>();
}
}
Expand All @@ -98,6 +97,7 @@ public void OnShutdown(ShutdownContext context)
public void Init()
{
SetRandomLimit();
currentLiquidColor = waterColor;
}

public void Fill(bool keyState)
Expand All @@ -106,8 +106,7 @@ public void Fill(bool keyState)
{
if (waterFillHeight <= maxFillHeight)
{
Log.Editor.Write("Water Height: " + waterFillHeight + " Range Pos: " + waterLimitPosY);
waterFillHeight += fillSpeed;
waterFillHeight += fillSpeed * Time.TimeScale;
isFilling = true;
}
}
Expand Down Expand Up @@ -140,14 +139,13 @@ public void Fill(bool keyState)

public void OnUpdate()
{
if (DualityApp.Keyboard.KeyHit(Key.A))
if (DualityApp.Keyboard.KeyPressed(Key.A))
{
SetRandomLimit();
Time.TimeScale = 0.5f;
}

if (DualityApp.Keyboard.KeyHit(Key.R))
else
{
Scene.Reload();
Time.TimeScale = 1f;
}
}

Expand All @@ -157,6 +155,27 @@ public void RestartGame()
waterFillHeight = 0;
isFilling = false;
fillingSoundPlaying = false;

// set random color
var colorId = rnd.Next(0, 4);
switch (colorId)
{
case 0:
currentLiquidColor = waterColor;
break;

case 1:
currentLiquidColor = coffeeColor;
break;

case 2:
currentLiquidColor = sodaColor;
break;

case 3:
currentLiquidColor = greenTeeColor;
break;
}
}

public void SetRandomLimit()
Expand All @@ -165,8 +184,6 @@ public void SetRandomLimit()
var offset = 20;
limitRange = rnd.Next(10, 30);
waterLimitPosY = rnd.Next(-maxFillHeight + offset, -offset - limitRange / 2);
// fix this
Log.Editor.Write("Range: " + limitRange + " Range Pos: " + waterLimitPosY);
}

public override void Draw(IDrawDevice device)
Expand All @@ -193,7 +210,7 @@ public override void Draw(IDrawDevice device)
}

// draw water
canvas.State.ColorTint = new ColorRgba(52, 152, 219);
canvas.State.ColorTint = currentLiquidColor;
canvas.FillRect(pos.X - cupWidth / 2f, cupBottomPosY - waterFillHeight, 0.2f, cupWidth, waterFillHeight);
}
}
Expand Down
29 changes: 22 additions & 7 deletions FillItUp/Source/Code/CorePlugin/GameManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Duality;
using Duality.Audio;
using Duality.Input;
using Duality.Resources;
using System.Diagnostics;
Expand Down Expand Up @@ -45,6 +46,12 @@ public bool GameOver

private Cup activeCup = null;
private readonly ContentRef<Sound> comboSound = new ContentRef<Sound>(null, "Data/Audio/combo.Sound.res");
private readonly ContentRef<Sound> tickingSound = new ContentRef<Sound>(null, "Data/Audio/ticking-clock.Sound.res");

private SoundInstance tickingSoundInstance = null;

[DontSerialize]
private bool tickingSoundPlaying = false;

[DontSerialize]
private bool gameOver = false;
Expand All @@ -56,10 +63,10 @@ public bool GameOver
private int score = 0;

[DontSerialize]
private float startGameTimer = 4000f;
private float startGameTimer = 4000f; // 4000f;

[DontSerialize]
private float countdown = 21000f;
private float countdown = 21000f; // 21

[DontSerialize]
private float gameoverTimer = 2000f;
Expand Down Expand Up @@ -95,20 +102,20 @@ public void InformScore(bool success)
}

// add time to countdown
if (comboCounter == 5)
if ((comboCounter % 5) == 0)
{
DualityApp.Sound.PlaySound(comboSound);
countdown += 5000f;

// reset the combo counter
comboCounter = 0;
}
}
else
{
previousScoreSuccess = false;
comboCounter = 0;
}

var value = comboCounter % 5;
Log.Editor.Write("VALUe: " + value);
}

public void OnUpdate()
Expand All @@ -119,14 +126,22 @@ public void OnUpdate()
{
activeCup?.Fill(keystate);
countdown = MathF.Max(0.0f, countdown - Time.MsPFMult * Time.TimeMult);

if (countdown <= 6000.0f && !tickingSoundPlaying)
{
tickingSoundInstance = DualityApp.Sound.PlaySound(tickingSound);
tickingSoundPlaying = true;
tickingSoundInstance.Looped = true;
}
}

if (countdown <= 0.0f)
{
gameoverTimer = MathF.Max(0.0f, gameoverTimer - Time.MsPFMult * Time.TimeMult);
gameOver = true;
tickingSoundInstance?.Stop();

// don't reload the scene instantly when the game is finished an the play spamms the space key
// don't reload the scene instantly when the game is finished and the play spamms the space key
if (keystate && gameoverTimer <= 0.0f)
Scene.Reload();
}
Expand Down
38 changes: 14 additions & 24 deletions FillItUp/Source/Code/CorePlugin/HUD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,9 @@ public override void Draw(IDrawDevice device)

if (!gameManager.GameStarted)
{
var backgroundHeight = 200f;
const float backgroundHeight = 200f;
var countdownValue = (int)(gameManager.StartGameTimer / 1000f);
if (countdownValue > 0)
gameStartTimerText.ApplySource(countdownValue.ToString());
else
gameStartTimerText.ApplySource("GO");
gameStartTimerText.ApplySource(countdownValue > 0 ? countdownValue.ToString() : "GO");

// countdown text
canvas.State.ColorTint = ColorRgba.White;
Expand All @@ -55,58 +52,51 @@ public override void Draw(IDrawDevice device)

// background
canvas.State.TransformScale = new Vector2(1);
canvas.State.ColorTint = new ColorRgba(0, 0, 0, 0.8f);
canvas.State.ColorTint = new ColorRgba(0, 0, 0, 0.9f);
canvas.FillRect(0, resolution.Y / 2 - backgroundHeight / 2, 0.05f, resolution.X, backgroundHeight);
}
else if (gameManager.GameStarted)
{
// score
canvas.State.TransformScale = new Vector2(0.5f);
canvas.DrawText("Cups filled: " + gameManager.Score, 20, 30, 0f, Alignment.Left);
canvas.DrawText(gameManager.Score.ToString(), resolution.X / 2f, resolution.Y / 2f + 120, 0f, Alignment.Center);

// countdown
var countdownValue = (int)(gameManager.Countdown / 1000f);
canvas.State.TransformScale = new Vector2(1f);
canvas.State.ColorTint = countdownValue > 5 ? ColorRgba.Black : ColorRgba.Red;
canvas.State.ColorTint = countdownValue > 5 ? ColorRgba.Black : new ColorRgba(231, 76, 60);
countdownText.ApplySource(countdownValue.ToString());
canvas.DrawText("Time left: " + countdownText.SourceText, resolution.X / 2f, 100, 0f, Alignment.Center);
canvas.DrawText("Time left: " + countdownText.SourceText, resolution.X / 2f, resolution.Y / 2f - 200, 0f, Alignment.Center);

// combo counter
var comboValue = gameManager.ComboCounter;
canvas.State.TransformScale = new Vector2(1f);
if (comboValue >= 3)
{
canvas.State.ColorTint = ColorRgba.Green;
}
else
{
canvas.State.ColorTint = ColorRgba.Black;
}
canvas.State.TransformScale = new Vector2(0.75f);
canvas.State.ColorTint = comboValue >= 3 ? new ColorRgba(39, 174, 96) : ColorRgba.Black;
comboCounterText.ApplySource(comboValue.ToString());
canvas.DrawText("Combos: " + comboCounterText.SourceText, resolution.X / 2f, 160, 0f, Alignment.Center);
canvas.DrawText("Combos: " + comboCounterText.SourceText, resolution.X / 2f, resolution.Y / 2f - 140, 0.1f, Alignment.Center);
}

if (gameManager.GameOver)
{
var backgroundHeight = 300f;
const float backgroundHeight = 300f;
gameStartTimerText.ApplySource("GAME OVER");

// game over text
canvas.State.ColorTint = ColorRgba.White;
canvas.State.TransformScale = new Vector2(1.5f);
canvas.DrawText(gameStartTimerText.SourceText, resolution.X / 2f, resolution.Y / 2f, 0f, Alignment.Center);
canvas.DrawText(gameStartTimerText.SourceText, resolution.X / 2f, resolution.Y / 2f - 60, 0f, Alignment.Center);

// cups filled text
canvas.State.TransformScale = new Vector2(0.5f);
canvas.DrawText("YOU FILLED >" + gameManager.Score + "< CUPS", resolution.X / 2f, resolution.Y / 2f + 70f, 0f, Alignment.Center);
canvas.DrawText("YOU FILLED " + gameManager.Score + " CUPS", resolution.X / 2f, resolution.Y / 2f + 20f, 0f, Alignment.Center);

// restart game text
canvas.State.TransformScale = new Vector2(0.45f);
canvas.DrawText("PRESS SPACE TO RESTART", resolution.X / 2f, resolution.Y / 2f + 120f, 0f, Alignment.Center);
canvas.DrawText("PRESS SPACE TO RESTART", resolution.X / 2f, resolution.Y / 2f + 80f, 0f, Alignment.Center);

// background
canvas.State.TransformScale = new Vector2(1);
canvas.State.ColorTint = new ColorRgba(0, 0, 0, 0.8f);
canvas.State.ColorTint = new ColorRgba(0, 0, 0, 0.9f);
canvas.FillRect(0, resolution.Y / 2 - backgroundHeight / 2, 0.05f, resolution.X, backgroundHeight);
}
}
Expand Down
Binary file added FillItUp/Source/Media/Audio/ticking-clock.ogg
Binary file not shown.
2 changes: 1 addition & 1 deletion FillItUp/UserData.dat
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<customData />
<gfxAAQuality dataType="Enum" type="Duality.AAQuality" name="High" value="0" />
<gfxHeight dataType="Int">720</gfxHeight>
<gfxMode dataType="Enum" type="Duality.ScreenMode" name="FullWindow" value="2" />
<gfxMode dataType="Enum" type="Duality.ScreenMode" name="FixedWindow" value="1" />
<gfxRefreshMode dataType="Enum" type="Duality.RefreshMode" name="VSync" value="2" />
<gfxWidth dataType="Int">1280</gfxWidth>
<sfxEffectVol dataType="Float">1</sfxEffectVol>
Expand Down

0 comments on commit 3fa7c92

Please sign in to comment.