public void ActivatePlayerStructure(bool value) { if (value) { _audioComponent.PlayAudio("chose-player"); _cinemachine.Follow = this.transform; } if (_hightlight != null) { _hightlight.SetActive(value); } _activePlayerUI.ActivatePlayerSlot(slotInstanceId.Value); _uIManager.ActivateInventory(_isMainPlayer); _uIManager.ActivateActionSlots(_isMainPlayer); _uIManager.ActivateStomach(_canPoop); IsActive = value; if (_canMoveByClick) { _movementMouseComponent.SetActivationComponent(value); } if (_canInteract) { _interactableComponent.SetActivationComponent(value); } if (_canPoop) { _stomachComponent.SetActivationComponent(value); } }
private void ManageMouseUniqueLeftClick() { if (_inputManager.MouseLeftButton == 1 && !_leftButtomPressed) { _leftButtomPressed = true; _audioComponent.PlayAudio("click"); List <IInteractable> interactableList = new List <IInteractable>(); List <Button> buttonList = new List <Button>(); List <IPlayer> playersList = new List <IPlayer>(); InventorySlotComponent _inventorySlotComponent = null; bool hitSomeUIComponent = false; _canMove = true; Vector2 mousePosition = this.ManageMouseClick((hitUI) => { hitSomeUIComponent = true; if (_inventorySlotComponent is null) { _inventorySlotComponent = hitUI.gameObject.GetComponent <InventorySlotComponent>(); } }, (hit) => { buttonList.AddRange(hit.collider.gameObject.GetComponents <Button>()); interactableList.AddRange(hit.collider.gameObject.GetComponents <IInteractable>().Where(e => e.PlayerInteractWith).ToList()); playersList.AddRange(hit.collider.gameObject.GetComponents <IPlayer>().ToList()); }); // => UI INTERACTIONS if (_inventorySlotComponent != null) { _inventorySlotComponent.StartInteraction(); } if (hitSomeUIComponent) { return; } // => NORMAL INTERACTIONS IInteractable interactableChoice = interactableList.OrderBy(e => e.Order()).FirstOrDefault(); if (playersList.Any() && interactableChoice is IDamageTaker) { interactableChoice = interactableList.Where(e => !(e is IDamageTaker)).OrderBy(e => e.Order()).FirstOrDefault(); } if (interactableChoice is IDamageTaker damagable) { DamageDealerComponent damageDealerComponent = _playerStateManager.GetActivePlayerStructure().GetDamageDealerComponent(); if (damageDealerComponent is null) { return; } damagable.StartCombat(damageDealerComponent); } if (interactableChoice is IPickable pickable) { pickable.PickUp(); } if (interactableChoice is IPlantable plantable) { plantable.Interact(); } } else if (_inputManager.MouseLeftButton == 0 && _leftButtomPressed) { _leftButtomPressed = false; } }