Update() private method

private Update ( ) : void
return void
Beispiel #1
0
 // Update is called once per frame
 public static void Update()
 {
     UIController.Update();
     InputController.Update();
     World.Update();
     Lifeforms.Update();
 }
Beispiel #2
0
    private void InputHandler()
    {
        if (inputController.OnMouseDown == null)
        {
            inputController.OnMouseDown = MouseDown;
        }

        if (inputController.OnMouseUp == null)
        {
            inputController.OnMouseUp = MouseUp;
        }

        if (inputController.OnKeyDown == null)
        {
            inputController.OnKeyDown = OnKeyDown;
        }

        inputController.Update();

        if (inputController.isMiddleMouse)
        {
            ViewportService.cameraPosition += inputController.delta;

            Repaint();
        }

        if (inputController.isScroll)
        {
            //Zoom normalno ne rabotaet
            //ViewportService.Zoom += inputController.delta.y * 0.01F;

            Repaint();
        }
    }
        /// <summary>
        /// Do all the preparations before frame rendering and updates the game state.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            InputController.Update();

            totalTimeElapsed += e.Time;
            // Prevents redundant Updating of FixedUpdate() method.
            // *REASON: Rendering is slower than physics fixed updates.*
            //
            // Cheks if the time elapsed is bigger than deltaTimeFixedUpdate
            // than choose elapsed time from the last frame render for a FixedUpdate.
            if (totalTimeElapsed >= deltaTimeFixedUpdate)
            {
                foreach (var gameObject in gameObjects.ToList <GameObject>())
                {
                    gameObject.PerformFixedUpdate(totalTimeElapsed);
                }
            }
            totalTimeElapsed = 0f;

            foreach (var gameObject in gameObjects.ToList <GameObject>())
            {
                gameObject.PerformUpdate(e.Time);
            }

            base.OnUpdateFrame(e);
        }
Beispiel #4
0
 void Update()
 {
     if (b_takeInput)
     {
         m_ptrInputController.Update();
     }
 }
    void HandleTouches()
    {
        if (InputController.Update())
        {
            return;
        }

        for (int i = 0; i < Input.touchCount; i++)
        {
            Touch touch = Input.GetTouch(i);
            if (touch.phase != TouchPhase.Moved)
            {
                continue;
            }
            Vector2 touch_p              = touch.position;
            Vector2 touch_delta_p        = touch.deltaPosition;
            float   coef_scrolling       = 2f * Camera.main.orthographicSize / Screen.height;
            float   scroll               = touch_delta_p.y * coef_scrolling;
            bool    is_right_screen_part = touch_p.x > Screen.width / 2.0f;
            if (is_right_screen_part)
            {
                m_RightConveyor.Scroll(scroll);
            }
            else
            {
                m_LeftConveyor.Scroll(scroll);
            }
        }
    }
 private void Update()
 {
     if (GameStateModel.GameState == GameStateModel.GAME_STATE_PLAYING)
     {
         inputController.Update();
         elementsController.Update();
     }
 }
Beispiel #7
0
 private IEnumerator GameProcess()
 {
     while (true)
     {
         _inputController.Update();
         yield return(null);
     }
 }
 public override void Update(int timeElapsed)
 {
     PlayerInputController.Update(timeElapsed);
     playerAngle = (float)Math.Atan2(Velocity.Y, Velocity.X);
     Position   += Velocity;
     gameWorld.GridLogic.UpdateEntity(this);
     Position.WrapAround(GlobalVars.worldWidth, GlobalVars.worldHeight);
     Debug.WriteLine("cellID: " + InCell.ID);
 }
Beispiel #9
0
    void Update()
    {
        if (CurrentState == null)
        {
            return;
        }

        inputController.Update();
    }
Beispiel #10
0
        public override void Update(int timeElapsed)

        {
            PlayerInputController.Update(timeElapsed);

            Position += Velocity;



            playerAngle = (float)Math.Atan2(Velocity.Y, Velocity.X);
        }
Beispiel #11
0
    public void Update(float deltaTime)
    {
        m_inputCtrl.Update(deltaTime, 0);

        while (!m_inputCtrl.MessageQueue.Empty())
        {
            var localMessage = m_inputCtrl.MessageQueue.Dequeue();
            m_match.ProcessMessage(localMessage);
        }

        m_match.Update(deltaTime);
    }
Beispiel #12
0
        // Update is called once per frame
        public void Update()
        {
            if (inputController != null)
            {
                inputController.Update();
            }

            if (musicController != null)
            {
                musicController.Update();
            }
        }
Beispiel #13
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            _inputController.Update(gameTime.ElapsedGameTime.Milliseconds);
            _screenController.Update(gameTime.ElapsedGameTime.Milliseconds);

            base.Update(gameTime);
        }
Beispiel #14
0
        public bool Update()
        {
            _context.WriteCases();
            var nextAction = _input.Update(_context.Cases);

            if (nextAction != null)
            {
                _out.Write();
                nextAction();
                return(true);
            }
            return(false);
        }
Beispiel #15
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.F4))
            {
                Exit();
            }

            InputController.Update(gameTime);
            menus.Update();

            // TODO: Add your update logic here

            base.Update(gameTime);
        }
