/// <summary> /// Handles updates including keypresses and time management for game over/resetting to inactive /// </summary> /// <returns> the state of this enemy after the update has effected </returns> public ActiveType ProcessInput() { float chargeAmount = _charger.Charge(); if (_state == ActiveType.Aggressive) { if (chargeAmount >= 0.25f * _chargeLevel) { _level -= 1; if (_level == 0) { _state = ActiveType.Inactive; GetComponent <Image>().color = Color.white; } else { // TODO: rethink this, possible to abuse? // Give only what is possible for player to handle in time // 2.5 instead of 3 so that player has 0.5s at least to react int maxChargeLevel = (int)System.Math.Min((2.5f - (Time.time - _activeTime)) / 0.5f, 4f); _chargeLevel = Random.Range(1, maxChargeLevel); GetComponent <Image>().color = _colorTabel[_chargeLevel]; } } } else if (_state == ActiveType.Friendly) { if (chargeAmount >= 0.25f) { _state = ActiveType.GameOver; } } _elapsedTime = Time.time - _activeTime; if (_state == ActiveType.Aggressive && _elapsedTime >= _gameOverTime) { _state = ActiveType.GameOver; } else if (_state == ActiveType.Friendly && _elapsedTime >= _friendlyTime) { _state = ActiveType.Inactive; GetComponent <Image>().color = Color.white; } return(_state); }
public void InstanceTest() { var exception = (Exception)null; try { var usbConnector = new UsbConnector(); var usbToUsbCAdapter = new UsbToUsbCAdapter(usbConnector); var charger = new Charger(usbToUsbCAdapter); charger.ConnectUsbC(); charger.Charge(); } catch (Exception e) { exception = e; } Assert.IsTrue(exception is null, $"An exception was thrown: {exception?.Message}"); }
public void Charge() { Output.WriteLine("Charge the phone:"); Charger.Charge(); }
public void Charge() { Charger.Charge(); }
private static void AdapterPattern() { Battery carBattery = new Charger(); carBattery.Charge(); }