コード例 #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);
		}
コード例 #2
0
        public void OnHoverButton(GameObject butObj)
        {
            int     ID      = GetButtonID(butObj);
            Ability ability = GameControl.GetSelectedUnit().GetUnitAbility(ID);

            lbTooltipName.text     = ability.name;
            lbTooltipDesp.text     = ability.desp;
            lbTooltipCost.text     = "cost: " + ability.GetCost() + "AP";
            lbTooltipCooldown.text = "cooldown: " + ability.GetCooldown();

            tooltipRectT.localPosition = new Vector3(tooltipRectT.localPosition.x, buttonList[ID].rectT.localPosition.y + 40, 0);

            tooltipObj.SetActive(true);
        }
コード例 #3
0
		public void _OnTile(Tile tile){
			if(!FactionManager.IsPlayerTurn()) return;
			
			if(tile.unit!=null){
				if(attackableTileList.Contains(tile)) GameControl.GetSelectedUnit().Attack(tile.unit);
				else GameControl.SelectUnit(tile.unit);
			}
			//if the tile is within the move range of current selected unit, move to it
			else if(walkableTileList.Contains(tile)){
				ClearWalkableHostileList();	//in case the unit move into the destination and has insufficient ap to attack
				GameControl.GetSelectedUnit().Move(tile);
			}
			
			ClearHoveredTile();	//clear the hovered tile so all the UI overlay will be cleared
		}
コード例 #4
0
		void _OnUnitDestroyed(Unit unit){
			if(GameControl.GetSelectedUnit()==null) return;
			
			Tile tile=unit.tile;
			if(attackableTileList.Contains(tile)){
				attackableTileList.Remove(tile);	//remove from target tile
				OverlayManager.RemoveHostileIndicator(tile);
			}
			
			int dist=GetDistance(tile, GameControl.GetSelectedUnit().tile, true);
			
			if(dist>0 && dist<GameControl.GetSelectedUnit().GetMoveRange()){	//if within walkable distance, add to walkable tile since the tile is now open
				walkableTileList.Add(tile);
				OverlayManager.ShowMoveableIndicator(walkableTileList);
			}
		}
コード例 #5
0
ファイル: TurnControl.cs プロジェクト: Hengle/TBTKPrototype
        //call by unit when all action is depleted
        public static void SelectedUnitMoveDepleted()
        {
            if (GameControl.GetGamePhase() == _GamePhase.Over)
            {
                return;
            }

            if (instance.turnMode == _TurnMode.FactionPerTurn)
            {
                //if not in free move order, cant switch to next unit without end turn
                if (instance.moveOrder != _MoveOrder.Free)
                {
                    TBTK.OnAllUnitOutOfMove();
                    if (GameControl.GetSelectedUnit().HP <= 0)
                    {
                        instance.StartCoroutine(instance.AutoEndTurn());
                    }
                }
                else
                {
                    if (!FactionManager.SelectNextUnitInFaction_Free())
                    {
                        TBTK.OnAllUnitOutOfMove();
                    }
                }
            }
            else if (instance.turnMode == _TurnMode.FactionUnitPerTurn)
            {
                TBTK.OnAllUnitOutOfMove();
                if (GameControl.GetSelectedUnit().HP <= 0)
                {
                    instance.StartCoroutine(instance.AutoEndTurn());
                }
            }
            else if (instance.turnMode == _TurnMode.UnitPerTurn)
            {
                TBTK.OnAllUnitOutOfMove();
                if (GameControl.GetSelectedUnit().HP <= 0)
                {
                    instance.StartCoroutine(instance.AutoEndTurn());
                }
            }
        }
コード例 #6
0
        private int currentButtonID = -1;       //last touched button, for touch mode only
        public void OnAbilityButton(GameObject butObj, int pointerID = -1)
        {
            int ID = GetButtonID(butObj);

            if (UIMainControl.InTouchMode())
            {
                if (currentButtonID >= 0)
                {
                    buttonList[currentButtonID].imgHighlight.enabled = false;
                }
                currentButtonID = ID;
                buttonList[ID].imgHighlight.enabled = true;
            }
            else
            {
                string exception = GameControl.GetSelectedUnit().SelectAbility(ID);
                if (exception != "")
                {
                    UIMessage.DisplayMessage(exception);
                }
            }
        }
コード例 #7
0
 public void OnReleaseAbilityButton(GameObject butObj, int pointId = -1)
 {
     if (UIMainControl.InTouchMode())
     {
         if (tooltipObj.activeSelf)
         {
             OnExitButton(null);
             if (currentButtonID >= 0)
             {
                 buttonList[currentButtonID].imgHighlight.enabled = false;
             }
             currentButtonID = -1;
         }
         else
         {
             int ID = GetButtonID(butObj);
             if (currentButtonID == ID)                   // this check is BS because the buttons seem to capture focus, but leave it in since it doesn't break anything HACK
             {
                 string exception = GameControl.GetSelectedUnit().SelectAbility(ID);
                 if (exception != "")
                 {
                     UIMessage.DisplayMessage(exception);
                     buttonList[currentButtonID].imgHighlight.enabled = false;
                 }
                 else
                 {
                     bool isInTargetMode = GameControl.GetSelectedUnit().abilityList[ID].requireTargetSelection;
                     if (!isInTargetMode)
                     {
                         buttonList[currentButtonID].imgHighlight.enabled = false;
                         currentButtonID = -1;
                     }
                 }
             }
         }
     }
 }
コード例 #8
0
        bool UpdateDisplay()
        {
            if (GridManager.CanMoveToTile(lastHoveredTile))
            {
                indicator.position = lastHoveredTile.GetPos() + new Vector3(0, 0.05f, 0);
                indicator.gameObject.SetActive(true);
            }
            else
            {
                indicator.gameObject.SetActive(false);
            }

            if (GridManager.CanMoveToTile(lastHoveredTile) && GameControl.UseAPForMove())
            {
                verticalOffset = -65;
                tooltipPanelBodyObj.SetActive(false);

                UpdateTooltipPos();

                lbAction.text = "Move";
                lbAPCost.text = GameControl.GetSelectedUnit().GetMoveAPCostToTile(lastHoveredTile) + "AP";

                return(true);
            }

            if (GridManager.CanAttackTile(lastHoveredTile))
            {
                verticalOffset = 0;
                tooltipPanelBodyObj.SetActive(true);

                UpdateTooltipPos();

                Unit selectedUnit = GameControl.GetSelectedUnit();

                lbAction.text = "Attack";

                if (GameControl.UseAPForAttack())
                {
                    lbAPCost.text = "";
                }
                else
                {
                    lbAPCost.text = selectedUnit.GetAttackAPCost().ToString("f0") + "AP";
                }

                AttackInstance attInstance = selectedUnit.GetAttackInfo(lastHoveredTile.unit);

                if (!attInstance.isMelee)
                {
                    lbDamage.text = selectedUnit.GetDamageMin() + "-" + selectedUnit.GetDamageMax();
                }
                else
                {
                    lbDamage.text = selectedUnit.GetDamageMinMelee() + "-" + selectedUnit.GetDamageMaxMelee();
                }

                lbChance.text  = (attInstance.hitChance * 100).ToString("f0") + "%\n";
                lbChance.text += (attInstance.critChance * 100).ToString("f0") + "%\n";

                return(true);
            }

            return(false);
        }