Beispiel #16
0
        internal void UpdateInput(GameTime gameTime, InputManager inputManager)
        {
            if (Input == null)
            {
                throw new NullReferenceException("Input is Null, Initialize must be called before UpdateInput.");
            }

            if (Input.Actions.Count == 0)
            {
                return;
            }

            Input.Update(gameTime, inputManager);
        }
        public void MultipleTriggerTest()
        {
            var trigger1 = new EventTrigger(AlwaysTrue)
            {
                IsRepeatingTrigger = true
            };
            var trigger2 = new EventTrigger(AlwaysTrue)
            {
                IsRepeatingTrigger = true
            };
            var trigger3 = new EventTrigger(AlwaysTrue)
            {
                IsRepeatingTrigger = true
            };
            var sequenceTrigger = new SequenceTrigger(trigger1, trigger2, trigger3);
            int trigger1Count   = 0;
            int trigger2Count   = 0;
            int trigger3Count   = 0;

            trigger1.ConditionsMet += () => ++ trigger1Count;
            trigger2.ConditionsMet += () => ++ trigger2Count;
            trigger3.ConditionsMet += () => ++ trigger3Count;
            InputController.AddTrigger(sequenceTrigger);
            Assert.AreEqual(0, trigger1Count);
            Assert.AreEqual(0, trigger2Count);
            Assert.AreEqual(0, trigger3Count);

            InputController.Update();
            Assert.AreEqual(1, trigger1Count);
            Assert.AreEqual(0, trigger2Count);
            Assert.AreEqual(0, trigger3Count);

            InputController.Update();
            Assert.AreEqual(1, trigger1Count);
            Assert.AreEqual(1, trigger2Count);
            Assert.AreEqual(0, trigger3Count);

            InputController.Update();
            Assert.AreEqual(1, trigger1Count);
            Assert.AreEqual(1, trigger2Count);
            Assert.AreEqual(1, trigger3Count);

            InputController.Update();
            Assert.AreEqual(2, trigger1Count);
            Assert.AreEqual(1, trigger2Count);
            Assert.AreEqual(1, trigger3Count);
        }
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            _cloud2.Update(gameTime);

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            inputController.Update(gameTime);

            animatedSprite.Update(gameTime);

            // TODO: Add your update logic here

            base.Update(gameTime);
        }
    public void Update(float deltaTime)
    {
        m_gameClient.Update();
        if (!m_gameClient.IsConnected())
        {
            return;
        }

        m_inputCtrl.Update(deltaTime, 0);
        ProcessNetworkMessages();

        while (!m_inputCtrl.MessageQueue.Empty())
        {
            var localMessage = m_inputCtrl.MessageQueue.Dequeue();
            // m_gameClient.Send(localMessage);
            // m_match.ProcessMessage(localMessage);
        }

        m_match.Update(deltaTime);
    }
Beispiel #20
0
    void Update()
    {
        input.Update();

        if (inputModel.isDragging)
        {
            World clone = LogicService.CloneWorldWithoutBullets(model);

            Position shootDir = input.GetShootDir();
            Position leftDir  = (shootDir + Position.RotateLeft(shootDir) * Config.SPREAD).Normalize();
            Position rightDir = (shootDir + Position.RotateRight(shootDir) * Config.SPREAD).Normalize();

            LogicService.ShootBullet(clone, shootDir);
            LogicService.ShootBullet(clone, leftDir);
            LogicService.ShootBullet(clone, rightDir);

            List <Position> predictionPoints = new List <Position>();
            for (int i = 0; i < Config.PREDICTION_STEPS; i++)
            {
                for (int j = 0; j < 1; j++)
                {
                    LogicService.Tick(clone);
                }

                foreach (var b in clone.bullets.Values)
                {
                    predictionPoints.Add(b.pos);
                }
            }

            ViewService.DrawPredictionPoints(view, predictionPoints);

            var p1 = Camera.main.ScreenToWorldPoint(inputModel.startDragPos);
            p1.y -= 0.5f;
            var p2 = Camera.main.ScreenToWorldPoint(inputModel.currentDragPos);
            p2.y -= 0.5f;

            ViewService.DrawInputUI(view, p1, p2);
        }
    }
Beispiel #21
0
    void Update()
    {
        float control;

        InputController.Update();

        control = InputController.GetAxis(InputController.Axis.Cross_Horizontal);

        if (control != 0)
        {
            move.x = control;
        }
        else
        {
            move.x = Input.GetAxis("Horizontal");
        }

        if (Input.GetKeyDown(KeyCode.R) || Input.GetKeyDown(KeyCode.Joystick1Button0))
        {
            int sceneIndex = SceneManager.GetActiveScene().buildIndex;
            SceneManager.LoadScene(sceneIndex);
        }
    }
