public void Initialization() { foreach (var controller in _executeControllers) { if (controller is IInitialization initialization) { initialization.Initialization(); } } ServiceLocator.Resolve<InputController>().On(); ServiceLocator.Resolve<PlayerController>().On(); }
public void Execute() { if (!IsActive) { return; } if (Input.GetKeyDown(_activeFlashLight)) { ServiceLocator.Resolve <FlashLightController>().Switch(); } if (Input.GetKeyDown(_toggleHighlightInfo)) { ServiceLocator.Resolve <HighlightController>().Switch(); } }
public Controllers() { IMotor motor = new UnitMotor(ServiceLocatorMonoBehaviour.GetService <CharacterController>()); ServiceLocator.SetService(new PlayerController(motor)); ServiceLocator.SetService(new FlashLightController()); ServiceLocator.SetService(new InputController()); ServiceLocator.SetService(new SelectionController()); _executeControllers = new IExecute[4]; _executeControllers[0] = ServiceLocator.Resolve <PlayerController>(); _executeControllers[1] = ServiceLocator.Resolve <FlashLightController>(); _executeControllers[2] = ServiceLocator.Resolve <InputController>(); _executeControllers[3] = ServiceLocator.Resolve <SelectionController>(); }
public void Execute() { if (!IsActive) { return; } if (Input.GetKeyDown(_activeFlashLight)) { ServiceLocator.Resolve <FlashLightController>().Switch(ServiceLocator.Resolve <Inventory>().FlashLight); } else if (Input.GetKeyDown(KeyCode.Alpha1)) { SelectWeapon(0); } else if (Input.GetKeyDown(_cancel)) { ServiceLocator.Resolve <WeaponController>().Off(); ServiceLocator.Resolve <FlashLightController>().Off(); } else if (Input.GetKeyDown(_reloadClip)) { ServiceLocator.Resolve <WeaponController>().ReloadClip(); } else if (Input.GetKeyDown(_removeWeapon)) { ServiceLocator.Resolve <WeaponController>().Off(); ServiceLocator.Resolve <Inventory>().RemoveWeapon(); } if (Input.GetMouseButton(_mouseButton)) { if (ServiceLocator.Resolve <WeaponController>().IsActive) { ServiceLocator.Resolve <WeaponController>().Fire(); } } if (Input.GetAxis("Mouse ScrollWheel") > 0) // todo manager { MouseScroll(MouseScrollWheel.Up); } if (Input.GetAxis("Mouse ScrollWheel") < 0) { MouseScroll(MouseScrollWheel.Down); } }
/// <summary> /// Выбор оружия по номеру /// </summary> /// <param name="i">Номер оружия</param> public static void SelectWeapon(int i) { if (i < 0) { i = 0; } if (i > 2) { i = 2; } ServiceLocator.Resolve <WeaponController>().Off(); var tempWeapon = ServiceLocator.Resolve <Inventory>().Weapons[i]; if (tempWeapon != null) { ServiceLocator.Resolve <WeaponController>().On(tempWeapon); _weaponNumber = i; } }
/// <summary> /// Выбор оружия по номеру /// </summary> /// <param name="i">Номер оружия</param> public Weapon SelectWeapon(int i) { if (i < 0) { i = 0; } if (i >= Weapons.Length) { i = Weapons.Length - 1; } Weapon tempWeapon = ServiceLocator.Resolve <Inventory>().Weapons[i]; if (tempWeapon != null) { _weaponIndex = i; return(tempWeapon); } else { return(ServiceLocator.Resolve <Inventory>().Weapons[0]); } }
public void Initialization() { _highlightUI = Object.FindObjectOfType <HighlightUI>(); _transform = ServiceLocator.Resolve <PlayerController>().PlayerModel.Transform; }
public void Execute() { if (!IsActive) { return; } if (Input.GetKeyDown(_activeFlashLight)) { ServiceLocator.Resolve <FlashLightController>().Switch(ServiceLocator.Resolve <Inventory>().FlashLight); } //todo реализовать выбор оружия по колесику мыши - done if (Input.GetAxis("Mouse ScrollWheel") > 0) { Inventory.SelectNextWeapon(); } if (Input.GetAxis("Mouse ScrollWheel") < 0) { Inventory.SelectPreviousWeapon(); } if (Input.GetKeyDown(KeyCode.Alpha0)) { Inventory.RemoveWeapon(); } if (Input.GetKeyDown(KeyCode.Alpha1)) { Inventory.SelectWeapon(0); } if (Input.GetKeyDown(KeyCode.Alpha2)) { Inventory.SelectWeapon(1); } if (Input.GetKeyDown(KeyCode.Alpha3)) { Inventory.SelectWeapon(2); } if (Input.GetMouseButton(_mouseButton)) { if (ServiceLocator.Resolve <WeaponController>().IsActive) { ServiceLocator.Resolve <WeaponController>().Fire(); } } if (Input.GetKeyDown(_cancel)) { ServiceLocator.Resolve <WeaponController>().Off(); ServiceLocator.Resolve <FlashLightController>().Off(); } if (Input.GetKeyDown(_reloadClip)) { ServiceLocator.Resolve <WeaponController>().ReloadClip(); } }
public static void RemoveWeapon() { ServiceLocator.Resolve <WeaponController>().Off(); _weaponNumber = 0; }
private void MouseScroll(MouseScrollWheel value) { var tempWeapon = ServiceLocator.Resolve <Inventory>().SelectWeapon(value); SelectWeapon(tempWeapon); }
private void SelectWeapon(int value) { var tempWeapon = ServiceLocator.Resolve <Inventory>().SelectWeapon(value); SelectWeapon(tempWeapon); }