コード例 #1
0
        private void Restart()
        {
            playerHP        = 100;
            player.position = new MFVector(0.0f, 0.0f);
            player.Spawn();
            state = MainGameState.Running;
            GameStateEventArgs args = new GameStateEventArgs();

            args.state = state;
            OnEventGameState(this, args);
        }
コード例 #2
0
        protected override void OnUpdate()
        {
            base.OnUpdate();
            if (state == MainGameState.Running)
            {
                if (player == null)
                {
                    player          = new MFEntity(this);
                    player.position = new MFVector(0.0f, 0.0f);
                    player.size     = new MFVector(0.3f, 0.3f);
                    player.Spawn();
                }
                if (Env.GetKey(Keys.A))
                {
                    player.position.x -= 1.0f * Env.deltaTime;
                }
                if (Env.GetKey(Keys.D))
                {
                    player.position.x += 1.0f * Env.deltaTime;
                }
                if (Env.GetKey(Keys.W))
                {
                    player.position.y -= 1.0f * Env.deltaTime;
                }
                if (Env.GetKey(Keys.S))
                {
                    player.position.y += 1.0f * Env.deltaTime;
                }

                timer -= Env.deltaTime;
                if (timer <= 0.0f)
                {
                    RandomRefreshTime();
                    SpawnBullet();
                }
                foreach (MFBullet b in listBullet)
                {
                    b.Move();
                }
                CheckBullets();
                CheckHit();
            }
            else if (state == MainGameState.GameOver)
            {
                if (Env.GetKeyDown(Keys.Space))
                {
                    Restart();
                }
            }
        }