void AbilityInteract(Ray mouse, RaycastHit point) { if (Physics.Raycast(mouse, out point)) { //if hits something //Debug.Log("hit something"); Collider objCollider = point.collider; if (objCollider.GetComponent <Tile>()) { Tile tile = objCollider.GetComponent <Tile>(); if (tile.IsTargetable && Input.GetMouseButtonDown(0)) { _abilityTarget = new Vector2(tile.GetXPosition, tile.GetYPosition); GridHandler.ShowReleventGrid(_abilityTarget, _selectedAbility.SplashRange, Color.red, Actions.ABILITY); _interactState = UIInteractions.ABILITYUSE; _battleCam.FocusPosition(tile.gameObject, CameraModes.ZOOMING); } } else if (objCollider.GetComponent <GridToken>()) { GridToken gt = objCollider.GetComponent <GridToken>(); if (gt.GetTile.IsTargetable && Input.GetMouseButtonDown(0)) { _abilityTarget = new Vector2(gt.GetTile.GetXPosition, gt.GetTile.GetYPosition); GridHandler.ShowReleventGrid(_abilityTarget, _selectedAbility.SplashRange, Color.red, Actions.ABILITY); _interactState = UIInteractions.ABILITYUSE; _battleCam.FocusPosition(gt.gameObject, CameraModes.ZOOMING); } } } }
//Turn off character Interaction UI public void HideActionsMenu() { //Debug.Log("hide called"); _optionsRef.ResetUIMovements(); _interactState = UIInteractions.FREE; _selectedAbility = null; }
//if zoomed and click, unzoom and put details off screen void CheckForExitingClick() { if (!_battleCam.IsMoving) { if (Input.GetMouseButtonDown(0) || CancelButtonPressed()) { _interactState = UIInteractions.NONE; UnShowDetail(); } } }
//show the long character details void ShowDetail(Tile clickedOnToken) { _interactState = UIInteractions.NONE; //Debug.Log("detail shown"); HideActionsMenu(); //get character info from GridHandler by sending GridToken Position Character clickedOnCharacter = GridHandler.RetrieveCharacter(clickedOnToken.GetXPosition, clickedOnToken.GetYPosition); _detailHolder.ShowUI(clickedOnCharacter); _battleCam.FocusPosition(clickedOnToken.gameObject, CameraModes.ZOOMING); }
void UndoSelection() { if (!_optionsRef.IsMoving) { if (CancelButtonPressed()) { switch (_interactState) { case UIInteractions.MENUOPEN: if (!_optionsRef.IsHidden) { HideActionsMenu(); } else { _optionsRef.BackToMenu(); _optionsRef.GetAbilityPanel.ResetFading(); } break; case UIInteractions.MOVESELECT: _battleCam.FocusPosition(GridHandler.RetrieveToken(_timeRef.GetCurrentTurnCharacter.CurrentPosition).gameObject, CameraModes.MOVING); _interactState = UIInteractions.MENUOPEN; _optionsRef.BackToMenu(); _optionsRef.GetAbilityPanel.ResetFading(); break; case UIInteractions.ATTACKSELECT: _battleCam.FocusPosition(GridHandler.RetrieveToken(_timeRef.GetCurrentTurnCharacter.CurrentPosition).gameObject, CameraModes.MOVING); _interactState = UIInteractions.MENUOPEN; _optionsRef.BackToMenu(); _optionsRef.GetAbilityPanel.ResetFading(); break; case UIInteractions.ABILITYSELECT: _battleCam.FocusPosition(GridHandler.RetrieveToken(_timeRef.GetCurrentTurnCharacter.CurrentPosition).gameObject, CameraModes.MOVING); _interactState = UIInteractions.MENUOPEN; _optionsRef.ShowOnlyAbilites(); break; case UIInteractions.ABILITYUSE: _battleCam.FocusPosition(GridHandler.RetrieveTile(_abilityTarget).gameObject, CameraModes.MOVING); AbilitySelected(_selectedAbility); break; default: break; } } } }
public void CharacterDoneAttacking() { if (_timeRef.GetCurrentTurnCharacter.Team == TeamType.PLAYER) { _timeRef.GetCurrentTurnCharacter.Strategy.HasAttacked = true; _optionsRef.ShowUI(); _interactState = UIInteractions.MENUOPEN; _battleCam.FocusPosition(GridHandler.RetrieveToken(_timeRef.GetCurrentTurnCharacter.CurrentPosition).gameObject, CameraModes.MOVING); } else { _timeRef.GetCurrentTurnCharacter.Strategy.ContinueTurn(); } }
//turn on character interaction UI void ShowActionsMenu(Tile chara) { _battleCam.FocusPosition(chara.gameObject, CameraModes.MOVING); Character gridChar = GridHandler.RetrieveCharacter(chara.GetXPosition, chara.GetYPosition); if (gridChar == _timeRef.GetCurrentTurnCharacter && !_optionsRef.IsMoving) { _interactState = UIInteractions.MENUOPEN; _optionsRef.ShowUI(gridChar); } else { HideActionsMenu(); } }
//initalize public void Init(CameraFollow camref) { if (!_initialized) { _uiRef = UIHolder.UIInstance; _battleCam = camref; _selector = Instantiate <GameObject>(Resources.Load <GameObject>("GridObjects/Selector")); _selector.SetActive(false); SetUI(); } else { _timeRef.ContinueFight(); } _battleCam.ChangeToBattleMode(); _interactState = UIInteractions.FREE; }
public void CheckNextTurn(Character currentchara) { _battleCam.FocusPosition(GridHandler.RetrieveToken(currentchara.CurrentPosition).gameObject, CameraModes.MOVING); if (_timeRef.GetCurrentTurnCharacter.Team == TeamType.PLAYER) { Debug.Log("Player turn"); GameUpdate.PlayerSubscribe += PlayerInteract; _interactState = UIInteractions.MENUOPEN; currentchara.StartTurn(); _optionsRef.ShowUI(currentchara); } else { Debug.Log("enemy turn"); currentchara.StartTurn(); } }
public void CharacterDoneMoving(GridToken currChar) { if (_timeRef.GetCurrentTurnCharacter.Team == TeamType.PLAYER) { if (!_timeRef.GetCurrentTurnCharacter.CheckForMoreMove(currChar.GetTile.GetXPosition, currChar.GetTile.GetYPosition)) { _interactState = UIInteractions.MOVESELECT; } else { _optionsRef.ShowUI(); _interactState = UIInteractions.MENUOPEN; } } else { _timeRef.GetCurrentTurnCharacter.Strategy.ContinueTurn(); } _battleCam.FocusPosition(currChar.gameObject, CameraModes.MOVING); }
public void ChangeBattleInteraction(UIInteractions state) { _batRef.GetInteractionState = state; }
public void AbilitySelected(Ability ability) { _selectedAbility = ability; GridHandler.ShowReleventGrid(_timeRef.GetCurrentTurnCharacter.CurrentPosition, _selectedAbility.TargetRange, Color.red, Actions.ATTACK); _interactState = UIInteractions.ABILITYSELECT; }