Beispiel #22
0
        protected override void Update(GameTime gameTime)
        {
            float deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

            input.Update(deltaTime);
            if (input.Quit)
            {
                Exit();
            }

            var newPlasmas =
                (from plasma in plasmas
                 let colliders =
                     from asteroid in asteroids
                     where Vector2.Distance(plasma.Position, asteroid.Position) < 20.0f
                     select asteroid
                     where plasma.X > 50.0f &&
                     plasma.X <600.0f &&
                               plasma.Y> 50.0f &&
                     plasma.Y < 600.0f &&
                     colliders.Count() == 0
                     select plasma.CreateMoved(-Vector2.UnitY * 200.0f * deltaTime)).ToList();

            currentWeapon.Update(deltaTime, ship.Position);
            if (input.Shooting)
            {
                currentWeapon.PullTrigger();
            }
            newPlasmas.AddRange(currentWeapon.NewBullets);

            if (Keyboard.GetState().IsKeyDown(Keys.D1))
            {
                currentWeapon = new Blaster(Content);
            }
            if (Keyboard.GetState().IsKeyDown(Keys.D2))
            {
                currentWeapon = new DoubleBlaster(Content);
            }

            var newAsteroids =
                (from asteroid in asteroids
                 let colliders =
                     from plasma in plasmas
                     where Vector2.Distance(plasma.Position, asteroid.Position) < 20.0f
                     select plasma
                     where asteroid.X > 50.0f &&
                     asteroid.X <600.0f &&
                                 asteroid.Y> 50.0f &&
                     asteroid.Y < 300.0f &&
                     colliders.Count() == 0
                     select asteroid.CreateMoved(Vector2.UnitY * 100.0f * deltaTime)).ToList();

            Vector2 shipVelocity = input.ShipMovement * shipSpeed;
            var     newShip      = ship.CreateMoved(shipVelocity * deltaTime);

            switch (gameLogic.Execute(deltaTime))
            {
            case InstructionResult.DoneAndCreateAsteroid:
                newAsteroids.Add(
                    new Entity(new Vector2((float)(randomGenerator.NextDouble() * 500.0 + 51.0), 51.0f),
                               Content.Load <Texture2D>("asteroid")));
                break;

            case InstructionResult.RunningAndCreateAsteroid:
                newAsteroids.Add(
                    new Entity(new Vector2((float)(randomGenerator.NextDouble() * 500.0 + 51.0), 51.0f),
                               Content.Load <Texture2D>("asteroid")));
                break;
            }

            // COMMIT CHANGES TO THE STATE
            plasmas   = newPlasmas;
            asteroids = newAsteroids;
            ship      = newShip;

            base.Update(gameTime);
        }
