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); } }
public void UseLinkedSkill() { if (skillData.TargetType == TargetType.FoeSingle || skillData.TargetType == TargetType.FriendSingle) { if (skillData.SkillType == SkillType.Physical) { Cursor.SetCursor(GameManager.Instance.Texture2DUtils.attackCursor, Vector2.zero, CursorMode.Auto); } else if (skillData.SkillType == SkillType.Defensive) { Cursor.SetCursor(GameManager.Instance.Texture2DUtils.buffCursor, Vector2.zero, CursorMode.Auto); } else if (skillData.SkillType == SkillType.Magical) { Cursor.SetCursor(GameManager.Instance.Texture2DUtils.magicCursor, Vector2.zero, CursorMode.Auto); } if (skillData.TargetType == TargetType.FoeSingle) { BattleHandler.ActivateFeedbackSelection(false, true); } else { BattleHandler.ActivateFeedbackSelection(true, false); } // TODO: find an other way GameManager.Instance.GetBattleUI.GetComponent <UIBattleHandler>().GetSkillsPanelIndex(skillData.SkillUser.GetComponent <PawnInstance>()).gameObject.SetActive(false); BattleHandler.WaitForSkillConfirmation(skillData); } else { GameManager.Instance.GetBattleUI.GetComponent <UIBattleHandler>().GetSkillsPanelIndex(skillData.SkillUser.GetComponent <PawnInstance>()).gameObject.SetActive(false); BattleHandler.WaitForSkillConfirmation(skillData); // WARNING: change sensitive code, test it Debug.LogWarning("Have you tested this code yet?"); BattleHandler.PendingSkill.UseSkill(); } }
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); } } } }