public void add(FlavorTextObject text) { if (counter == flavorTexts.Length) { ensureCapacity(counter * 2 + 1); } flavorTexts[counter] = text; counter++; }
private void ensureCapacity(int minSize) { FlavorTextObject[] biggerList; if (flavorTexts.Length < minSize) { biggerList = new FlavorTextObject[minSize]; Array.Copy(flavorTexts, 0, biggerList, 0, counter); flavorTexts = biggerList; } }
// Gets information private void Start() { // Gets edgework and day of the week lastSerialDigit = Bomb.GetSerialNumberNumbers().Last(); batteryCount = Bomb.GetBatteryCount(); if (Bomb.GetPortCount(Port.Serial) > 0) { hasSerialPort = true; } foreach (object[] plate in Bomb.GetPortPlates()) { if (plate.Length == 0) { hasEmptyPlate = true; break; } } // Gets the list of flavor texts and chooses a random text flavorTexts = AllFlavorTexts.AddFlavorTexts(); module = flavorTexts.getRandomFlavorText(); // Formats the flavor text for logging string modifiedFlavorText = module.getFlavorText(); modifiedFlavorText = modifiedFlavorText.Replace('\n', ' '); Debug.LogFormat("[Training Text #{0}] The module selected was {1}.", moduleId, module.getModuleName()); Debug.LogFormat("[Training Text #{0}] The flavor text is: {1}", moduleId, modifiedFlavorText); Debug.LogFormat("[Training Text #{0}] The module was released on {1}/{2}/{3}.", moduleId, module.getMonth(), module.getDay(), module.getYear()); // Sets a random time on the clock currentTime = UnityEngine.Random.Range(0, 1440); CalculateCorrectTime(); DisplayCurrentTime(); FlavorText.text = module.getFlavorText(); }