Beispiel #23
0
    // Update is called once per frame
    void Update()
    {
        int control;

        InputController.Update();

        control = InputController.GetAxisDown(InputController.Axis.Cross_Horizontal);

        switch ((int)PageTrig)
        {
        case 0:
            if (Input.GetKeyDown(KeyCode.W))
            {
                PageTrig += 2;
                animator.SetFloat("Page_Manager", PageTrig);
                animator.SetTrigger("take1->2");

                audioSource.PlayOneShot(sound[1]);
            }
            if (Input.GetKeyDown(KeyCode.A) || control == -1)
            {
                // PageTrig -= 1;
                // animator.SetFloat("Page_Manager", PageTrig);
            }

            if (Input.GetKeyDown(KeyCode.D) || control == 1)
            {
                PageTrig += 1;
                animator.SetFloat("Page_Manager", PageTrig);
            }

            if (Input.GetKeyDown(KeyCode.LeftShift))
            {
                ClosePage = true;
                PageTrig  = 10;
                animator.SetBool("Back_Select", ClosePage);
            }
            if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.JoystickButton1))
            {
                audioSource.PlayOneShot(sound[2]);

                SceneManager.LoadScene("Stage1");
            }
            break;

        case 1:
            if (Input.GetKeyDown(KeyCode.W))
            {
                PageTrig += 2;
                animator.SetFloat("Page_Manager", PageTrig);
                animator.SetTrigger("take1->2");

                audioSource.PlayOneShot(sound[1]);
            }
            if (Input.GetKeyDown(KeyCode.A) || control == -1)
            {
                PageTrig -= 1;
                animator.SetFloat("Page_Manager", PageTrig);
            }

            /*if (Input.GetKeyDown(KeyCode.S))
             * {
             *  PageTrig -= 2;
             *  animator.SetTrigger("take1->2");
             * }*/
            if (Input.GetKeyDown(KeyCode.D) || control == 1)
            {
                PageTrig += 1;
                animator.SetFloat("Page_Manager", PageTrig);
                animator.SetTrigger("take1->2");

                audioSource.PlayOneShot(sound[1]);
            }
            if (Input.GetKeyDown(KeyCode.LeftShift))
            {
                ClosePage = true;
                animator.SetBool("Back_Select", ClosePage);
            }
            if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.JoystickButton1))
            {
                audioSource.PlayOneShot(sound[2]);

                SceneManager.LoadScene("Stage2");
            }
            break;

        case 2:
            if (Input.GetKeyDown(KeyCode.W))
            {
                PageTrig += 2;
                //animator.ResetTrigger("take1->2");
                animator.SetFloat("Page_Manager", PageTrig);
                animator.SetTrigger("take2->3");

                audioSource.PlayOneShot(sound[1]);
            }
            if (Input.GetKeyDown(KeyCode.A) || control == -1)
            {
                PageTrig -= 1;
                animator.SetFloat("Page_Manager", PageTrig);
                animator.SetTrigger("take2->2-B");

                audioSource.PlayOneShot(sound[1]);
            }
            if (Input.GetKeyDown(KeyCode.S))
            {
                PageTrig -= 2;
                //animator.ResetTrigger("take1->2");
                animator.SetFloat("Page_Manager", PageTrig);
                animator.SetTrigger("take2->2-B");
            }
            if (Input.GetKeyDown(KeyCode.D) || control == 1)
            {
                PageTrig += 1;
                animator.SetFloat("Page_Manager", PageTrig);
            }

            if (Input.GetKeyDown(KeyCode.Return))
            {
                ClosePage = true;
                PageTrig  = 10;
                animator.SetBool("Back_Select", ClosePage);
            }
            if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.JoystickButton1))
            {
                audioSource.PlayOneShot(sound[2]);

                SceneManager.LoadScene("Stage3");
            }
            break;

        case 3:
            if (Input.GetKeyDown(KeyCode.W))
            {
                PageTrig += 2;
                animator.SetFloat("Page_Manager", PageTrig);
                animator.SetTrigger("take2->3");

                audioSource.PlayOneShot(sound[1]);
            }
            if (Input.GetKeyDown(KeyCode.A) || control == -1)
            {
                PageTrig -= 1;
                animator.SetFloat("Page_Manager", PageTrig);
            }
            if (Input.GetKeyDown(KeyCode.S))
            {
                PageTrig -= 2;
                animator.SetFloat("Page_Manager", PageTrig);
                animator.SetTrigger("take2->2-B");
            }
            if (Input.GetKeyDown(KeyCode.D) || control == 1)
            {
                PageTrig += 1;
                animator.SetFloat("Page_Manager", PageTrig);
                animator.SetTrigger("take2->3");

                audioSource.PlayOneShot(sound[1]);
            }
            if (Input.GetKeyDown(KeyCode.LeftShift))
            {
                ClosePage = true;
                PageTrig  = 10;
                animator.SetBool("Back_Select", ClosePage);
            }
            if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.JoystickButton1))
            {
                audioSource.PlayOneShot(sound[2]);

                SceneManager.LoadScene("Stage4");
            }
            break;

        case 4:
            if (Input.GetKeyDown(KeyCode.W))
            {
                PageTrig += 2;
                animator.SetFloat("Page_Manager", PageTrig);
                animator.SetTrigger("take3->4");

                audioSource.PlayOneShot(sound[1]);
            }
            if (Input.GetKeyDown(KeyCode.A) || control == -1)
            {
                PageTrig -= 1;
                animator.SetFloat("Page_Manager", PageTrig);
                animator.SetTrigger("take3->3-B");

                audioSource.PlayOneShot(sound[1]);
            }
            if (Input.GetKeyDown(KeyCode.S))
            {
                PageTrig -= 2;
                animator.SetFloat("Page_Manager", PageTrig);
                animator.SetTrigger("take3->3-B");
            }
            if (Input.GetKeyDown(KeyCode.D) || control == 1)
            {
                PageTrig += 1;
                animator.SetFloat("Page_Manager", PageTrig);
            }
            if (Input.GetKeyDown(KeyCode.LeftShift))
            {
                ClosePage = true;
                PageTrig  = 10;
                animator.SetBool("Back_Select", ClosePage);
            }
            if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.JoystickButton1))
            {
                audioSource.PlayOneShot(sound[2]);

                SceneManager.LoadScene("Stage5");
            }
            break;

        case 5:
            if (Input.GetKeyDown(KeyCode.W))
            {
                PageTrig += 2;
                animator.SetFloat("Page_Manager", PageTrig);
                animator.SetTrigger("take3->4");

                audioSource.PlayOneShot(sound[1]);
            }
            if (Input.GetKeyDown(KeyCode.A) || control == -1)
            {
                PageTrig -= 1;
                animator.SetFloat("Page_Manager", PageTrig);
            }
            if (Input.GetKeyDown(KeyCode.S))
            {
                PageTrig -= 2;
                animator.SetFloat("Page_Manager", PageTrig);
                animator.SetTrigger("take3->3-B");
            }
            if (Input.GetKeyDown(KeyCode.D) || control == 1)
            {
                PageTrig += 1;
                animator.SetFloat("Page_Manager", PageTrig);
                animator.SetTrigger("take3->4");

                audioSource.PlayOneShot(sound[1]);
            }
            if (Input.GetKeyDown(KeyCode.LeftShift))
            {
                ClosePage = true;
                PageTrig  = 10;
                animator.SetBool("Back_Select", ClosePage);
            }
            if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.JoystickButton1))
            {
                audioSource.PlayOneShot(sound[2]);

                SceneManager.LoadScene("Stage6");
            }
            break;

        case 6:

            if (Input.GetKeyDown(KeyCode.A) || control == -1)
            {
                PageTrig -= 1;
                animator.SetFloat("Page_Manager", PageTrig);
                animator.SetTrigger("take4->4-B");

                audioSource.PlayOneShot(sound[1]);
            }
            if (Input.GetKeyDown(KeyCode.S))
            {
                PageTrig -= 2;
                animator.SetFloat("Page_Manager", PageTrig);
                animator.SetTrigger("take4->4-B");
            }
            if ((Input.GetKeyDown(KeyCode.D) || control == 1) && (PageTrig < 7))
            {
                PageTrig += 1;
                animator.SetFloat("Page_Manager", PageTrig);
            }
            if (Input.GetKeyDown(KeyCode.LeftShift))
            {
                ClosePage = true;
                PageTrig  = 10;
                animator.SetBool("Back_Select", ClosePage);
            }
            if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.JoystickButton1))
            {
                audioSource.PlayOneShot(sound[2]);

                SceneManager.LoadScene("Stage7");
            }
            break;

        case 7:

            if (Input.GetKeyDown(KeyCode.A) || control == -1)
            {
                PageTrig -= 1;
                animator.SetFloat("Page_Manager", PageTrig);
            }
            if (Input.GetKeyDown(KeyCode.S))
            {
                PageTrig -= 2;
                animator.SetFloat("Page_Manager", PageTrig);
                animator.SetTrigger("take4->4-B");
            }
            if (Input.GetKeyDown(KeyCode.LeftShift))
            {
                ClosePage = true;
                PageTrig  = 10;
                animator.SetBool("Back_Select", ClosePage);
            }
            if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.JoystickButton1))
            {
                audioSource.PlayOneShot(sound[2]);

                SceneManager.LoadScene("Stage8");
            }
            break;

        default:
            // animator.GetCurrentAnimatorStateInfo(0).IsName("Page_Manager");
            if (Input.GetKeyDown(KeyCode.RightShift) && (ClosePage == true))
            {
                PageTrig = 0;
                animator.SetFloat("Page_Manager", PageTrig);
                ClosePage = false;
                animator.SetBool("Back_Select", ClosePage);
            }
            break;
        }
    }
