Exemple #1
0
        protected override void OnUpdate(ref UpdateParams p)
        {
            // detect music render time rp.Time from the main beat track, if music plays
            double t = 0;
            if (mainSoundTrack != null)
                t = mainSoundTrack.CurrentPlayTime;
            if (t == 0)
            {
                musicRp.Time = p.gameTime.TotalGameTime.TotalSeconds;
            }
            else
            {
                musicRp.Time = t;
            }

            // music rendering - also apply a time rewind
            //musicRp.Time = p.gameTime.TotalGameTime.TotalSeconds ; //- musicStartTime - musicRewindTime ;
            //musicRp.Time -= musicRewindTime;
            if (RunningGameState.musicEngine != null)
            {
                musicCanvas = RunningGameState.musicEngine.Render(musicScript, musicRp);
                // music engine update - call once per frame only on average
                if (p.simTime >= lastMusicEngineUpdTime + 0.1667f)
                {
                    RunningGameState.musicEngine.Update();
                    lastMusicEngineUpdTime += 0.1667f;
                }

            }
            else
            {
                // fake the musicengine
                musicScript.Render(musicRp, new RenderCanvas() );
            }
        }
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            // move level towards the target
            if (progressValue < progressValueTarget)
            {
                progressValue += ProgressCatchupSpeed * p.Dt;
                if (progressValue > progressValueTarget)
                {
                    progressValue = progressValueTarget;
                }
            }

            // pulsing
            if (isPulsing)
            {
                // animate percentage text a bit
                float ampl      = 0.043f;
                float frequency = 0.383f;// +progressSpeed * 0.0000001f; //0.6243f;
                textScale = 1f + ampl + ampl * (float)Math.Sin(MathHelper.TwoPi * (double)frequency * SimTime);

                // bar color
                ampl = 0.080f;
                float v = (1 - ampl) + ampl * (float)Math.Sin(MathHelper.TwoPi * (double)frequency * SimTime);
                DrawInfo.DrawColor = new Color(1f, v, v, 1f);
            }
            else
            {
                DrawInfo.DrawColor = Color.White;
                textScale          = 1f;
            }
        }
        protected override void OnUpdate(ref UpdateParams p)
        {
            float accy = 0f;

            if (Keyboard.GetState().IsKeyDown(Keys.Up))
            {
                accy = -SHIP_ACC_MAX;
                //parentShip.Velocity = new Vector2(0f,-SHIP_VEL_MAX);
            }
            else if (Keyboard.GetState().IsKeyDown(Keys.Down))
            {
                accy = +SHIP_ACC_MAX;
                //parentShip.Velocity = new Vector2(0f, +SHIP_VEL_MAX);
            }
            else
            {
                // 0
                //parentShip.Velocity = Vector2.Zero;
            }

            // acc brake
            if (Keyboard.GetState().IsKeyDown(Keys.LeftControl))
                parentShip.velocityMax = SHIP_VEL_MAX / 3.0f;
            else
                parentShip.velocityMax = SHIP_VEL_MAX ;

            parentShip.driveAcceleration = new Vector2(0, accy);
        }
Exemple #4
0
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            if (Keyboard.GetState().IsKeyDown(Keys.Space))
                Parent.SetNextState(new LevelIntroState() );
        }
Exemple #5
0
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            // color
            bgColMultiplier      += RandomMath.RandomBetween(-0.0005f, +0.0005f);
            bg.DrawInfo.DrawColor = Color.White * bgColMultiplier;
            if (bgColMultiplier <= 0.08f)
            {
                bgColMultiplier += RandomMath.RandomBetween(0f, +0.0008f);
            }
            if (bgColMultiplier > 0.5432f)
            {
                bgColMultiplier -= RandomMath.RandomBetween(-0.0008f, -0.0002f);
            }


            //
            //float f = (SimTime % 4.0f) / 4.0f ;
            //if (bg.Target.X < bg.Position.X)
            //    bg.Position.X = bg.Target.X;
            //float g = (SimTime % 20.0f)/20.0f;
            //Vector2 v = new Vector2(bg.Texture.Width * (0.2f + 0.7f * f), bg.Texture.Height * (0.1f + 0.8f * g));
            float   freq = 0.0123f;
            Vector2 v    = new Vector2((float)Math.Cos(MathHelper.TwoPi * freq * SimTime), (float)Math.Sin(MathHelper.TwoPi * freq * SimTime));

            v = new Vector2(0.5f, 0.5f) + 0.33f * v;
            bg.Motion.Position = Screen.Center - Motion.ScaleAbs * v;
        }
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            // update my on-screen position (shifting the big bitmap around to match middle point set)
            Motion.Position = Screen.Center - Motion.ScaleAbs * FromPixels(Position);
        }
Exemple #7
0
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            // copy target
            nrgValueTarget = RunningGameState.player.NRG;

            // move nrg level towards the target
            if (curNrgValue < nrgValueTarget)
            {
                curNrgValue += nrgCatchupSpeed * p.dt;
                if (curNrgValue > nrgValueTarget)
                    curNrgValue = nrgValueTarget;
            }
            if (curNrgValue > nrgValueTarget)
            {
                curNrgValue -= nrgCatchupSpeed * p.dt;
                if (curNrgValue < nrgValueTarget)
                    curNrgValue = nrgValueTarget;
            }

            // draw color
            if (curNrgValue > 120f || curNrgValue < 20f)
            {
                if (SimTime % 0.6f > 0.2f)
                    textColor = Color.Red;
                else
                    textColor = Color.Black;
            }
            else
            {
                textColor = Color.White;
            }
        }
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            // enable the following behavior - or not
            Following.Active = isFollowHero;

            // check when to start following our rescuer
            float dist = (Level.Current.hero.Position - Position).Length();

            if (dist < 1.5f)
            {
                Level.Current.FoundPinkArthur();
                // start following hero
                if (!isFollowHero)
                {
                    isFollowHero = true;
                }
            }

            // check win position
            if (Position.X <= 44f && Position.Y <= 74f)
            {
                Level.Current.WinLevel();
                isFollowHero = false;
            }
        }
