public void CloseSkillsPanel() { GameManager.Instance.ClearListKeeperSelected(); Cursor.SetCursor(GameManager.Instance.Texture2DUtils.iconeMouse, Vector2.zero, CursorMode.Auto); BattleHandler.ActivateFeedbackSelection(true, false); BattleHandler.DeactivateFeedbackSelection(false, true); }
// TODO: some things are in double for left click private void HandleActionValidationDuringBattle() { bool isClickOnWrongTarget = false; if (!EventSystem.current.IsPointerOverGameObject()) { RaycastHit hitInfo; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo, Mathf.Infinity, ~layerMaskClickGauche) == true) { GameObject clickTarget = hitInfo.collider.gameObject; if (clickTarget.GetComponentInParent <PawnInstance>() != null) { if ((BattleHandler.PendingSkill.TargetType == TargetType.FoeSingle && clickTarget.GetComponentInParent <Monster>() != null) || BattleHandler.PendingSkill.TargetType == TargetType.FriendSingle && (clickTarget.GetComponentInParent <Keeper>() != null || clickTarget.GetComponentInParent <Escortable>() != null)) { CursorNormalState(); BattleHandler.DeactivateFeedbackSelection(true, true); BattleHandler.PendingSkill.UseSkill(clickTarget.GetComponentInParent <PawnInstance>()); } else { isClickOnWrongTarget = true; } } else { CursorNormalState(); BattleHandler.DeactivateFeedbackSelection(true, true); BattleHandler.ActivateFeedbackSelection(true, false); BattleHandler.PendingSkill = null; GameManager.Instance.ClearListKeeperSelected(); } } else { CursorNormalState(); BattleHandler.DeactivateFeedbackSelection(true, true); BattleHandler.ActivateFeedbackSelection(true, false); BattleHandler.PendingSkill = null; GameManager.Instance.ClearListKeeperSelected(); } } else { CursorNormalState(); BattleHandler.DeactivateFeedbackSelection(true, true); BattleHandler.ActivateFeedbackSelection(true, false); BattleHandler.PendingSkill = null; GameManager.Instance.ClearListKeeperSelected(); } if (!BattleHandler.WasTheLastToPlay && !BattleHandler.IsWaitingForSkillEnd && !isClickOnWrongTarget) { CursorNormalState(); BattleHandler.DeactivateFeedbackSelection(true, true); BattleHandler.ActivateFeedbackSelection(true, false); } }
private void InBattleControls() { if (BattleHandler.IsABattleAlreadyInProcess() && BattleHandler.IsKeepersTurn && BattleHandler.HasDiceBeenThrown && !BattleHandler.IsWaitingForSkillEnd) { if (Input.GetMouseButtonDown(0)) { if (GameManager.Instance.ListOfSelectedKeepers != null && GameManager.Instance.ListOfSelectedKeepers.Count > 0 && BattleHandler.PendingSkill != null) { HandleActionValidationDuringBattle(); } else { if (!EventSystem.current.IsPointerOverGameObject()) { RaycastHit hitInfo; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo, Mathf.Infinity, ~layerMaskClickGauche) == true) { GameObject clickTarget = hitInfo.collider.gameObject; if (GameManager.Instance.ListOfSelectedKeepers != null && GameManager.Instance.ListOfSelectedKeepers.Count > 0) { // TODO: find another way GameManager.Instance.GetBattleUI.GetComponent <UIBattleHandler>().GetSkillsPanelIndex(GameManager.Instance.GetFirstSelectedKeeper()).gameObject.SetActive(false); } if (clickTarget.GetComponentInParent <PawnInstance>() != null) { if (clickTarget.GetComponentInParent <Keeper>() != null || clickTarget.GetComponentInParent <Prisoner>() != null) { if (clickTarget.GetComponentInParent <Fighter>() != null && !clickTarget.GetComponentInParent <Fighter>().HasPlayedThisTurn) { GameManager.Instance.ClearListKeeperSelected(); GameManager.Instance.AddKeeperToSelectedList(clickTarget.GetComponentInParent <PawnInstance>()); if (clickTarget.GetComponentInParent <Prisoner>() != null) { clickTarget.GetComponentInParent <Prisoner>().IsSelected = true; } else { clickTarget.GetComponentInParent <Keeper>().IsSelected = true; } GameManager.Instance.GetBattleUI.GetComponent <UIBattleHandler>().GetSkillsPanelIndex(clickTarget.GetComponentInParent <PawnInstance>()).gameObject.SetActive(true); } } } else { if (GameManager.Instance.ListOfSelectedKeepers != null && GameManager.Instance.ListOfSelectedKeepers.Count > 0) { // TODO: find another way GameManager.Instance.GetBattleUI.GetComponent <UIBattleHandler>().GetSkillsPanelIndex(GameManager.Instance.GetFirstSelectedKeeper()).gameObject.SetActive(false); } GameManager.Instance.ClearListKeeperSelected(); CursorNormalState(); BattleHandler.ActivateFeedbackSelection(true, false); BattleHandler.DeactivateFeedbackSelection(false, true); } } else { if (GameManager.Instance.ListOfSelectedKeepers != null && GameManager.Instance.ListOfSelectedKeepers.Count > 0) { // TODO: find another way GameManager.Instance.GetBattleUI.GetComponent <UIBattleHandler>().GetSkillsPanelIndex(GameManager.Instance.GetFirstSelectedKeeper()).gameObject.SetActive(false); } GameManager.Instance.ClearListKeeperSelected(); CursorNormalState(); BattleHandler.ActivateFeedbackSelection(true, false); BattleHandler.DeactivateFeedbackSelection(false, true); } } } } else if (Input.GetMouseButtonDown(1)) { if (GameManager.Instance.ListOfSelectedKeepers != null && GameManager.Instance.ListOfSelectedKeepers.Count > 0 && BattleHandler.PendingSkill != null) { HandleActionValidationDuringBattle(); } else if (GameManager.Instance.ListOfSelectedKeepers == null || GameManager.Instance.ListOfSelectedKeepers.Count == 0) { BattleHandler.ActivateFeedbackSelection(true, false); } } } }