public void TestRGBLED() { IWattCalculator test = new Breadboard(); Assert.AreEqual(3.50, test.Measure()); test = new RGBLED(test); Assert.AreEqual(15.48, test.Measure() - 3.50); }
public void TestResistor() { IWattCalculator test = new Breadboard(); Assert.AreEqual(3.50, test.Measure()); test = new Resistor(test); Assert.AreEqual(17.24, test.Measure() - 3.50); }
public void TestBuzzer() { IWattCalculator test = new Breadboard(); Assert.AreEqual(3.50, test.Measure()); test = new Buzzer(test); Assert.AreEqual(8.91, test.Measure() - 3.50); }
void Awake() { if (instance != null) { Debug.LogWarning("More than one breadboard created!"); return; } instance = this; }
public void TestComponents() { IWattCalculator test = new ArduinoUno(); Assert.AreEqual(21.40, test.Measure()); test = new ArduinoDuo(); Assert.AreNotEqual(21.40, test.Measure()); Assert.AreEqual(27.43, test.Measure()); test = new Breadboard(); Assert.AreNotEqual(27.43, test.Measure()); Assert.AreEqual(3.50, test.Measure()); }
// Start is called before the first frame update void Start() { breadboard = Breadboard.instance; slots = itemsParent.GetComponentsInChildren <BreadboardSlot>(); BreadboardSlot[] row_slots = new BreadboardSlot[SLOTS_IN_ROW]; int row_number = 0; for (int i = 0; i < slots.Length; i++) { if (0 == i % SLOTS_IN_ROW && i != 0) { InitRow(row_slots); row_slots = new BreadboardSlot[SLOTS_IN_ROW]; } row_slots[i % SLOTS_IN_ROW] = slots[i]; slots[i].id = i; slots[i].parent = this; } }
private void TrySpawnOnBreadboard() { if (_holes.Count == _activeSpawnablePrefabHolesNeeded) { // Breadboard holes Transform H_1_place = _holes.Dequeue(); Transform H_2_place = _holes.Dequeue(); GameEvents.current.FireEvent_UnmarkHoleAsWiring(H_1_place); GameEvents.current.FireEvent_UnmarkHoleAsWiring(H_2_place); Breadboard breadboard = _breadboard.GetComponent <Breadboard>(); if (breadboard.HolesOccupied(H_1_place, H_2_place, out string errorText)) { GameEvents.current.FireEvent_HUDMessage(errorText, Controllers.HUDMessageType.Error); return; } if (breadboard.HolesNearbyInline(H_1_place, H_2_place)) { // Init prefab GameObject prefab = Instantiate(_activeSpawnablePrefab); PlaceComponentOnBreadboard(prefab, H_1_place, H_2_place); ComponentType type = ComponentType.Unknown; foreach (Tag tag in prefab.GetComponent <BaseComponent>().Tags) { switch (tag) { case Tag.LED: { type = ComponentType.LED; prefab.GetComponent <LED>().CathodeCoord = // Breadboard first click is always Cathode (-) H_1_place.name.Replace("H_", ""); // Name is like H_G1, etc., we only need postfix prefab.GetComponent <LED>().AnodeCoord = // Second click is always Anode (+) H_2_place.name.Replace("H_", ""); // Name is like H_J2, etc., we only need postfix break; } case Tag.Resistor: { type = ComponentType.Resistor; prefab.GetComponent <Resistor>().SetResistance(_resistorOhmConfigured); prefab.GetComponent <Resistor>().Coord1 = // No polarity component, coord1 might be coord2, // It doesn't matter H_1_place.name.Replace("H_", ""); // Name is like H_G1, etc., we only need postfix prefab.GetComponent <Resistor>().Coord2 = // No polarity component, coord1 might be coord2, // It doesn't matter H_2_place.name.Replace("H_", ""); // Name is like H_G1, etc., we only need postfix break; } } } // Inform about occupied breaboard holes GameEvents.current.FireEvent_ComponentSpawnBreadboard(H_1_place, H_2_place, type, prefab); //GameEvents.current.FireEvent_HUDMessage("Component spawned!", Controllers.HUDMessageType.Info); } else { GameEvents.current.FireEvent_HUDMessage("Draudžiamos mazgų pozicijos!", Controllers.HUDMessageType.Error); } } }