Exemple #9
0
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            // enable the following behavior
            if (isFollowHero)
            {
                Following.Active = true;
            }

            // check when to start following our rescuer
            float dist = (Level.Current.pixie.Position - Position).Length();
            if (dist < 1.5f)
            {
                Level.Current.FoundPrincess();
                // start following hero
                if (!isFollowHero)
                    isFollowHero = true;
            }

            // check win position
            if (Position.X <= 54f)
            {
                Level.Current.WinLevel();
            }
        }
Exemple #10
0
            public override void OnUpdate(Gamelet g, ref UpdateParams p)
            {
                base.OnUpdate(g, ref p);
                int    phase = (int)Math.Round((SimTime * 2f) % 3.0f);
                string t     = "Loading \"" + loadingDisplay.game.Name + "\"";

                switch (phase)
                {
                case 0: t += " .";
                    break;

                case 1: t += " ..";
                    break;

                case 2: t += " ...";
                    break;
                }
                loadingDisplay.tbox.Text = t;

                if (loadingDisplay.nextStateTimer >= 0f && SimTime > loadingDisplay.nextStateTimer)
                {
                    loadingDisplay.nextStateTimer = -1f;
                    g.SetNextState(new StateLoadingDisplay_Playing(loadingDisplay));
                }

                loadingDisplay.helpTextBox.Text = loadingDisplay.game.HelpText;
            }
Exemple #11
0
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            rp.Time = SimTime; // gameTime.ElapsedGameTime.TotalSeconds;
            MusicEngine.GetInstance().Render(soundScript, rp);
        }
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            // check keyboard inputs from user
            KeyboardControls(ref p);
        }
            public override void OnUpdate(Gamelet g, ref UpdateParams p)
            {
                base.OnUpdate(g, ref p);
                // fade in
                loadingDisplay.iggNameBox.ColorB.FadeTarget = 1.0f;

                if (SimTime <= 1f || isFirstDraw)
                {
                    loadingDisplay.tbox.Text = "   Enjoy \"" + loadingDisplay.game.Name + "\"";
                }
                else
                {
                    // suppress drawing during play of another game - save resources and avoid gfx conflicts.
                    GardenGame.Instance.SuppressDraw();
                }
                if (SimTime > TIME_SHOW_PLAYING_MESSAGE)
                {
                    g.SetNextState(new StateLoadingDisplay_Empty(loadingDisplay));
                }

                // check keyboard - if esc, get back to garden state
                if (Keyboard.GetState().IsKeyDown(Keys.Escape))
                {
                    g.SetNextState(new StateBrowsingMenu());
                }
            }
Exemple #14
0
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            rp.Time = SimTime;
            MusicEngine.GetInstance().Render(soundScript, rp);
        }
Exemple #15
0
        protected void MouseControls(ref UpdateParams p)
        {
            MouseState st = Mouse.GetState();

            if (st.LeftButton == ButtonState.Released && wasMouseButPressed)
            {
                wasMouseButPressed = false;
                panel.OnUserInput(GamesPanel.UserInput.STOP_SELECT);
            }

            if (st.LeftButton == ButtonState.Pressed)
            {
                if (!wasMouseButPressed)
                {
                    lastPointerPos = pointerPos;
                    pointerPos     = new Vector2(st.X, st.Y);
                    panel.OnUserInput(GamesPanel.UserInput.POSITION_SELECT, pointerPos);
                    //if ((pointerPos - lastPointerPos).Length() < 30f)
                    //{
                    //   panel.OnUserInput(GamesPanel.UserInput.START_SELECT);
                    //}
                }
                wasMouseButPressed = true;
            }
        }
Exemple #16
0
        public async Task <ActionResult> ChecklistSelect([FromQuery] UpdateParams uparams)
        {
            if (uparams.Platform == null)
            {
                return(BadRequest("Platform is missing"));
            }
            if (uparams.Site == null)
            {
                return(BadRequest("Site is missing"));
            }
            if (uparams.UpdateNum < 0)
            {
                return(BadRequest("Update number is missing"));
            }
            if (uparams.System == null)
            {
                return(BadRequest("System is missing"));
            }
            if (uparams.Process == null)
            {
                return(BadRequest("Process is missing"));
            }

            var checklist = await _repo.SingleChecklistSelect(uparams);

            if (checklist != null)
            {
                return(Ok(checklist));
            }

            var checklists = await _repo.ChecklistSelect(uparams);

            return(Ok(checklists));
        }
Exemple #17
0
            public override void OnUpdate(Gamelet g, ref UpdateParams p)
            {
                base.OnUpdate(g, ref p);
                if (SimTime > 1f && !isFirstDraw)
                {
                    // suppress drawing during play of another game - save resources and avoid gfx conflicts.
                    GardenGame.Instance.SuppressDraw();
                }

                // check keyboard - if esc, get back to garden state
                if (loadingDisplay.isExiting)
                {
                    loadingDisplay.timeExiting += p.Dt;
                    if (loadingDisplay.timeExiting > TIME_ESC_PRESS_TO_EXIT)
                    {
                        loadingDisplay.willExitSoon = true;
                    }
                }

                // perform real exit operation (abort launcher task) when ESC released
                if (!loadingDisplay.isExiting && loadingDisplay.willExitSoon)
                {
                    GardenGame.Instance.launcher.Abort();
                    loadingDisplay.willExitSoon = false;
                }
            }
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            // keep this control always-active
            IsTargetMoveDefined = true;
            AllowNextMove();
        }
Exemple #19
0
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            IsTargetMoveDefined = false;
            TargetMove          = Vector2.Zero;
            wTime -= p.Dt;
        }
 protected override void OnUpdate(ref UpdateParams p)
 {
     base.OnUpdate(ref p);
     double x = MathHelper.TwoPi * 0.08f * SimTime;
     (Parent as Motion).ScaleModifier *= 1f + (float) Math.Sin( x);
     if (x > Math.PI)
         Delete = true;
 }
