Ejemplo n.º 1
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            if (this.isPop)
            {
                if (!keepUpdating.IsCompleted)
                {
                    keepUpdating = new Task(new Action(LoadingScreen));
                }
                Reset();
            }
            if (Input_Handler.KeyPressed(Keys.F11))
            {
                if (!DevelopmentMode)
                {
                    DevelopmentMode = true;
                }
                else
                {
                    DevelopmentMode = false;
                }
            }
            if (DevelopmentMode)
            {
                if (Input_Handler.KeyPressed(Keys.P))
                {
                    if (plotTexture == false)
                    {
                        GameRef.MousePointer = GameRef.Content.Load <Texture2D>(@"UI Content\Flag");
                        //gamePlayMouse.Update(gameTime, arrowTexture);
                        plotTexture = true;
                    }
                    else
                    {
                        GameRef.MousePointer = Game.Content.Load <Texture2D>(@"UI Content\Pointer");
                        //gamePlayMouse.Update(gameTime, arrowTexture);
                        plotTexture = false;
                    }
                }
                if (Mouse.GetState().LeftButton == ButtonState.Pressed && placeLock == false)
                {
                    cPlotPosition.Position.Add(new Vector2(Mouse.GetState().X, Mouse.GetState().Y));



                    placeLock = true;
                }
                if (Keyboard.GetState().IsKeyDown(Keys.O))
                {
                    writer = new StreamWriter(@"Txt\Map.txt", true);
                    foreach (Vector2 pos in cPlotPosition.Position)
                    {
                        writer.Write(pos.X.ToString() + '#' + pos.Y.ToString() + '-');
                    }

                    writer.Close();
                }
                if (placeLock == true && Mouse.GetState().LeftButton == ButtonState.Released)
                {
                    placeLock = false;
                }
            }
            if (keepUpdating.IsCompleted)
            {
                //this.Hide();

                StateManager.AddLoaded(GameRef.GamePlayScreen);
            }
            objManager.Update(gameTime);
        }
Ejemplo n.º 2
0
        public override void Update(GameTime gameTime)
        {
            if (hasPopped)
            {
                Reset();
                hasPopped = false;
            }

            StoryTime += (float)gameTime.ElapsedGameTime.TotalSeconds;
            if (StatusBar.Health <= 0)
            {
                GameOver(this, null);
            }
            if (Input_Handler.KeyReleased(Keys.Escape))
            {
                GameRef.Exit();
            }

            if (ObjManager.MoneyGain > 0)
            {
                Gold                += ObjManager.TakeMoney();
                StatusBar.Gold      += Gold;
                GameRef.player.gold += Gold;
                Gold                 = 0;
            }
            if (ObjManager.DamageGiven > 0)
            {
                Damage            = ObjManager.TakeDamage();
                StatusBar.Health -= Damage;
                Damage            = 0;
            }
            if (counter != 5)
            {
                time += gameTime.ElapsedGameTime.TotalMilliseconds;
            }

            if (Input_Handler.KeyPressed(Keys.F11))
            {
                if (DevelopmentMode == false)
                {
                    DevelopmentMode = true;
                }
                else
                {
                    DevelopmentMode = false;
                }
            }

            #region Development
            if (DevelopmentMode)
            {
                if (Input_Handler.KeyPressed(Keys.I))
                {
                    //Waypoints.Enqueue(new Vector2(Mouse.GetState().X, Mouse.GetState().Y));
                }
                if (Input_Handler.KeyPressed(Keys.P))
                {
                    if (plotTexture == false)
                    {
                        GameRef.MousePointer = texTeleport;
                        //gamePlayMouse.Update(gameTime, arrowTexture);
                        plotTexture = true;
                    }
                    else
                    {
                        GameRef.MousePointer = Game.Content.Load <Texture2D>(@"UI Content\Pointer");
                        //gamePlayMouse.Update(gameTime, arrowTexture);
                        plotTexture = false;
                    }
                }
                if (Mouse.GetState().LeftButton == ButtonState.Pressed && placeLock == false)
                {
                    //save plot position
                    if (level == 0)
                    {
                        writer = new StreamWriter(@"GameData\Plot.txt", true);
                    }
                    else if (level == 1)
                    {
                        writer = new StreamWriter(@"GameData\Plot1.txt", true);
                    }
                    else if (level == 2)
                    {
                        writer = new StreamWriter(@"GameData\Plot2.txt", true);
                    }
                    else if (level == 3)
                    {
                        writer = new StreamWriter(@"GameData\Plot3.txt", true);
                    }

                    writer.WriteLine(Mouse.GetState().X.ToString() + "_" + Mouse.GetState().Y.ToString());
                    writer.Close();

                    ObjManager.AddLst.Add(new Plot(Content.Load <Texture2D>(@"UI Content\teleport_128"), new Vector2(Mouse.GetState().X, Mouse.GetState().Y), 5, 1, 0f, 0, 0, 0));

                    placeLock = true;
                }
                if (placeLock == true && Mouse.GetState().LeftButton == ButtonState.Released)
                {
                    placeLock = false;
                }
                if (Input_Handler.KeyPressed(Keys.O))
                {
                    writer = new StreamWriter(@"GameData\Plot.txt", true);
                    writer.Dispose();
                    writer.Close();
                    for (int x = 0; x < ObjManager.Count - 1; x++)
                    {
                        if (ObjManager[x].Type == "Plot")
                        {
                            ObjManager.RemoveAt(x);
                        }
                    }
                }
                #endregion
            }

            ObjManager.Update(gameTime);


            base.Update(gameTime);
        }