Exemple #1
0
        private static void MovePlayer(int xoffset, int yoffset)
        {
            int  x     = Global.Player.X + xoffset;
            int  y     = Global.Player.Y + yoffset;
            bool Moved = false;

            // Check for movement to a new screen
            if (x == 0)
            {
                Global.Player.Map -= 1;
                Global.Player.X    = 80;
                // TODOX Rename Show to Hide to match Pascal version?
                if (Global.WorldDat.Show[Global.Player.Map] == 0)
                {
                    Global.Player.LastMap = Global.Player.Map;
                }

                Global.LoadMap(Global.Player.Map);
                DrawMap();
            }
            else if (x == 81)
            {
                Global.Player.Map += 1;
                Global.Player.X    = 1;
                // TODOX Rename Show to Hide to match Pascal version?
                if (Global.WorldDat.Show[Global.Player.Map] == 0)
                {
                    Global.Player.LastMap = Global.Player.Map;
                }

                Global.LoadMap(Global.Player.Map);
                DrawMap();
            }
            else if (y == 0)
            {
                Global.Player.Map -= 80;
                Global.Player.Y    = 20;
                // TODOX Rename Show to Hide to match Pascal version?
                if (Global.WorldDat.Show[Global.Player.Map] == 0)
                {
                    Global.Player.LastMap = Global.Player.Map;
                }

                Global.LoadMap(Global.Player.Map);
                DrawMap();
            }
            else if (y == 21)
            {
                Global.Player.Map += 80;
                Global.Player.Y    = 1;
                // TODOX Rename Show to Hide to match Pascal version?
                if (Global.WorldDat.Show[Global.Player.Map] == 0)
                {
                    Global.Player.LastMap = Global.Player.Map;
                }

                Global.LoadMap(Global.Player.Map);
                DrawMap();
            }
            else
            {
                if (Global.CurrentMap.W[(y - 1) + ((x - 1) * 20)].Terrain == 1)
                {
                    DrawPlayer(x, y);
                    Moved = true;
                }
            }

            // Check for special
            bool Special = false;

            foreach (SPECIAL_STRUCT SS in Global.CurrentMap.Special)
            {
                if ((SS.HotSpotX == x) && (SS.HotSpotY == y))
                {
                    Special = true;

                    if ((SS.WarpMap > 0) && (SS.WarpX > 0) && (SS.WarpY > 0))
                    {
                        Global.Player.Map = SS.WarpMap;
                        Global.Player.X   = SS.WarpX;
                        Global.Player.Y   = SS.WarpY;
                        // TODOX Rename Show to Hide to match Pascal version?
                        if (Global.WorldDat.Show[Global.Player.Map] == 0)
                        {
                            Global.Player.LastMap = Global.Player.Map;
                        }

                        Global.LoadMap(Global.Player.Map);
                        DrawMap();
                        break;
                    }
                    else if ((SS.RefFile != "") && (SS.RefName != ""))
                    {
                        RTReader.Execute(SS.RefFile, SS.RefName);
                        break;
                    }
                }
            }

            // Check if need to run random event
            if (Moved && !Special && (Global.CurrentMap.BattleOdds > 0) && (Global.CurrentMap.BatFile != "") && (Global.CurrentMap.BatName != ""))
            {
                if (new Random().Next(Global.CurrentMap.BattleOdds) == 0)
                {
                    RTReader.Execute(Global.CurrentMap.BatFile, Global.CurrentMap.BatName);
                }
            }
        }
