Exemplo n.º 1
0
		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);
		}
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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("");
        }
Exemplo n.º 4
0
		void _ClearHoveredTile(){
			if(hoveredTile!=null){
				ClearWalkableHostileList();
			}
			
			ShowHostileIndicator(attackableTileList);
			
			hoveredTile=null;
			
			OverlayManager.HideCoverOverlay();
			
			if(AbilityManager.InTargetMode()) ClearTargetModeHoveredTile();
			
			TBTK.OnHoverTile(null);
		}
Exemplo n.º 5
0
		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);
 }
Exemplo n.º 7
0
        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();
        }
Exemplo n.º 8
0
		public static bool CanCastAbility(Tile tile){ return AbilityManager.CanCastAbility(tile); }
Exemplo n.º 9
0
 public void Awake()
 {
     instance = this;
 }