void MovementMouseUI(Hex mouseHex)
    {
        //button needs to be disabled if the player is moving or has the ball
        //need to be able to free throw - different UI

        hexOutliner.SetActive(true);
        hexOutliner.transform.position = mouseHex.Position + outlinerOffset;

        if (selected != null)
        {
            if (selected.Moving == false && selected.MoveHexesInRange.Contains(mouseHex))
            {
                AStarPath p = new AStarPath(GridManager.Instance.Grid, selected.CurrentHex, mouseHex, true);

                List <Vector3> hexPositions = new List <Vector3> ();

                LineRenderer lr = selected.GetComponent <LineRenderer> ();
                lr.enabled = true;

                hexPositions.Add(selected.transform.position + outlinerOffset - selected.HexOffset);
                while (p.IsNextHex())
                {
                    hexPositions.Add(p.GetNextHex().Position + outlinerOffset);
                }

                lr.positionCount = hexPositions.Count;

                lr.SetPositions(hexPositions.ToArray());
            }
            else
            {
                selected.GetComponent <LineRenderer> ().enabled = false;
            }
        }
    }
Exemple #2
0
    IEnumerator MoveCoroutine(Hex destHex)
    {
        moving = true;

        if (onMoveBegan != null)
        {
            onMoveBegan(this);
        }

        HideMovementHexes();

        AStarPath p = new AStarPath(GridManager.Instance.Grid, currentHex, destHex, true);

        Hex next;

        Hex current = CurrentHex;

        destOccupant = destHex.Occupant;
        CurrentHex   = destHex;

        while (p.IsNextHex())
        {
            next = p.GetNextHex();

            CheckHex(next.Occupant);

            if (movesInActionRemaining >= next.MoveCost)
            {
                yield return(StartCoroutine(MoveToHex(current, next)));
            }

            current = next;
        }

        onMoveComplete(this);

        if (UserControlManager.Instance.Selected == this)
        {
            ShowMovementHexes();
        }

        moving = false;
    }