Beispiel #24
0
    // Update is called once per frame
    void Update()
    {
        int control;

        InputController.Update();

        control = InputController.GetAxisDown(InputController.Axis.Cross_Horizontal);

        switch (clickNum)
        {
        case 0:

            if (Input.GetKeyDown(KeyCode.D) || control == 1)
            {
                clickNum   += 1;
                RightLimmit = true;
                LeftLimmit  = false;
                Flamepos.x  = 7.0f;
                Flamepos.z  = -3.1f;
                Flamepos.y  = 0.0f;
                transform.Translate(Flamepos);
            }
            if (Input.GetKeyDown(KeyCode.W))
            {
                clickNum += 2;
            }

            break;

        case 1:
            if ((Input.GetKeyDown(KeyCode.A) || control == -1) && (LeftLimmit == true))
            {
                clickNum   -= 1;
                LeftLimmit  = false;
                RightLimmit = true;
                Flamepos.x  = 7.0f;
                Flamepos.z  = -3.1f;
                Flamepos.y  = 0.0f;
                transform.Translate(Flamepos);
            }
            else if ((Input.GetKeyDown(KeyCode.A) || control == -1) && (LeftLimmit == false))
            {
                clickNum   -= 1;
                RightLimmit = false;
                LeftLimmit  = true;
                Flamepos.x  = -7.0f;
                Flamepos.z  = 3.1f;
                Flamepos.y  = 0.0f;
                transform.Translate(Flamepos);
            }

            if ((Input.GetKeyDown(KeyCode.D) || control == 1) && (RightLimmit == true))
            {
                clickNum   += 1;
                RightLimmit = false;
                LeftLimmit  = true;
                Flamepos.x  = -7.0f;
                Flamepos.z  = 3.1f;
                Flamepos.y  = 0.0f;
                transform.Translate(Flamepos);
            }
            else if ((Input.GetKeyDown(KeyCode.D) || control == 1) && (RightLimmit == false))
            {
                clickNum   += 1;
                LeftLimmit  = false;
                RightLimmit = true;
                Flamepos.x  = 7.0f;
                Flamepos.z  = -3.1f;
                Flamepos.y  = 0.0f;
                transform.Translate(Flamepos);
            }
            if (Input.GetKeyDown(KeyCode.W))
            {
                clickNum += 2;
            }
            break;

        case 6:
            if ((Input.GetKeyDown(KeyCode.A) || control == -1) && (LeftLimmit == true))
            {
                clickNum   -= 1;
                LeftLimmit  = false;
                RightLimmit = true;
                Flamepos.x  = 7.0f;
                Flamepos.z  = -3.1f;
                Flamepos.y  = 0.0f;
                transform.Translate(Flamepos);
            }
            else if ((Input.GetKeyDown(KeyCode.A) || control == -1) && (LeftLimmit == false))
            {
                clickNum   -= 1;
                RightLimmit = false;
                LeftLimmit  = true;
                Flamepos.x  = -7.0f;
                Flamepos.z  = 3.1f;
                Flamepos.y  = 0.0f;
                transform.Translate(Flamepos);
            }

            if ((Input.GetKeyDown(KeyCode.D) || control == 1) && (RightLimmit == true))
            {
                clickNum   += 1;
                RightLimmit = false;
                LeftLimmit  = true;
                Flamepos.x  = -7.0f;
                Flamepos.z  = 3.1f;
                Flamepos.y  = 0.0f;
                transform.Translate(Flamepos);
            }
            else if ((Input.GetKeyDown(KeyCode.D) || control == 1) && (RightLimmit == false))
            {
                clickNum   += 1;
                LeftLimmit  = false;
                RightLimmit = true;
                Flamepos.x  = 7.0f;
                Flamepos.z  = -3.1f;
                Flamepos.y  = 0.0f;
                transform.Translate(Flamepos);
            }
            if (Input.GetKeyDown(KeyCode.S))
            {
                clickNum -= 2;
            }
            break;

        case 7:
            if (Input.GetKeyDown(KeyCode.A) || control == -1)
            {
                clickNum   -= 1;
                LeftLimmit  = true;
                RightLimmit = false;
                Flamepos.x  = -7.0f;
                Flamepos.z  = 3.1f;
                Flamepos.y  = 0.0f;
                transform.Translate(Flamepos);
            }

            if (Input.GetKeyDown(KeyCode.S))
            {
                clickNum -= 2;
            }
            break;

        default:
            if ((Input.GetKeyDown(KeyCode.A) || control == -1) && (LeftLimmit == true))
            {
                clickNum   -= 1;
                LeftLimmit  = false;
                RightLimmit = true;
                Flamepos.x  = 7.0f;
                Flamepos.z  = -3.1f;
                Flamepos.y  = 0.0f;
                transform.Translate(Flamepos);
            }
            else if ((Input.GetKeyDown(KeyCode.A) || control == -1) && (LeftLimmit == false))
            {
                clickNum   -= 1;
                RightLimmit = false;
                LeftLimmit  = true;
                Flamepos.x  = -7.0f;
                Flamepos.z  = 3.1f;
                Flamepos.y  = 0.0f;
                transform.Translate(Flamepos);
            }

            if ((Input.GetKeyDown(KeyCode.D) || control == 1) && (RightLimmit == true))
            {
                clickNum   += 1;
                RightLimmit = false;
                LeftLimmit  = true;
                Flamepos.x  = -7.0f;
                Flamepos.z  = 3.1f;
                Flamepos.y  = 0.0f;
                transform.Translate(Flamepos);
            }
            else if ((Input.GetKeyDown(KeyCode.D) || control == 1) && (RightLimmit == false))
            {
                clickNum   += 1;
                LeftLimmit  = false;
                RightLimmit = true;
                Flamepos.x  = 7.0f;
                Flamepos.z  = -3.1f;
                Flamepos.y  = 0.0f;
                transform.Translate(Flamepos);
            }

            if (Input.GetKeyDown(KeyCode.W))
            {
                clickNum += 2;
            }

            if (Input.GetKeyDown(KeyCode.S))
            {
                clickNum -= 2;
            }
            break;
        }
    }
