Exemple #1
0
    /* #endregion */
    /* ======================================================================================== */

    /* #region ==== D R A W  /  C L E A R  R O T A T I O N  T A R G E T  O V E R L A Y ======== */

    /* #region ---- Draw Rotation Target Overlay ---------------------------------------------- */
    public void DrawRotationTarget(MatchPlayer Player, PitchTile targetTile)
    {
        if (Player.PlayerMode == PlayerMode.Rotate)
        {
            ClearRotationTarget(Player);

            List <PitchTile> neighbourTiles = Player.CurrentTile.NeighbourTiles;

            foreach (var tile in neighbourTiles)
            {
                if (tile == targetTile)
                {
                    tile.ActivateRotateTargetOverlay(true);
                    int direction = Player.GetRotationIndicator(targetTile.transform);
                    int apCost    = Player.CalcRotationApCost(direction);
                    MatchManager.Hud.UpdateAccAPCost(apCost);
                    break;
                }
            }
        }
    }
Exemple #2
0
    /* #endregion */
    /* ======================================================================================== */

    /* #region ==== D R A W  P A T H  L I N E ================================================= */

    /* #region ---- Draw movement path line from active player to target tile ----------------- */
    public void Draw(PitchTile targetIn)
    {
        if (MatchManager.MatchPlayerManager.CurrentActivePlayer.PlayerMode == PlayerMode.Move)
        {
            if (!MatchManager.MatchPlayerManager.PlayInAction)
            {
                PitchManager PitchManager = MatchManager.PitchManager;
                PitchGrid    PitchGrid    = MatchManager.PitchGrid;
                MatchPlayer  Player       = MatchManager.MatchPlayerManager.GetActivePlayer();


                /* #region ---- Reset Path ----------------------------------------- */
                ClearPlayerMovePathLines();
                setAllTilesNoneViableTarget(PitchManager);
                ResetAccMoveCost();
                MatchManager.PitchGrid.DeactivateMoveTargetOverlay();

                /* #endregion ------------------------------------------------------ */

                /* #region ---- Set new Path to target ----------------------------- */
                List <PitchTile> pathToTarget = PitchGrid.PathFinding.GetPathToTarget(targetIn, Player);
                listLinePoints = new List <Vector3>();

                /* #endregion ------------------------------------------------------ */

                /* #region ---- Draw Path Line & Rotate Player --------------------- */
                if (pathToTarget != null)
                {
                    /* #region ---- Player Calculate AP cost for rotation - */
                    int rotation = Player.GetRotationIndicator(pathToTarget[1].transform);
                    AccumulatedMoveCost = Player.CalcRotationApCost(rotation);

                    /* #endregion --------------------------------------------------- */

                    /* #region ---- Add to waypoints to List & update HUD ---------- */
                    GameObject PathLineObject = MatchManager.InstantiateGameObject(PitchGrid.PathLinePrefab);
                    PathLineObject.name = "PlayerMove PathLine";
                    LineRenderer lineRenderer = PathLineObject.GetComponent <LineRenderer>();
                    int          counter      = 0;
                    foreach (PitchTile pathTile in pathToTarget)
                    {
                        counter++;
                        //TODO: QuickFix: Find out why CurrentActionPoints has to be reduced by one for the player to not exceed CurrentActionPoints
                        if (Player.CurrentActionPoints - 1 >= AccumulatedMoveCost)
                        {
                            Vector3 linePoint = new Vector3(
                                pathTile.transform.position.x,
                                PathLineObject.transform.position.y,
                                pathTile.transform.position.z);

                            listLinePoints.Add(linePoint);

                            if (counter != 1)
                            {
                                AccumulatedMoveCost += pathTile.CostToEnter;
                            }
                            pathTile.IsViableTarget = true;
                        }

                        updateAPCostInHUD(AccumulatedMoveCost);
                    }
                    /* #endregion --------------------------------------------------- */

                    /* #region ---- Draw line and target tile overlay --------------- */
                    lineRenderer.positionCount = listLinePoints.Count;
                    activateTargetOverlay(listLinePoints);
                    lineRenderer.SetPositions(listLinePoints.ToArray());
                    /* #endregion --------------------------------------------------- */
                }

                /* #endregion ------------------------------------------------------ */
            }
        }
    }
    /* #endregion ----------------------------------------------------------------------------- */

    /* #region ---- Get AP-Cost --------------------------------------------------------------- */
    private int getApCost(PitchTile targetTile)
    {
        int direction = Player.GetRotationIndicator(targetTile.transform);

        return(Player.CalcRotationApCost(direction));
    }