示例#1
0
    /*
     * -------------------------------------------------------------------------
     * MARK: UNIT SELECTION FUNCTIONS
     * -------------------------------------------------------------------------
     */

    /*
     * Handles switching active unit selections.
     * Constructs menu maps and updates valid menus.
     */
    public void SetActiveSelection(EntityController nextActiveSelection)
    {
        activeSelection = nextActiveSelection;

        if (activeSelection != EntityController.Empty &&
            activeSelection.EntityType == Utils.EntityType.PartyMember)
        {
            GroundGraph groundGraph  = terrainController.GroundController.groundGraph;
            bool        hasValidMove = groundGraph.ConstructMoveMap(activeSelection.transform.position, activeSelection.Movement, activeSelection.EntityType);
            guiController.ValidMoveMenu = !activeSelection.Moved && hasValidMove;

            bool hasValidAttack = groundGraph.ConstructAttackMap(activeSelection.transform.position, activeSelection.MinRange, activeSelection.MaxRange, activeSelection.EntityType);
            guiController.ValidAttackMenu = !activeSelection.Tapped && hasValidAttack;

            if (!hasValidMove && !hasValidAttack)
            {
                activeSelection.Tapped = true;
            }
        }
    }