Exemple #2
0
        public static void Start()
        {
            // Ensure the platform/architecture we're running on has the right data type sizes
            DataStructures.Validate();

            // Load the game data files into memory
            Global.LoadDataFiles();

            // Initialize the RTReader engine
            RTGlobal.OnDRAWMAP  += RTGlobal_OnDRAWMAP;
            RTGlobal.OnMOVEBACK += RTGlobal_OnMOVEBACK;
            RTGlobal.OnUPDATE   += RTGlobal_OnUPDATE;

            // TODOX Pascal did this -- needed?
            //Global.Player.RealName = Door.DropInfo.RealName;
            //Global.Player.LastDayOn = (short)RTGlobal.Time;
            //Global.Player.LastDayPlayed = RTGlobal.Time;
            //Global.Player.LastSaved = RTGlobal.Time;

            // Load the rules and run maint, if it's a new day
            RTReader.Execute("RULES.REF", "RULES");
            if (Global.IsNewDay)
            {
                RTReader.Execute("MAINT.REF", "MAINT");
            }

            // Check if user has a Global.Player already
            RTGlobal.PlayerNum = Global.LoadPlayerByRealName(Door.DropInfo.RealName, out Global.Player);
            if (RTGlobal.PlayerNum == -1)
            {
                if (Global.TotalPlayerAccounts() < 200)
                {
                    // Nope, so try to get them to create one
                    RTReader.Execute("GAMETXT.REF", "NEWPLAYER");
                    RTGlobal.PlayerNum = Global.LoadPlayerByRealName(Door.DropInfo.RealName, out Global.Player);
                }
                else
                {
                    RTReader.Execute("GAMETXT.REF", "FULL");
                }
            }

            // Now check again to see if the user has a Global.Player (either because they already had one, or because they just created one)
            if (RTGlobal.PlayerNum != -1)
            {
                try
                {
                    // Global.Player exists, so start the game
                    RTReader.Execute("GAMETXT.REF", "STARTGAME");

                    // We're now in map mode until we hit a hotspot
                    Global.LoadMap(Global.Player.Map);
                    DrawMap();

                    /*TODO W Write mail to another player
                     *  H Interact with another player.The player pressing this key must be on the
                     *      same map square as the player they are trying to interact with.
                     *  B Show the log of messages.
                     *  F Show the last three messages.
                     *  Q Quit the game.  Confirmation will be requested.*/
                    // Allow Global.Player to move around
                    char?Ch = null;
                    while (Ch != 'Q')
                    {
                        Ch = Door.ReadKey();
                        if (Ch != null)
                        {
                            Ch = char.ToUpper((char)Ch);
                            switch (Ch)
                            {
                            case Door.ExtendedKeys.UpArrow:
                            case '8':
                                MovePlayer(0, -1);
                                break;

                            case Door.ExtendedKeys.LeftArrow:
                            case '4':
                                MovePlayer(-1, 0);
                                break;

                            case Door.ExtendedKeys.RightArrow:
                            case '6':
                                MovePlayer(1, 0);
                                break;

                            case Door.ExtendedKeys.DownArrow:
                            case '2':
                                MovePlayer(0, 1);
                                break;

                            case 'L':
                                RTReader.Execute("HELP", "LISTPLAYERS");
                                break;

                            case 'M':
                                RTReader.Execute("HELP", "MAP");
                                break;

                            case 'P':
                                RTReader.Execute("HELP", "WHOISON");
                                break;

                            case 'Q':
                                // Confirm exit
                                Door.GotoXY(1, 23);
                                Door.Write("`r0`2  Are you sure you want to quit back to the BBS? [`%Y`2] : ");

                                bool KeepLooping = true;
                                while (KeepLooping)
                                {
                                    // Repeat until we have a valid selection
                                    Ch = Door.ReadKey();
                                    if (Ch != null)
                                    {
                                        Ch = char.ToUpper((char)Ch);
                                        switch (Ch)
                                        {
                                        case 'N':
                                            Ch = null;
                                            Door.GotoXY(1, 23);
                                            Door.Write(StringUtils.PadRight("", ' ', 79));
                                            Door.GotoXY(Global.Player.X, Global.Player.Y);
                                            KeepLooping = false;
                                            break;

                                        case '\r':
                                        case 'Y':
                                            Ch          = 'Q';
                                            KeepLooping = false;
                                            break;
                                        }
                                    }
                                }
                                break;

                            case 'T':
                                RTReader.Execute("HELP", "TALK");
                                break;

                            case 'V':
                                RTReader.Execute("GAMETXT", "STATS");
                                //TODOX ViewInventory();
                                RTReader.Execute("GAMETXT", "CLOSESTATS");
                                break;

                            case 'Y':
                                RTReader.Execute("HELP", "YELL");
                                break;

                            case 'Z':
                                RTReader.Execute("HELP", "Z");
                                break;

                            case '?':
                                RTReader.Execute("HELP", "HELP");
                                break;
                            }
                        }
                    }

                    // TODO Clear status bar and disable events so its not redrawn
                    RTReader.Execute("GAMETXT", "ENDGAME");
                    Thread.Sleep(2500);
                }
                finally
                {
                    // Ensure the player gets saved even if we run into an exception above
                    SavePlayer();
                }
            }
        }