public MenuItem(Vector2 pos)
 {
     currPos = pos;
     currPosX = (double)pos.X;
     currPosY = (double)pos.Y;
     state = TransState.Idle;
 }
        public void SetTransitionOff(double time, Vector2 start, Vector2 end, float dur, EasingFunction funcX, EasingFunction funcY)
        {
            startPos = start;
            targPos = end;
            currPos = startPos;
            currPosX = (double)startPos.X;
            currPosY = (double)startPos.Y;

            easeX = funcX;
            easeY = funcY;

            startTime = time;
            transDuration = dur;

            state = TransState.Off;
        }
Exemple #3
0
 // Update is called once per frame
 void Update()
 {
     if (fadeState != TransState.Complete)
     {
         timer += Time.deltaTime;
         if (fadeState == TransState.In && timer >= 1)
         {
             timer     = 0;
             fadeState = TransState.Show;
         }
         if (fadeState == TransState.Show && timer >= showDuration)
         {
             timer     = 0;
             fadeState = TransState.Out;
             PickTrans();
         }
         if (fadeState == TransState.Out && timer >= 1)
         {
             timer     = 0;
             fadeState = TransState.Complete;
         }
     }
 }
Exemple #4
0
 void SwitchState(TransState state)
 {
     CurrentTrans = state;
     CurrentTime  = Time.time;
 }
Exemple #5
0
 private void InitEngine()
 {
     this.game = new GameData();
     Game = this.game;
     Framework = this;
     this.textureCollection = new SortedDictionary<string, Texture>();
     this.textureDisposePolicies = new SortedDictionary<string, TextureDisposePolicy>();
     this.timer = new Stopwatch();
     this.InitRendering();
     this.updateFrameTime = Stopwatch.Frequency / ((long) this.updateFPS);
     this.renderFrameTime = Stopwatch.Frequency / ((long) this.renderFPS);
     this.InitInput();
     this.LoadConfig();
     this.InitSounds();
     this.game.InitGame();
     this.quitDialog = new QuitDialog();
     this.drawColor = Color.White;
     this.transState = TransState.Showing;
     this.running = true;
     this.gameWindow.Location = new Point(200, 200);
     this.gameWindow.Show();
 }
Exemple #6
0
 private void GameWindow_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (this.running)
     {
         e.Cancel = true;
     }
     if (this.transState == TransState.Showing)
     {
         this.transState = TransState.Dialog;
     }
 }
Exemple #7
0
 public void ReturnToScene()
 {
     if (this.transState == TransState.Dialog)
     {
         if (!(this.curScene is Menu) && (this.currentSong != null))
         {
             this.currentSong.SetPaused(false);
         }
         this.transState = TransState.Showing;
     }
     else
     {
         this.ChangeScene(this.game.CurrentMap);
     }
 }
Exemple #8
0
 public void ChangeScene(Scene newScene)
 {
     if (newScene is GameMap)
     {
         if (this.enableMusic && (this.currentSong != null))
         {
             this.currentSong.SetPaused(false);
         }
         this.game.CurrentMap = (GameMap) newScene;
     }
     if (this.curScene != null)
     {
         this.transScene = newScene;
         this.transProg = 0f;
         this.transState = TransState.FadingOut;
     }
     else
     {
         this.curScene = newScene;
         this.curScene.InitScene();
     }
 }
