Exemplo n.º 1
0
    public void CreateOption(int index)
    {
        var uiChooseTile = UIManager.Singleton.UIChoosingTile;

        HexTile hexTile = null;

        if (index == 0)
        {
            hexTile = HexUtils.BuildHexTile(_hexTile.Data, Player.MyPlayer, HexTileRole.InUI);
        }
        else
        {
            var         affordAble = false;
            var         counter    = 0;
            HexTileData randomData = null;
            while (!affordAble)
            {
                randomData = HexUtils.CreateRandomData(_hexTile.Data.X, _hexTile.Data.Y);
                counter++;
                if (counter == 100)
                {
                    randomData = _hexTile.Data;
                    UnityEngine.Debug.LogWarning("Could not find Random Data");
                }
                affordAble = Player.MyPlayer.HasResource(HexUtils.CalcHexPrice(randomData));
            }

            hexTile = HexUtils.BuildHexTile(randomData, Player.MyPlayer, HexTileRole.InUI);
        }

        hexTile.transform.SetParent(uiChooseTile.ChoosingTransforms[index].transform, false);

        hexTile.OnClickCallback = OnTileChosen;
    }
Exemplo n.º 2
0
    public void OnTileChosen(HexTile hexTile)
    {
        var uiChooseTile = UIManager.Singleton.UIChoosingTile;

        uiChooseTile.gameObject.SetActive(false);

        _hexTile.Data = hexTile.Data;
        GridManager.Singleton.TileWasBought(_hexTile);

        Player.MyPlayer.PlayerResources.Reduce(HexUtils.CalcHexPrice(_hexTile.Data));

        Clear();
    }
Exemplo n.º 3
0
    public void TileClicked(HexTile hexTile)
    {
        //check GameManagerState.
        if (GameManager.Singleton.GameState != GameState.Idle)
        {
            return;
        }

        if (!IsNeighbor(hexTile))
        {
            return;
        }

        if (!HasResource(HexUtils.CalcHexPrice(hexTile.Data)))
        {
            Debug.Log("Not enoght resources");
            return;
        }

        BuyingTileCommand.Create(hexTile);
    }