Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
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);
        }