Ejemplo n.º 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));
     }
 }
Ejemplo n.º 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 Command(Command.CommandType.Spell, 0);
                }
                else if (CurrentInput[Input.InputType.D] && !PrevInput[Input.InputType.D])
                {
                    command = new Command(Command.CommandType.Spell, 1);
                }
                else if (CurrentInput[Input.InputType.X] && !PrevInput[Input.InputType.X])
                {
                    command = new Command(Command.CommandType.Spell, 2);
                }
                else if (CurrentInput[Input.InputType.C] && !PrevInput[Input.InputType.C])
                {
                    command = new Command(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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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));
     }
 }