using System; using System.Collections; using System.Text; using PowerTools; using UnityEngine; public class UploadDataGame : Minigame { public SpriteAnim LeftFolder; public SpriteAnim RightFolder; public AnimationClip FolderOpen; public AnimationClip FolderClose; public SpriteRenderer Runner; public HorizontalGauge Gauge; public TextRenderer PercentText; public TextRenderer EstimatedText; public TextRenderer SourceText; public TextRenderer TargetText; public SpriteRenderer Button; public Sprite DownloadImage; public GameObject Status; public GameObject Tower; private int count; private float timer; public const float RandomChunks = 5f; public const float ConstantTime = 3f; private bool running = true; public override void Begin(PlayerTask task) { PlayerControl.LocalPlayer.SetPlayerMaterialColors(this.Runner); base.Begin(task); if (this.MyNormTask.taskStep == 0) { this.Button.sprite = this.DownloadImage; this.Tower.SetActive(false); this.SourceText.Text = this.MyTask.StartAt.ToString(); this.TargetText.Text = "My Tablet"; return; } this.SourceText.Text = "My Tablet"; this.TargetText.Text = "Headquarters"; } public void Click() { base.StartCoroutine(this.Transition()); } private IEnumerator Transition() { this.Button.gameObject.SetActive(false); this.Status.SetActive(true); float target = this.Gauge.transform.localScale.x; for (float t = 0f; t < 0.15f; t += Time.deltaTime) { this.Gauge.transform.localScale = new Vector3(t / 0.15f * target, 1f, 1f); yield return null; } base.StartCoroutine(this.PulseText()); base.StartCoroutine(this.DoRun()); base.StartCoroutine(this.DoText()); base.StartCoroutine(this.DoPercent()); yield break; } private IEnumerator PulseText() { MeshRenderer rend2 = this.PercentText.GetComponent(); MeshRenderer rend1 = this.EstimatedText.GetComponent(); Color gray = new Color(0.3f, 0.3f, 0.3f, 1f); while (this.running) { yield return new WaitForLerp(0.4f, delegate(float t) { Color value = Color.Lerp(Color.black, gray, t); rend2.material.SetColor("_OutlineColor", value); rend1.material.SetColor("_OutlineColor", value); }); yield return new WaitForLerp(0.4f, delegate(float t) { Color value = Color.Lerp(gray, Color.black, t); rend2.material.SetColor("_OutlineColor", value); rend1.material.SetColor("_OutlineColor", value); }); } rend2.material.SetColor("_OutlineColor", Color.black); rend1.material.SetColor("_OutlineColor", Color.black); yield break; } private IEnumerator DoPercent() { while (this.running) { float num = (float)this.count / 5f * 0.7f + this.timer / 3f * 0.3f; if (num >= 1f) { this.running = false; } num = Mathf.Clamp(num, 0f, 1f); this.Gauge.Value = num; this.PercentText.Text = Mathf.RoundToInt(num * 100f) + "%"; yield return null; } yield break; } private IEnumerator DoText() { StringBuilder txt = new StringBuilder("Estimated Time: "); int baselen = txt.Length; int max = 604800; this.count = 0; while ((float)this.count < 5f) { txt.Length = baselen; int num = IntRange.Next(max / 6, max); int num2 = num / 86400; if (num2 > 0) { txt.Append(num2 + "d "); } int num3 = num / 3600 % 24; if (num3 > 0) { txt.Append(num3 + "hr "); } int num4 = num / 60 % 60; if (num4 > 0) { txt.Append(num4 + "m "); } int num5 = num % 60; if (num5 > 0) { txt.Append(num5 + "s"); } this.EstimatedText.Text = txt.ToString(); max /= 4; yield return new WaitForSeconds(FloatRange.Next(0.6f, 1.2f)); this.count++; } this.timer = 0f; while (this.timer < 3f) { txt.Length = baselen; int num6 = Mathf.RoundToInt(3f - this.timer); txt.Append(num6 + "s"); this.EstimatedText.Text = txt.ToString(); yield return null; this.timer += Time.deltaTime; } yield break; } private IEnumerator DoRun() { while (this.running) { UploadDataGame.<>c__DisplayClass25_0 CS$<>8__locals1 = new UploadDataGame.<>c__DisplayClass25_0(); CS$<>8__locals1.<>4__this = this; this.LeftFolder.Play(this.FolderOpen, 1f); CS$<>8__locals1.pos = this.Runner.transform.localPosition; yield return new WaitForLerp(1.125f, delegate(float t) { CS$<>8__locals1.pos.x = Mathf.Lerp(-1.25f, 0.5625f, t); CS$<>8__locals1.<>4__this.Runner.transform.localPosition = CS$<>8__locals1.pos; }); this.LeftFolder.Play(this.FolderClose, 1f); this.RightFolder.Play(this.FolderOpen, 1f); yield return new WaitForLerp(1.375f, delegate(float t) { CS$<>8__locals1.pos.x = Mathf.Lerp(0.5625f, 1.25f, t); CS$<>8__locals1.<>4__this.Runner.transform.localPosition = CS$<>8__locals1.pos; }); yield return new WaitForAnimationFinish(this.RightFolder, this.FolderClose); CS$<>8__locals1 = null; } this.EstimatedText.Text = "Complete"; this.MyNormTask.NextStep(); base.StartCoroutine(base.CoStartClose(0.75f)); yield break; } }