Exemple #21
0
        public ObservableCollection <UpdateParams> GetAllUnprocessedItems(int _mode)
        {
            // Get all none processed Items from CUBISCAN files ** \\wmsapp\ILS\Interface\Cubiscan
            ObservableCollection <UpdateParams> _upParams = new ObservableCollection <UpdateParams>();

            try
            {
                using (IDbConnection Conn = new SqlConnection(stringConn))
                {
                    DynamicParameters param = new DynamicParameters();
                    param.Add("@Mode", _mode);

                    var _UpCollection = Conn.Query <UpdateParams>("CUBISCAN_GET_UNPROCESSED_ITEMS", param, null, true, null, CommandType.StoredProcedure);
                    foreach (var _upC in _UpCollection)
                    {
                        UpdateParams _col = new UpdateParams();
                        _col.ITEM = _upC.ITEM;
                        if (_upC.CONTAINER != "EA")
                        {
                            _col.CASEQTY = _upC.CASEQTY;
                        }
                        else
                        {
                            _col.CASEQTY = 1;       // Just a double check, protecting the users from itself
                        }
                        _col.CONTAINER = _upC.CONTAINER;
                        _col.LENGTH    = _upC.LENGTH;
                        _col.WIDTH     = _upC.WIDTH;
                        _col.HEIGHT    = _upC.HEIGHT;
                        _col.WEIGHT    = _upC.WEIGHT;
                        _col.USER_DEF1 = _upC.USER_DEF1;
                        _col.USER_DEF2 = _upC.USER_DEF2;
                        _col.USER_DEF3 = _upC.USER_DEF3;
                        _col.USER_DEF4 = _upC.USER_DEF4;
                        _col.USER_DEF5 = _upC.USER_DEF5;
                        _col.USER_DEF6 = _upC.USER_DEF6;
                        _col.USER_DEF7 = _upC.USER_DEF7;
                        _col.USER_DEF8 = _upC.USER_DEF8;

                        _upParams.Add(_col);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLogParams exparams = new ErrorLogParams();
                exparams.ITEM        = "SortBySequence";
                exparams.DESCRIPTION = ex.Message.ToString();
                exparams.FILE_NAME   = "N/A";
                Update_ErrLog(exparams);
                return(null);
            }
            finally
            {
            }
            return(_upParams);
        }
Exemple #22
0
        public async Task <GetResourceResult> UpdateResourceAsync(UpdateParams parameters)
        {
            var url = Api.ApiUrlV.ResourceType("resources").Add(Api.GetCloudinaryParam(parameters.ResourceType)).Add(parameters.Type).Add(parameters.PublicId).BuildUrl();

            using (var response = await Api.CallAsync(HttpMethod.Post, url, parameters.ToParamsDictionary(), null, null))
            {
                return(await GetResourceResult.Parse(response));
            }
        }
Exemple #23
0
 protected override void OnUpdate(ref UpdateParams p)
 {
     base.OnUpdate(ref p);
     if (!isFreeToMoveFromSquareTable && SimTime > TIME_START_MOVING && Health > 0f)
     {
         isFreeToMoveFromSquareTable = true;
         ComplexBehavior.Active      = true;
     }
 }
Exemple #24
0
 protected override void OnUpdate(ref UpdateParams p)
 {
     base.OnUpdate(ref p);
     timeVisible += p.Dt;
     if (timeVisible > HideTime)
     {
         Motion.TargetPos = Level.Current.HELPSCROLL_HIDE_POS;
     }
 }
 public override void OnUpdate(Gamelet g, ref UpdateParams p)
 {
     base.OnUpdate(g, ref p);
     if (SimTime > 1f && !isFirstDraw)
     {
         // suppress drawing during play of another game - save resources and avoid gfx conflicts.
         GardenGame.Instance.SuppressDraw();
     }
 }
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            // function: quick boom bulge out then slower decay towards zero again.
            float t = 1f*SimTime % (140f/60f);
            float d = - Ampl * t * (float)Math.Exp(-8.0f * (double)t);
            depthParam.SetValue( new Vector2(d,d) );
        }
Exemple #27
0
 protected override void OnUpdate(ref UpdateParams p)
 {
     float shakeAmplx = amplx * (float) Math.Sin(2*Math.PI*freq*SimTime);
     float shakeAmply = amplx * (float)Math.Sin(2 * Math.PI * (freq + 0.0238223) * SimTime);
     shakeAmplx += RandomMath.RandomBetween(-amplx, +amplx);
     shakeAmply += RandomMath.RandomBetween(-amply, +amply);
     //parentPars.position += new Vector2(shakeAmplx, shakeAmply);
     Position = new Vector2(shakeAmplx, shakeAmply);
 }
Exemple #28
0
 protected override void OnUpdate(ref UpdateParams p)
 {
     base.OnUpdate(ref p);
     if (thumb.Motion.Scale == sz1 && !isInShrink)
     { // target reached?
         thumb.MotionB.ScaleTarget = sz2;
         thumb.MotionB.ScaleSpeed  = spd2;
         isInShrink = true;
     }
 }
Exemple #29
0
        // scroll the level background to match pixie
        protected override void ScrollBackground(ref UpdateParams p)
        {
            // scrolling background at borders
            Vector2 pixiePos = pixie.Motion.PositionAbs;

            if (pixiePos.X < BOUND_X || pixiePos.X > (Screen.Width - BOUND_X))
            {
                Background.Target.X = pixie.Position.X;
            }
        }
 public override void OnUpdate(Gamelet g, ref UpdateParams p)
 {
     base.OnUpdate(g, ref p);
     simTime += p.Dt;
     if (stateDuration > 0f)
     {
         if (simTime > stateDuration)
             GardenGame.Instance.TreeRoot.SetNextState(new StateBrowsingMenu());
     }
 }
 protected override void OnUpdate(ref UpdateParams p)
 {
     base.OnUpdate(ref p);
     if (thumb.Motion.Scale == sz1 && !isInShrink)
     { // target reached?
         thumb.MotionB.ScaleTarget = sz2;
         thumb.MotionB.ScaleSpeed = spd2;
         isInShrink = true;
     }
 }
Exemple #32
0
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);
            double x = MathHelper.TwoPi * 0.08f * SimTime;

            (Parent as Motion).ScaleModifier *= 1f + (float)Math.Sin(x);
            if (x > Math.PI)
            {
                Delete = true;
            }
        }
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            // time keeping
            timeSinceLastChange += p.Dt;

            // keep this control always-active
            IsTargetMoveDefined = true;
            AllowNextMove();
        }
