public override void EnterState() { Utilities.DeathData Data = (Utilities.DeathData)Utilities.InterStateResources.Instance.Resources["Game_DeathData"]; Utilities.NotableEventsLog NEL = (Utilities.NotableEventsLog)Utilities.InterStateResources.Instance.Resources["Game_NotableEventsLog"]; Filename = DateTime.Now.Date.ToString() + " - " + DateTime.Now.TimeOfDay.ToString() + ".txt"; Filename = Filename.Replace('/', '-').Replace(':', '-'); Filename = System.Windows.Forms.Application.ExecutablePath.Substring(0, System.Windows.Forms.Application.ExecutablePath.LastIndexOf('\\') + 1) + "morgues\\" + Filename; System.IO.StreamWriter SW = new System.IO.StreamWriter(Filename); SW.WriteLine(Data.Player.FirstName + " " + Data.Player.LastName + ", the level 0 Dwarf"); SW.WriteLine("He survived for " + Data.TurnsSurvived + " turns and descended " + Data.LevelsDescended + " levels into the pit."); SW.WriteLine("He was killed by " + Data.Killer.FirstName + " " + Data.Killer.LastName + " the " + Data.Killer.Type.ToString().Replace('_', ' ')); SW.WriteLine("Notable Events:"); foreach (Utilities.NotableEvent NE in Utilities.NotableEventsLog.NotableEvents) { SW.WriteLine(NE.Turn.ToString() + ": " + NE.Description); } SW.Close(); }
public override void MainLoop() { libtcodWrapper.KeyPress key; CurrentLevel.CalculateVisible(Player.Position.X, Player.Position.Y, Player.BaseAim); Render(); while (true) { key = libtcodWrapper.Keyboard.WaitForKeyPress(true); if (ProcessInput(key)) { break; } DEBUG_PerformanceTime = DateTime.Now; CurrentLevel.CalculateVisible(Player.Position.X, Player.Position.Y, Player.BaseAim); if (!SkipAI) { do { AI(); Render(); TurnsPassed++; } while (SkipTurns-- > 0); } DEBUG_PassedMilliseconds = DateTime.Now.Millisecond - DEBUG_PerformanceTime.Millisecond; libtcodWrapper.RootConsole.WindowTitle = "Run, Urist, Run! Time: " + DEBUG_PassedMilliseconds.ToString() + "ms"; SkipAI = false; if (!Player.IsAlive()) { Utilities.DeathData DD = (Utilities.DeathData)Utilities.InterStateResources.Instance.Resources["Game_DeathData"]; DD.LevelsDescended = LevelNumber; DD.TurnsSurvived = TurnsPassed; StateManager.QueueState(StateManager.PersistentStates["GameOverState"]); break; } } }
public void Attack(CreatureBase Target) { Random RndGen = new Random(DateTime.Now.Millisecond); double ChanceToHit = (((double)BaseAim - (double)Target.BaseSpeed) + (double)RndGen.Next(1, 10)) / (double)10 * (double)100; int DamageDone = 0; if (RndGen.Next(0, 100) > ChanceToHit)//Miss { Utilities.MessageLog.AddMsg(FirstName + " swings at " + Target.FirstName + " with a precision that leaves something to be desired."); return; } //Pick limb to use for attack bool HasPickedALimb = false; while (!HasPickedALimb) { foreach (LimbBase Limb in PreferredLimbAttackOrder) { if (RndGen.Next(0, 100) < 95) { DamageDone = Limb.AttackWith(); HasPickedALimb = true; break; } } } //Pick limb on target to strike HasPickedALimb = false; while (!HasPickedALimb) { foreach (LimbBase Limb in Target.Limbs) { if (RndGen.Next(0, 100) < Limb.HitChance) { if (Limb.HP == 0) { Utilities.MessageLog.AddMsg(FirstName + " swings at the empty spot where " + Target.FirstName + "'s " + Limb.Description + " once was, severely injuring the air"); //Miss return; } else { Limb.RecieveDamage(DamageDone); if (Limb.HP < 30) { foreach (LimbDependency Dep in LimbDependencies) { if (Dep.TargetLimb == Limb) { Dep.RequiredLimb.BleedRate++; } } } Utilities.MessageLog.AddMsg(Target.FirstName + "'s " + Limb.Description + " takes the brunt of the impact!"); HasPickedALimb = true; break; } } } } Utilities.DeathData DD = (Utilities.DeathData)Utilities.InterStateResources.Instance.Resources["Game_DeathData"]; DD.Killer = this; Utilities.InterStateResources.Instance.Resources["Game_DeathData"] = DD; }