Beispiel #25
0
        protected override void Update(GameTime gameTime)
        {
            float deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

            input.Update(deltaTime);
            if (input.Quit)
            {
                Exit();
            }

            var newPlasmas =
                (from plasma in plasmas
                 let colliders =
                     from asteroid in asteroids
                     where Vector2.Distance(plasma.Position, asteroid.Position) < 20.0f
                     select asteroid
                     where plasma.X > 50.0f &&
                     plasma.X <600.0f &&
                               plasma.Y> 50.0f &&
                     plasma.Y < 600.0f &&
                     colliders.Count() == 0
                     select plasma.CreateMoved(-Vector2.UnitY * 200.0f * deltaTime)).ToList();

            if (input.Shooting)
            {
                newPlasmas.Add(
                    new Entity(ship.Position,
                               Content.Load <Texture2D>("plasmaSmall")));
            }

            var newAsteroids =
                (from asteroid in asteroids
                 let colliders =
                     from plasma in plasmas
                     where Vector2.Distance(plasma.Position, asteroid.Position) < 20.0f
                     select plasma
                     where asteroid.X > 50.0f &&
                     asteroid.X <600.0f &&
                                 asteroid.Y> 50.0f &&
                     asteroid.Y < 300.0f &&
                     colliders.Count() == 0
                     select asteroid.CreateMoved(Vector2.UnitY * 100.0f * deltaTime)).ToList();

            Vector2 shipVelocity = input.ShipMovement * shipSpeed;
            var     newShip      = ship.CreateMoved(shipVelocity * deltaTime);

            switch (gameLogicScriptPC)
            {
            case 0:
                if (true)
                {
                    gameLogicScriptPC = 1;
                    iLine1            = 1;
                    rndNumberLine1    = randomGenerator.Next(20, 60);
                }
                else
                {
                    gameLogicScriptPC = 9;
                }
                break;

            case 1:
                if (iLine1 <= rndNumberLine1)
                {
                    gameLogicScriptPC = 2;
                }
                else
                {
                    gameLogicScriptPC = 4;
                    timeToWaitLine4   = (float)(randomGenerator.NextDouble() * 2.0 + 5.0);
                }
                break;

            case 2:
                newAsteroids.Add(
                    new Entity(new Vector2((float)(randomGenerator.NextDouble() * 500.0 + 51.0), 51.0f),
                               Content.Load <Texture2D>("asteroid")));
                gameLogicScriptPC = 3;
                timeToWaitLine3   = (float)(randomGenerator.NextDouble() * 0.2 + 0.1);
                break;

            case 3:
                timeToWaitLine3 -= deltaTime;
                if (timeToWaitLine3 > 0.0f)
                {
                    gameLogicScriptPC = 3;
                }
                else
                {
                    gameLogicScriptPC = 1;
                    iLine1++;
                }
                break;

            case 4:
                timeToWaitLine4 -= deltaTime;
                if (timeToWaitLine4 > 0.0f)
                {
                    gameLogicScriptPC = 4;
                }
                else
                {
                    gameLogicScriptPC = 5;
                    iLine5            = 1;
                    rndNumberLine5    = randomGenerator.Next(10, 20);
                }
                break;

            case 5:
                if (iLine5 <= rndNumberLine5)
                {
                    gameLogicScriptPC = 6;
                }
                else
                {
                    gameLogicScriptPC = 8;
                    timeToWaitLine8   = (float)(randomGenerator.NextDouble() * 2.0 + 5.0);
                }
                break;

            case 6:
                newAsteroids.Add(
                    new Entity(new Vector2((float)(randomGenerator.NextDouble() * 500.0 + 51.0), 51.0f),
                               Content.Load <Texture2D>("asteroid")));
                gameLogicScriptPC = 7;
                timeToWaitLine7   = (float)(randomGenerator.NextDouble() * 1.5 + 0.5);
                break;

            case 7:
                timeToWaitLine7 -= deltaTime;
                if (timeToWaitLine7 > 0)
                {
                    gameLogicScriptPC = 7;
                }
                else
                {
                    gameLogicScriptPC = 5;
                    iLine5++;
                }
                break;

            case 8:
                timeToWaitLine8 -= deltaTime;
                if (timeToWaitLine8 > 0.0f)
                {
                    gameLogicScriptPC = 8;
                }
                else
                {
                    gameLogicScriptPC = 0;
                }
                break;

            default:
                break;
            }


            // COMMIT CHANGES TO THE STATE
            plasmas   = newPlasmas;
            asteroids = newAsteroids;
            ship      = newShip;

            base.Update(gameTime);
        }
