Пример #1
0
        public void DecideWhatToDraw()
        {
            //Decides what needs to be displayed on the screen
            //based on user input, boolean variables inorbit, inencounter, insystem, innersteller and menu selections.
            //Where we decided what to do basically..

            Random rnd = new Random();

            spriteobj.Begin(SpriteFlags.AlphaBlend | SpriteFlags.SortDepthBackToFront);

            if (theWindowMgr.FindWindow("Command") == -1)
            {
                if (theWindowMgr.LoadWindow("CMenuWindow", 500, 500, 144, 144, Color.FromArgb(217, 255, 255, 255)) == true)
                {
                    theWindowMgr.ShowWindow(theWindowMgr.FindWindow("Command"), true);
                }
            }

            mnu = (CMenuWindow)theWindowMgr.GetWindow(theWindowMgr.FindWindow("Command"));

            //*** Catch all the non-implemented mnu.userchoice selections.
            switch (mnu.userchoice)
            {
                case 7:
                case 8:
                case 9:
                case 21:
                case 22:
                case 55:
                case 53:
                    break;
                case 49:
                    //Land
                    if (!theGameState.IsGameInState(GameStates.Orbiting))
                    {
                        msgbox.pushmsgs("We need to orbit a planet first.");
                        mnu.userchoice = -1;
                    }

                    break;
                case 24:
                    //Engage
                    if (!theGameState.IsGameInState(GameStates.Interstellar))
                    {
                        msgbox.pushmsgs("There are no enemy ships nearby.");
                        mnu.userchoice = -1;
                    }

                    break;
                case 54:
                    break;
                case 50:
                    //Disembark
                    if (!theGameState.IsGameInState(GameStates.Landed))
                    {
                        if (rnd.NextDouble() < 0.5f)
                        {
                            msgbox.pushmsgs("to sick bay!");
                            msgbox.pushmsgs("Captain, perhaps you should report");
                        }
                        else
                        {
                            msgbox.othermessage(14);
                        }
                        mnu.userchoice = -1;
                    }

                    break;
                case 16:
                    break;
                case 14:
                    // Sensors
                    if (!theGameState.IsGameInState(GameStates.Orbiting))
                    {
                        msgbox.othermessage(1);
                        mnu.userchoice = -1;
                    }

                    break;
                case 15:
                    //Anylysys
                    if (!theGameState.IsGameInState(GameStates.Orbiting))
                    {
                        mnu.userchoice = -1;
                        msgbox.othermessage(11);
                    }

                    break;
                case -1:
                    break;
                default:
                    mnu.userchoice = -1;
                    break;
            }
            //*** End that non-sense!

            msgbox.noNewMessages = true;
            // To prevent repeating messages in the message stack. See class messages.

            //Testing for gregg ////////////////////
            if (mnu.userchoice == 53)
            {
                //Cargo For NOW!
                mnu.userchoice = -1;
            }
            //Testing for gregg ///////////////////

            if (mnu.userchoice == 55)
            {
                //Captains PDA
                if (theWindowMgr.FindWindow("Captain's PDA") == -1)
                {
                    if (theWindowMgr.LoadWindow("CPDAWindow", ClientArea.Center.X - 160, ClientArea.Center.Y - 200, 320, 400, Color.FromArgb(217, 255, 255, 255)) == true)
                    {
                        theWindowMgr.DoModal(theWindowMgr.FindWindow("Captain's PDA"));
                        mnu.showmenu = false;
                        mnu.userchoice = -1;
                    }
                }

                if (theWindowMgr.FindWindow("Captain's PDA") == -1)
                {
                    mnu.userchoice = -1;
                    //theWindowMgr.RemoveWindow(theWindowMgr.FindWindow("Captain's PDA"))
                }
            }

            if (mnu.userchoice == 9)
            {
                //Exit Hyperspace
                if (theGameState.IsGameInState(GameStates.Orbiting) || theGameState.IsGameInState(GameStates.InEncounter))
                {
                    msgbox.othermessage(13);
                    mnu.userchoice = -1;
                }
                else
                {
                    theGameState.AddState(GameStates.InEncounter);
                    theGameState.RemoveState(GameStates.Interstellar);
                    theGameState.RemoveState(GameStates.Orbiting);
                    mnu.userchoice = -1;
                    encX = XCor;
                    encY = YCor;
                    XCor = 100;
                    YCor = 100;
                }
            }

            if (mnu.userchoice == 24)
            {
                //Engage
                theGameState.AddState(GameStates.InEncounter);

                if (theGameState.IsGameInState(GameStates.Interstellar))
                {
                    XCor = 100;
                    YCor = 100;
                    theGameState.RemoveState(GameStates.Interstellar);
                }

                mnu.userchoice = -1;
                encX = XCor;
                encY = YCor;

                // Raise the shields and arm the weapons
                if (playership.shieldsUp == false)
                {
                    mnu.items[21] = mnu.temps[1];
                    //Swap Shields Up, Shields Down
                    mnu.temps[1] = mnu.temps[2];
                    mnu.temps[2] = mnu.items[21];
                    playership.shieldsUp = true;
                }

                if (playership.weaponsArmed == false)
                {
                    mnu.items[22] = mnu.temps[3];
                    //Same as above.. Disarm Weapons.
                    mnu.temps[3] = mnu.temps[4];
                    //Swap
                    mnu.temps[4] = mnu.items[22];
                    playership.weaponsArmed = true;
                }

                mnu.showmenu = false;
                playership.displaystatus = true;
            }

            if (mnu.userchoice == 7)
            {
                //Navigate
                mnu.showmenu = false;

                if (!theGameState.IsGameInState(GameStates.Landing))
                {
                    playership.X = XCor;
                    playership.Y = YCor;
                    playership.letsMove();
                    XCor = playership.X;
                    YCor = playership.Y;
                }
                else
                {
                    msgbox.pushmsgs("terrain vechicle");
                    msgbox.pushmsgs("Disembark to manuver the");
                    mnu.userchoice = -1;
                }
            }

            if (mnu.userchoice == 21)
            {
                //Shields!
                mnu.items[21] = mnu.temps[1];
                //Swap Shields Up, Shields Down
                mnu.temps[1] = mnu.temps[2];
                mnu.temps[2] = mnu.items[21];
                mnu.userchoice = -1;
                playership.shieldsUp = !playership.shieldsUp;
            }

            if (mnu.userchoice == 22)
            {
                //Arm Weapons!
                mnu.items[22] = mnu.temps[3];
                //Same as above.. Disarm Weapons.
                mnu.temps[3] = mnu.temps[4];
                //Swap
                mnu.temps[4] = mnu.items[22];
                mnu.userchoice = -1;
                playership.weaponsArmed = !playership.weaponsArmed;
            }

            if (theGameState.IsGameInState(GameStates.Starmap))
            {
                playership.X = XCor;
                playership.Y = YCor;
                //playership.letsMove()
                XCor = playership.X;
                YCor = playership.Y;
                theStarmap.Run();
            }

            if (mnu.userchoice == 8)
            {
                //Show star map
                if (theGameState.IsGameInState(GameStates.Interstellar) && !(theGameState.IsGameInState(GameStates.Starmap)))
                {
                    theGameState.AddState(GameStates.Starmap);
                    mnu.userchoice = -1;
                    theStarmap = new starmap(0.28F, 0.79F);
                }
                else if (theGameState.IsGameInState(GameStates.Starmap))
                {
                    theGameState.RemoveState(GameStates.Starmap);
                    mnu.userchoice = -1;
                    theStarmap = null;
                }
                else
                {
                    msgbox.othermessage(10);
                    mnu.userchoice = -1;
                }
            }

            if (mnu.userchoice == 7)
            {
                // Navigate
                userinput.MouseXY(0, 0);
            }
            else
            {
                userinput.MouseXY(16, 25);
            }

            if (theGameState.IsGameInState(GameStates.InEncounter))
            {
                //inencounter
                drawEncounter(otherships);

                if (XCor > ClientArea.Width - 32 || XCor < 2 || YCor > ClientArea.Height - 1 || YCor < 25)
                {
                    theGameState.RemoveState(GameStates.Orbiting);
                    theGameState.AddState(GameStates.Interstellar);

                    mnu.userchoice = 7;
                    //Navigate
                    mnu.startitem = 0;
                    mnu.selected = 0;
                    XCor = encX + 0.7F;
                    YCor = encY + 0.7F;

                    theGameState.RemoveState(GameStates.InEncounter);
                }
                //endinencounter
            }

            if (mnu.userchoice == 7)
            {
                userinput.MouseXY(0, 0);
            }
            else
            {
                userinput.MouseXY(16, 25);
            }

            // base state of the program. In the title screen.
            if (MainTitle.GetState() == 0)
            {
                theGameState.AddState(GameStates.MainTitle);
            }
            else
            {
                theGameState.RemoveState(GameStates.MainTitle);
            }

            if (theGameState.IsGameInState(GameStates.InSystem) && !theGameState.IsGameInState(GameStates.InEncounter))
            {
                //In a system?
                theGameState.RemoveState(GameStates.Interstellar);
                theGameState.RemoveState(GameStates.Orbiting);
                theGameState.RemoveState(GameStates.DockedAtStation);

                if (Currentsystems[(int)SysX, (int)SysY] == null)
                {
                    Currentsystems[(int)SysX, (int)SysY] = new SolarSystem((int)SysX, (int)SysY, theVerse);
                }

                drawSystem((int)SysX, (int)SysY);

                if (XCor > ClientArea.Width - 32 || XCor < 2 || YCor > ClientArea.Height - 1 || YCor < 25)
                {
                    theGameState.RemoveState(GameStates.Orbiting);
                    theGameState.RemoveState(GameStates.InSystem);
                    theGameState.AddState(GameStates.Interstellar);
                    theGameState.RemoveState(GameStates.Landing);

                    mnu.userchoice = 7;
                    mnu.startitem = 0;
                    mnu.selected = 0;
                    XCor = SysX + 0.7F;
                    YCor = SysY + 0.7F;
                }
            }
            //End Systementered?

            // Outside of system, intersteller
            if (theGameState.IsGameInState(GameStates.Interstellar) && !(theGameState.IsGameInState(GameStates.Starmap)))
            {
                systemEntry();
                //Test to see if we are near a system.
                drawStarShip();
            }
            //end base state

            if (mnu.userchoice == 16)
            {
                //Ships status
                playership.displaystatus = !playership.displaystatus;
                mnu.userchoice = -1;
            }

            if (theWindowMgr.RunWindows() == false)
            {
                //userinput not handled by a window
                //If Not (theGameState.IsGameInState(GameStates.MainTitle)) Then
                if (userinput.CheckButton("Right", true))
                {
                    mnu.showmenu = !mnu.showmenu;
                    mnu.Move();
                }
            }
            //End If

            //spriteobj.Flush()
            spriteobj.End();
        }
