Exemple #1
0
 public static void StartReplay(string path)
 {
     try {
         Display.Screen.AddResult(new Results.Fade(Display.Screen.FadeType.FadeOut));
         isLogging = false;
         replayInputs.Clear();
         using (StreamReader reader = new StreamReader(path, true)) {
             int seed = reader.ReadLine().ToInt();
             StartDungeon(seed);
             while(!reader.EndOfStream){
                 string[] commandString = reader.ReadLine().Split(' ');
                 Command command = new Command((Command.CommandType)commandString[0].ToInt());
                 for (int i = 1; i < commandString.Length; i++) {
                     command.AddArg(commandString[i].ToInt());
                 }
                 replayInputs.Add(command);
             }
         }
         Display.Screen.AddResult(new Results.Fade(Display.Screen.FadeType.FadeIn));
     } catch (Exception ex) {
         Logs.Logger.LogError(new Exception("Replay Error with " + path + "\n", ex));
     }
 }
Exemple #2
0
        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);
        }
Exemple #3
0
        //the intention, and its result to that frame
        //"choose the action to partake in"
        public static void ProcessDecision(Command command, ActiveChar character, ref bool moveMade)
        {
            //translates commands into actions
            if (character == FocusedCharacter && command.Type != Command.CommandType.None && isLogging) {
                Logs.Logger.LogJourney(command);
            }

            switch (command.Type) {
                case Command.CommandType.Dir: {
                        ProcessDir((Direction8)command[0], character, ref moveMade);
                    }
                    break;
                case Command.CommandType.Move:
                    {
                        Display.Screen.BeginRunModeConcurrent(CharIndex(character));
                        //takes a dir argument
                        //Display.Screen.ResultList.Add(new Results.StartTag("Move"));
                        if (command.ArgCount > 0) {
                            ProcessDir((Direction8)command[0], character, ref moveMade);
                        }
                        ProcessWalk(character, ref moveMade);
                        //Display.Screen.ResultList.Add(new Results.EndTag());
                    }
                    break;
                    #if GAME_MODE
                    case Command.CommandType.Attack: {
                        Display.Screen.BeginConcurrent();
                        //takes a dir argument
                        if (command.ArgCount > 0) {
                            ProcessDir((Direction8)command[0], character, ref moveMade);
                        }
                        Attack(character, ref moveMade);
                    }
                    break;
                    case Command.CommandType.Pickup:
                    {
                        Display.Screen.BeginConcurrent();
                        //takes an index argument
                        ProcessPickup(character, ref moveMade);
                    }
                    break;
                    case Command.CommandType.Use:
                    {
                        Display.Screen.BeginConcurrent();
                        //takes an index argument
                        ProcessItemUse(character, command[0], ref moveMade);
                    }
                    break;
                    case Command.CommandType.Throw:
                    {
                        Display.Screen.BeginConcurrent();
                        //takes an index argument
                        ProcessThrow(character, command[0], ref moveMade);
                    }
                    break;
                    case Command.CommandType.Drop:
                    {
                        Display.Screen.BeginConcurrent();
                        //takes an index argument
                        ProcessDrop(character, command[0], ref moveMade);
                    }
                    break;
                    case Command.CommandType.Spell:
                    {
                        Display.Screen.BeginConcurrent();
                        //takes an index argument
                        UseMove(character, command[0], ref moveMade);
                    }
                    break;
            #endif
                    case Command.CommandType.Wait:
                    {
                        moveMade = true;
                    }
                    break;
                    default: break;
            }
            if (moveMade) {
                ProcessTurnEnd(character);
            }
        }