Exemple #34
0
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            // check keyboard/mouse inputs from user
            if (GardenGame.Instance.IsActive)
            {
                KeyboardControls(ref p);
                MouseControls(ref p);
            }
        }
        public async Task UpdateAsync([Required] UpdateParams parameters)
        {
            // Check if player is authenticated
            await _authentication.AuthenticateAsync(parameters.AuthToken);

            var comment = await _repository.Comments.FindAsync(parameters.CommentId);

            // Pass the new comment to the object
            comment.Text = parameters.Comment;

            await _repository.SaveChangesAsync();
        }
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);
            IsTargetMoveDefined = false;
            TargetMove          = Vector2.Zero;

            wTime += p.Dt;
            if (wTime >= 0.2f / MoveSpeed)
            {
                wTime = 0f;
            }
        }
Exemple #37
0
 public override void OnUpdate(Gamelet g, ref UpdateParams p)
 {
     base.OnUpdate(g, ref p);
     simTime += p.Dt;
     if (stateDuration > 0f)
     {
         if (simTime > stateDuration)
         {
             GardenGame.Instance.TreeRoot.SetNextState(new StateBrowsingMenu());
         }
     }
 }
Exemple #38
0
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            // check for dead chase targets
            if (ChaseTarget != null && ChaseTarget.Delete)
            {
                ChaseTarget = null;
            }

            // check the idle when far mode: if active, check distance to hero
            // and when far away from it don't bother to reget a new chase target.
            // since 'FindNearest' is CPU intensive.
            if (IsIdleWhenFarAway && ChaseTarget == null)
            {
                Vector2 dif  = Level.Current.hero.Position - ParentThing.Target;
                float   dist = dif.Length();
                if (dist >= FAR_AWAY_DISTANCE)
                {
                    return;
                }
            }

            // recheck for nearest chase target
            if (ChaseTarget == null && ChaseTargetType != null)
            {
                ChaseTarget = ParentThing.FindNearest(ChaseTargetType);
            }

            if (ChaseTarget != null && !ChaseTarget.IsStealthy && ChaseTarget.Health > 0f)
            {
                Vector2 dif  = ChaseTarget.Position - ParentThing.Target;
                float   dist = dif.Length();
                if (dist <= ChaseRange)
                {
                    if (dist > SatisfiedRange)
                    {
                        // indicate we're chasing
                        IsTargetMoveDefined = !isPauseChase;
                        AllowNextMove();
                    }
                }
                else
                {
                    if (ChaseTargetType != null)
                    {
                        // too far away - loose target; find a new one on next update.
                        ChaseTarget = null;
                    }
                }
            }
        }
Exemple #39
0
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);
            // adapt scroll speed to how fast pixie goes
            Background.TargetSpeed = SCREEN_MOTION_SPEED * pixie.Velocity;

            // create new pixels falling
            timerNewBaddie += p.Dt;
            if (timerNewBaddie >= nextBaddieInterval && SimTime >= 4.0f)
            {
                timerNewBaddie     = 0f;
                nextBaddieInterval = RandomMath.RandomBetween(MinPauseBetweenBaddies, MaxPauseBetweenBaddies);
                BadPixel b = BadPixel.Create((int)Math.Round(RandomMath.RandomBetween(-0.49f, 23.49f)));
                float    x = RandomMath.RandomBetween(-40f, 40f);
                float    y = RandomMath.RandomBetween(-50f, -40f);
                b.PositionAndTarget = new Vector2(x + pixie.Target.X, y + LevelBackground.ViewPos.Y);
                AddNextUpdate(b);
            }
            if (pixie.Score > 0)
            {
                tObjCount.Text    = "Tree-score: " + pixie.Score;
                tObjCount.Visible = true;
            }
            // scroll background
            if (SimTime >= SCROLLING_START_TIME)
            {
                Background.Target.Y = BG_STARTING_POS.Y - SCROLL_SPEED_PIXELS_PER_SEC * (SimTime - SCROLLING_START_TIME);
            }
            //Level.Current.Background.Motion.ZoomCenterTarget = Level.Current.pixie.Motion;

            // resolution scale changing
            //if (SimTime>= SCROLLING_START_TIME && Background.Target.Y < 700f && numberOfZoomOuts == 0)
            //    ScreenBorderHit();
            //if (Background.Target.Y < 710f && numberOfZoomOuts == 1) ScreenBorderHit();
            //if (Background.Target.Y < 700f && numberOfZoomOuts == 2) ScreenBorderHit();

            // test position on screen - if pixie beneath lower border much, lose
            if (SimTime >= SCROLLING_START_TIME && !hasLost && (pixie.Motion.PositionAbsZoomedPixels.Y > Screen.HeightPixels + 100f))
            {
                hasLost = true;
            }

            if (hasLost)
            {
                Music.Fade(-0.1f * p.Dt);
                this.Background.DrawInfo.DrawColor = Color.White * Music.Volume;
                if (Music.Volume == 0)
                {
                    PixieGame.Instance.Exit();
                }
            }
        }
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            Vector2 posDelta = new Vector2( ampl * (float)Math.Sin( MathHelper.TwoPi * 0.5f/moveDuration * SimTime ) , 0f);
            Parent.Motion.PositionModifier += posDelta;

            if (SimTime >= moveDuration)
            {
                // delete myself and restore the old layerdepth of Parent again.
                //Parent.LayerDepth = layerDepthOld;
                Delete = true;
            }
        }
Exemple #41
0
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            if (hasFired)
            {
                growthTime += p.dt;
                // increase ring size
                if (RingRadius < 3f)
                    RingRadius = 0.001f + growthTime * 2f;
                else
                    Visible = false; // shut off after not visible anymore
                if (RingWidth > 0.5f)
                    RingWidth  -= p.dt * 5f;

                // fade away as parent moves further away?
            }
        }
