コード例 #1
0
 public override void Update()
 {
     if (Engine.GetKey(Keys.ESCAPE))
     {
         Program.ActualScreenState = Program.ScreenFlow.mainMenuScreen;
     }
 }
コード例 #2
0
 public void Update()
 {
     if (Engine.GetKey(Keys.ESCAPE))
     {
         Program.ActualScreenState = Program.ScreenFlow.level1Screen;
     }
 }
コード例 #3
0
        public List <bool> CheckInputs()
        {
            if (Engine.GetKey(Keys.LEFT))
            {
                inputs[0] = true;
            }
            else
            {
                inputs[0] = false;
            }

            if (Engine.GetKey(Keys.RIGHT))
            {
                inputs[1] = true;
            }
            else
            {
                inputs[1] = false;
            }



            //pasar de nivel
            if (Engine.GetKey(Keys.P))
            {
                inputs[2] = true;
            }
            else
            {
                inputs[2] = false;
            }

            return(inputs);
        }
コード例 #4
0
 public void Update()
 {
     if (Engine.GetKey(Keys.ESCAPE))
     {
         GameManager.Instance.ChangeGameState(GameState.MainMenu);
     }
 }
コード例 #5
0
        public override void Update()
        {
            if (!LifeController.Destroyed)
            {
                //timer += Time.DeltaTime;
                //Console.WriteLine("Respawn in" + timer);

                ScreenLimits();
                Move();

                timerShoot += Time.DeltaTime;
                //Console.WriteLine("Shoot Timer" + timerShoot);

                if (Engine.GetKey(Keys.SPACE) && timerShoot >= timetoShoot)
                {
                    canShoot = true;
                    Shoot();
                    timerShoot = 0;
                }

                collisionTimer += Time.DeltaTime;
                //Console.WriteLine($"Collisiontimer {collisionTimer}");
                //if (/*canReceiveDamage && */collisionTimer >= collisionMaxTimer)
                CheckForCollisionsWEnemy();

                //Console.WriteLine("Can Respawn: " + canRespawn);
            }
        }
コード例 #6
0
 //private const float IDLE_ANIMATION_PATH = "Png/Player/Idle/;
 public void InputDetection()
 {
     isMoveRightKeyPressed = Engine.GetKey(Keys.D);
     isMoveLeftKeyPressed  = Engine.GetKey(Keys.A);
     isShootingKeyPressed  = Engine.GetKey(Keys.SPACE);
     isMoveDownKeyPressed  = Engine.GetKey(Keys.S);
     isMoveUpKeyPressed    = Engine.GetKey(Keys.W);
 }
コード例 #7
0
        public void Update()
        {
            currentButton = currentButton.Update();
            arrow.Update(currentButton.PosX, currentButton.PosY);

            if (Engine.GetKey(Keys.SPACE))
            {
                EnterButton();
            }
        }
コード例 #8
0
 public override void Update()
 {
     actualBtn = actualBtn.Update();
     if (Engine.GetKey(Keys.SPACE) && Program.canPressSpace)
     {
         Program.canPressSpace = false;
         Program.timerSpace    = 0f;
         EnterButton();//MMenuS
         arrow.Update();
     }
 }
コード例 #9
0
        public void Update()
        {
            buttonActual = buttonActual.Update();
            select.Update(buttonActual.PosX, buttonActual.PosY);

            EnterDelay();

            if (Engine.GetKey(Keys.RETURN) && canEnter)
            {
                canEnter   = false;
                timerEnter = 0f;
                EnterButton();
            }
        }
コード例 #10
0
ファイル: Menu.cs プロジェクト: laujuvi/TPOrientacionaObjetos
        public void Actualizar()
        {
            esperaDeInput += Program.deltaTime;


            botonActual = botonActual.Actualizar();

            flecha.Actualizar(botonActual.posX, botonActual.posY);

            if (Engine.GetKey(Keys.RETURN))
            {
                EnterButon();
            }

            esperaDeInput = 0;
        }
コード例 #11
0
        public void Update()
        {
            if (Engine.GetKey(Keys.F1))
            {
                ChangeGameState(GameState.WinScreen);
            }

            if (Engine.GetKey(Keys.F2))
            {
                ChangeGameState(GameState.GameOverScreen);
            }


            switch (CurrentState) //casos posibles de var
            {
            case GameState.MainMenu:
                EnemyListIsEmpty();
                MainMenu.Update();
                break;

            case GameState.Credits:
                Credits.Update();
                break;

            case GameState.Options:

                break;

            case GameState.GameOverScreen:
                GameOverScreen.Update();

                break;

            case GameState.WinScreen:
                WinScreen.Update();

                break;

            case GameState.Level:
                LevelController.Update();
                WinCondition();
                break;

            default:
                break;
            }
        }
コード例 #12
0
        public Button Update()
        {
            _timer += Program.deltaTime;

            if (Engine.GetKey(Keys.UP) && _timer >= _pressTimer)
            {
                _timer = 0f;
                return(_buttonUp);
            }
            else if (Engine.GetKey(Keys.DOWN) && _timer >= _pressTimer)
            {
                _timer = 0f;
                return(_buttonDown);
            }
            else
            {
                return(this);
            }
        }
コード例 #13
0
        public Boton Actualizar()
        {
            timer += Program.deltaTime;

            if (Engine.GetKey(Keys.W) && timer >= tiempoParaApretar)
            {
                timer = 0f;
                return(GetUp());
            }
            else if (Engine.GetKey(Keys.S) && timer >= tiempoParaApretar)
            {
                timer = 0f;
                return(GetDown());
            }
            else
            {
                return(this);
            }
        }