Beispiel #26
0
 public void Update(float dt)
 {
     first.Update(dt);
     second.Update(dt);
 }
Beispiel #27
0
 void Update()
 {
     inputController_.Update();
 }
Beispiel #28
0
    // Update is called once per frame
    void Update()
    {
        int control;

        InputController.Update();

        control = InputController.GetAxisDown(InputController.Axis.Cross_Horizontal);

        switch (pageNum)
        {
        case 0:
            if (Input.GetKeyDown(KeyCode.W))
            {
                pageNum     += 2;
                Nextpageflug = true;
                Pagetype     = 3;
            }

            if (Input.GetKeyDown(KeyCode.D) || control == 1)
            {
                pageNum += 1;
            }

            break;

        case 1:
            if (Input.GetKeyDown(KeyCode.W))
            {
                pageNum     += 2;
                Nextpageflug = true;
                Pagetype     = 3;
            }

            if (Input.GetKeyDown(KeyCode.D) || control == 1)
            {
                pageNum     += 1;
                Nextpageflug = true;
                Pagetype     = 3;
            }

            if (Input.GetKeyDown(KeyCode.A) || control == -1)
            {
                pageNum -= 1;
            }
            break;

        case 2:
            if (Input.GetKeyDown(KeyCode.W))
            {
                pageNum     += 2;
                Nextpageflug = true;
                Pagetype     = 5;
            }

            if (Input.GetKeyDown(KeyCode.D) || control == 1)
            {
                pageNum += 1;
            }

            if (Input.GetKeyDown(KeyCode.A) || control == -1)
            {
                pageNum     -= 1;
                Backpageflug = true;
                Pagetype     = 1;
            }

            if (Input.GetKeyDown(KeyCode.S))
            {
                pageNum     -= 2;
                Backpageflug = true;
                Pagetype     = 1;
            }
            break;

        case 3:
            if (Input.GetKeyDown(KeyCode.W))
            {
                pageNum     += 2;
                Nextpageflug = true;
                Pagetype     = 5;
            }

            if (Input.GetKeyDown(KeyCode.D) || control == 1)
            {
                pageNum     += 1;
                Nextpageflug = true;
                Pagetype     = 5;
            }

            if (Input.GetKeyDown(KeyCode.A) || control == -1)
            {
                pageNum -= 1;
            }

            if (Input.GetKeyDown(KeyCode.S))
            {
                pageNum     -= 2;
                Backpageflug = true;
                Pagetype     = 1;
            }
            break;

        case 4:
            if (Input.GetKeyDown(KeyCode.W))
            {
                pageNum     += 2;
                Nextpageflug = true;
                Pagetype     = 7;
            }

            if (Input.GetKeyDown(KeyCode.D) || control == 1)
            {
                pageNum += 1;
            }

            if (Input.GetKeyDown(KeyCode.A) || control == -1)
            {
                pageNum     -= 1;
                Backpageflug = true;
                Pagetype     = 3;
            }

            if (Input.GetKeyDown(KeyCode.S))
            {
                pageNum     -= 2;
                Backpageflug = true;
                Pagetype     = 3;
            }
            break;

        case 5:
            if (Input.GetKeyDown(KeyCode.W))
            {
                pageNum     += 2;
                Nextpageflug = true;
                Pagetype     = 7;
            }

            if (Input.GetKeyDown(KeyCode.D) || control == 1)
            {
                pageNum     += 1;
                Nextpageflug = true;
                Pagetype     = 7;
            }

            if (Input.GetKeyDown(KeyCode.A) || control == -1)
            {
                pageNum -= 1;
            }

            if (Input.GetKeyDown(KeyCode.S))
            {
                pageNum     -= 2;
                Backpageflug = true;
                Pagetype     = 3;;
            }
            break;

        case 6:

            if (Input.GetKeyDown(KeyCode.D) || control == 1)
            {
                pageNum += 1;
            }

            if (Input.GetKeyDown(KeyCode.A) || control == -1)
            {
                pageNum     -= 1;
                Backpageflug = true;
                Pagetype     = 5;
            }

            if (Input.GetKeyDown(KeyCode.S))
            {
                pageNum     -= 2;
                Backpageflug = true;
                Pagetype     = 5;
            }
            break;

        case 7:

            if (Input.GetKeyDown(KeyCode.A) || control == -1)
            {
                pageNum -= 1;
            }

            if (Input.GetKeyDown(KeyCode.S))
            {
                pageNum     -= 2;
                Backpageflug = true;
                Pagetype     = 5;
            }
            break;
        }

        if (Nextpageflug == true)
        {
            ChangeTex_time++;
            if (ChangeTex_time >= 5)
            {
                switch (Pagetype)
                {
                case 1:
                    gameObject.GetComponent <Renderer>().material.mainTexture = tex1;
                    ChangeTex_time = 0;
                    Nextpageflug   = false;
                    break;

                case 3:
                    gameObject.GetComponent <Renderer>().material.mainTexture = tex3;
                    ChangeTex_time = 0;
                    Nextpageflug   = false;
                    break;

                case 5:
                    gameObject.GetComponent <Renderer>().material.mainTexture = tex5;
                    ChangeTex_time = 0;
                    Nextpageflug   = false;
                    break;

                case 7:
                    gameObject.GetComponent <Renderer>().material.mainTexture = tex7;
                    ChangeTex_time = 0;
                    Nextpageflug   = false;
                    break;
                }
            }
        }
        if (Backpageflug == true)
        {
            ChangeTex_time++;
            if (ChangeTex_time >= 60)
            {
                switch (Pagetype)
                {
                case 1:
                    gameObject.GetComponent <Renderer>().material.mainTexture = tex1;
                    ChangeTex_time = 0;
                    Backpageflug   = false;
                    break;

                case 3:
                    gameObject.GetComponent <Renderer>().material.mainTexture = tex3;
                    ChangeTex_time = 0;
                    Backpageflug   = false;
                    break;

                case 5:
                    gameObject.GetComponent <Renderer>().material.mainTexture = tex5;
                    ChangeTex_time = 0;
                    Backpageflug   = false;
                    break;

                case 7:
                    gameObject.GetComponent <Renderer>().material.mainTexture = tex7;
                    ChangeTex_time = 0;
                    Backpageflug   = false;
                    break;
                }
            }
        }
    }