Exemple #42
0
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            if (!loadingStarted)
            {
                loadingStarted = true;
                loadingReady = false;
                Thread oThread = new Thread(new ThreadStart(this.LoadLevel));
                oThread.Priority = ThreadPriority.Normal;
                oThread.Start();
            }

            if (loadingReady)
            {
                Parent.SetNextState(new LevelState());
                loadingReady = false;
            }
        }
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            float f = 2.0f;
            if (this.SimTime > 0.5f / f)
            {
                Delete = true; // TODO, may add item to a "to be deleted" list when Delete is called! requires to block direct access to 'bool delete'.
            }
            else
            {
                //Parent.PositionModifier += new Vector2(0.2f, 0f);
                if(vImpact.X >= 0)
                    Parent.PositionModifier += new Vector2(-vImpact.X, vImpact.Y) * (float)Math.Sin(MathHelper.TwoPi * f * this.SimTime);
                else
                    Parent.PositionModifier += vImpact * (float)Math.Sin(MathHelper.TwoPi * f * this.SimTime);
                Parent.RotateModifier += rotAmpl * (float)Math.Sin(MathHelper.TwoPi * f * this.SimTime);
            }
        }
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            // handle fading over time
            if (FadeTarget > Intensity)
            {
                Intensity += FadeSpeed * p.Dt;
                if (FadeTarget < Intensity)
                    Intensity = FadeTarget;
                DrawInfo.Alpha = Intensity;
            }
            else if (FadeTarget < Intensity)
            {
                Intensity -= FadeSpeed * p.Dt;
                if (FadeTarget > Intensity)
                    Intensity = FadeTarget;
                DrawInfo.Alpha = Intensity;
            }
        }
Exemple #45
0
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            // copy scope
            ScoreTarget = RunningGameState.player.Score;

            // move nrg level towards the target
            if (scoreCurrent < ScoreTarget)
            {
                scoreCurrent += ScoreSpeed * p.dt;
                if (scoreCurrent > ScoreTarget)
                    scoreCurrent = ScoreTarget;
            }
            if (scoreCurrent > ScoreTarget)
            {
                scoreCurrent -= ScoreSpeed * p.dt;
                if (scoreCurrent < ScoreTarget)
                    scoreCurrent = ScoreTarget;
            }
        }
Exemple #46
0
 protected override void OnUpdate(ref UpdateParams p)
 {
     Vector2 pos = PositionAbsolute;
     // remove if away from screen at the left
     if (pos.X < -0.1f || pos.Y < -0.5f || pos.Y > 1.5f )
     {
         this.Delete = true;
         // FIXME - only remove items after a specified lifetime!
     }
     // remove if away at the right
     else if (pos.X > 2f && NrShipCollides > 0 ) // TODO bound set
     {
         this.Delete = true;
     }
 }
        /// <summary>
        /// handles all keyboard input into the menu, transforming that into events sent to GUI components
        /// </summary>
        /// <param name="p">UpdateParams from TTEngine OnUpdate()</param>
        protected void KeyboardControls(ref UpdateParams p)
        {
            KeyboardState st = Keyboard.GetState();

            // time bookkeeping
            float timeSinceLastKeypress = p.SimTime - lastKeypressTime;

            // -- check all relevant key releases
            if (!st.IsKeyDown(Keys.Escape) && wasEscPressed)
            {
                wasEscPressed = false;
                panel.OnUserInput(GamesPanel.UserInput.STOP_EXIT);
            }

            if (!st.IsKeyDown(Keys.Enter) && wasEnterPressed)
            {
                wasEnterPressed = false;
                panel.OnUserInput(GamesPanel.UserInput.STOP_SELECT);
            }

            // for new keypresses - only proceed if a key pressed and some minimal delay has passed...
            if (timeSinceLastKeypress < MIN_MENU_CHANGE_DELAY)
                return;
            // if no keys pressed, skip further checks
            if (st.GetPressedKeys().Length == 0)
            {
                prevKeyboardState = st;
                return;
            }

            // -- esc key
            if (st.IsKeyDown(Keys.Escape))
            {
                if (!wasEscPressed)
                {
                    panel.OnUserInput(GamesPanel.UserInput.START_EXIT);
                }
                wasEscPressed = true;
            }

            // -- website launch key
            if (st.IsKeyDown(Keys.W) && !prevKeyboardState.IsKeyDown(Keys.W))
            {
                panel.OnUserInput(GamesPanel.UserInput.LAUNCH_WEBSITE);
            }

            // -- music togglekey
            if (st.IsKeyDown(Keys.M) && !prevKeyboardState.IsKeyDown(Keys.M))
            {
                panel.OnUserInput(GamesPanel.UserInput.TOGGLE_MUSIC);
            }

            // -- a navigation key is pressed - check keys and generate action(s)
            if (st.IsKeyDown(Keys.Left)) {
                panel.OnUserInput(GamesPanel.UserInput.LEFT);
            }
            if (st.IsKeyDown(Keys.Right)) {
                panel.OnUserInput(GamesPanel.UserInput.RIGHT);
            }

            if (st.IsKeyDown(Keys.Up)) {
                panel.OnUserInput(GamesPanel.UserInput.UP);
            }

            if (st.IsKeyDown(Keys.Down)){
                panel.OnUserInput(GamesPanel.UserInput.DOWN);
            }

            if (st.IsKeyDown(Keys.Enter))
            {
                if (!wasEnterPressed)
                    panel.OnUserInput(GamesPanel.UserInput.START_SELECT);
                wasEnterPressed = true;
            }

            // (time) bookkeeping for next keypress
            lastKeypressTime = p.SimTime;
            prevKeyboardState = st;
        }
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            // check keyboard inputs from user
            KeyboardControls(ref p);
        }
 protected override void OnUpdate(ref UpdateParams p)
 {
     base.OnUpdate(ref p);
 }