コード例 #14
0
        public void Update()
        {
            currentInputDelayTime -= Program.deltaTime;
            foreach (var button in buttons)
            {
                button.Update();
            }

            if (Engine.GetKey(Keys.UP) && currentInputDelayTime <= 0)
            {
                ChangeButton(currentButton.PreviousButton);
            }
            if (Engine.GetKey(Keys.DOWN) && currentInputDelayTime <= 0)
            {
                ChangeButton(currentButton.NextButton);
            }
            if (Engine.GetKey(Keys.SPACE) && currentInputDelayTime <= 0)
            {
                SelectButton(currentButton);
            }
        }
コード例 #15
0
        static void Main(string[] args)
        {
            Engine.Initialize("A ver q onda");
            //Cuando comienza el juego, empieza en el menu principal. Luego entra en el GameLoop
            NivelesManager.AccederMenu();
            pj = new Personaje(100F, 500F);

            while (true)
            {
                Engine.Clear();
                NivelesManager.EjecutarNivelActual();
                if (Jugando)
                {
                    if (Engine.GetKey(Keys.Q))
                    {
                        MenuManager.GuardarPartida();
                    }
                }
                Engine.Show();
            }
        }
コード例 #16
0
        public override void Move()
        {
            if (Engine.GetKey(Keys.W))
            {
                Transform.Position -= new Vector2(0, Speed.Y * Time.DeltaTime);
            }

            if (Engine.GetKey(Keys.S))
            {
                Transform.Position += new Vector2(0, Speed.Y * Time.DeltaTime);
            }

            if (Engine.GetKey(Keys.A))
            {
                Transform.Position -= new Vector2(Speed.X * Time.DeltaTime, 0);
            }

            if (Engine.GetKey(Keys.D))
            {
                Transform.Position += new Vector2(Speed.X * Time.DeltaTime, 0);
            }
        }
コード例 #17
0
        public override void Update()
        {
            if (!LifeController.Destroyed)
            {
                //timer += Time.DeltaTime;

                ScreenLimits();
                Move();

                timerShoot += Time.DeltaTime;

                if (Engine.GetKey(Keys.SPACE) && timerShoot >= timetoShoot)
                {
                    Shoot();
                    timerShoot = 0;
                }

                if (LifeController.Damaged)
                {
                    Respawn();
                }
            }
        }
コード例 #18
0
        public void Actualizar()
        {
            iSentido = -1;

            if (Engine.GetKey(Keys.D))
            {
                x += velocidad * Program.deltaTime;

                estadoActual = Estado.CorrerDer;
                animCorrerDer.Play();

                if (x >= wGame - ((wTex * escala) / 2))
                {
                    x = wGame - (wTex * escala) / 2;
                }

                xGlobal -= velocidad * Program.deltaTime;
                if (xGlobal <= despX)
                {
                    xGlobal = despX;
                }

                int fila    = (int)((y + (-yGlobal)) / tilemap.tamañoTile);
                int columna = (int)((GetXMax() + (-xGlobal)) / tilemap.tamañoTile);
                if (columna > 14)
                {
                    columna = 14;
                }
                if (columna < 0)
                {
                    columna = 0;
                }
                if (fila > 8)
                {
                    fila = 8;
                }
                if (fila < 0)
                {
                    fila = 0;
                }
                int numeroTile = tilemap.tiles[fila, columna];

                if (numeroTile == 2 || numeroTile == 3)
                {
                    if (Program.estadoActual == Program.estado.nivel1)
                    {
                        Program.nivel2.ResetearNivel2();
                        Program.estadoActual = Program.estado.nivel2;
                    }
                    else if (Program.estadoActual == Program.estado.nivel2)
                    {
                        Engine.Debug("GANASTE");

                        Program.estadoActual = Program.estado.win;
                    }
                }
                else if (numeroTile != -1)
                {
                    x       -= velocidad * Program.deltaTime;
                    xGlobal += velocidad * Program.deltaTime;
                }
            }
            else if (Engine.GetKey(Keys.A))
            {
                x -= velocidad * Program.deltaTime;

                estadoActual = Estado.CorrerIzq;
                animCorrerIzq.Play();


                if (x <= ((wTex * escala) / 2))
                {
                    x = (wTex * escala) / 2;
                }

                xGlobal += velocidad * Program.deltaTime;
                if (xGlobal >= 0)
                {
                    xGlobal = 0;
                }

                int fila    = (int)((y + (-yGlobal)) / tilemap.tamañoTile);
                int columna = (int)((GetXMin() + (-xGlobal)) / tilemap.tamañoTile);
                if (columna > 14)
                {
                    columna = 14;
                }
                if (columna < 0)
                {
                    columna = 0;
                }
                if (fila > 8)
                {
                    fila = 8;
                }
                if (fila < 0)
                {
                    fila = 0;
                }
                int numeroTile = tilemap.tiles[fila, columna];

                if (numeroTile == 2 || numeroTile == 3)
                {
                    if (Program.estadoActual == Program.estado.nivel1)
                    {
                        Program.nivel2.ResetearNivel2();
                        Program.nivel2.ResetearVida();
                        Program.estadoActual = Program.estado.nivel2;
                    }
                    else if (Program.estadoActual == Program.estado.nivel2)
                    {
                        Engine.Debug("GANASTE");
                        Program.estadoActual = Program.estado.win;
                    }
                }
                else if (numeroTile != -1)
                {
                    x       += velocidad * Program.deltaTime;
                    xGlobal -= velocidad * Program.deltaTime;
                }
            }
            else
            {
                if (estadoActual == Estado.CorrerDer)
                {
                    estadoActual = Estado.IdleDer;
                    animIdleDer.Play();
                }
                else if (estadoActual == Estado.CorrerIzq)
                {
                    estadoActual = Estado.IdleIzq;
                    animIdleIzq.Play();
                }
            }
        }