private void Start() { gameState = GameState.Play; Time.timeScale = 1; playerHasDied = false; this.levelDescriptions = XmlHelpers.DeserializeDatabaseFromXML <LevelDescription>(this.levelDescriptionXml); // Spawn the player. GameObject player = (GameObject)GameObject.Instantiate(Instance.playerPrefab, new Vector3(0f, 0f), Quaternion.identity); this.PlayerAvatar = player.GetComponent <PlayerAvatar>(); if (this.PlayerAvatar == null) { Debug.LogError("Can't retrieve the PlayerAvatar script."); } switch (gameType) { case GameType.Levels: currentLevel = new Level(); StarNextLevel(); break; case GameType.Endless: break; default: Debug.LogWarning("Unknown game type." + gameType.ToString()); break; } }
/// <summary> /// File for recording odds of a match /// </summary> /// <param name="type"></param> /// <param name="team1"></param> /// <param name="team2"></param> /// <param name="dateStr"></param> /// <returns></returns> public static string ConstructRecordFileName(GameType type, string team1, string team2, string dateStr) { string filename = type.ToString() + "-" + team1 + "-" + team2 + "-" + Convert.ToDateTime(dateStr).ToShortDateString().Replace('/', '_') + ".json"; string workdir = Path.Combine(DataFolder, type.ToString());; return(Path.Combine(workdir, filename)); }
/// <summary> /// File for recording collection continuation info /// </summary> /// <param name="gameType"></param> /// <returns></returns> public static string ConstructCollectContinuationFileName(GameType gameType) { string filename = gameType.ToString() + "-Collect.ini"; string workdir = Path.Combine(DataFolder, gameType.ToString());; return(Path.Combine(workdir, filename)); }
public static int GetScore(string name, GameType type, GameMode.Mode mode, GameDifficult.Difficult diff) { JObject jobj; if (!UserData.ContainsKey("myBestScore")) { return(0); } jobj = (JObject)UserData["myBestScore"]; if (!jobj.ContainsKey(type.ToString())) { return(0); } jobj = (JObject)jobj[type.ToString()]; if (!jobj.ContainsKey(name)) { return(0); } jobj = (JObject)jobj[name]; if (!jobj.ContainsKey(mode.ToString())) { return(0); } jobj = (JObject)jobj[mode.ToString()]; if (!jobj.ContainsKey(diff.ToString())) { return(0); } return((int)jobj[diff.ToString()]); }
/// <summary> /// File for one analysis report /// </summary> /// <param name="type"></param> /// <returns></returns> public static string ConstructReportFileName(GameType type) { string filename = type.ToString() + "-" + DateTime.Today.ToShortDateString().Replace('/', '_') + "-Report" + ".txt"; string workdir = Path.Combine(DataFolder, type.ToString()); return(Path.Combine(workdir, filename)); }
public static string GetEZRDataPath(GameType type, string songName) { if (type == GameType.EZ2ON || type == GameType.EZ2DJ) { return(Path.Combine(EZR.Master.GameResourcesFolder, "EZ2Series", type.ToString(), songName + ".ezr")); } else { return(Path.Combine(EZR.Master.GameResourcesFolder, type.ToString(), "Songs", songName + ".ezr")); } }
public void SaveToken_old(string token) { var test = _gameType.ToString() + "token"; var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var encryptedToken = EncryptionHelper.Encrypt(token); config.AppSettings.Settings[_gameType.ToString() + "token"].Value = encryptedToken; config.Save(ConfigurationSaveMode.Modified); config.Save(); ConfigurationManager.RefreshSection("appSettings"); }
public void getScore(GameType gameType, int limit) { Dictionary <string, string> data = new Dictionary <string, string>() { { "game", gameType.ToString() }, { "limit", limit.ToString() } }; Thread thread = new Thread(() => getScoreRequest(Request.DictionaryToJson(data))); thread.Name = "GET_SCORE THREAD -- " + gameType.ToString(); thread.Start(); }
public void setScore(GameType game, int score) { Dictionary <string, string> data = new Dictionary <string, string>() { { "game", game.ToString() }, { "user", System.Security.Principal.WindowsIdentity.GetCurrent().Name.Replace('\\', ' ') }, { "score", score.ToString() } }; Thread thread = new Thread(() => setScoreRequest(Request.DictionaryToJson(data))); thread.Name = "SET_SCORE THREAD -- " + game.ToString(); thread.Start(); }
public string SaveGameToFile(DateTime date, int roundNumber, List <Player> players) { string dateStr = date.ToString(); dateStr = DateTime.Now.ToString("ddMMyyyy") + ".txt"; var savingDirectory = Path.Combine(path + "/" + gameType.ToString() + "/" + fileName + dateStr); int j = 1; while (File.Exists(savingDirectory)) { string uniqueId = string.Format("({0})", j); if (File.Exists(savingDirectory + uniqueId)) { j++; uniqueId = string.Format("({0})", j); } savingDirectory = Path.Combine(savingDirectory + uniqueId); } StreamWriter file = new StreamWriter(savingDirectory); string output = date.ToString(); output = date.ToString(); file.WriteLine(output); output = roundNumber.ToString(); file.WriteLine(output); foreach (Player player in players) { output = player.Name; file.WriteLine(output); output = player.IsAI.ToString().ToLower(); file.WriteLine(output); Score[] score = player.GetScoreList(); for (int i = 0; i < score.Length; i++) { output = ""; output += score[i].Points + "|" + score[i].TakenChoice; file.WriteLine(output); } } file.Close(); return(path + fileName + dateStr); }
public void LoadOnlineKibitzing() { // FilePathOpeningBook = Ap.FolderSettings + @"Books\" + InfinitySettings.Settings.DefaultOpeningBook; GameMode = GameMode.Kibitzer; GameType = (GameType)DbGame.GameTypeID; GameTime.Set(DbGame); GameResult = DbGame.GameResultIDE; //GameResultE.InProgress; Player1.PlayerType = PlayerType.Human; Player1.PlayerTitle = DbGame.WhiteUser.UserName; Player2.PlayerType = PlayerType.Human; Player2.PlayerTitle = DbGame.BlackUser.UserName; if (DbGame.IsRated) { gameTypeTitle = GameType.ToString() + " " + DbGame.TimeMinute.ToString() + "m + " + DbGame.TimeSecond.ToString() + "s, " + "Rated"; if (DbGame.EloBlackBefore != 0 && !DbGame.BlackUser.IsGuest) { Player2.PlayerTitle += " " + DbGame.EloBlackBefore.ToString(); } if (DbGame.EloWhiteBefore != 0 && !DbGame.WhiteUser.IsGuest) { Player1.PlayerTitle += " " + DbGame.EloWhiteBefore.ToString(); } } else { gameTypeTitle = GameType.ToString() + " " + DbGame.TimeMinute.ToString() + "m + " + DbGame.TimeSecond.ToString() + "s, " + "Unrated"; } }
//Settings public static void CreateSettings() { //Ok, Make new var parser = new FileIniDataParser(); IniData data = new IniData(); data["Satisfactory"]["DriveLetter"] = DriveLetter; data["Satisfactory"]["FolderPath"] = FolderPath; data["Satisfactory"]["ProgramName"] = ProgramName; data["Satisfactory"]["SFSM_Installed"] = SFSM_Installed.ToString(); data["Satisfactory"]["SFSM_Port"] = SFSM_Port.ToString(); data["Satisfactory"]["GameType"] = GameType.ToString(); data["Session"]["StartLoc"] = StartLoc.ToString(); data["Session"]["WorldName"] = WorldName; data["Session"]["SaveName"] = SaveName; data["Session"]["AdminPassword"] = AdminPassword; data["Network"]["MultiHome"] = MultiHome.ToString(); data["Network"]["LanOnly"] = LanOnly.ToString(); data["Timers"]["EnableAutoRestart"] = EnableAutoRestart.ToString(); data["Timers"]["AutoRestartMinutesInterval"] = AutoRestartMinutesInterval.ToString(); data["Web"]["WebListenIP"] = WebListenIP.ToString(); data["Web"]["WebPort"] = WebPort.ToString(); data["Web"]["AccessSecret"] = AccessSecret.ToString(); parser.WriteFile("Configuration.ini", data); }
void SetGameTypeByString(GameType gameType) { if (g.goAssets.name.Contains(gameType.ToString()) == true) { g.gameType = gameType; } }
public static void SetHighScore(GameType type, float score) { if (score > GetHighScore(type)) { PlayerPrefs.SetFloat(type.ToString() + "HighScore", score); } }
private static void OnGameInjectionStateChange(GameType gameType, InjectionState injectionState) { if (injectionState != InjectionState.Injected) { return; } if (!config.TryGetValue(gameType.ToString(), out var subConfig)) { subConfig = new Dictionary <string, object>(); } if (Logger.DebugMode) { subConfig["debug"] = true; } else { subConfig.Remove("debug"); } string jsonConfig = JsonConvert.SerializeObject(subConfig); if (ProcessMonitor.SendCommand(gameType, CommandType.Config, jsonConfig, 10000) != "Done") { if (ProcessMonitor.SendCommand(gameType, CommandType.Config, jsonConfig, 5000) != "Done") { Logger.LogError("Unable to send config to in-game UI"); } } }
public void StartNewGame(int gameIndex) { GameType game = (GameType)gameIndex; var gameString = game.ToString().ToLower(); GameViewModel newGame = null; //TODO Reflection var memoryGameName = (nameof(MemoryGameViewModel)).ToLower(); var quizGameName = (nameof(QuizGameViewModel)).ToLower(); var hangmanGameName = (nameof(HangmanGameViewModel)).ToLower(); if (memoryGameName.Contains(gameString)) { newGame = new MemoryGameViewModel(); } if (quizGameName.Contains(gameString)) { newGame = new QuizGameViewModel(); } if (hangmanGameName.Contains(gameString)) { newGame = new HangmanGameViewModel(); } this.mainWindow.DataContext = newGame; }
/// <summary> /// Evaluates the case where only the minimum elo specified. /// </summary> /// <param name="c">The command argument information.</param> /// <returns><c>true</c> if the evaluation was successful, otherwise <c>false</c>.</returns> private async Task <bool> EvalMinEloSpecified(Cmd c) { int min; var minAcceptable = ((int.TryParse(Helpers.GetArgVal(c, 2), out min) && min >= 0)); if ((!minAcceptable)) { await DisplayArgLengthError(c); return(false); } MinimumRequiredElo = min; MaximumRequiredElo = 0; UpdateConfig(true); StatusMessage = string.Format( "^2[SUCCESS]^7 {0} Elo limit ^2ON.^7 Players must have at least^2 {1} ^7{0} Elo to play on this server.", GameType.ToString().ToUpper(), min); await SendServerSay(c, StatusMessage); await BatchRemoveEloPlayers(); Log.Write(string.Format( "Received {0} request from {1} to enable Elo limiter module with {2} minimum Elo. Enabling.", (c.FromIrc ? "IRC" : "in-game"), c.FromUser, min), _logClassType, _logPrefix); return(true); }
public void Setup(int rounds, GameType gType, List <PlayerStat> t1, List <PlayerStat> t2) { _roundTotal = rounds; _roundsToWin = (int)(Mathf.Floor((float)rounds / 2f) + 1f); _gameType = gType; team1 = t1; team2 = t2; if (_gameType != GameType.Pratice) { int[] missingPlayers = MissingPlayers(_gameType); if (missingPlayers[0] > 0 || missingPlayers[1] > 0) { for (int i = 0; i < missingPlayers.Length; i++) { for (int j = 0; j < missingPlayers[i]; j++) { //TODO: add player bot to team i Debug.Log("<color=purple>Adding Bot to Team</color>"); } } } else if (missingPlayers[0] < 0 || missingPlayers[1] < 0) { Debug.LogError("TOO MANY PLAYERS FOR GAMETYPE: " + _gameType.ToString()); } } _currentRound = 0; team1Score = team2Score = 0; StartGame(); }
public FFGImport(GameType t, Platform p, string contentPath, bool e = false) { type = t; platform = p; path = contentPath + t.ToString() + "/import"; editor = e; }
/*public Rules Rules { get; }*/ public override string ToString() { string s = ""; s += player_on_turn != -1? Board.ToString(player_on_turn) + Environment.NewLine : ""; s += GameType.ToString(); //if (GameType == GameType.Match) // s += " Length: " + match_to + " Stake: " + stake + " Score: " + Score(player_on_turn) + "-" + Score(1 - player_on_turn) + " Crawford: " + IsCrawford.ToString() + Environment.NewLine; //if (GameType == GameType.Money) // s += " Stake: " + stake + " Limit: " + limit + Environment.NewLine; s += " |Len {" + match_to + "} |Stakes {" + stake + "(" + limit + ")" + "} |Score {" + Score(player_on_turn) + "-" + Score(1 - player_on_turn) + "} |Crawford {" + IsCrawford.ToString() + "}" + Environment.NewLine; if (DiceRolled) { s += "D: " + Math.Max(dice[0], dice[1]) + "" + Math.Min(dice[0], dice[1]) + " "; } s += "C {" + cube.Value + "@" + cube.Owner + "} "; s += "On roll {" + player_on_roll + "} |Turn {" + player_on_turn + "} |Offer {" + offer.ToString() + "} |Can double {" + CanDouble().ToString() + "}" + " |Resign value {" + (int)resign_offer_value + "}" + Environment.NewLine; /* string s = player_on_turn != -1?Board.ToString(player_on_turn) + Environment.NewLine : ""; * s += "Cube: value " + cube.Value + " owner " + cube.Owner + Environment.NewLine; * s += "Dice: " + dice[0] + " " + dice[1] + Environment.NewLine; * s += "Player on roll: " + player_on_roll + Environment.NewLine; * s += "Player on turn: " + player_on_turn + Environment.NewLine; * s += "Offer: " + offer.ToString();*/ return(s); }
public Form1(GameType type) { this.type = type; Text = type.ToString(); InitializeComponent(); Form = this; }
private void StartOnlineE2EGame() { FilePathOpeningBook = Ap.Options.CurrentBookFilePath; GameTime.Set(DbGame); Player1.PlayerTitle = DbGame.WhiteUser.UserName + " " + DbGame.WhiteUser.Engine.Name; Player2.PlayerTitle = DbGame.BlackUser.UserName + " " + DbGame.BlackUser.Engine.Name; Player1.Color = PlayerColorE.White; Player2.Color = PlayerColorE.Black; if (DbGame.IsCurrentUserWhite) { Player1.Engine = UCIEngine.Load(Ap.PlayingMode.SelectedEngine.EngineFile, Ap.PlayingMode.SelectedEngine.HashTableSize, this); Player1.Engine.UseTablebases = Ap.EngineOptions.UseTablebases; DefaultEngine = Player1.Engine; Player1.Book = Ap.PlayingMode.SelectedBook; if (Player1.Book != null) { Player1.Book.Game = this; Player1.Book.NewGame(); } if (DbGame.EloBlackBefore != 0) { Player2.PlayerTitle += " " + DbGame.EloBlackBefore.ToString(); } } else { Player2.Engine = UCIEngine.Load(Ap.PlayingMode.SelectedEngine.EngineFile, Ap.PlayingMode.SelectedEngine.HashTableSize, this); Player2.Engine.UseTablebases = Ap.EngineOptions.UseTablebases; DefaultEngine = Player2.Engine; Player2.Book = Ap.PlayingMode.SelectedBook; if (Player2.Book != null) { Player2.Book.Game = this; Player2.Book.NewGame(); } if (DbGame.EloWhiteBefore != 0) { Player1.PlayerTitle += " " + DbGame.EloWhiteBefore.ToString(); } } if (DbGame.IsRated) { gameTypeTitle = GameType.ToString() + " " + DbGame.TimeMin.ToString() + "' + " + DbGame.GainPerMoveMin.ToString() + "'', " + "Rated"; } else { gameTypeTitle = GameType.ToString() + " " + DbGame.TimeMin.ToString() + "' + " + DbGame.GainPerMoveMin.ToString() + "'', " + "Unrated"; } GameData.SetPlayers(Player1.PlayerTitle, "", Player2.PlayerTitle, ""); }
public static string GetDisplayName(GameType gameType) { switch (gameType) { case GameType.NoLimitHoldem: return "No Limit Holdem"; case GameType.FixedLimitHoldem: return "Fixed Limit Holdem"; case GameType.PotLimitOmaha: return "Pot Limit Omaha"; case GameType.PotLimitOmahaHiLo: return "Pot Limit Omaha Hi-Lo"; case GameType.FixedLimitOmahaHiLo: return "Fixed Limit Omaha Hi-Lo"; case GameType.PotLimitHoldem: return "Pot Limit Holdem"; case GameType.Any: return "Any"; case GameType.CapNoLimitHoldem: return "Cap NL Holdem"; case GameType.CapPotLimitOmaha: return "Cap Pot Limit Omaha"; case GameType.Unknown: return "Unknown"; default: return gameType.ToString(); } }
/// <summary> /// Ends current round. /// </summary> void EndGame() { Pause(); HardPause = true; Program.Debug(LogLevel.Error, "Game ended, hits: {0}, misses: {1}", clicks.Where(x => x.Score).Count(), clicks.Where(x => !x.Score).Count()); String clicks_str = ""; String clicks_stats = ""; int index = 0; foreach (Click c in clicks) { index++; clicks_str += String.Format("Click x:{0}, y:{1}, hit: {2}, distance to nearest target: {3}, target lifetime: {4}\n", c.X, c.Y, c.Score, c.Distance, c.TargetLiveTime ); clicks_stats += String.Format("Strzał#{0} x:{1}, y:{2}, trafienie: {3}{4}{5}\n", index, c.X, c.Y, (c.Score ? "Tak":"Nie"), (!c.Score ? String.Format(", dystans do najbliższego celu: {0}", c.Distance) : ""), (c.TargetLiveTime != TimeSpan.FromTicks(0) ? String.Format(", czas życia celu: {0}", c.TargetLiveTime) : "") ); } Program.Debug(LogLevel.Error, clicks_str); FileLogger fl; fl = new FileLogger(); string text = String.Format("Czas gry: {0}\nTrafienia: {1}\nChybienia: {2}\nCelność: {3}%", ElapsedTime, GetHits(), GetMisses(), ((Program.game.GetHits() != 0 || Program.game.GetMisses() != 0) ? 100 * Program.game.GetHits() / (Program.game.GetHits() + Program.game.GetMisses()) : 0) ); Task.Run(() => fl.WriteData(String.Format("{0}.txt", DateTime.Now.ToString("dd_MM_yyyy_HH-mm-ss")), "Data: {0}\nTryb gry: {1}\n{2}{3}{4}{5}{6}{7}\n{8}", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), type.ToString(), String.Format("Poruszające się cele: {0}\n", MovingTargets ? "Tak" : "Nie"), type == GameType.ScoreTrial ? (String.Format("Zmieniające wielkość cele: {0}\n", ResizableTargets ? "Tak" : "Nie")) : "", type == GameType.ScoreTrial ? String.Format("Czas życia celu: {0}\n", TimeSpan.FromMilliseconds(TargetLifetime * (1000 / 30.0))) : "", String.Format("Ilość celów na start: {0}\n", StartingTargets), type == GameType.ScoreTrial ? String.Format("Czas pojawiania się kolejnych celów: {0}\n", TargetAddTime) : "", text, clicks_stats )); var box = MessageBox.Show(text, "Koniec gry!", MessageBoxButtons.OK); if (box == DialogResult.OK) { gf1.ShowMenu(); } }
public string GetGameDetails() { if (Team1 != null) { return(GameType == GameType.Group ? $"group: {Team1.Group}" : GameType.ToString()); } return("-"); }
public static bool SetScore(int score, string name, GameType type, GameMode.Mode mode, GameDifficult.Difficult diff) { if (score == 0) { return(false); } JObject jobj; if (!UserData.ContainsKey("myBestScore")) { UserData["myBestScore"] = new JObject(); } jobj = (JObject)UserData["myBestScore"]; if (!jobj.ContainsKey(type.ToString())) { jobj[type.ToString()] = new JObject(); } jobj = (JObject)jobj[type.ToString()]; if (!jobj.ContainsKey(name)) { jobj[name] = new JObject(); } jobj = (JObject)jobj[name]; if (!jobj.ContainsKey(mode.ToString())) { jobj[mode.ToString()] = new JObject(); } jobj = (JObject)jobj[mode.ToString()]; if (!jobj.ContainsKey(diff.ToString())) { jobj[diff.ToString()] = score; return(true); } var bestScore = (int)jobj[diff.ToString()]; if (score > bestScore) { jobj[diff.ToString()] = score; return(true); } else { return(false); } }
/// <summary> /// This function places the ball based on the game type /// There are prefabs created in a order to make the placement easy based on the selected game type /// </summary> private void PlaceBallBasedOnGameType() { // just cue doesnt place any balls in the table except for the cueball if (_gameType != GameType.JustCue) { string rackString = "Rack"; Instantiate((Resources.Load(_gameType.ToString() + rackString, typeof(GameObject)) as GameObject), _rackTransform.position, _rackTransform.rotation); } }
public Database(Variant variant, InterfaceRules rules, GameType gameType) { this.variant = variant; this.gameType = gameType; this.rules = rules; this.fileName = gameType.ToString(); this.playersfromfile = new List <Player>(); Directory.CreateDirectory(path + fileName); }
public Task GameGetSetting([FromForm] GameType type) { IGameProvider iProvider = GameFactory.GetFactory(type.ToString(), string.Empty); return(this.GetResult(new { Setting = iProvider == null ? new JsonString("[]") : new JsonString(iProvider.ToSetting()) })); }
// Use this for initialization void Start() { //gameType = GameType.MapGen; mDebug.Log("Starting GameManager with GameType " + gameType.ToString() + "..."); //game = new Game(this); game = new ExodusGame(this); drawer.game = game; inputHandler.SetGame(game); }
public void WriteOutputData(ref XElement elem) { XMLUtil.CreateAttribute(ATTRIBUTE_Y_MAX, yMax.ToString(), ref elem); XMLUtil.CreateAttribute(ATTRIBUTE_Y_MIN, yMin.ToString(), ref elem); XMLUtil.CreateAttribute(ATTRIBUTE_X_MAX, xMax.ToString(), ref elem); XMLUtil.CreateAttribute(ATTRIBUTE_X_MIN, xMin.ToString(), ref elem); XMLUtil.CreateAttribute(ATTRIBUTE_SHUFFLE, shuffleTrials.ToString(), ref elem); XMLUtil.CreateAttribute(ATTRIBUTE_GAMETYPE, gameType.ToString(), ref elem); }
public void GameIsSavedToMongoDatabaseWhenCreated(string gameName, GameType gameType) { var page = SeleniumEnvironment.Instance.NavigateToInitialPage<CreateGamePage>(ApplicationUrls.CreateGame); page.GameName = gameName; page.Type = gameType; page.CreateGame(); var gamesCollection = Mongo.GetCollection<BsonDocument>("Game"); WaitFor.Condition(() => gamesCollection.Count() > 0); var savedDocument = gamesCollection.FindAll().Single(); Assert.Equal(gameName, savedDocument.GetElement("name").Value.AsString); Assert.Equal(gameType.ToString(), savedDocument.GetElement("type").Value.AsString); }
public static void SetGameType(GameType type) { try { if (rkOptions != null) { rkOptions.SetValue(gameTypeKeyName, type.ToString()); } } catch { } }
public string GetGameTypeHandHistoryText(PokerFormat pokerFormat, SiteName siteName, GameType gameType) { return GetHandText(pokerFormat, siteName, "GameTypeTests", gameType.ToString()); }