public IEnumerable <Programmer> MakeProgrammers(IEnumerable <ProgrammerSpec> specs) { var newProgrammers = new List <Programmer>(); foreach (var programmerSpec in specs) { programmerSpec.Status.DisposeRegisteredEvents(); var newProgrammer = Instantiate(programmerTemplate); var randomVector = StageField.GetRandomVector(); newProgrammer.transform.position = randomVector; newProgrammer.Ability = programmerSpec.Ability; foreach (var activeSkill in newProgrammer.Ability.AcquiredActiveSkills) { activeSkill.ResetStageParameters(); } newProgrammer.Status = programmerSpec.Status; newProgrammer.Status.ResetStageParameters(); newProgrammers.Add(newProgrammer); } return(newProgrammers); }
private void InitializeProgrammers() { Programmers.Clear(); HashSet <Vector3> programmerPositions = new HashSet <Vector3>(); foreach (var programmerSpec in CurrentStage.ProgrammerSpecs) { programmerSpec.Status.DisposeRegisteredEvents(); var newProgrammer = Instantiate(programmerTemplate); var randomVector = StageField.GetRandomVector(); while (programmerPositions.Contains(randomVector)) { randomVector = StageField.GetRandomVector(); } newProgrammer.transform.position = randomVector; newProgrammer.Ability = programmerSpec.Ability; foreach (var activeSkill in newProgrammer.Ability.AcquiredActiveSkills) { activeSkill.ResetStageParameters(); } newProgrammer.Status = programmerSpec.Status; newProgrammer.Status.ResetStageParameters(); programmerPositions.Add(randomVector); Programmers.Add(newProgrammer); } }
protected internal override IEnumerator RespondToCommandInternal(string inputCommand) { string[] commands = inputCommand.ToLowerInvariant().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (commands.Length < 2) { yield break; } IEnumerable <string> buttonLabels = _buttons.Select(button => button.GetComponentInChildren <TextMesh>().text.ToLowerInvariant()).ToList(); if (buttonLabels.Any(label => label == " ")) { yield break; } IEnumerable <string> submittedText = commands.Skip(1); List <KMSelectable> selectables = new List <KMSelectable>(); if (commands[0].EqualsAny("press", "label", "lab", "l")) { foreach (string text in submittedText) { IEnumerable <string> matchingLabels = buttonLabels.Where(label => label.Contains(text)).ToList(); string fixedText = text; if (!buttonLabels.Contains(text)) { switch (matchingLabels.Count()) { case 1: fixedText = matchingLabels.First(); break; case 0: yield return($"sendtochaterror There isn't any label that contains \"{text}\"."); yield break; default: yield return ($"sendtochaterror There are multiple labels that contain \"{text}\": {string.Join(", ", matchingLabels.ToArray())}."); yield break; } } selectables.Add(_buttons[buttonLabels.IndexOf(label => label == fixedText)]); } } else if (commands[0].EqualsAny("position", "pos", "index", "ind", "i")) { foreach (string text in submittedText) { if (int.TryParse(text, out int index)) { if (index < 1 || index > 5) { yield break; } selectables.Add(_buttons[index - 1]); } } } else { yield break; } int startingStage = (int)StageField.GetValue(_component); foreach (KMSelectable selectable in selectables) { yield return(null); yield return(DoInteractionClick(selectable)); if (startingStage != (int)StageField.GetValue(_component)) { yield break; } } }