protected void SetupTwoColumnAnswers(SouvenirModule souvenir, float xSpacing, float ySpacing) { SetupAnswers(souvenir, NumAnswers > 4 ? souvenir.HighlightShort : souvenir.HighlightLong, getX: i => - 18.125f + xSpacing * (i / 2), getZ: i => - 16.25f + ySpacing * (1 - i % 2), boxCenter: new Vector3(NumAnswers > 4 ? 5 : 8, 0, 0), boxSize: new Vector3(NumAnswers > 4 ? 13 : 19, 6, 3)); }
public override void SetAnswers(SouvenirModule souvenir) { SetupTwoColumnAnswers(souvenir, _answers.Length > 4 ? 13.125f : 19.375f, 7.75f); for (int i = 0; i < souvenir.Answers.Length; i++) { var spriteRenderer = souvenir.Answers[i].transform.Find("SpriteHolder").GetComponent <SpriteRenderer>(); spriteRenderer.gameObject.SetActive(i < _answers.Length); spriteRenderer.sprite = i < _answers.Length ? _answers[i] : null; } }
public override IEnumerable <string> GetAnswers(SouvenirModule module) { var builder = new StringBuilder(); while (true) { foreach (var characterList in characterLists) { for (int i = characterList.Count - 1; i >= 0; --i) { builder.Append(characterList.Pick()); } } yield return(builder.ToString()); builder.Length = 0; } }
protected void SetupAnswers(SouvenirModule souvenir, Mesh highlightMesh, Func <int, float> getX, Func <int, float> getZ, Vector3 boxCenter, Vector3 boxSize) { for (int i = 0; i < souvenir.Answers.Length; i++) { souvenir.Answers[i].gameObject.SetActive(Application.isEditor || i < NumAnswers); souvenir.Answers[i].transform.Find("SpriteHolder").gameObject.SetActive(false); souvenir.Answers[i].transform.Find("AnswerText").gameObject.SetActive(false); var h1 = souvenir.Answers[i].transform.Find("Highlight"); h1.GetComponent <MeshFilter>().sharedMesh = highlightMesh; var h2 = h1.Find("Highlight(Clone)"); if (h2 != null) { h2.GetComponent <MeshFilter>().sharedMesh = highlightMesh; } souvenir.Answers[i].transform.localPosition = new Vector3(getX(i), 2.525f, getZ(i)); souvenir.Answers[i].GetComponent <BoxCollider>().center = boxCenter; souvenir.Answers[i].GetComponent <BoxCollider>().size = boxSize; } }
public override IEnumerable <string> GetAnswers(SouvenirModule module) { var answers = module.GetAnswers(Source); if (answers != null) { if (answers.Length >= 10) { while (true) { yield return(answers.PickRandom()); } } answers = (string[])answers.Clone(); answers.Shuffle(); foreach (var answer in answers) { yield return(answer); } } }
public override void SetAnswers(SouvenirModule souvenir) { if (_layout == AnswerLayout.OneColumn4Answers) { SetupAnswers(souvenir, souvenir.HighlightVeryLong, getX: i => - 18.125f, getZ: i => - 17f + 5 * (3 - i), boxCenter: new Vector3(17, 0, 0), boxSize: new Vector3(38, 5, 3)); } else { SetupTwoColumnAnswers(souvenir, _answers.Length > 4 ? 13.125f : 19.375f, 6.25f); } for (int i = 0; i < souvenir.Answers.Length; i++) { var mesh = souvenir.Answers[i].transform.Find("AnswerText").GetComponent <TextMesh>(); mesh.gameObject.SetActive(true); mesh.text = i < _answers.Length ? _answers[i] : "•"; mesh.font = _font; mesh.fontSize = _fontSize; mesh.GetComponent <MeshRenderer>().material = _fontMaterial; mesh.GetComponent <MeshRenderer>().material.mainTexture = _fontTexture; // Determine size of the answer and if it’s too long, shrink it horizontally to make it fit var origRotation = mesh.transform.localRotation; mesh.transform.eulerAngles = new Vector3(90, 0, 0); mesh.transform.localScale = new Vector3(1, 1, 1); var bounds = mesh.GetComponent <Renderer>().bounds.size; var fac = (_layout == AnswerLayout.OneColumn4Answers ? 1.5 : _answers.Length > 4 ? .45 : .7) * souvenir.SurfaceSizeFactor; if (bounds.x > fac) { mesh.transform.localScale = new Vector3((float)(fac / bounds.x), 1, 1); } mesh.transform.localRotation = origRotation; } }
public override IEnumerable <string> GetAnswers(SouvenirModule module) { if (MaxSteps >= 10) { while (true) { yield return((Random.Range(0, MaxSteps) * Step + Min).ToString(Format)); } } // With no more than 6 possible values, the above case may go into an infinite loop trying to generate 5 distinct values. // In this case, we will return all possible values in a random order and then halt. var values = new int[MaxSteps]; for (int i = MaxSteps - 1; i >= 0; --i) { values[i] = i * Step + Min; } values.Shuffle(); foreach (var i in values) { yield return(i.ToString(Format)); } }
public abstract IEnumerable <string> GetAnswers(SouvenirModule module);
public abstract void BlinkCorrectAnswer(bool on, SouvenirModule souvenir);
public abstract void SetAnswers(SouvenirModule souvenir);
public override void BlinkCorrectAnswer(bool on, SouvenirModule souvenir) { souvenir.Answers[CorrectIndex].transform.Find("SpriteHolder").gameObject.SetActive(on); }