public override void Added() { base.Added(); string trackerApiSettingsFile = Path.Combine(GetSavePath(), "tf-tracker-api.txt"); if (File.Exists(trackerApiSettingsFile)) { string[] trackerApiSettings = File.ReadAllLines(trackerApiSettingsFile); if (trackerApiSettings.Length < 2) { TFGame.Log(new Exception("Invalid tf-tracker-api.txt contents"), false); return; } string apiUrl = trackerApiSettings[0]; string apiKey = trackerApiSettings[1]; TrackerMatchStats stats = new TrackerMatchStats(); stats.rounds = ((MySession)this.session).RoundsPlayedThisMatch; for (int index = 0; index < this.session.MatchStats.Length; index++) { if (TFGame.Players[index]) { stats.kills[index] = (int)this.session.MatchStats[index].Kills.Kills; stats.deaths[index] = (int)this.session.MatchStats[index].Deaths.Kills + (int)this.session.MatchStats[index].Deaths.SelfKills + (int)this.session.MatchStats[index].Deaths.TeamKills; stats.wins[index] = this.session.MatchStats[index].Won ? 1 : 0; stats.selfs[index] = (int)this.session.MatchStats[index].Kills.SelfKills; stats.teamKills[index] = (int)this.session.MatchStats[index].Kills.TeamKills; stats.revives[index] = (int)this.session.MatchStats[index].Revives; } } string payload = stats.ToJSON(apiKey).Replace("\"", "\\\""); Process.Start( "/bin/bash", "-c \"curl '" + apiUrl + "matches' " + "-X POST -H 'Content-Type: application/json' -H 'Accept: application/json' " + "--data-binary '" + payload + "' --compressed\"" ); } }
public void OnPlayerGhostDeath(PlayerGhost ghost, PlayerCorpse corpse) { String logicName = this.RoundLogic.GetType().Name; TFGame.Log(new Exception(logicName), false); switch (logicName) { case "TeamDeathmatchRoundLogic": ((MyTeamDeathmatchRoundLogic)this.RoundLogic).OnPlayerGhostDeath(ghost, corpse); break; case "HeadhuntersRoundLogic": ((MyHeadhuntersRoundLogic)this.RoundLogic).OnPlayerGhostDeath(ghost, corpse); break; case "LastManStandingRoundLogic": ((MyLastManStandingRoundLogic)this.RoundLogic).OnPlayerGhostDeath(ghost, corpse); break; } }
private static void Main() { try { using (var game = new TFGame(SpireSettings.IsIntroDisabled)) { //Start debug load logging so that we can log any errors that occur in the controller to the loadlog.txt directly. TFGame.StartLoadLog(); //Initialize the SpireController SpireController.Instance.Initialize(); //We have to do this because TowerFall crashes if this is not done. game.Graphics.PreparingDeviceSettings += (sender, e) => e.GraphicsDeviceInformation.GraphicsProfile = GraphicsProfile.HiDef; //Run the game. game.Run(); } } catch (Exception e) { //Exit the game upon exception occuring. Instance.Exit(); Logger.LogException(e); //Also log any inner exceptions to console. if (e.InnerException != null) { Logger.LogException(e.InnerException); } Console.ReadKey(); } }
public TfGameEventArgs(TFGame game) { Game = game; }
private static void LogException(Exception exception, bool isOnLoad) { TFGame.WriteLineToLoadLog(CreateMessageString(exception.Message, true)); TFGame.Log(exception, isOnLoad); Console.WriteLine($"{CreateMessageString(exception.Message, true)}"); }
public static void LogMessageOnLoad(string message) { message = CreateMessageString(message, false); TFGame.WriteLineToLoadLog(message); Console.WriteLine(message); }
public override int NotJoinedUpdate() { if (this.input != null) { if (this.input.MenuBack && !base.MainMenu.Transitioning) { for (int i = 0; i < 8; i++) { TFGame.Players[i] = false; } Sounds.ui_clickBack.Play(160f, 1f); if ((MainMenu.RollcallMode == MainMenu.RollcallModes.Versus) || (MainMenu.RollcallMode == MainMenu.RollcallModes.Trials)) { base.MainMenu.State = MainMenu.MenuState.Main; } else { base.MainMenu.State = MainMenu.MenuState.CoOp; } } else if (this.input.MenuLeft && this.CanChangeSelection) { this.drawDarkWorldLock = false; this.ChangeSelectionLeft(); Sounds.ui_move2.Play(160f, 1f); this.arrowWiggle.Start(); this.rightArrowWiggle = false; } else if (this.input.MenuRight && this.CanChangeSelection) { this.drawDarkWorldLock = false; this.ChangeSelectionRight(); Sounds.ui_move2.Play(160f, 1f); this.arrowWiggle.Start(); this.rightArrowWiggle = true; } else if (this.input.MenuAlt && GameData.DarkWorldDLC) { this.drawDarkWorldLock = false; this.altWiggle.Start(); Sounds.ui_altCostumeShift.Play(base.X, 1f); if (this.archerType == ArcherData.ArcherTypes.Normal) { this.archerType = ArcherData.ArcherTypes.Alt; } else { this.archerType = ArcherData.ArcherTypes.Normal; } this.portrait.SetCharacter(this.CharacterIndex, this.archerType, 1); } else if ((this.input.MenuConfirmOrStart && !TFGame.CharacterTaken(this.CharacterIndex)) && (TFGame.PlayerAmount < this.MaxPlayers)) { if (ArcherData.Get(this.CharacterIndex, this.archerType).RequiresDarkWorldDLC&& !GameData.DarkWorldDLC) { this.drawDarkWorldLock = true; if ((this.darkWorldLockEase < 1f) || !TFGame.OpenStoreDarkWorldDLC()) { this.portrait.Shake(); this.shakeTimer = 30f; Sounds.ui_invalid.Play(base.X, 1f); if (TFGame.PlayerInputs[this.playerIndex] != null) { TFGame.PlayerInputs[this.playerIndex].Rumble(1f, 20); } } return(0); } if ((this.input.MenuAlt2Check && (this.archerType == ArcherData.ArcherTypes.Normal)) && (ArcherData.SecretArchers[this.CharacterIndex] != null)) { this.archerType = ArcherData.ArcherTypes.Secret; this.portrait.SetCharacter(this.CharacterIndex, this.archerType, 1); } this.portrait.Join(false); TFGame.Players[this.playerIndex] = true; TFGame.AltSelect[this.playerIndex] = this.archerType; if (TFGame.PlayerInputs[this.playerIndex] != null) { TFGame.PlayerInputs[this.playerIndex].Rumble(1f, 20); } this.shakeTimer = 20f; if (TFGame.PlayerAmount == this.MaxPlayers) { this.ForceStart(); } return(1); } } return(0); }
private static void RespCallback(IAsyncResult ar) { TFGame.Log(new Exception("Result Callback"), false); }