// Runs every frame void Update() { if (CountingDown) { if (CountdownRemaining > 0) { _timer += Time.deltaTime; GOCountdown.text = CountdownRemaining.ToString(); } else { _timer = 0f; CountingDown = false; Ended = false; GOCountdown.gameObject.transform.parent.gameObject.SetActive(false); } } else if (Lost) { if (!Ended) { EndGame(); } } else { if (TimeRemaining > 0f && !Ended) { // Create platform after gapsize if (_prevPlatform.localPosition.x <= PlatformStartX - GapSize) { CreatePlatform(PlatformStartX - GapSize - _prevPlatform.localPosition.x); } // Set UI variables _timer += Time.deltaTime; GOTimeRem.text = TimeRemaining.ToString(); } else if (_finalPlatform == null) { if (_prevPlatform.localPosition.x <= PlatformStartX - GapSize) { _finalPlatform = CreatePlatform(PlatformStartX - GapSize - _prevPlatform.localPosition.x, true); } } } }
public void Draw() { SpriteBatch.Begin(); MiniCoin.Draw(SpriteBatch); MiniAvatar.Draw(SpriteBatch); SpriteBatch.DrawString(TextFont, "PLAYER", TopLeft, Color.Lerp(Color.White, Color.Transparent, .05f)); SpriteBatch.DrawString(TextFont, PlayerName, TopLeft + new Vector2(Constants.ZERO, 25), Color.Lerp(Color.White, Color.Transparent, .05f)); SpriteBatch.DrawString(TextFont, "SCORE", Top2ndRight, Color.Lerp(Color.White, Color.Transparent, .05f)); SpriteBatch.DrawString(TextFont, Score.ToString(), Top2ndRight + new Vector2(Constants.ZERO, 25), Color.Lerp(Color.White, Color.Transparent, .05f)); SpriteBatch.DrawString(TextFont, "LIVES", TopCenter, Color.Lerp(Color.White, Color.Transparent, .05f)); SpriteBatch.DrawString(TextFont, Lives.ToString(), TopCenter + new Vector2(Constants.ZERO, 25), Color.Lerp(Color.White, Color.Transparent, .05f)); SpriteBatch.DrawString(TextFont, "COINS", Top2ndLeft, Color.Lerp(Color.White, Color.Transparent, .05f)); SpriteBatch.DrawString(TextFont, Coins.ToString(), Top2ndLeft + new Vector2(Constants.ZERO, 25), Color.Lerp(Color.White, Color.Transparent, .05f)); SpriteBatch.DrawString(TextFont, "TIME", TopRight, Color.Lerp(Color.White, Color.Transparent, .05f)); SpriteBatch.DrawString(TextFont, TimeRemaining.ToString(), TopRight + new Vector2(Constants.ZERO, 25), Color.Lerp(Color.White, Color.Transparent, .05f)); SpriteBatch.End(); }
public override string ToString() { return(IsRunning ? TimeRemaining.ToString() : "0.0f"); }
public virtual string ToString(string format) { return(TimeRemaining.ToString(format)); }