Beispiel #1
0
    //code execution for when a left mouse click happen on a tile and when a touch is double tap on a tile
    public void OnTouchMouseDown()
    {
                #if !UNITY_IPHONE && !UNITY_ANDROID
        if (GameControlTB.IsCursorOnUI(Input.mousePosition))
        {
            return;
        }
        //if(GameControlTB.IsObjectOnUI(pos)) return;
                #endif

        if (GameControlTB.IsUnitPlacementState())
        {
            PlaceUnit();
            return;
        }

        if (GameControlTB.GetTurnMode() != _TurnMode.SingleUnitPerTurn)
        {
            if (!GameControlTB.IsPlayerTurn())
            {
                //if(GameControlTB.turnID!=GameControlTB.GetPlayerFactionTurnID()){
                return;
            }
        }

        if (GameControlTB.IsActionInProgress())
        {
            return;
        }

        if (!walkable && !GridManager.IsInTargetTileSelectMode())
        {
            return;
        }

        UnitTB sUnit = UnitControl.selectedUnit;

        //if a friendly unit has been selected
        //if(sUnit!=null && sUnit.IsControllable(GameControlTB.GetPlayerFactionID())){
        if (sUnit != null && sUnit.IsControllable())
        {
            //if HexFridManager is actively looking for a target for current selectedUnit
            if (GridManager.IsInTargetTileSelectMode())
            {
                ManualSelect();
            }
            else
            {
                if (!walkableToSelected && !attackableToSelected)
                {
                    ManualSelect();
                }
                else
                {
                    if (attackableToSelected && unit != null)
                    {
                        sUnit.Attack(unit);
                    }
                    else if (walkableToSelected)
                    {
                        sUnit.Move(this);
                    }
                    else
                    {
                        Debug.Log("error");
                    }
                }
            }

            return;
        }
        else
        {
            ManualSelect();
        }
    }