Exemple #50
0
        protected override void OnUpdate(ref UpdateParams p)
        {
            height = shipShape.HeightAbsolute;
            width = shipShape.WidthAbsolute;
            maxY = Screen.Height;

            Acceleration = Vector2.Zero;
            if (driveAcceleration.LengthSquared() > 0)
            {
                Acceleration = driveAcceleration;
            }

            //-- decelerate by default (after applying acc/vel above)
            Vector2 accBreak = Vector2.Negate(Velocity);
            if (driveAcceleration.LengthSquared() == 0f && accBreak.LengthSquared() > 0f)
            {
                accBreak.Normalize();  // determine (unity) direction opposite to where we go now.
                accBreak *= defaultDeceleration ;
                // check if we can stop right now with this deceleration
                if (accBreak.LengthSquared()/2 >= Velocity.LengthSquared())
                {
                    Velocity = Vector2.Zero;
                    Acceleration = Vector2.Zero;
                }
                else
                {
                    Acceleration = accBreak;
                }
            }

            EnforcePosLimits();

            // energy use of ship
            player.NRG -= NrgBurnRate * p.dt;
            if (player.NRG < 0)
                player.NRG = 0f;
        }
 public HttpResponseMessage Update(UpdateParams submitted)
 {
     try
     {
         return !Common.HasGroupReadPermission(submitted.ResourceGroupId) 
             ? Request.CreateResponse(HttpStatusCode.Unauthorized, new { Message = App_GlobalResources.Errors.ErrorNotAuthorized }) 
             : Request.CreateResponse(HttpStatusCode.OK, new { Success = true, Message = _repository.Update(UpdateMessage(new MessageViewModel(submitted.Message))) });
     }
     catch (Exception)
     {
         return Request.CreateResponse(HttpStatusCode.InternalServerError, App_GlobalResources.Errors.ErrorGeneric);
     }
 }
