// Use this for initialization private void Start() { NotDestroyMusic.Instance.gameObject.SetActive(false); //Load the QA Set from database sql server to mainQASetSrc and sub QA SetSrc pass in the scene ID DataBaseLoader.LoadQADatabase(LevelManager.instance.sceneID, mainQuestionsSource, subQuestionsSource); //Random the data to NPC in one scene InitData(); heartCount = LevelManager.instance.playerHealth; score = 0; levelText.text = "Màn chơi Lý Thường Kiệt"; doingSetup = true; //Invoke("HideLevelIntro", levelStartDelay); //Spawn the player and time hole for level intro StartCoroutine(SpawnObject()); //Display the player's life for (int i = 0; i < heartCount; i++) { hearts[i].gameObject.SetActive(true); } //Debug.Log("Câu hỏi chính" + mainQuestionsSource[0]); //Debug.Log("Câu hỏi phụ" + subQuestionsSource[0]); }
private void Start() { isUnlock = false; Debug.Log("PlayerID " + LevelManager.instance.playerID); //Load the isCompleted variable in each scene in to the isCompleted array DataBaseLoader.LoadResultDataBase(LevelManager.instance.playerID, isCompleted); //Check if the scene is completed for (int i = 0; i < isCompleted.Length; i++) { if (isCompleted[i]) { //Enable the tick icon tickIcon[i].SetActive(true); countCompletedLevel++; } } if (countCompletedLevel == 4)// 4 level is completed , the final level is unlock { StartCoroutine(UnlockFinalScene()); } else if (countCompletedLevel == 5) { lockIcon.SetActive(false); lockScreen.SetActive(false); isUnlock = true; } }
public void PlayChoosingScene() { bool m_result; SoundManager.instance.PlaySingleClip(buttonClickSound); //Load the isCompleted scene add pass in the SaveGameInNormalScene function to save the isCompleted properties in case of plalyer play the scene again and does not pass it but has passed it before bool isCompleted = DataBaseLoader.LoadResultInOneScene(LevelManager.instance.playerID, LevelManager.instance.sceneID); //The player has completed the scene but when not complete the scene when play again if (isCompleted == true && LevelManager.instance.result == false) { //Save Game in normal scene DataBaseLoader.SaveGameInNormalScene( LevelManager.instance.playerID, LevelManager.instance.sceneID, LevelManager.instance.scoreInOneScene, isCompleted ); } else { //Save Game in normal scene DataBaseLoader.SaveGameInNormalScene( LevelManager.instance.playerID, LevelManager.instance.sceneID, LevelManager.instance.scoreInOneScene, LevelManager.instance.result ); } Application.LoadLevel("ChoosingScene"); }
public void PassFinal() { Application.LoadLevel("FinalSuccessResultScene"); //Save the result to database DataBaseLoader.SaveGameInNormalScene(LevelManager.instance.playerID, LevelManager.instance.sceneID, LevelManager.instance.scoreInOneScene, true); }
public void DataLoadStart() { if (loader == null) { loader = new DataBaseLoader("CurlingArena", new MonoSQLite()); } IDataBase[] dataBase = new IDataBase[] { new AffiliationDataBase(), new CharacterDataBase(), new JobDataBase(), new RarityDataBase(), new SizeDataBase(), new SkillDataBase(), new SpeciesDataBase(), new BasicDataBase(), new SynergyDataBase(), }; loader.Process(dataBase); string msg = loader.ErrorMsg; if (msg != string.Empty) { Debug.Log(msg); } EndDataLoadEvent?.Invoke(); }
public ProfileController(ILogger <ProfileController> logger, DataBaseLoader DBloader, IUserService userService, InDataBaseService _DBService) { _logger = logger; _DBloader = DBloader; _userService = userService; this._DBService = _DBService; }
public async Task MainAsync() { DeserializeSettings(); _client = new DiscordSocketClient(new DiscordSocketConfig { LogLevel = LogSeverity.Info }); commandService = new CommandService(new CommandServiceConfig { CaseSensitiveCommands = false, DefaultRunMode = RunMode.Async }); DataBaseLoader.LoadDatabase(); _client.Log += Log; await _client.LoginAsync(TokenType.Bot, PrivateSettings.Token); await _client.StartAsync(); _client.Ready += _client_Ready; await InstallCommands(); await Task.Delay(-1); }
private async Task GetIntro(IGuildUser user) { if (user.Id == Program._client.CurrentUser.Id) { var builder = new EmbedBuilder() .WithColor(Color.LightOrange) .WithTitle($"Introduction for {Program._client.CurrentUser.Username}"); builder.Description = "I'm the server's bot. Type !help for my commands."; var embed = builder.Build(); await ReplyAsync("", false, embed); await Task.Delay(1000); await Context.Message.DeleteAsync(); return; } if (user.IsBot) { await ReplyAsync("Introduction unavailable for bot"); } else { var info = await DataBaseLoader.GetInfo(user); if (info.IntroMessage == 0) { await ReplyAsync($"No intro for that user found.{user.Mention} send a message to <#{Program.PrivateSettings.IntrosChannel}> introducing yourself"); return; } IMessage message = await Program.IntrosChannel.GetMessageAsync(info.IntroMessage); if (message == null) { await ReplyAsync($"Intro message for {user.Mention} seems to have been deleted. Try sending another message to <#{Program.PrivateSettings.IntrosChannel}>").DeleteAfterSeconds(20); await Context.Message.DeleteAsync(); return; } string messageLink = "https://discordapp.com/channels/" + Context.Guild.Id + "/" + Program.PrivateSettings.IntrosChannel.ToString() + "/" + info.IntroMessage; var builder = new EmbedBuilder() .WithColor(Color.LightOrange) .WithTitle($"Introduction for {user.Username}") .WithUrl(messageLink); builder.Description = message.Content; var embed = builder.Build(); await ReplyAsync("", false, embed); await Task.Delay(1000); await Context.Message.DeleteAsync(); } }
public async Task PurgeDb(int days = 7) { if (Context.User.Id == 385164566658678784) { DataBaseLoader.PruneDatabase(TimeSpan.FromDays(days)); await Context.User.DM("Database purged"); } }
#pragma warning restore IDE1006 // Naming Styles public Services(CommandService commandService) { this.commandService = commandService; databaseLoader = new DataBaseLoader(this); time = new Timing(this); random = new Random(); }
private async Task IntroductionsEditAsync(Cacheable <IMessage, ulong> arg1, SocketMessage arg2, ISocketMessageChannel arg3) { if (!arg2.Author.IsBot && arg2.Channel.Id == PrivateSettings.IntrosChannel) { DataBaseLoader.SetIntro(arg2.Author, arg2.Id); await arg2.Channel.SendMessageAsync($"{arg2.Author} I've updated your intro :thumbsup:").DeleteAfterSeconds(15); } }
async Task IntroductionsAsync(SocketMessage message) { if (!message.Author.IsBot && message.Channel.Id == PrivateSettings.IntrosChannel) { DataBaseLoader.SetIntro(message.Author, message.Id); await message.Channel.SendMessageAsync($"{message.Author} I've updated your intro :thumbsup:").DeleteAfterSeconds(15); } }
// Use this for initialization void Start() { DataBaseLoader.LoadScoreAllScenes(LevelManager.instance.playerID, ref scoreScene); //load score for (int i = 0; i < scoreText.Length; i++) { scoreText[i].text = scoreScene[i].ToString(); } }
public async Task Warn(IGuildUser user, string reason) { await Context.Message.DeleteAsync(); DataBaseLoader.AddWarning(user, $"\"{reason}\" {DateTime.UtcNow.ToString("g", CultureInfo.CreateSpecificCulture("en-US"))} (warning by {Context.User.Tag()})"); await Program.LogChannel.SendMessageAsync($"{Context.User.Mention} warned {user.Mention} that \"{reason}\""); await ReplyAsync($"**{user.Mention} {reason}** \n Persisting with this behaviour will get you muted and eventually banned."); }
public void SetPlayerButton(Button ID) { string playerName = ID.GetComponentInChildren <Text>().text; if (playerName != "") { PlayerPrefs.SetString("CurrentPlayer", playerName); LevelManager.instance.playerID = DataBaseLoader.LoadPlayerID(playerName); Application.LoadLevel("Menu"); } }
public void PlaySceneWithLevel(int gameLife) { //Call the function CreateNewGame from the DatabaseLoader DataBaseLoader.CreateNewGame(LevelManager.instance.playerID); //Save game mode to sql DataBaseLoader.SaveGameModeToDb(LevelManager.instance.playerID, gameLife); LevelManager.instance.playerHealth = gameLife; Application.LoadLevel("ChoosingScene"); }
public async Task WarningList(IGuildUser user) { var info = await DataBaseLoader.GetInfo(user); StringBuilder builder = new StringBuilder(); builder.Append($"Warnings for {user.Tag()} (Count: {info.Warnings.Length}): \n"); for (int i = 0; i < info.Warnings.Length; i++) { builder.Append($"{i}: {info.Warnings[i]} \n"); } await ReplyAsync(builder.ToString()); }
// Use this for initialization void Start() { //Debug.Log("Run Final GameManager"); levelText.text = "Màn chơi cuối"; if (LevelManager.instance.wasRandom == false) { DataBaseLoader.LoadDatabase(4, Resources); RandomResource(); //Random question and set into 4 doors LevelManager.instance.wasRandom = true; //LevelManager.instance.scoreInOneScene = 0; //LevelManager.instance.playerHealth = 3; LevelManager.instance.heartCount_Player = LevelManager.instance.playerHealth; LevelManager.instance.heartCount_Dof = 3; LevelManager.instance.doorSound = doorSound; for (int i = 0; i < 4; i++) { LevelManager.instance.doors[i] = doors[i]; } } else { for (int i = 0; i < 4; i++) { if (LevelManager.instance.doors[i].isCompleted) { doorButton[i].SetActive(false); } } } score = LevelManager.instance.scoreInOneScene; scoreText.text = "Score:" + score.ToString(); heartCount_Player = LevelManager.instance.heartCount_Player; gameLife = LevelManager.instance.playerHealth; ////Display the player's life //for (int i = heartCount_Player - 1; i < gameLife - 1; i++) //{ // heart_Player[i + 1].gameObject.SetActive(false); //} for (int i = 0; i < heartCount_Player; i++) { heart_Player[i].gameObject.SetActive(true); } }
private async Task KarmaHandlerAsync(SocketMessage messageParam) { if (!messageParam.Author.IsBot && messageParam.MentionedUsers.Count > 0) { string lower = messageParam.Content.ToLower(); List <SocketUser> users = messageParam.MentionedUsers.ToList(); if (PrivateSettings.KarmaTriggers.Any(x => lower.Contains(x))) { if (users.Any(x => x.Id == messageParam.Author.Id)) { await messageParam.Channel.SendMessageAsync(":expressionless:").DeleteAfterSeconds(30); } else if (KarmaCooldowns.Contains(messageParam.Author.Id)) { await messageParam.Channel.SendMessageAsync($"You have to wait {PrivateSettings.KarmaCooldown / 1000} seconds before giving another karma."); } else { users.RemoveAll(x => x.IsBot); if (users.Count == 0) { await messageParam.Channel.SendMessageAsync("Bots need no Karma...").DeleteAfterSeconds(20); return; } KarmaCooldowns.Add(messageParam.Author.Id); DataBaseLoader.AddKarma(users, 1); StringBuilder builder = new StringBuilder(); builder.Append($"{messageParam.Author.Username} gave karma to "); builder.Append($"{users[0]}"); for (int i = 1; i < users.Count - 1; i++) { builder.Append($", {users[i]}"); } if (users.Count > 1) { builder.Append($" and {users[users.Count - 1]}"); } builder.Append("."); await messageParam.Channel.SendMessageAsync(builder.ToString()).DeleteAfterSeconds(20); await Task.Delay(PrivateSettings.KarmaCooldown); KarmaCooldowns.Remove(messageParam.Author.Id); } } } }
public async Task MuteCommand(IGuildUser user, uint seconds, string reason = "Not specified") { if (user.Id == Program._client.CurrentUser.Id) { await ReplyAsync("I'm unmutable :smiling_imp:"); } else { DataBaseLoader.AddWarning(user, $"\"{reason}\" {DateTime.UtcNow.ToString("g", CultureInfo.CreateSpecificCulture("en-US"))} (mute by {Context.User.Tag()})"); await Context.Message.DeleteAsync(); await Muting.Mute(user, seconds, reason, Context); } }
public void GameOver() { Application.LoadLevel("FinalFailedResultScene"); //Load the isCompleted scene add pass in the SaveGameInNormalScene function to save the isCompleted properties in case of plalyer play the scene again and does not pass it but has passed it before bool isCompleted = DataBaseLoader.LoadResultInOneScene(LevelManager.instance.playerID, LevelManager.instance.sceneID); bool m_result = false; if (isCompleted == true) { m_result = true; } //Save the result to database DataBaseLoader.SaveGameInNormalScene(LevelManager.instance.playerID, LevelManager.instance.sceneID, LevelManager.instance.scoreInOneScene, m_result); }
private Task _client_Ready() { if (!Initialized) { Guild = _client.GetGuild(PrivateSettings.ServerId); LogChannel = Guild.GetTextChannel(PrivateSettings.LogChannel); WelcomeChannel = Guild.GetTextChannel(PrivateSettings.WelcomeChannel); IntrosChannel = Guild.GetTextChannel(PrivateSettings.IntrosChannel); CommandsChannel = Guild.GetTextChannel(PrivateSettings.CommandsChannel); DataBaseLoader.ReloadTimedActions(); Initialized = true; } return(Task.CompletedTask); }
private async Task XpHandlerAsync(SocketMessage messageParam) { if (!messageParam.Author.IsBot && !XpCooldowns.Contains(messageParam.Author.Id)) { XpCooldowns.Add(messageParam.Author.Id); var info = await DataBaseLoader.GetInfo(messageParam.Author); int oldLevel = info.Level(); info.Xp += PrivateSettings.XpPerMessage; DataBaseLoader.AddXp(messageParam.Author, PrivateSettings.XpPerMessage); if (info.Level() != oldLevel) { await messageParam.Channel.SendMessageAsync($"{messageParam.Author.Username} leveled up!").DeleteAfterSeconds(20); } await Task.Delay(PrivateSettings.XpCooldown); XpCooldowns.Remove(messageParam.Author.Id); } }
private async Task Profile(IUser user = null) { EmbedBuilder embedBuilder = new EmbedBuilder(); embedBuilder.WithColor(Color.Gold); embedBuilder.Title = user == null ? Context.User.Username : user.Username; if (user != null && user.IsBot) { embedBuilder.AddField("Level: ", 99999).AddInlineField("Xp: ", 9999); embedBuilder.AddField("Karma: ", 99999); } else { DataBaseLoader.UserInfo info = await DataBaseLoader.GetInfo(user ?? Context.User); embedBuilder.AddField("Level: ", info.Level()).AddInlineField("Xp: ", info.Xp); embedBuilder.AddField("Karma: ", info.Karma); } await ReplyAsync("", embed : embedBuilder.Build()); }
private void Start() { //Load the game mode from sql and assign it to playerHealth LevelManager.instance.playerHealth = DataBaseLoader.LoadGameMode(LevelManager.instance.playerID); }
public async Task ClearWarnings(IGuildUser user) { DataBaseLoader.ClearWarnings(user); await ReplyAsync("Warnings cleared"); }
public async Task RemoveWarnings(IGuildUser user, int index) { DataBaseLoader.RemoveWarning(user, index); await ReplyAsync("Warning removed"); }
public HomeController(ILogger <HomeController> logger, DataBaseLoader DBloader, InDataBaseService _DataBaseservice) { _logger = logger; _DBloader = DBloader; this._DataBaseservice = _DataBaseservice; }
public AccountController(ILogger <AccountController> logger, DataBaseLoader DBloader, IUserService userService, InDataBaseService _userDatabaseService) { _userService = userService; this._userDatabaseService = _userDatabaseService; }