Пример #2
0
        public bool LoadWindow(string wndType, int x, int y, int width, int height, Color wndcolor, define_sprite_struct[] spritedefs)
        {
            CWindow aWindow = null;
            bool bRetVal = false;

            switch (wndType)
            {
                case "CPDAWindow":
                    aWindow = new CPDAWindow(x, y, width, height, wndcolor);
                    break;
                case "CTitleWindow":
                    aWindow = new CTitleWindow(x, y, width, height, wndcolor);
                    break;
                case "COptionsWindow":
                    aWindow = new COptionsWindow(x, y, width, height, wndcolor);
                    break;
                case "CmsgWindow":
                    aWindow = new CMsgWindow(x, y, width, height, wndcolor);
                    break;
                case "CstatusWindow":
                    aWindow = new CstatusWindow(x, y, width, height, wndcolor);
                    break;
                case "CStarportWindow":
                    aWindow = new CStarportWindow(x, y, width, height, wndcolor);
                    break;
                case "CScanWindow":
                    aWindow = new CScanWindow(x, y, width, height, wndcolor);
                    break;
                case "CAnalysisWindow":
                    aWindow = new CAnalysisWindow(x, y, width, height, wndcolor);
                    break;
                case "CMenuWindow":
                    aWindow = new CMenuWindow(x, y, width, height, wndcolor);
                    break;
            }

            if (spritedefs != null)
            {
                for (int i = 0; i < (spritedefs.GetUpperBound(0) + 1); i++)
                {
                    aWindow.LoadSprite(spritedefs[i].number, spritedefs[i].file, spritedefs[i].width,
                        spritedefs[i].height, spritedefs[i].Colorkey);
                }
            }

            if (aWindow != null)
            {
                AddWindow(aWindow);
                bRetVal = true;
            }

            return bRetVal;
        }
