Exemple #1
0
 public void Select(Court c, Tile tile)
 {
     if (tile)
     {
         var b = c.GetBallmanAt(tile);
         if (b && b.Team == team)
         {
             OnSelected(tile);
         }
     }
 }
Exemple #2
0
 public void Select(Court c, Tile tile)
 {
     if (tile)
     {
         var ballman = order.CurrentTurn();
         if (!c.GetBallmanAt(tile))
         {
             ballman.MoveToTile(tile, true);
             c.SetBallmanPosition(ballman, tile);
             c.TileSelector = null;
         }
         else
         {
             // already someone there.
         }
     }
 }
Exemple #3
0
    private void ShowMoveButtons(Ballman bm)
    {
        court.TileSelector = null;
        var currentBallman = bm;
        var buttons        = new List <Button>();

        var plays    = bm.GetPlays();
        var position = new Vector2(Screen.width / 2f - 40, Screen.height / 2f - plays.Length * 15);

        foreach (var play in plays)
        {
            var newButton = Instantiate(buttonTemplate, canvas.transform);
            newButton.GetComponentInChildren <Text>().text = play.GetName();
            newButton.gameObject.SetActive(true);
            newButton.onClick.AddListener(() =>
            {
                buttons.ForEach((b) => Destroy(b.gameObject));
                buttons.Clear();
                var selector       = play.GetTargetSelector(bm);
                court.TileSelector = selector;
                if (selector != null)
                {
                    selector.OnSelected += (selected) =>
                    {
                        RunPlay(play, currentBallman, court.GetBallmanAt(selected));
                    };
                }
                else
                {
                    RunPlay(play, currentBallman, null);
                }
            });
            newButton.transform.position = position;
            position += new Vector2(0, 30);
            buttons.Add(newButton);
        }
    }