void _NewHoveredTile(Tile tile){ hoveredTile=tile; if(AbilityManager.InTargetMode()){ SetTargetModeHoveredTile(tile); return; } bool isWalkable=walkableTileList.Contains(tile); bool isSelectedUnitTile=GameControl.GetSelectedUnit()==null ? false : true; if(isSelectedUnitTile) isSelectedUnitTile=GameControl.GetSelectedUnit().tile!=tile ? false : true ; //show cover overlay if cover-system is enabled if(GameControl.EnableCover() && (isWalkable || isSelectedUnitTile)){ OverlayManager.ShowCoverOverlay(tile); } //highlight potential target for the unit to be moved into this tile if(isWalkable && GameControl.GetSelectedUnit().CanAttack()){ SetWalkableHostileList(tile); } TBTK.OnHoverTile(tile); }
public void Trigger(Unit unit) { if (!destroyTriggerEffect) { ObjectPoolManager.Spawn(triggerEffectObj, transform.position, Quaternion.identity); } else { ObjectPoolManager.Spawn(triggerEffectObj, transform.position, Quaternion.identity, triggerEffectDuration); } if (facAbilityIDList.Count > 0) { int facAbilityID = facAbilityIDList[Random.Range(0, facAbilityIDList.Count)]; FactionAbility ability = AbilityManagerFaction.GetFactionAbility(facAbilityID); if (ability != null) { if (!ability.requireTargetSelection) { AbilityManager.ApplyAbilityEffect(null, ability.Clone(), (int)ability.type); } else { AbilityManager.ApplyAbilityEffect(unit.tile, ability.Clone(), (int)ability.type); } } } unit.ApplyEffect(CloneEffect()); CollectibleManager.TriggerCollectible(this); Destroy(gameObject); }
public string _SelectAbility(int index) { AbilityManager.ExitAbilityTargetMode(); FactionAbility ability = GetAbilityFromCurrentFaction(index); if (ability == null) { return("error"); } string exception = ability.IsAvailable(); if (exception != "") { return(exception); } requireTargetSelection = ability.requireTargetSelection; if (!requireTargetSelection) { ActivateAbility(null, ability); } else { ActivateTargetModeFaction(ability.GetAOERange(), ability.targetType, index, this.ActivateAbility, null); } return(""); }
void _ClearHoveredTile(){ if(hoveredTile!=null){ ClearWalkableHostileList(); } ShowHostileIndicator(attackableTileList); hoveredTile=null; OverlayManager.HideCoverOverlay(); if(AbilityManager.InTargetMode()) ClearTargetModeHoveredTile(); TBTK.OnHoverTile(null); }
public void _OnCursorDown(int cursorID=-1){ //Debug.Log("_OnCursorDown"); if(hoveredTile==null) return; if(TBTK.IsCursorOnUI(cursorID)) return; if(!TurnControl.ClearToProceed()) return; if(GameControl.GetGamePhase()==_GamePhase.Over) return; if(GameControl.GetGamePhase()==_GamePhase.UnitDeployment){ if(hoveredTile.unit==null) FactionManager.DeployUnitOnTile(hoveredTile); else if(hoveredTile.unit!=null) FactionManager.UndeployUnit(hoveredTile.unit); return; } if(AbilityManager.InTargetMode()){ Debug.Log("AbilityTargetSelected"); targetModeTargetSelected(hoveredTile); } else OnTile(hoveredTile); }
public void OnCancelButton(GameObject butObj, int pointerID = -1) { AbilityManager.ExitAbilityTargetMode(); buttonCancel.SetActive(false); }
IEnumerator OnLeftCursorDown(int pointer = -1) { yield return(null); if (UI.IsCursorOnUI(pointer)) { yield break; } Tile tile = GridManager.GetHoveredTile(); if (tile != null) { if (GameControl.GetGamePhase() == _GamePhase.UnitDeployment) { GridManager.OnCursorDown(); yield break; } if (AbilityManager.InTargetMode()) { GridManager.OnCursorDown(); yield break; } heldTile = tile; holdStartedTime = Time.time; if (touchMode && GridManager.CanAttackTile(GridManager.GetHoveredTile())) { NewClickTile(tile); } else if (touchMode && GridManager.CanMoveToTile(GridManager.GetHoveredTile())) { NewClickTile(tile); } else { if (!GridManager.CanPerformAction(tile)) { //ClearLastClickTile(); dont call last click tile, we dont want to hide unit info if there's any lastClickTile = null; UIInputOverlay.SetNewHoveredTile(null); } else { GridManager.OnCursorDown(); //ClearLastClickTile() will be called as soon as unit move or attack or cast ability } } } else { ClearLastClickTile(); } //~ if(tile!=null){ //~ if(tile.unit!=null){ //~ if(!GameControl.CanSelectUnit(tile.unit)) UIUnitInfo.Show(tile); //~ else{ //~ GridManager.OnCursorDown(); //~ UIUnitInfo.Hide(); //~ return; //~ } //~ } //~ else UIUnitInfo.Hide(); //~ if(touchMode && GridManager.CanAttackTile(GridManager.GetHoveredTile())){ //~ NewClickTile(tile); //~ } //~ else if(touchMode && GridManager.CanMoveToTile(GridManager.GetHoveredTile())){ //~ NewClickTile(tile); //~ } //~ else{ //~ if(!GridManager.CanPerFormAction(tile)){ //~ //ClearLastClickTile(); dont call last click tile, we dont want to hide unit info if there's any //~ lastClickTile=null; //~ UIInputOverlay.SetNewHoveredTile(null); //~ } //~ else GridManager.OnCursorDown(); //ClearLastClickTile() will be called as soon as unit move or attack or cast ability //~ } //~ } //~ else ClearLastClickTile(); }
public static bool CanCastAbility(Tile tile){ return AbilityManager.CanCastAbility(tile); }
public void Awake() { instance = this; }