Update() 공개 메소드

public Update ( ) : void
리턴 void
        public void Update(float delta)
        {
            if (MinigamesUI.Timer.Duration == MinigamesUI.Timer.Elapsed)
            {
                MinigamesUI.Timer.Pause();
                game.OnTimesUp();
            }

            //game.gameTime.Update(delta);
            anturaTimer.Update(delta);
            //game.timerText.text = ((int)game.gameTime.Time).ToString();

            if (game.currentLetter.dragging)
            {
                anturaTimer.Reset();
                anturaTimer.Start();
            }



            //check if we placed the CurrentLetter:
            if (!game.currentLetter.dragging && game.currentLetter.collidedTubes.Count > 0)
            {
                game.SetCurrentState(game.ResetState);
            }
        }
예제 #2
0
    private void Update()
    {
        // Check if the timer is done
        _countdownTimer.Update();

        if (_countdownTimer.IsDone())
        {
            // Level failed (Game Over is automatically triggered by the player when lives == 0)
            _player.Die();
            // Reset timer
            ResetTimer();
        }
        else
        {
            // Update timer text
            if (_timerText != null)
            {
                _timerText.text = _countdownTimer.Seconds.ToString("00");
            }
        }

        // Check if all 5 lilypads have been occupied
        if (LilypadsOccupied == 5)
        {
            NextLevel();
        }
    }
예제 #3
0
        void Update()
        {
            time += Time.deltaTime * m_CameraVelocity;
            float t = cameraAnimationCurve.Evaluate(time);

            vignetting.fadeOut = Mathf.Pow((1 - t), 2);

            for (int i = 0; i < autoMoveObjects.Length; ++i)
            {
                autoMoveObjects[i].SetTime(t);
            }

            if (m_Start)
            {
                m_Start = false;
                Debug.Log("Start Introduction");
                foreach (var mazeCharacter in m_MazeCharacters)
                {
                    mazeCharacter.SetDestination();
                }
                StartCoroutine(DoIntroduction());
            }
            else
            {
                if (m_End)
                {
                    countDown.Update(Time.deltaTime);
                }
            }

            Camera.main.transform.position = Vector3.Lerp(m_CameraStartPosition, m_CameraEndPosition, t);
        }
        public void Update(float delta)
        {
            anturaTimer -= delta;

            if (anturaTimer <= 0.0f)
            {
                if (isAnturaRunning)
                {
                    StopAntura();
                }
                else
                {
                    StartAntura();
                }
            }

            gameTime.Update(delta);
            game.Context.GetOverlayWidget().SetClockTime(gameTime.Time);

            if (!hurryUpSfx)
            {
                if (gameTime.Time < 4f)
                {
                    hurryUpSfx = true;

                    timesUpAudioSource = game.Context.GetAudioManager().PlaySound(Sfx.DangerClockLong);
                }
            }
        }
예제 #5
0
        /// <summary>
        /// This is where it all happens. Grabs a scene that has already been rendered,
        /// and uses postprocess magic to add a glowing bloom effect over the top of it.
        /// </summary>
        /// <param name="gameTime"></param>
        public void Draw(GameTime gameTime)
        {
            if (Enabled)
            {
                frameTimer.Update(gameTime);

                //Grab a frame if the timer has expired
                if (!frameTimer.Paused && !frameTimer.HasTimeRemaining)
                {
                    CurrentImageList.AddFrame(sceneRenderTarget, (int)(FrameDelay * 1000));
                    frameTimer.Start(FrameDelay);
                }

                //Draw the entire rendered frame to the screen.
                GraphicsDevice.SetRenderTargets(prevRenderTargets);

                int width  = GraphicsDevice.PresentationParameters.BackBufferWidth;
                int height = GraphicsDevice.PresentationParameters.BackBufferHeight;

                SpriteBatch.Begin(SpriteSortMode.Deferred,
                                  BlendState.Opaque,
                                  null, null, null, null);
                SpriteBatch.Draw(sceneRenderTarget, new Rectangle(0, 0, width, height), Color.White);
                SpriteBatch.End();
            }
        }
예제 #6
0
        public void Update(GameTime gameTime)
        {
            _endGameTimer.Update(gameTime);

            if (_endGame)
            {
                return;
            }

            foreach (var bullet in _bullets)
            {
                bullet.Update(gameTime);
            }

            foreach (var laser in _lasers)
            {
                laser.Update(gameTime);
            }

            MoverManager.Update();
            CollisionWorld.Update(gameTime);
            ParticleManager.Update(gameTime);

            _bullets.RemoveAll(b => !b.Used);
        }