Exemple #52
0
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);
            dtAfterGolUpdate += p.dt;

            if (needFirstUpdate || dtAfterGolUpdate >= golUpdatePeriod)
            {
                effDoGolUpdate.SetValue(1.0f);
                needFirstUpdate = false;
                dtAfterGolUpdate -= golUpdatePeriod;
            }
            else
            {
                effDoGolUpdate.SetValue(0.0f);
            }
            effTime.SetValue(p.simTime);
            RenderTargetBinding[] rt_old = spriteBatch.GraphicsDevice.GetRenderTargets();
            //spriteBatch.GraphicsDevice.SetRenderTargets(new RenderTargetBinding[] {rtBuf,null} );
            spriteBatch.GraphicsDevice.SetRenderTarget(renderBufOutput);

            // switch to the Update technique
            eff.CurrentTechnique = eff.Techniques[1];
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque, null, null, null, eff);
            spriteBatch.Draw(renderBufInput, Vector2.Zero, null, DrawColor);
            spriteBatch.End();
            spriteBatch.GraphicsDevice.SetRenderTargets(rt_old);

            // buffer swap
            RenderTarget2D temp = renderBufInput;
            renderBufInput = renderBufOutput;
            renderBufOutput = temp;
        }
 protected override void OnUpdate(ref UpdateParams p)
 {
     Parent.Position += (direction * (float)Math.Sin(2.0 * Math.PI * (double)frequency * SimTime));
 }
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            GardenItem selGame = SelectedGame;

            // update info box
            if (selGame == null && infoBox != null)
            {
                infoBox.SetGameInfo(selGame);
            }

            // handle download/install/launching of a game
            if (selGame != null && isGameLaunchOngoing && timeLaunching < TIME_BEFORE_GAME_LAUNCH)
            {
                timeLaunching += p.Dt;
                GameThumbnail th = thumbnailsCache[selGame.GameID];
                float sc = (1f + timeLaunching/3f);
                th.Motion.ScaleTarget = THUMBNAIL_SCALE_SELECTED * sc; // blow up size of thumbnail while user requests launch
                cursor.Motion.ScaleTarget = sc;
                cursor.Motion.ScaleSpeed = th.Motion.ScaleSpeed / selGame.ScaleIcon; // TODO correct ScaleIcon?
            }

            if (!isGameLaunchOngoing)
            {
                cursor.Motion.ScaleTarget = CURSOR_SCALE_REGULAR;
            }

            // launch of a game
            if (isGameLaunchConfirmed && selGame != null)
            {
                cursor.Motion.ScaleTarget = CURSOR_SCALE_REGULAR;

                GameThumbnail thumb = thumbnailsCache[selGame.GameID];
                if (selGame.IsIggClient)
                {
                    if (selGame.IsInstalled)
                    {
                        GardenGame.Instance.music.FadeOut();
                        GardenGame.Instance.ActionLaunchGame(selGame, thumb);
                        isExiting = true;
                        timeExiting = TIME_BEFORE_EXIT;
                    }
                    else
                    {
                        GardenGame.Instance.ActionDownloadAndInstallGame(selGame);
                    }
                }
                else
                {
                    if (selGame.IsWebGame)
                    {
                        GardenGame.Instance.ActionLaunchWebsitePlayGame(selGame, thumb);
                    }
                    else if (!selGame.IsGrowable)
                    {
                        thumb.Motion.Add(new TemporaryScaleBlowup());
                    }
                    else if (selGame.IsInstalled)
                    {
                        GardenGame.Instance.music.FadeOut();
                        GardenGame.Instance.ActionLaunchGame(selGame, thumb);
                    }
                    else // if (not installed)
                    {
                        GardenGame.Instance.ActionDownloadAndInstallGame(selGame);
                    }
                }
                isGameLaunchOngoing = false;
                isGameLaunchConfirmed = false;
                timeLaunching = 0f;
            }

            // handle exit key
            if (isExiting)
            {
                GardenGame.Instance.music.FadeOut();
                timeExiting += p.Dt;
                if (timeExiting > TIME_BEFORE_EXIT)
                {
                    parentMenu.background.Motion.ScaleModifier = 1f / (1f + (timeExiting-TIME_BEFORE_EXIT) / 11f);
                    if (!isExitingUnstoppable)
                    {
                        GardenGame.Instance.SignalExitGame();
                        isExitingUnstoppable = true;
                        Motion.ZoomSpeed = PANEL_ZOOM_SPEED_QUITTING;
                    }
                    return;
                }
            }
            else
            {
                if (timeExiting > 0f)
                {
                    if(GardenGame.Instance.music.UserWantsMusic)
                        GardenGame.Instance.music.FadeIn();
                    timeExiting = 0f;
                }
            }

            //-- website launch
            if (isLaunchWebsite)
            {
                if (selGame != null)
                {
                    GameThumbnail thumb = thumbnailsCache[selGame.GameID];
                    GardenGame.Instance.ActionLaunchWebsite(selGame, thumb);
                }
                isLaunchWebsite = false;
            }

            //-- loop all nearby games adapt their display properties where needed
            if (gl == null)
                return;
            GardenItem g;

            // upd cache with possibly new items around cursor
            List<GardenItem> c = gl.GetItemsAround((int)cursor.GridPosition.X, (int)cursor.GridPosition.Y, (int) CURSOR_DISCOVERY_RANGE);
            if (selGame != null)
                c.Add(selGame);
            for (int i = c.Count - 1; i >= 0; i--)
            {
                g = c[i];

                // if GameThumbnail for current game does not exist yet, create it
                if (!thumbnailsCache.ContainsKey(g.GameID) && g.IsVisible && g.GameID.Length > 0 )
                {
                    // create now
                    GameThumbnail th = new GameThumbnail(g);
                    Add(0, th);
                    thumbnailsCache.Add(g.GameID, th);
                    //th.Position = new Vector2(RandomMath.RandomBetween(-0.4f,2.0f), RandomMath.RandomBetween(-0.4f,1.4f) );
                    //th.Scale = RandomMath.RandomBetween(0.01f, 0.09f);
                    // create with new position and scale
                    th.Motion.Position = Screen.Center;
                    th.Motion.Scale = 0.05f;
                    th.Motion.ScaleTarget = 0.05f;
                    th.Motion.ScaleSpeed = 0.01f; // TODO const

                    th.DrawInfo.LayerDepth = LAYER_GRID_ITEMS + ((float)th.ID) * float.Epsilon;
                    th.Visible = false;
                    th.ColorB.Intensity = 0.0f;

                    // special case thumbnails
                    if (g.GameID.Equals("igg_controls"))
                        th.Motion.Add(new MyFuncyModifier( delegate(float v) { return v/22.3f; }, "Rotate"));
                }
            }

            // visit all cached items and adjust positions, visibility, etc.
            List<GameThumbnail> toRemoveFromCache = new List<GameThumbnail>();
            foreach(GameThumbnail th in thumbnailsCache.Values)
            {
                g = th.Game;

                // check if out of range. If so, remove from cache later
                if (cursor.DistanceTo(th) > CURSOR_DESTRUCTION_RANGE)
                {
                    toRemoveFromCache.Add(th);
                    th.Delete = true;
                }
                else
                {
                    // check if thnail invvisible but in range. If so, start loading it
                    if (!th.Visible && cursor.DistanceTo(th) <= CURSOR_DISCOVERY_RANGE)
                    {
                        th.LoadInBackground();
                        th.ColorB.Intensity = 0f;
                    }

                    // check if thnail is loaded and still in range. If so, start displaying it (fade in)
                    if (th.IsLoaded() && cursor.DistanceTo(th) <= CURSOR_DISCOVERY_RANGE)
                    {
                        if (th.Game.IsGrowable)
                            th.ColorB.FadeTarget = (0.65f + 0.35f * g.InstallProgress);
                        else
                            th.ColorB.FadeTarget = 1f;
                    }

                    // check if thnail in range to fade out
                    if (th.IsLoaded() && cursor.DistanceTo(th) > CURSOR_FADEOUT_RANGE)
                        th.ColorB.FadeTarget = 0f;

                }

                th.Motion.ScaleTarget = THUMBNAIL_SCALE_UNSELECTED;
                th.ColorB.FadeSpeed = THUMBNAIL_FADE_SPEED; // TODO do this only once per th?

                // coordinate position where to move a game thumbnail to
                Vector2 targetPos = (g.Position - PanelShiftPos) * new Vector2(PANEL_DELTA_GRID_X, PANEL_DELTA_GRID_Y);
                th.Motion.TargetPos = targetPos;
                th.Motion.TargetPosSpeed = PANEL_SPEED_SHIFT;

            } // end for loop over all games
            foreach (GameThumbnail th in toRemoveFromCache)
            {
                thumbnailsCache.Remove(th.Game.GameID);
            }

            // --- for selected game only
            if (selGame != null)
            {
                g = selGame;
                // update text box with currently selected game info
                if( g != infoBox.game)
                    infoBox.SetGameInfo(g);

                //-- helpful controls text
                if (g.GameID.Equals("igg_controls") && !isExiting)
                {
                    helpTextBitmap.Motion.TargetPos = HELPTEXT_SHOWN_POSITION;
                    if (g.Name.Length == 0)
                    {
                        string msg = GardenConfig.Instance.ServerMsg;
                        string[] msgLines = msg.Split(new char[] { '\n' },2);
                        g.Name = msgLines[0];
                        if (msgLines.Length > 1)
                            g.Description = msgLines[1];

                    }
                }
                else
                {
                    helpTextBitmap.Motion.TargetPos = HELPTEXT_HIDDEN_POSITION;
                }

                //-- credits text
                if (g.GameID.Equals("igg_credits") && !isExiting)
                {
                    creditsBitmap.Motion.TargetPos = CREDITS_SHOWN_POSITION;
                    Vector2 cpd = cursor.Motion.PositionAbsZoomed;
                    if (cpd.Y <= 0.35f) // TODO const
                    {
                        float dxp = PANEL_SPEED_SHIFT * p.Dt;
                        PanelShiftPos.Y -= dxp;
                    }
                }
                else
                {
                    creditsBitmap.Motion.TargetPos = CREDITS_HIDDEN_POSITION;
                }

                if (!isGameLaunchOngoing)
                {
                    if (thumbnailsCache.ContainsKey(g.GameID))
                    {
                        GameThumbnail th = thumbnailsCache[g.GameID];

                        if (g.IsInstalling)
                        {
                            // wobble the size of icon when installing.
                            th.Motion.ScaleTarget = 1.0f + 0.1f * (float)Math.Sin(MathHelper.TwoPi * 0.16f * SimTime);
                        }
                        else
                        {
                            // displaying selected thumbnails larger
                            if (g.IsGrowable)
                            {
                                th.Motion.ScaleTarget = THUMBNAIL_SCALE_SELECTED;
                            }
                            else
                            {
                                th.Motion.ScaleTarget = THUMBNAIL_SCALE_UNSELECTED;
                            }
                        }
                    }
                }
            }

            // cursor where to move to
            cursor.Motion.TargetPos = (cursor.GridPosition - PanelShiftPos) * new Vector2(PANEL_DELTA_GRID_X, PANEL_DELTA_GRID_Y);
            cursor.Motion.TargetPosSpeed = PANEL_SPEED_SHIFT;

            // panel shift effect when cursor hits edges of panel
            Vector2 cp = cursor.Motion.PositionAbsZoomed;
            float chw = cursor.DrawInfo.WidthAbs / 2.0f; // cursor-half-width
            float chh = cursor.DrawInfo.HeightAbs / 2.0f; // cursor-half-height
            float dx = PANEL_SPEED_SHIFT * p.Dt;
            const float xMargin = CURSOR_MARGIN_X; // TODO into gui props
            const float yMargin = CURSOR_MARGIN_Y;
            if (cp.X <= chw + xMargin)
            {
                PanelShiftPos.X -= dx;
            }
            else if (cp.X >= PANEL_SIZE_X - chw - xMargin)
            {
                PanelShiftPos.X += dx;
            }
            if (cp.Y <= chh + yMargin)
            {
                PanelShiftPos.Y -= dx;
            }
            else if (cp.Y >= PANEL_SIZE_Y - chh - yMargin)
            {
                PanelShiftPos.Y += dx;
            }
        }
