public void RemoveElement(SweetTreatRestorationElement restorationElement) { if (restorationElement == null) { return; } BattleUIManager.Instance.RemoveUIElement(restorationElement); RestorationElements.Remove(restorationElement); }
protected void SpawnElement() { //Get an element to spawn RestoreTypes restoreType = ChooseElementToSpawn(); //If we get this value, we shouldn't be spawning if (restoreType == RestoreTypes.None) { Debug.LogError($"{nameof(SweetTreatElementSpawner)} is trying to spawn an element when it shouldn't be!"); return; } int randColRow = GeneralGlobals.Randomizer.Next(0, ColumnRows); float valAdd = randColRow * ColumnRowDiffVal; //Create the element Vector2 startPos = StartSpawnPos; Vector2 endPos = EndSpawnPos; if (IsVertical == true) { startPos.X += valAdd; endPos.X += valAdd; } else { startPos.Y += valAdd; endPos.Y += valAdd; } SweetTreatRestorationElement element = new SweetTreatRestorationElement(restoreType, MovementDur, startPos, endPos); RestorationElements.Add(element); BattleUIManager.Instance.AddUIElement(element); //Remove from this element RestorationTypeTracker[restoreType]--; //Remove the entry if we shouldn't spawn any more of them if (RestorationTypeTracker[restoreType] <= 0) { RestorationTypeTracker.Remove(restoreType); AllowedRestorationTypes.Remove(restoreType); } }