예제 #7
0
        public void Update(float delta)
        {
            if (game.CurrentScoreRecord >= ToboganGame.MAX_ANSWERS_RECORD)
            {
                // Maximum tower height reached
                game.SetCurrentState(game.ResultState);
                return;
            }

            game.Context.GetOverlayWidget().SetClockTime(gameTime.Time);

            if (!hurryUpSfx)
            {
                if (gameTime.Time < 4f)
                {
                    hurryUpSfx = true;

                    timesUpAudioSource = game.Context.GetAudioManager().PlaySound(Sfx.DangerClockLong);
                }
            }

            gameTime.Update(delta);

            if (requestNextQueston)
            {
                nextQuestionTimer -= delta;

                if (nextQuestionTimer <= 0f)
                {
                    game.questionsManager.StartNewQuestion();
                    requestNextQueston = false;
                }
            }
        }
예제 #8
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            _shootBulletTimer.Update(gameTime);

            if (_newPositionTime.TotalMilliseconds > 0)
            {
                if (!Boss.TargetingPosition)
                {
                    _newPositionTime -= gameTime.ElapsedGameTime;
                }
            }
            else
            {
                _newPositionTime = TimeSpan.FromSeconds(0);

                var newPosition = new Vector2(
                    Boss.Game.GameManager.Random.Next((int)(Boss.Width() / 2f), GameConfig.VirtualResolution.X - (int)(Boss.Width() / 2f)),
                    Boss.Game.GameManager.Random.Next((int)(Boss.Height() / 2f) + 42, 288 - (int)(Boss.Height() / 2f))
                    );

                Boss.MoveTo(newPosition, 1.5f);
            }
        }
예제 #9
0
    /// <summary>
    /// Updates this instance.
    /// </summary>
    private void Update()
    {
        // Check gamestate
        if (_game.GameState == GameState.Paused)
        {
            return;
        }

        // Check for keyboard input
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            // Disable destroy action
            if (DestroyMode)
            {
                ToggleDestroyMode();
            }
        }

        // Spawn traffic
        if (_timer != null)
        {
            if (_timer.IsDone())
            {
                SpawnTraffic();

                // Reset timer
                _timer.ResetClock();
                _timer.Begin();
            }
            else
            {
                _timer.Update();
            }
        }
    }
예제 #10
0
        public void Update(float delta)
        {
            game.questionsManager.Update(delta);

            if (game.CurrentScoreRecord >= ToboganGame.MAX_ANSWERS_RECORD)
            {
                // Maximum tower height reached
                game.SetCurrentState(game.ResultState);
                return;
            }

            game.Context.GetOverlayWidget().SetClockTime(gameTime.Time);

            gameTime.Update(delta);

            if (requestNextQueston)
            {
                nextQuestionTimer -= delta;

                if (nextQuestionTimer <= 0f)
                {
                    game.questionsManager.StartNewQuestion();
                    requestNextQueston = false;
                }
            }
        }
예제 #11
0
    /// <summary>
    /// Finds a path between two roads.
    /// </summary>
    /// <param name="start">The starting point.</param>
    /// <param name="goal">The destination.</param>
    public void FindPath(Node start, Node goal)
    {
        // Check if the map needs updating
        Node[] nodes      = NodeGroup.GetComponentsInChildren <Node>();
        int    childCount = nodes.Length;

        if (childCount != noOfTiles)
        {
            UpdateMap();
            noOfTiles = childCount;
        }

        // Clear previous colour path
        if (ShowPath)
        {
            foreach (Node node in nodes)
            {
                SpriteRenderer sp = node.gameObject.GetComponent <SpriteRenderer>();
                sp.color = Color.white;
            }
        }

        _grid        = gameObject.GetComponent <Grid>();
        _grid.Layout = _map;
        _pathfinder  = new Pathfinder(_grid);
        _pathfinder.Start(start, goal);

        // Prevent infinite loop
        CountdownTimer timeoutTimer = new CountdownTimer {
            Seconds = 1f
        };

        timeoutTimer.Begin();

        while (!_pathfinder.PathFound)
        {
            _pathfinder.Step();

            if (timeoutTimer.IsDone())
            {
                return;
            }

            timeoutTimer.Update();
        }

        // Debug.Log("Search done, path length: " + _pathfinder.Path.Count + ", iterations: " + _pathfinder.Iterations);

        // Show path
        if (ShowPath)
        {
            foreach (Node node in _pathfinder.Path)
            {
                SpriteRenderer sp = GetTile(node.Label).gameObject.GetComponent <SpriteRenderer>();
                sp.color = Color.red;
            }
        }
    }
