Example #1
0
    public override void OnStartServer()
    {
        api   = new HttpApiLogic(HttpRequestSender.GetInstance());
        roads = RoadController.GetInstance();
        roads.OnCustomStartServer();

        var randomPositions = AchievementController.GetRandomPositions(COINS_COUNT, roads);

        foreach (Vector2 position in randomPositions)
        {
            NetworkServer.Spawn(
                Instantiate(
                    achievementPrefab,
                    new Vector3(position.x, 1.5f, position.y),
                    Quaternion.AngleAxis(45, Vector3.up) * Quaternion.AngleAxis(90, Vector3.forward)
                    )
                );
        }

        var superPosition = AchievementController.GetPoint(roads);

        NetworkServer.Spawn(
            Instantiate(
                superAchievementPrefab,
                new Vector3(superPosition.x, 1.5f, superPosition.y),
                Quaternion.AngleAxis(45, Vector3.up) * Quaternion.AngleAxis(90, Vector3.forward)
                )
            );
    }
        public static PromptValidator <FoundChoice> Create(IApiInterface api)
        {
            return(async(promptContext, cancellationToken) =>
            {
                if (!promptContext.Recognized.Succeeded)
                {
                    return await Task.FromResult(false);
                }

                if (promptContext.Recognized.Value.Value == Phrases.None)
                {
                    return await Task.FromResult(true);
                }

                var user = await api.GetUser(promptContext.Context);

                var resources = await api.GetResourcesForUser(user);

                // Make sure the index and name still match up in case the schema changed.
                var selectedChoice = promptContext.Recognized.Value;
                var selectedIndex = selectedChoice.Index;

                if (selectedIndex >= resources.Count)
                {
                    return await Task.FromResult(false);
                }

                return await Task.FromResult(resources[selectedIndex].Name == selectedChoice.Value);
            });
        }
Example #3
0
 public DialogBase(StateAccessors state, DialogSet dialogs, IApiInterface api, IConfiguration configuration)
 {
     this.state         = state;
     this.dialogs       = dialogs;
     this.api           = api;
     this.configuration = configuration;
 }
Example #4
0
        public static async Task <User> CreateUser(IApiInterface api)
        {
            var user = new User()
            {
                PhoneNumber = Guid.NewGuid().ToString()
            };
            await api.Create(user);

            return(user);
        }
Example #5
0
        public TheBot(IConfiguration configuration, StateAccessors state, CosmosInterface api)
        {
            this.configuration = configuration;

            this.state   = state ?? throw new ArgumentNullException(nameof(state));
            this.dialogs = new DialogSet(state.DialogContextAccessor);

            this.api = api ?? throw new ArgumentNullException(nameof(api));

            // Register prompts.
            Prompt.Register(this.dialogs, this.configuration, this.api);
        }
Example #6
0
 /// <summary>
 /// Adds each prompt to the master dialog set
 /// </summary>
 public static void Register(DialogSet dialogs, IConfiguration configuration, IApiInterface api)
 {
     dialogs.Add(new CustomChoicePrompt(ChoicePrompt));
     dialogs.Add(new CustomConfirmPrompt(ConfirmPrompt));
     dialogs.Add(new NumberPrompt <int>(IntPrompt, NotNegativeIntPromptValidator.Create()));
     dialogs.Add(new TextPrompt(TextPrompt));
     dialogs.Add(new TextPrompt(LocationTextPrompt, LocationPromptValidator.Create(configuration)));
     dialogs.Add(new TextPrompt(HourPrompt, HourPromptValidator.Create()));
     dialogs.Add(new TextPrompt(HourMinutePrompt, HourMinutePromptValidator.Create()));
     dialogs.Add(new TextPrompt(DaysPrompt, DaysPromptValidator.Create()));
     dialogs.Add(new CustomChoicePrompt(CategoryPrompt, CategoryPromptValidator.Create()));
     dialogs.Add(new CustomChoicePrompt(ResourcePrompt, ResourcePromptValidator.Create()));
 }
 /* Uncomment the line to use Approov SDK */
 //private static ApproovHttpClient httpClient;
 public GetShapePlatform()
 {
     /* Comment out the line to use Approov SDK */
     httpClient = new HttpClient();
     /* Uncomment the lines bellow to use Approov SDK */
     //var factory = new ApproovHttpClientFactory();
     //httpClient = factory.GetApproovHttpClient("<enter-your-config-string-here>");
     httpClient.BaseAddress = new Uri("https://shapes.approov.io");
     try
     {
         apiClient = RestService.For <IApiInterface>(httpClient);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Exception during RestService: " + ex.Message);
     }
 }
Example #8
0
 public UpdateDialog(StateAccessors state, DialogSet dialogs, IApiInterface api, IConfiguration configuration)
     : base(state, dialogs, api, configuration)
 {
 }
Example #9
0
 public RequestDialog(StateAccessors state, DialogSet dialogs, IApiInterface api, IConfiguration configuration)
     : base(state, dialogs, api, configuration)
 {
     this.translator = new Translator(configuration);
 }
Example #10
0
 public InitApiMiddleware(IApiInterface api)
 {
     this.api = api ?? throw new ArgumentNullException(nameof(api));
 }
Example #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TranslationMiddleware"/> class.
 /// </summary>
 public TranslationMiddleware(IApiInterface api, StateAccessors state, Translator translator)
 {
     this.api        = api ?? throw new ArgumentNullException(nameof(api));
     this.state      = state ?? throw new ArgumentNullException(nameof(state));
     this.translator = translator ?? throw new ArgumentNullException(nameof(translator));
 }
Example #12
0
 public InteropInterface(IApiInterface value)
 {
     this._object = value;
 }
Example #13
0
 public RecipeSearchService(IApiInterface apiInterface)
 {
     this.apiInterface = apiInterface;
 }
Example #14
0
 public static StackItem FromInterface(IApiInterface value)
 {
     return(new InteropInterface(value));
 }