Exemple #9
0
 private void OnFrameMove()
 {
     this.BeforeUpdate();
     if (this.devicePresent)
     {
         if (this.switchFullScreen)
         {
             this.switchFullScreen = false;
             this.fullScreen = !this.fullScreen;
             this.InitRendering();
         }
         if (this.lockTimer > 0)
         {
             this.lockTimer--;
             if (this.lockTimer == 0)
             {
                 this.PlaySound(SoundEffects.OpenDoor);
             }
         }
         else if (this.KeyPressed(1))
         {
             if (this.curScene.ShowDialogOnExit)
             {
                 if (this.transState == TransState.Showing)
                 {
                     this.transState = TransState.Dialog;
                 }
             }
             else
             {
                 this.Quit();
             }
         }
         else
         {
             if (this.KeyDown(0x1d) && this.KeyPressed(0x21))
             {
                 this.ToggleFullscreen();
             }
             this.game.UpdateStatsBar();
             if (this.transState == TransState.Showing)
             {
                 if (this.enableMusic && (this.currentSong != null))
                 {
                     this.currentSong.Update();
                 }
                 this.curScene.Update(false);
             }
             else if (this.transState == TransState.FadingOut)
             {
                 if (this.enableMusic && (this.currentSong != null))
                 {
                     this.currentSong.Update();
                 }
                 this.transProg += 0.05f;
                 if (this.transProg < 1f)
                 {
                     int red = 0xff - ((int) (255f * this.transProg));
                     this.drawColor = Color.FromArgb(0xff, red, red, red);
                     this.curScene.SetFade(red);
                 }
                 else
                 {
                     if ((this.transScene is GameMap) && (this.curScene is GameMap))
                     {
                         GameMap curScene = (GameMap) this.curScene;
                         GameMap transScene = (GameMap) this.transScene;
                         if (!curScene.TextureFilename.Equals(transScene.TextureFilename))
                         {
                             this.DisposeTextures(TextureDisposePolicy.DisposeOnTileChange);
                         }
                         else
                         {
                             this.DisposeTextures(TextureDisposePolicy.DisposeOnTileChange);
                         }
                     }
                     PointF playerEntry = Game.GetPlayerStats().PlayerEntry;
                     if (playerEntry.X > 0f)
                     {
                         Game.GetPlayer().Location = new PointF(playerEntry.X, playerEntry.Y);
                         Game.GetPlayerStats().PlayerEntry = new PointF(0f, 0f);
                     }
                     this.transScene.InitScene();
                     this.transScene.SetFade(0);
                     this.transState = TransState.FadingIn;
                     this.transProg = 0f;
                     this.curScene = this.transScene;
                     this.transScene = null;
                 }
             }
             else if (this.transState == TransState.FadingIn)
             {
                 if (this.enableMusic && (this.currentSong != null))
                 {
                     this.currentSong.Update();
                 }
                 this.transProg += 0.05f;
                 if (this.transProg < 1f)
                 {
                     int num2 = (int) (255f * this.transProg);
                     this.drawColor = Color.FromArgb(0xff, num2, num2, num2);
                     this.curScene.SetFade(num2);
                 }
                 else
                 {
                     this.transState = TransState.Showing;
                     this.transProg = 0f;
                     this.drawColor = Color.White;
                     this.curScene.SetFade(-1);
                 }
             }
             else if (this.transState == TransState.Dialog)
             {
                 if (this.currentSong != null)
                 {
                     this.currentSong.SetPaused(true);
                 }
                 this.quitDialog.Update(false);
             }
         }
     }
 }
Exemple #10
0
 /// <summary>
 /// Tell the screen to start transitioning on
 /// </summary>
 public virtual void SetTransitionOn(double time)
 {
     state = TransState.On;
 }
Exemple #11
0
        public void SetTransitionOn(double time, Vector2 start, Vector2 end, float dur, EasingFunction funcX, EasingFunction funcY)
        {
            startPos = start;
            targPos = end;
            currPos = startPos;
            currPosX = (double)startPos.X;
            currPosY = (double)startPos.Y;

            easeX = funcX;
            easeY = funcY;

            startTime = time;
            transDuration = dur;

            state = TransState.On;

            Debug.WriteLine("Item Set to transition on!");
        }
Exemple #12
0
        protected void Transition(GameTime gameTime)
        {
            double dt = gameTime.TotalGameTime.TotalSeconds - startTime;

            if (dt >= transDuration)
                state = TransState.Idle;

            // Ease X
            currPosX = easeX(dt, (double)startPos.X, (double)targPos.X, (double)transDuration);//EasingFunctions.BounceEaseOut(dt, (double)startPos.X, (double)targPos.X, (double)transDuration);

            //Ease Y
            currPosY = easeY(dt, (double)startPos.Y, (double)targPos.Y, (double)transDuration);//EasingFunctions.Linear(dt, (double)startPos.Y, (double)targPos.Y, (double)transDuration);

            //Debug.WriteLine("item moved! " + currPosX + ", " + currPosY);
        }