예제 #12
0
        public override void OnUpdate()
        {
            timer.Update();

            if (timer.HasElapsed())
            {
                Finish();
            }
        }
예제 #13
0
        public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
            time.Update(gameTime);

            lifeBar.Update(gameTime);
            superBar.Update(gameTime);
            manaBar.Update(gameTime);
            timer.Update(time);
        }
예제 #14
0
        public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);

            timer.Update(gameTime);
            if (!timer.HasTimeRemaining && IsActive)
            {
                ScreenManager.ClearScreens();
                LoadingScreen.Load(ScreenManager, new MainMenuScreen());
            }
        }
예제 #15
0
 /// <summary>
 /// Updates this instance.
 /// </summary>
 private void Update()
 {
     // Load scene after splash timer has ended
     if (_timer.IsDone())
     {
         SceneManager.LoadScene(NextScene);
     }
     else
     {
         _timer.Update();
     }
 }
        public override void Update(GameTime gameTime, bool otherWindowHasFocus, bool covered)
        {
            base.Update(gameTime, otherWindowHasFocus, covered);
            timer.Update(gameTime);

            //just ask for a rating and exit the screen
            if (!timer.HasTimeRemaining && !IsExiting)
            {
                Task.Run(() => AskForRating());
                ExitScreen();
            }
        }
예제 #17
0
        public void Update(GameTime gameTime)
        {
            if (!EndGame() || (GameIsFinished() || TransitioningToEndGame()))
            {
                MoverManager.Update();
            }

            if (!_ready)
            {
                return;
            }

            _cameraZoomTimer.Update(gameTime);
            _explosionTimer.Update(gameTime);

            if (_boss != null && (!EndGame() || (GameIsFinished() || TransitioningToEndGame())))
            {
                _boss.Update(gameTime);
            }

            if (!EndGame() || (GameIsFinished() || TransitioningToEndGame()))
            {
                foreach (var bullet in _bullets)
                {
                    bullet.Update(gameTime);
                }

                _bullets.RemoveAll(b => !b.Used);

                foreach (var laser in _lasers)
                {
                    laser.Update(gameTime);
                }

                ParticleManager.Update(gameTime);
            }

            if (GameIsFinished())
            {
                return;
            }

            _playTime += gameTime.ElapsedGameTime;

            if (_boss != null && _boss.IsReady() && !EndGame())
            {
                _timer += gameTime.ElapsedGameTime;
            }

            CollisionWorld.Update(gameTime);

            _player.Update(gameTime);
        }
예제 #18
0
        public override void OnUpdate()
        {
            timer.Update();

            if (timer.HasElapsed())
            {
                Finish();
                return;
            }

            // interpolate position
            SetPosition(Vector3.Lerp(this.positionFrom, this.positionTo, timer.GetRatio()));
        }
예제 #19
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            _shootBulletTimer.Update(gameTime);

            var newPosition = new Vector2(
                Boss.Game.GameManager.Random.Next((int)(Boss.Width() / 2f), GameConfig.VirtualResolution.X - (int)(Boss.Width() / 2f)),
                Boss.Game.GameManager.Random.Next((int)(Boss.Height() / 2f) + 200, (int)(Boss.Height() / 2f) + 300)
                );

            Boss.MoveTo(newPosition, 1.5f);
        }
예제 #20
0
        public override void OnUpdate()
        {
            timer.Update();

            if (timer.HasElapsed())
            {
                Finish();
                return;
            }

            // interpolate scale
            transform.localScale = Vector3.Lerp(scaleFrom, scaleTo, timer.GetRatio());
        }
