Пример #1
0
 public string CheckInteraction(Vector2 pMousePosition, GameState pGameState, bool pHaveClicked, SoundEffect pSoundEffect1, SoundEffect pSoundEffect2)
 {
     if (currentSystemSolar.CheckInteraction(pMousePosition, pGameState) == "selection")
     {
         {
             myInterfaceManager.Clear();
         }
     }
     if (myInterfaceManager.CheckInteraction(pMousePosition, pHaveClicked, pSoundEffect1, pSoundEffect2) == "launch")
     {
         Close();
         return("launch");
     }
     return(null);
 }
Пример #2
0
        public void UpdateGameplay(MouseState pCurrentMouseState, GameTime pGameTime)
        {
            myGameState.count_humans += 1;

            if (myGameState.currentAltitude >= myGameState.targetAltitude)
            {
                reset();
                myRocket = null;
                myRocket = new Rocket(defaultRocketPosition, img_rocket);
                myGameState.count_humans  -= (int)myGameState.rocketHumansCapacity;
                myGameState.rocketArrived += 1;
                currentState = "win";
            }


            float destabilizationRNG = myRandom.Next(1, 1000);

            if (destabilizationRNG == myGameState.destabilizationChance)
            {
                myGameState.isStabilized = "NOT STABILIZED";
            }
            if (pCurrentMouseState.LeftButton == ButtonState.Pressed && oldMouseState.LeftButton == ButtonState.Released)
            {
                myInterfaceManager.CheckInteraction(new Vector2(pCurrentMouseState.Position.X, pCurrentMouseState.Position.Y), true, sound_switchOn, sound_switchOff);
            }

            if (panel_gpsLever.isOn && panel_buttonElectricity.isOn)
            {
                myGameState.isStabilized = "STABILIZED";
                panel_gpsLever.ForceInteraction();
            }


            if (panel_buttonOxygene.isOn && panel_lever.isOn == false && myGameState.currentAltitude == myGameState.defaultAltitude && panel_buttonElectricity.isOn)
            {
                if (myGameState.currentOxygene < 1)
                {
                    myGameState.currentOxygene += 0.005f;
                }
                else
                {
                    panel_buttonOxygene.ForceInteraction();
                }
            }
            else
            {
                if (myGameState.currentOxygene > 0)
                {
                    myGameState.currentOxygene -= 0.0001f;
                }
            }
            if (panel_buttonCool.isOn && panel_lever.isOn == false && myGameState.currentAltitude == myGameState.defaultAltitude && panel_buttonElectricity.isOn)
            {
                if (myGameState.currentTemperature > 0)
                {
                    myGameState.currentTemperature -= 0.005f;
                    if (myGameState.soundEnabled)
                    {
                        sound_coolInstance.Play();
                    }
                }
                else
                {
                    panel_buttonCool.ForceInteraction();
                }
            }
            else
            {
                if (myGameState.currentTemperature < 1 && myRocket.inSpace == false)
                {
                    myGameState.currentTemperature += 0.0005f;
                }
                else if (myGameState.currentTemperature < 1 && myRocket.inSpace)
                {
                    myGameState.currentTemperature -= 0.0005f;
                }
            }

            //--- DEATH DETECTION
            if (myGameState.currentTemperature > myGameState.explosionTemperature && myGameState.currentAltitude > myGameState.defaultAltitude && myRocket.isDestroyed == false)
            {
                myRocket.health -= 0.5f;
                for (int i = 0; i < 10; i++)
                {
                    myRocket.Burn(myRandom, img_particleFire);
                }
            }
            if (myRocket.health < myGameState.rocketMinHealth && myRocket.isDestroyed == false)
            {
                myRocket.isDestroyed = true;
                for (int i = 0; i < 5; i++)
                {
                    myRocket.Explode(myRandom, img_particleFire);
                }
                myRocket.Destroy(myRandom, fragmentArray);
            }
            if (myGameState.currentOxygene < 0 && myGameState.currentAltitude != myGameState.defaultAltitude)
            {
                timerGameOver += 0.1f;
                if (timerGameOver > maxTimerGameOver)
                {
                    myRocket = null;
                    myRocket = new Rocket(defaultRocketPosition, img_rocket);
                    reset();
                    currentState = "gameover";
                    myGameover.giveReason("NO MORE OXYGENE-");
                }
            }
            //--- ROCKET PHYSICS
            if (panel_buttonRefuel.isOn && panel_lever.isOn == false && myGameState.currentAltitude == myGameState.defaultAltitude)
            {
                if (myGameState.currentFuel < 1)
                {
                    if (sound_refuelInstance.State == SoundState.Stopped && myGameState.soundEnabled)
                    {
                        sound_refuelInstance.Play();
                    }

                    myGameState.currentFuel += 0.005f;
                }
                else
                {
                    panel_buttonRefuel.ForceInteraction();
                }
            }

            if (myGameState.currentAltitude > myGameState.maxAltitude && myRocket.isDestroyed == false)
            {
                if (myGameState.soundEnabled)
                {
                    sound_musicInstance.Play();
                }
                myRocket.checkStabilization(myRandom, myGameState.isStabilized);
                myRocket.inSpace = true;
            }
            if (panel_lever.isOn && myGameState.currentFuel > 0.05f && myRocket.inSpace == false && myRocket.isDestroyed == false && myGameState.currentAltitude >= myGameState.defaultAltitude)
            {
                if (myRocket.engineOn == false && myGameState.soundEnabled)
                {
                    sound_engine.Play();
                }
                if (myGameState.soundEnabled)
                {
                    sound_airInstance.Play();
                }
                myRocket.engineOn = true;
                myRocket.Vibrate(myRandom);
                Vector2 propulsion = new Vector2(0, -0.1f);
                myRocket.applyForce(propulsion);
                myGameState.currentFuel     -= 0.0002f;
                myGameState.currentAltitude -= myRocket.velocity.Y;
                string result = myRocket.checkStabilization(myRandom, myGameState.isStabilized);
                if (result == "gameover")
                {
                    myRocket.isDestroyed = true;
                    myRocket.Burn(myRandom, img_particleFire);
                    myRocket.Destroy(myRandom, fragmentArray);
                    myGameover.giveReason("WRONG ORIENTATION");
                }
            }
            else
            {
                if (myGameState.currentAltitude > myGameState.defaultAltitude && myRocket.isDestroyed == false && myGameState.currentAltitude < myGameState.maxAltitude)
                {
                    if (myGameState.soundEnabled)
                    {
                        sound_airInstance.Play();
                    }
                    myRocket.engineOn = false;
                    Vector2 gravity = new Vector2(0, 1);
                    myRocket.applyForce(gravity);
                    myGameState.currentAltitude -= myRocket.velocity.Y;
                }
                else if (myGameState.currentAltitude > myGameState.maxAltitude && myRocket.isDestroyed == false)
                {
                    myRocket.engineOn            = false;
                    myGameState.currentAltitude -= myRocket.velocity.Y;
                }
                else if (myGameState.currentAltitude <= myGameState.defaultAltitude)
                {
                    if (myRocket.velocity.Y >= 10)
                    {
                        myRocket.Destroy(myRandom, fragmentArray);
                        myRocket.Burn(myRandom, img_particleFire);
                        myRocket.isDestroyed = true;
                    }

                    myRocket.engineOn           = false;
                    myGameState.currentAltitude = myGameState.defaultAltitude;
                    myRocket.velocity           = Vector2.Zero;
                    myRocket.acceleration       = Vector2.Zero;
                }
            }

            if (myRocket.isDestroyed)
            {
                timerGameOver += 0.1f;
                if (timerGameOver > maxTimerGameOver)
                {
                    if ((int)myRocket.rotation == 0)
                    {
                        myGameover.giveReason("ROCKET DESTROYED-");
                    }
                    myRocket = null;
                    myRocket = new Rocket(defaultRocketPosition, img_rocket);
                    reset();
                    currentState = "gameover";
                }
            }


            myRocket.Update(myRandom, img_particleFire);
            myParticleStarManager.ApplyForce(new Vector2(0, 0.01f));
            myParticleStarManager.Update();
        }