public static void LogJourney(Logic.Gameplay.Command command) { #if GAME_MODE try { string date = DateTime.Now.ToShortTimeString(); string filePath = "Logs/Journey/" + journeyStart.ToString().Replace("/", "-").Replace(":", "-") + ".txt"; using (StreamWriter writer = new StreamWriter(filePath, true)) { writer.Write((int)command.Type); for (int i = 0; i < command.ArgCount; i++) { writer.Write(' '); writer.Write(command[i]); } writer.WriteLine(); } } catch (Exception ex) { System.Diagnostics.Debug.Write(ex.ToString()); } #endif }
private static void ProcessPlayerInput(ActiveChar character, ref bool moveMade) { if (MenuManager.Menus.Count > 0) { MenuManager.ProcessMenus(CurrentInput, character, ref moveMade); return; } else if (replayInputs.Count > 0 && !isLogging) { ProcessDecision(replayInputs[0], character, ref moveMade); replayInputs.RemoveAt(0); return; } Command command = new Command(Command.CommandType.None); bool jump = false; bool spell = false; bool turn = false; bool diagonal = false; #if GAME_MODE //menu button presses if (CurrentInput[Input.InputType.Enter] && !PrevInput[Input.InputType.Enter]) { MenuManager.Menus.Insert(0, new MainMenu()); } else if (CurrentInput[Input.InputType.Q] && !PrevInput[Input.InputType.Q]) { MenuManager.Menus.Insert(0, new ItemMenu()); } else if (CurrentInput[Input.InputType.W] && !PrevInput[Input.InputType.W]) { MenuManager.Menus.Insert(0, new SpellMenu()); } else #endif //multi-button presses if (CurrentInput[Input.InputType.A]) { if (CurrentInput[Input.InputType.S] && !PrevInput[Input.InputType.S]) { command = new Logic.Gameplay.Command(Logic.Gameplay.Command.CommandType.Spell, 0); } else if (CurrentInput[Input.InputType.D] && !PrevInput[Input.InputType.D]) { command = new Logic.Gameplay.Command(Logic.Gameplay.Command.CommandType.Spell, 1); } else if (CurrentInput[Input.InputType.X] && !PrevInput[Input.InputType.X]) { command = new Logic.Gameplay.Command(Logic.Gameplay.Command.CommandType.Spell, 2); } else if (CurrentInput[Input.InputType.C] && !PrevInput[Input.InputType.C]) { command = new Logic.Gameplay.Command(Logic.Gameplay.Command.CommandType.Spell, 3); } else { //keep move display spell = true; if (CurrentInput.Direction != Direction8.None) { command = new Command(Command.CommandType.Dir); command.AddArg((int)CurrentInput.Direction); } } } else { if (CurrentInput[Input.InputType.Z]) { jump = true; } if (CurrentInput[Input.InputType.S]) { turn = true; } if (CurrentInput[Input.InputType.D]) { diagonal = true; } //single button presses if (CurrentInput[Input.InputType.X] && !PrevInput[Input.InputType.X]) { if (jump) { command = new Command(Command.CommandType.AltAttack); command.AddArg((int)character.CharDir); command.AddArg(1); } else { command = new Command(Command.CommandType.Attack); } jump = false; turn = false; diagonal = false; } else if (CurrentInput[Input.InputType.C] && !PrevInput[Input.InputType.C]) { if (jump) { command = new Command(Command.CommandType.Wait); } else { command = new Command(Command.CommandType.Pickup); } jump = false; turn = false; diagonal = false; }//directions else if (CurrentInput.Direction != Direction8.None) { if (Display.Screen.DebugSpeed != Display.Screen.GameSpeed.Instant || PrevInput.Direction == Direction8.None) { Command.CommandType cmdType = Command.CommandType.None; if (Operations.IsDiagonal(CurrentInput.Direction)) cmdType = Command.CommandType.Dir; else if (InputTime > RenderTime.FromMillisecs(20) || PrevInput.Direction == Direction8.None) cmdType = Command.CommandType.Dir; if (InputTime > RenderTime.FromMillisecs(60) || Display.Screen.DebugSpeed == Display.Screen.GameSpeed.Instant) cmdType = Command.CommandType.Move; if (jump) cmdType = Command.CommandType.AltAttack; if (turn) cmdType = Command.CommandType.Dir; if (!diagonal || Operations.IsDiagonal(CurrentInput.Direction)) { command = new Command(cmdType); command.AddArg((int)CurrentInput.Direction); } if (!turn) { jump = false; diagonal = false; } } } } #if GAME_MODE Display.Screen.Jump = jump; Display.Screen.Spell = spell; Display.Screen.Turn = turn; Display.Screen.Diagonal = diagonal; #endif ProcessDecision(command, character, ref moveMade); }
private static void ProcessPlayerInput(ActiveChar character, ref bool moveMade) { if (MenuManager.Menus.Count > 0) { MenuManager.ProcessMenus(CurrentInput, character, ref moveMade); return; } else if (replayInputs.Count > 0 && !isLogging) { ProcessDecision(replayInputs[0], character, ref moveMade); replayInputs.RemoveAt(0); return; } Command command = new Command(Command.CommandType.None); bool jump = false; bool spell = false; bool turn = false; bool diagonal = false; #if GAME_MODE //menu button presses if (CurrentInput[Input.InputType.Enter] && !PrevInput[Input.InputType.Enter]) { MenuManager.Menus.Insert(0, new MainMenu()); } else if (CurrentInput[Input.InputType.Q] && !PrevInput[Input.InputType.Q]) { MenuManager.Menus.Insert(0, new ItemMenu()); } else if (CurrentInput[Input.InputType.W] && !PrevInput[Input.InputType.W]) { MenuManager.Menus.Insert(0, new SpellMenu()); } else #endif //multi-button presses if (CurrentInput[Input.InputType.A]) { if (CurrentInput[Input.InputType.S] && !PrevInput[Input.InputType.S]) { command = new Logic.Gameplay.Command(Logic.Gameplay.Command.CommandType.Spell, 0); } else if (CurrentInput[Input.InputType.D] && !PrevInput[Input.InputType.D]) { command = new Logic.Gameplay.Command(Logic.Gameplay.Command.CommandType.Spell, 1); } else if (CurrentInput[Input.InputType.X] && !PrevInput[Input.InputType.X]) { command = new Logic.Gameplay.Command(Logic.Gameplay.Command.CommandType.Spell, 2); } else if (CurrentInput[Input.InputType.C] && !PrevInput[Input.InputType.C]) { command = new Logic.Gameplay.Command(Logic.Gameplay.Command.CommandType.Spell, 3); } else { //keep move display spell = true; if (CurrentInput.Direction != Direction8.None) { command = new Command(Command.CommandType.Dir); command.AddArg((int)CurrentInput.Direction); } } } else { if (CurrentInput[Input.InputType.Z]) { jump = true; } if (CurrentInput[Input.InputType.S]) { turn = true; } if (CurrentInput[Input.InputType.D]) { diagonal = true; } //single button presses if (CurrentInput[Input.InputType.X] && !PrevInput[Input.InputType.X]) { if (jump) { command = new Command(Command.CommandType.AltAttack); command.AddArg((int)character.CharDir); command.AddArg(1); } else { command = new Command(Command.CommandType.Attack); } jump = false; turn = false; diagonal = false; } else if (CurrentInput[Input.InputType.C] && !PrevInput[Input.InputType.C]) { if (jump) { command = new Command(Command.CommandType.Wait); } else { command = new Command(Command.CommandType.Pickup); } jump = false; turn = false; diagonal = false; }//directions else if (CurrentInput.Direction != Direction8.None) { if (Display.Screen.DebugSpeed != Display.Screen.GameSpeed.Instant || PrevInput.Direction == Direction8.None) { Command.CommandType cmdType = Command.CommandType.None; if (Operations.IsDiagonal(CurrentInput.Direction)) { cmdType = Command.CommandType.Dir; } else if (InputTime > RenderTime.FromMillisecs(20) || PrevInput.Direction == Direction8.None) { cmdType = Command.CommandType.Dir; } if (InputTime > RenderTime.FromMillisecs(60) || Display.Screen.DebugSpeed == Display.Screen.GameSpeed.Instant) { cmdType = Command.CommandType.Move; } if (jump) { cmdType = Command.CommandType.AltAttack; } if (turn) { cmdType = Command.CommandType.Dir; } if (!diagonal || Operations.IsDiagonal(CurrentInput.Direction)) { command = new Command(cmdType); command.AddArg((int)CurrentInput.Direction); } if (!turn) { jump = false; diagonal = false; } } } } #if GAME_MODE Display.Screen.Jump = jump; Display.Screen.Spell = spell; Display.Screen.Turn = turn; Display.Screen.Diagonal = diagonal; #endif ProcessDecision(command, character, ref moveMade); }