예제 #21
0
        public override void Update(GameTime gameTime)
        {
            var newPosition = new Vector2(
                Boss.Game.GameManager.Random.Next((int)(Boss.Width() / 2f), GameConfig.VirtualResolution.X - (int)(Boss.Width() / 2f)),
                Boss.Game.GameManager.Random.Next((int)(Boss.Height() / 2f) + 42, GameConfig.VirtualResolution.Y - (int)(Boss.Height() / 2f))
                );

            Boss.MoveTo(newPosition, 3f);

            UpdateActionPointPosition();
            _shootBulletTimer.Update(gameTime);

            base.Update(gameTime);
        }
예제 #22
0
        public void Update(float delta)
        {
            game.Context.GetOverlayWidget().SetClockTime(gameTime.Time);

            if (!hurryUpSfx)
            {
                if (gameTime.Time < 4f)
                {
                    hurryUpSfx = true;

                    timesUpAudioSource = game.Context.GetAudioManager().PlaySound(Sfx.DangerClockLong);
                }
            }
            gameTime.Update(delta);
        }
예제 #23
0
    /// <summary>
    /// Updates this instance.
    /// </summary>
    private void Update()
    {
        // Check for pause
        if (GameState == GameState.Paused)
        {
            return;
        }

        // Collect taxes
        if (_gameTimer != null)
        {
            if (_gameTimer.IsDone())
            {
                // Collect tax
                Money += Mathf.RoundToInt(_map.Buildings.Sum(building => building.CollectTax()));

                // Calculate upkeep costs
                float upkeep =
                    _map.Decorations.Select(tile => tile.gameObject.GetComponent <PurchasableTile>())
                    .Where(purchasable => purchasable != null)
                    .Sum(purchasable => purchasable.Upkeep);
                upkeep +=
                    _map.Roads.Select(tile => tile.gameObject.GetComponent <PurchasableTile>())
                    .Where(purchasable => purchasable != null)
                    .Sum(purchasable => purchasable.Upkeep);

                // Subtract upkeep costs
                Money -= Mathf.RoundToInt(upkeep);

                _gameTimer.ResetClock();
                _gameTimer.Begin();
            }
            else
            {
                _gameTimer.Update();
            }
        }

        // Check for gameover
        if (Money < -1000)
        {
            // Pause game
            SetPause(true);
            // Display game over screen
            GameOverScreen.SetActive(true);
        }
    }
예제 #24
0
        public void Update(float delta)
        {
            anturaTimer -= delta;

            if (anturaTimer <= 0.0f)
            {
                if (isAnturaRunning)
                {
                    StopAntura();
                }
                else
                {
                    StartAntura();
                }
            }

            gameTime.Update(delta);
            game.Context.GetOverlayWidget().SetClockTime(gameTime.Time);
        }
예제 #25
0
        /// <summary>
        /// Helper for updating the screen transition position.
        /// </summary>
        /// <param name="gameTime">the current game time</param>
        /// <param name="transitionOn">whether this transtion is moving onto or off of the screen</param>
        /// <returns>True if this transition is still ongoing, false if the transition has finished moving on/off</returns>
        public bool Update(GameTime gameTime, bool transitionOn)
        {
            //Will that transition flag change the state of the thing?
            if (StateChange(transitionOn))
            {
                //are we transitioning on or off?
                var time = transitionOn ? OnTime : OffTime;

                //Start the countdown timer
                _transitionTimer.Start(time);

                //fire off the event handler
                if (OnStateChange != null)
                {
                    OnStateChange(this, new EventArgs());
                }
            }

            _transitionTimer.Update(gameTime);

            // Update the transition position.
            if (transitionOn)
            {
                TransitionPosition = _transitionTimer.Lerp;
            }
            else
            {
                TransitionPosition = 1f - _transitionTimer.Lerp;
            }

            // Did we reach the end of the transition?
            if ((transitionOn && (TransitionPosition <= 0.0f)) ||
                (!transitionOn && (TransitionPosition >= 1.0f)))
            {
                TransitionPosition = MathHelper.Clamp(TransitionPosition, 0.0f, 1.0f);
                return(false);
            }

            // Otherwise we are still busy transitioning.
            return(true);
        }
예제 #26
0
        public void Update(float delta)
        {
            rightButtonTimer -= delta;

            if (correctButton != null && TutorialMode && rightButtonTimer < 0 && box.IsReady() && !Finished)
            {
                rightButtonTimer = 3;
                var uicamera = game.uiCamera;
                TutorialUI.SetCamera(uicamera);
                TutorialUI.Click(correctButton.transform.position);
            }

            if (!TutorialMode && showOldTimer)
            {
                game.radialWidget.percentage = gameTime.Time / gameTime.Duration;
            }
            if (!TutorialMode && ReadingGameConfiguration.Instance.ShowTimer && !Finished)
            {
                game.Context.GetOverlayWidget().SetClockTime(gameTime.Time);
            }
            gameTime.Update(delta);
        }