Пример #3
0
        public bool LoadWindow(string wndType, int x, int y, int width, int height, Color wndcolor, define_sprite_struct[] spritedefs)
        {
            CWindow aWindow = null;
            bool    bRetVal = false;

            switch (wndType)
            {
            case "CPDAWindow":
                aWindow = new CPDAWindow(x, y, width, height, wndcolor);
                break;

            case "CTitleWindow":
                aWindow = new CTitleWindow(x, y, width, height, wndcolor);
                break;

            case "COptionsWindow":
                aWindow = new COptionsWindow(x, y, width, height, wndcolor);
                break;

            case "CmsgWindow":
                aWindow = new CMsgWindow(x, y, width, height, wndcolor);
                break;

            case "CstatusWindow":
                aWindow = new CstatusWindow(x, y, width, height, wndcolor);
                break;

            case "CStarportWindow":
                aWindow = new CStarportWindow(x, y, width, height, wndcolor);
                break;

            case "CScanWindow":
                aWindow = new CScanWindow(x, y, width, height, wndcolor);
                break;

            case "CAnalysisWindow":
                aWindow = new CAnalysisWindow(x, y, width, height, wndcolor);
                break;

            case "CMenuWindow":
                aWindow = new CMenuWindow(x, y, width, height, wndcolor);
                break;
            }

            if (spritedefs != null)
            {
                for (int i = 0; i < (spritedefs.GetUpperBound(0) + 1); i++)
                {
                    aWindow.LoadSprite(spritedefs[i].number, spritedefs[i].file, spritedefs[i].width,
                                       spritedefs[i].height, spritedefs[i].Colorkey);
                }
            }

            if (aWindow != null)
            {
                AddWindow(aWindow);
                bRetVal = true;
            }

            return(bRetVal);
        }