Beispiel #1
0
        public override void InitState()
        {
            Console.WriteLine("Loading logo tex.");
            LogoTex = new StarEngine.Texture.VTex2D("Data\\2D\\Logo\\DarkArtLogo.png", LoadMethod.Single);
            PresTex = new VTex2D("Data\\2D\\Logo\\Presents.png", LoadMethod.Single);
            GameTex = new VTex2D("Data\\2D\\Logo\\ArenaLogo.png", LoadMethod.Single);
            Console.WriteLine("Loaded.");

            ms = StarSoundSys.Play2DFile("Data\\Music\\Logo\\LogoTheme1.wav");

            VPen.SetProj(0, 0, StarApp.W, StarApp.H);

            bool AlphaUp()
            {
                LogoAlpha = LogoAlpha + 0.015f;
                if (LogoAlpha > 1.0f)
                {
                    return(true);
                }
                return(false);
            }

            int waitStart = 0;

            void WaitInit()
            {
                waitStart = Environment.TickCount;
            }

            bool WaitABit()
            {
                if (Environment.TickCount > waitStart + 2000)
                {
                    return(true);
                }
                return(false);
            }

            bool logoDone = false;

            bool AlphaDown()
            {
                LogoAlpha -= 0.01f;
                if (LogoAlpha < 0.0f)
                {
                    logoDone  = true;
                    LogoAlpha = 0.0f;
                    return(true);
                }
                return(false);
            }

            void TestDo()
            {
            }

            void DoPresent()
            {
                LogoAlpha   = 0.0f;
                PresentLogo = true;
            }

            void DoGame()
            {
                LogoAlpha = 0.0f;
                GameLogo  = true;
            }

            void Done()
            {
                ms.Stop();
                ToMenu = true;
            }

            Logics.Flow(null, AlphaUp);
            Logics.Flow(WaitInit, WaitABit);
            Logics.Flow(null, AlphaDown, DoPresent);
            Logics.Flow(null, AlphaUp);
            Logics.Flow(WaitInit, WaitABit);
            Logics.Flow(null, AlphaDown, DoGame);
            Logics.Flow(null, AlphaUp);
            Logics.Flow(WaitInit, WaitABit);
            Logics.Flow(null, AlphaDown, Done);


            bool StateDone()
            {
                return(logoDone);
            }

            void NextState()
            {
                ms.Stop();
                PresentLogo = true;
            }

            bool UnlessMusic()
            {
                return(ms.Playing);
            }

            Logics.When(StateDone, NextState, UnlessMusic);
        }