Пример #1
0
        /// <summary> //VESTIGIAL PROTOTYPE...
        /// Draws the next turn based off the previous frame
        /// Avoids all the 'new'ing that takes place in the other DrawTurn
        /// </summary>
        /// <param name="frame"></param>
        /// <returns></returns>
        public override SimFrame DrawTurn(SimFrame frame)
        {
            frame.Find("ss").Position = new Vec2(SpaceShip.X,
                                           (FrameResolution.Y -
                                            (SpaceShip.Y / (SimVars.MoonLanderVars.SIM_HEIGHT / FrameResolution.Y))) - 60);

            frame.Find("downThrust").Position = new Vec2(SpaceShip.X + 4,
                                      (FrameResolution.Y -
                                       (SpaceShip.Y / (SimVars.MoonLanderVars.SIM_HEIGHT / FrameResolution.Y))) - 20);


            frame.Find("leftThrust").Position = new Vec2(SpaceShip.X - 10 - (32 * SpaceShip.Left / 3),
                                     (FrameResolution.Y -
                                      (SpaceShip.Y / (SimVars.MoonLanderVars.SIM_HEIGHT / FrameResolution.Y))) - 50);

            frame.Find("rightThrust").Position = new Vec2(SpaceShip.X + 42,
                                     (FrameResolution.Y -
                                      (SpaceShip.Y / (SimVars.MoonLanderVars.SIM_HEIGHT / FrameResolution.Y))) - 50);



            ((Sprite)frame.Find("downThrust")).Scale = new Vec2(1, SpaceShip.Throttle * .04);
            ((Sprite)frame.Find("leftThrust")).Scale = new Vec2(SpaceShip.Left / 3, .5);
            ((Sprite)frame.Find("rightThrust")).Scale = new Vec2(SpaceShip.Right / 3, .5);
                


            if (SpaceShip.Landed)
            {
                if (SpaceShip.Boom)
                {
                    frame.AddText("FAIL", new Vec2(250, 150), new SolidBrush(Color.Red), 100);
                    frame.ChangeImage("ss", SpriteList.SpaceShip_Explode);
                    Fail();
                }
                else
                {
                    frame.AddText("SAFE", new Vec2(250, 150), new SolidBrush(Color.Green), 100);
                    frame.ChangeImage("ss", SpriteList.SpaceShip_Landed);
                }
            }

            frame.ChangeText("ySpeed", "Speed Y:  " + SpaceShip.YVel.ToString("F"));
            frame.ChangeText("xSpeed", "Speed X:  " + SpaceShip.XVel.ToString("F"));
            frame.ChangeText("height", "Height:   " + SpaceShip.Y.ToString("F"));
            frame.ChangeText("xPos", "X-Pos:   " + SpaceShip.X.ToString("F"));
            frame.ChangeText("throttle", "Throttle: " + SpaceShip.Throttle.ToString("F"));
            frame.ChangeText("Fuel", "Fuel:     " + SpaceShip.Fuel.ToString("F"));

            return frame;

        }
        /// <summary>
        /// Renders MoonLander visual components based on their correlating simulation values 
        /// </summary>
        /// <param name="xscale"></param>
        /// <param name="yscale"></param>
        /// <returns>Rendered instance of Simulation moment (SimFrame)</returns>
        public override SimFrame DrawTurn(Vec2 scale)
        {
            // NEW FRAME
            SimFrame ret = new SimFrame
                               {
                                   Error = false,
                                   ToBeDrawn = true,
                                   BackGround = Color.Black,
                                   FrameId = Globals.turnCount,
                                   Renderables = new List<Drawable>()
                               };

            //ADD STRINGS
            ret.AddText("---SpaceShip---", new Vec2(500, 30), new SolidBrush(Color.Cornsilk));
            ret.AddText("Speed X: " + SpaceShip.Variables["YVel"].ToString(), new Vec2(500, 50), new SolidBrush(Color.Cornsilk));
            ret.AddText("Height: " + SpaceShip.Variables["Y"].ToString(), new Vec2(500, 70), new SolidBrush(Color.Cornsilk));
            ret.AddText("Throttle: " + SpaceShip.Variables["Throttle"].ToString(), new Vec2(500, 90), new SolidBrush(Color.Cornsilk));
            ret.AddText("Fuel: " + SpaceShip.Variables["Fuel"].ToString(), new Vec2(500, 110), new SolidBrush(Color.Cornsilk));

            //ADD MOON BACKGROUND
            ret.AddRenderable(new Sprite {Picture = SpriteList.MoonSurface, Position = new Vec2(0, FrameResolution.Y - 70)});

            //SET UP THE SPACESHIP
            Sprite shipSprite = new Sprite();
            shipSprite.Picture = SpriteList.SpaceShip; //Set Image for ship

            if (bool.Parse(SpaceShip.Variables["Landed"].ToString()))
            {
                if (bool.Parse(SpaceShip.Variables["Boom"].ToString()))
                {
                    ret.AddText("FAIL", new Vec2(250, 150), new SolidBrush(Color.Red), 100);
                    shipSprite.Picture = SpriteList.SpaceShip_Explode;
                    Fail();
                }
                else
                {
                    ret.AddText("SAFE", new Vec2(250, 150), new SolidBrush(Color.Green), 100);
                    shipSprite.Picture = SpriteList.SpaceShip_Landed;
                }
            }

            //CALCULATE SS RELATIVE POSITION ON SCREEN
            int simHeight = 5000;
            shipSprite.Position = new Vec2(double.Parse(SpaceShip.Variables["X"].ToString()),
                                           (FrameResolution.Y -
                                            (double.Parse(SpaceShip.Variables["Y"].ToString())/(simHeight/FrameResolution.Y))) - 60);

            ret.AddRenderable(shipSprite);//ADD THE SS OBJECT

            return ret; //RETURN THE FINAL FRAME
        }