public SmallFuelTank(AirplaneBase plane)
 {
     air = plane;
     air.AddMass(TANK_MASS);
     air.AddPower(TANK_POWER);
 }
 public SmallThruster(AirplaneBase plane)
 {
     air = plane;
     air.AddMass(MASS);
     air.IncreaseInitialVelocity(THRUST);
 }
 public MediumEngine(AirplaneBase plane)
 {
     air = plane;
     air.AddMass(MEDIUM_ENGINE_MASS);
 }
 public MediumElevators(AirplaneBase plane)
 {
     air = plane;
     air.AddMass(ELEVATOR_MASS);
 }
 public LargeEngine(AirplaneBase plane)
 {
     air = plane;
     air.AddMass(LARGE_ENGINE_MASS);
 }
Example #6
0
        public void UpdateMenu(GameTime time)
        {
            if (planeSelection)
            {
                Rectangle paperBox = new Rectangle(12, 50, paperAirplane.Width, paperAirplane.Height);
                Rectangle smallBox = new Rectangle(12 + paperAirplane.Width + 12, 50, smallAircraft.Width, smallAircraft.Height);
                Rectangle jetBox = new Rectangle(12 + paperAirplane.Width + 12 + smallAircraft.Width + 12, 50, jet.Width, jet.Height);
                Point mousePos = new Point(Mouse.GetState().X, Mouse.GetState().Y);

                if (Mouse.GetState().LeftButton.Equals(ButtonState.Pressed) && previousMouseState.LeftButton.Equals(ButtonState.Released))
                {
                    if (paperBox.Contains(mousePos))
                    {
                        plane = new PaperAirplane(paperAirplane);
                        plane.SetPosition(new Vector2(34, SCREEN_Y / 2));
                        planeSelection = false;
                    }
                    else if (smallBox.Contains(mousePos))
                    {
                        plane = new SmallAirplane(smallAircraft);
                        plane.SetPosition(new Vector2(34, SCREEN_Y / 2));
                        planeSelection = false;
                    }
                    else if (jetBox.Contains(mousePos))
                    {
                        plane = new FighterJet(jet);
                        plane.SetPosition(new Vector2(34, SCREEN_Y / 2));
                        planeSelection = false;
                    }
                }
            }
            else
            {
                if (Keyboard.GetState().IsKeyDown(Keys.Left))
                {
                    plane.AddInitialRotation(-0.01f);
                }
                else if (Keyboard.GetState().IsKeyDown(Keys.Right))
                {
                    plane.AddInitialRotation(0.01f);
                }

                if (Keyboard.GetState().IsKeyDown(Keys.LeftShift) || Keyboard.GetState().IsKeyDown(Keys.RightShift))
                {
                    plane.Launch(time);
                    inMenu = false;
                }

                Point mousePos = new Point(Mouse.GetState().X, Mouse.GetState().Y);

                if (Mouse.GetState().LeftButton.Equals(ButtonState.Pressed) && previousMouseState.LeftButton.Equals(ButtonState.Released))
                {
                    if (sEngineRect.Contains(mousePos))
                    {
                        plane = new SmallEngine(plane);
                    }
                    else if (mEngineRect.Contains(mousePos))
                    {
                        plane = new MediumEngine(plane);
                    }
                    else if (lEngineRect.Contains(mousePos))
                    {
                        plane = new LargeEngine(plane);
                    }
                    else if (sFuelRect.Contains(mousePos))
                    {
                        plane = new SmallFuelTank(plane);
                    }
                    else if (mFuelRect.Contains(mousePos))
                    {
                        plane = new MediumFuelTank(plane);
                    }
                    else if (lFuelRect.Contains(mousePos))
                    {
                        plane = new LargeFuelTank(plane);
                    }
                    else if (sElevateRect.Contains(mousePos))
                    {
                        plane = new SmallElevators(plane);
                    }
                    else if (mElevateRect.Contains(mousePos))
                    {
                        plane = new MediumElevators(plane);
                    }
                    else if (lElevateRect.Contains(mousePos))
                    {
                        plane = new LargeElevators(plane);
                    }
                    else if (sThrusterRect.Contains(mousePos))
                    {
                        plane = new SmallThruster(plane);
                    }
                    else if (mThrusterRect.Contains(mousePos))
                    {
                        plane = new MediumThruster(plane);
                    }
                    else if (lThrusterRect.Contains(mousePos))
                    {
                        plane = new LargeThruster(plane);
                    }
                    else if (undoRect.Contains(mousePos))
                    {
                        try
                        {
                            plane = ((AirplanePart)plane).RemovePart();
                        }
                        catch (Exception e)
                        {
                            Console.Out.WriteLine("No Parts to Remove!");
                        }
                    }
                }
            }
            previousMouseState = Mouse.GetState();
        }
Example #7
0
        public void UpdateGame(GameTime time)
        {
            GameTime fakeTime = new GameTime(time.TotalGameTime, new TimeSpan((long)((float)time.ElapsedGameTime.Ticks * simulationSpeed)));
            ForceIntegratorRegistry.IntegrateForces(fakeTime);
            plane.Update(fakeTime);

            if (plane.GetPosition().Y >= SCREEN_Y)
            {
                plane = null;
                inMenu = true;
                planeSelection = true;
            }
        }
 public SmallEngine(AirplaneBase plane)
 {
     air = plane;
     air.AddMass(SMALL_ENGINE_MASS);
 }