示例#1
0
    public void OnSelected(GameController controller)
    {
        Player player = controller.GetLocalPlayer().player;

        // Show UI action panel
        controller.uiController.EnableActionButtons(
            ResourceUtil.CanAffordPath(player.resources) &&
            controller.mapController.GetAdjecentPaths(workerController.worker.location, true).Length > 0,
            ResourceUtil.CanAffordHouse(player.resources) &&
            workerController.worker.location.type == LocationType.Available &&
            controller.mapController.GetConnectedLocations(workerController.worker.location, player).Where(l => l.type != LocationType.Available).Count() > 0,
            ResourceUtil.CanAffordCity(player.resources) &&
            workerController.worker.location.type == LocationType.House && controller.GetLocalPlayer().player.id.Equals(workerController.worker.location.occupiedBy),
            ResourceUtil.CanAffordCard(player.resources));
        controller.uiController.EnableActionPanel(
            true,
            () => EnableRoadPlacement(controller),
            () => BuildHouse(controller),
            () => BuildCity(controller),
            () => BuyCard(controller)
            );

        // Initialize moves to show
        if (workerController.state == WorkerController.WorkerState.Movable)
        {
            currentAvailableMoves = controller.mapController.GetReachableLocations(workerController.worker.location, player);
            foreach (var lc in currentAvailableMoves)
            {
                lc.SetSelectable(true);
            }
            shouldTryOverride = true;
            controller.GetLocalPlayer().SetState(PlayerController.State.WorkerMovement);
        }

        // Play sound effect
        workerController.PlayRandomSound();
    }