예제 #27
0
    //TODO: This method can cause problems, if want to use this AI and you have issues, refactor please
    private void GoToPosition(Vector3 destination)
    {
        bool canSeeDestination    = false;
        bool destinationHasChange = destination != _lastDestination;

        if (destinationHasChange)
        {
            _raycastCheckTimer = new CountdownTimer(TimeBetweenRayCastCheck, TimeBetweenRayCastCheck);
        }
        _raycastCheckTimer.Update(Time.deltaTime);

        Vector3 directionToMove = destination;

        if (_raycastCheckTimer.CurrentValue > _raycastCheckTimer.MaxValue)
        {
            canSeeDestination = !Physics.Raycast(transform.position, destination);
            _raycastCheckTimer.Reset();
        }

        if (!canSeeDestination)
        {
            if (destinationHasChange)
            {
                _pathToDestination = _agent.GetPathToDestination(destination);
                _lastDestination   = destination;
            }
            if (transform.position.x == _pathToDestination[0].x &&
                transform.position.z == _pathToDestination[0].z)
            {
                _pathToDestination.RemoveAt(0);
            }

            directionToMove = _pathToDestination[0];
        }

        directionToMove.y  = destination.y;
        transform.position = Vector3.MoveTowards(transform.position, directionToMove, Time.deltaTime * MoveVelocity);
    }
예제 #28
0
        /**
         * Update routines of the logger.
         */
        public void Update()
        {
            if (currentlyWriting)
            {
                // still writing
                return;
            }

            if (bufferQueue.Count == 0)
            {
                // nothing to write
                return;
            }

            writeTimer.Update();
            if (writeTimer.HasElapsed())
            {
                EnqueueWriteTask();
                Action action = ProcessTaskQueue;
                UnityThreadHelper.CreateThread(action);
                writeTimer.Reset();
            }
        }
예제 #29
0
        public void Update(GameTime gameTime)
        {
            if (_shaking)
            {
                if (_shakingTimer.TotalMilliseconds > 0)
                {
                    _shakingTimer -= gameTime.ElapsedGameTime;
                    Position       = _initialPosition + new Vector2((float)(_game.GameManager.Random.NextDouble() * _shakingMagnitude));
                }
                else
                {
                    _shaking      = false;
                    _shakingTimer = TimeSpan.Zero;
                    Position      = _initialPosition;
                }
            }

            if (_followingPosition && _followPositionDelegate != null)
            {
                Origin = _followPositionDelegate();
            }

            if (_targetingZoom)
            {
                _targetZoomTimer.Update(gameTime);

                var delta       = _targetZoomTimer.CurrentTime.TotalSeconds / _targetZoomTimer.Interval.TotalSeconds;
                var currentZoom = MathHelper.Lerp(_initialZoom, _targetZoom, (float)delta);
                Zoom = currentZoom;

                if (Math.Abs(Zoom - _targetZoom) < 0.0001f)
                {
                    Zoom           = _targetZoom;
                    _targetingZoom = false;
                }
            }
        }
예제 #30
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            var dt = (float)gameTime.ElapsedGameTime.TotalSeconds;

            _canRushTimer.Update(gameTime);
            _rushTimer.Update(gameTime);

            if (!TargetingPosition && !_rushing)
            {
                // Follow the player
                Sprite.Rotation += _angularSpeed * dt;

                if (_canRush)
                {
                    var playerAngle = Vector2.Normalize(_boss.GetPlayerPosition() - Position()).ToAngle() + (float)Math.PI;
                    if (Math.Abs(MathHelper.WrapAngle(Sprite.Rotation) - playerAngle) < 0.1f)
                    {
                        _canRush = false;
                        RushToPlayer();
                    }
                }
            }

            if (_rushing && Position() == TargetPosition)
            {
                _rushing = false;

                //_canRushTimer.Interval = TimeSpan.FromSeconds(1 + (_boss.Game.GameManager.Random.NextDouble() * 5));
                //_canRushTimer.Restart();
                //Speed *= 1.2f;

                Destroy();
            }
        }