Beispiel #29
0
 public override void Update(float dt)
 {
     first.Update(dt);
     second.Update(dt);
 }
Beispiel #30
0
    private void Update()
    {
        int control;

        InputController.Update();

        control = InputController.GetAxisDown(InputController.Axis.Cross_Horizontal);


        Debug.Log(BackGround.GetStageNum());
        if (((Input.GetKeyDown(KeyCode.A) || control == -1) && Select) || ((Input.GetKeyDown(KeyCode.D) || control == 1) && !Next && !Select))
        {
            Next = true;

            Select = false;

            End = false;

            case1.transform.position = new Vector3(0.82f, -0.6f, -2.51f);

            case1.SetActive(true);

            case2.SetActive(false);
        }

        else if (((Input.GetKeyDown(KeyCode.D) || control == 1) && !Select && !End) || ((Input.GetKeyDown(KeyCode.A) || control == -1) && End))
        {
            Next = false;

            Select = true;

            End = false;

            case1.SetActive(false);

            case2.SetActive(true);
        }
        else if ((Input.GetKeyDown(KeyCode.D) || control == 1) && Select || ((Input.GetKeyDown(KeyCode.A) || control == -1) && Next))
        {
            Next = false;

            Select = false;

            End = true;

            case1.transform.position = new Vector3(4.34f, -3.2f, -2.51f);

            case1.SetActive(true);

            case2.SetActive(false);
        }

        if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.JoystickButton1))
        {
            audioSource.PlayOneShot(sound[1]);

            if (Next)
            {
                NextStage();
            }

            if (Select)
            {
                SceneManager.LoadScene("Selecter");
            }

            if (End)
            {
                #if UNITY_EDITOR
                UnityEditor.EditorApplication.isPlaying = false;
                #else
                Application.Quit();
                #endif
            }
        }
    }