public void UpdateScore(Timer timer, bool taskFinished) { // Obtain the ratio of time remaining to total time //we want the player to be able to get 100% points & happiness //for the first 15% of time double ratio = Math.Min(1, timer.TimeRemaining / (timer.TotalTime * 0.85)); // Update the Score if (taskFinished) score = score + currentTaskValue + (currentTaskValue / 2); else score = score + currentTaskValue; // Update the Happiness and Multiplier if (!timer.help) { int currMulti = getMultiplier(); happinessChange = (int)(ratio * 30 - 15); if (prestige == 1 && happinessChange < 0) { if (ratio != 0.0) happinessChange = 0; else happinessChange = -5; } happiness += happinessChange; happiness = Math.Max(Math.Min(happiness, 100), 0); multiplierChange = getMultiplier() - currMulti; } else { timer.help = false; happinessChange = 0; } // Update the Prestige int currPres = prestige; UpdatePrestige(); prestigeChange = prestige - currPres; if (prestigeChange != 0) { level.AddSFX(Level.SFXNames.levelUp); if (prestige == 2) { needsAdvancedNotification = true; numAdvancedNotification = 0; } else if (prestige == 4) { needsAdvancedNotification = true; numAdvancedNotification = 1; } else if (prestige == 3) { needsAdvancedNotification = true; numAdvancedNotification = 2; } } // Check win/lose conditions if (prestige == 10) { level.GameEnd(true); } else if (happiness <= 0) { level.GameEnd(false); } updated = true; }
private void LoadHud() { guiItems = new List<IDisplayableItem>(); timer = new Timer(this, 45000, 745, 0); guiItems.Add(timer);// Prob need to define current allocated time from task. score = new Scorebar(this); guiItems.Add(score); background = Content.Load<Texture2D>("UI/game-backdrop"); hudBg = Content.Load<Texture2D>("UI/hud-backdrop"); hudFont = Content.Load<SpriteFont>("UI/Courier New"); #if !WINDOWS cursor = Content.Load<Texture2D>("Hand/hand-down"); cursor2 = Content.Load<Texture2D>("Hand/hand-up"); #endif }
public void updateCurrentTaskValue(Timer timer, int value) { if (newTask) { currentTaskValue = 0; newTask = false; } else { double ratio = Math.Min(1, timer.TimeRemaining / (timer.TotalTime * 0.85)); value = (int)(value * ratio); value = value * getMultiplier(); currentTaskValue += value; } }
public void Dispose() { timer = null; score = null; task = null; Element.ElementBuilder.OnBuild -= Add; if (!displayItems.Contains(tutorial)) tutorial.Dispose(); tutorial = null; foreach (IDisplayableItem item in displayItems) { item.Dispose(); } displayItems = null; foreach (IDisplayableItem item in guiItems) { item.Dispose(); } guiItems = null; foreach (IDisplayableItem item in displayItemsToAdd) { item.Dispose(); } displayItemsToAdd = null; foreach (IDisplayableItem item in displayItemsToRemove) { item.Dispose(); } displayItemsToRemove = null; }