Exemple #55
0
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            // set Max expected Alpha for the first time when called.
            if (float.IsNaN(maxAlpha))
                maxAlpha = Alpha;

            // TODO fade in behaviour
            if (SimTime < 1.0f)
            {
                Alpha = MathHelper.Clamp(SimTime, 0f, maxAlpha);
            }

            // fade out behaviour
            if (Duration > 0)
            {
                if (SimTime > Duration - 5.0f)
                {
                    Alpha = MathHelper.Clamp((Duration - SimTime) / 5f, 0f, maxAlpha);

                }
            }
        }
Exemple #56
0
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            //depthParam.SetValue( ampl * (float) Math.Sin((float) MathHelper.TwoPi * 0.3f * SimTime));
        }
Exemple #57
0
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            // at end of life, blow up myself and fade away
            if (isEndOfLifeMode)
            {
                Scale += p.dt * 4.6f; //2.4
                DrawColor *= (0.97f); // NOTE assumes a p.dt = 10 ms
                Rotate -= (1.0f * p.dt);
                if (Scale > 4.6f)
                    Delete = true;
            }
            else
            {
                // random flickering scale
                /*
                //float c = 1.2f * p.dt;
                float c = 4f * p.dt;
                Scale += RandomMath.RandomBetween(-c, c);
                if (Scale > 1.5f)
                    Scale = 1.5f - RandomMath.RandomBetween(0, c);
                if (Scale < 0.3f)
                    Scale = 0.3f + RandomMath.RandomBetween(0, c);
                */
                // pulsating with random magnitude
                float c = 0.1f * p.dt;
                pulseMagn += RandomMath.RandomBetween(-c, c);
                ScaleModifier = 1.0f + pulseMagn * (float) Math.Sin( (float) MathHelper.TwoPi * 0.3f * SimTime);
            }
            Rotate += (1.0f * p.dt);
            Rotate = Rotate % (MathHelper.TwoPi); // clip to 0-2pi TODO do this natively??
        }
Exemple #58
0
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            effTime.SetValue(p.simTime);
        }
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            // animation of loading
            if (!isLoaded)
            {
                Motion.RotateModifier += SimTime / 6.0f;
            }

            // adapt scale according to GameItem preset
            Motion.ScaleModifier *= ThumbnailScale;

            // check if a new texture has been loaded in background
            if (updatedTexture != null)
            {
                // yes: replace texture by new one
                lock (updateTextureLock)
                {
                    Texture = updatedTexture;
                    updatedTexture = null;
                    isLoaded = true;
                }
            }

            // effect on when FX mode says so, and only if thumbnail is loaded
            if (isLoaded)
                EffectEnabled = (Game.IsGrowable); // TODO && Game.IsInstalled ?;

            if (EffectEnabled)
            {
                Motion.ScaleModifier *= (1f / 0.7f); // this extends image for shader fx region, see .fx file
                haloTime += p.Dt; // move the 'halo' of the icon onwards as long as it's visible.
            }
        }
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            lock (songChangeLock)
            {
                List<SampleSoundEvent> songsToRemove = new List<SampleSoundEvent>();
                foreach (SampleSoundEvent ev in oldSongs)
                {
                    ev.Amplitude -= fadeSpeed * p.Dt;

                    // remove songs from list if completely faded out.
                    if (ev.Amplitude <= 0)
                    {
                        ev.Active = false;
                        songsToRemove.Add(ev);
                    }
                }
                foreach (SampleSoundEvent ev in songsToRemove)
                {
                    oldSongs.Remove(ev);
                }

                // check if current song is still on list
                if (currentSong != null)
                {

                    if (isFadeIn)
                    {
                        currentSong.Amplitude += fadeSpeed * p.Dt;
                        if (currentSong.Amplitude >= 1)
                        {
                            currentSong.Amplitude = 1;
                            isFadeIn = false;
                        }
                    }

                    if (isFadeOut)
                    {
                        currentSong.Amplitude -= fadeSpeed * p.Dt;
                        if (currentSong.Amplitude <= 0)
                        {
                            currentSong.Amplitude = 0;
                            isFadeOut = false;
                        }
                    }

                    // advance time only if volume nonzero
                    if (currentSong.Amplitude > 0)
                        rp.Time += p.Dt;

                    // remove current song if done playing
                    if (rp.Time - currentSongStartTime > currentSong.Duration + 0.3)
                        currentSong = null;
                }
            }

            if (currentSong != null && currentSong.Amplitude > 0)
                MusicEngine.GetInstance().Render(soundScript, rp);
        }