Esempio n. 1
0
        public Input GetInput()
        {
            int flag = DX.GetJoypadInputState(DX.DX_INPUT_KEY_PAD1);

            byte nextDirection = GetDirection(flag);
            var directionChanged = _prevDirection != nextDirection;

            var nextShot = (flag & DX.PAD_INPUT_1) > 0;
            var shotToggled = _prevShot != nextShot;

            var nextPause = (flag & DX.PAD_INPUT_2) > 0;
            var pauseToggled = _prevPause != nextPause;

            var nextTweet = DX.CheckHitKey(DX.KEY_INPUT_T) == DX.TRUE;
            var tweetToggled = _prevTweet != nextTweet;

            var nextInput = new Input(
                nextDirection, directionChanged,
                nextShot, shotToggled,
                nextPause, pauseToggled,
                nextTweet, tweetToggled);

            _prevDirection = nextDirection;
            _prevShot = nextShot;
            _prevPause = nextPause;
            _prevTweet = nextTweet;
            return nextInput;
        }
Esempio n. 2
0
 public void Update(Input input)
 {
     if (input.DirectionToggled)
     {
         switch (input.Direction)
         {
             case 4:
                 _stageNo--;
                 if (_stageNo < 0)
                     _stageNo = 0;
                 _world = new ShootingWorld(
                     _stageFactory.GetEnemies(_stageNo));
                 _view = new ShootingWorldView(_world)
                 {
                     Renderer = Renderer
                 };
                 break;
             case 6:
                 _stageNo++;
                 if (_stageNo > _stageFactory.LastStage)
                 {
                     _stageFactory.AddStage();
                 }
                 _world = new ShootingWorld(
                     _stageFactory.GetEnemies(_stageNo));
                 _view = new ShootingWorldView(_world)
                 {
                     Renderer = Renderer
                 };
                 break;
         }
     }
     if (DX.CheckHitKey(DX.KEY_INPUT_1) == DX.TRUE)
     {
         int x, y;
         DX.GetMousePoint(out x, out y);
         _stageFactory.AddEnemy(
             _stageNo, EnemyType.Green, MergePoint(x, y));
         _world = new ShootingWorld(_stageFactory.GetEnemies(_stageNo));
     }
     if (DX.CheckHitKey(DX.KEY_INPUT_2) == DX.TRUE)
     {
         int x, y;
         DX.GetMousePoint(out x, out y);
         _stageFactory.AddEnemy(
             _stageNo, EnemyType.Blue, MergePoint(x, y));
         _world = new ShootingWorld(_stageFactory.GetEnemies(_stageNo));
     }
     if (DX.CheckHitKey(DX.KEY_INPUT_3) == DX.TRUE)
     {
         int x, y;
         DX.GetMousePoint(out x, out y);
         _stageFactory.AddEnemy(
             _stageNo, EnemyType.Red, MergePoint(x, y));
         _world = new ShootingWorld(_stageFactory.GetEnemies(_stageNo));
     }
     if (DX.CheckHitKey(DX.KEY_INPUT_4) == DX.TRUE)
     {
         int x, y;
         DX.GetMousePoint(out x, out y);
         _stageFactory.AddEnemy(
             _stageNo, EnemyType.Silver, MergePoint(x, y));
         _world = new ShootingWorld(_stageFactory.GetEnemies(_stageNo));
     }
     if (DX.CheckHitKey(DX.KEY_INPUT_5) == DX.TRUE)
     {
         int x, y;
         DX.GetMousePoint(out x, out y);
         _stageFactory.AddEnemy(
             _stageNo, EnemyType.Gold, MergePoint(x, y));
         _world = new ShootingWorld(_stageFactory.GetEnemies(_stageNo));
     }
     if (DX.CheckHitKey(DX.KEY_INPUT_Q) == DX.TRUE)
     {
         int x, y;
         DX.GetMousePoint(out x, out y);
         _stageFactory.RemoveEnemy(
             _stageNo, new Point((short)x, (short)y));
         _world = new ShootingWorld(_stageFactory.GetEnemies(_stageNo));
     }
     if (input.ShotToggled && input.Shot)
     {
         new File().SaveStages(_stageFactory.ToData());
     }
 }
Esempio n. 3
0
File: Title.cs Progetto: progre/sx13
        public void Render(Input input)
        {
            if (DebugMode && input.Pause)
            {
                Edit = true;
                return;
            }
            if (_time < 0)
                _enabledEx = new File().CheckExFlag();
            _time++;
            if (_time < Scene1 + Scene2 + Scene3)
            {
                RenderPreTitleLogo(Renderer);
                return;
            }

            if (!_ranking)
            {
                if (input.DirectionToggled)
                {
                    switch (input.Direction)
                    {
                        case 2:
                            _selection++;
                            if (!_enabledEx && _selection == 1)
                                _selection = 2;
                            if (_selection > 2)
                                _selection = 0;
                            break;
                        case 8:
                            _selection--;
                            if (!_enabledEx && _selection == 1)
                                _selection = 0;
                            if (_selection < 0)
                                _selection = 2;
                            break;
                    }
                }
                if (input.ShotToggled && input.Shot)
                {
                    switch (_selection)
                    {
                        case 0:
                            IsEx = false;
                            Start = true;
                            break;
                        case 1:
                            IsEx = true;
                            Start = true;
                            break;
                        case 2:
                            Exit = true;
                            break;
                    }
                }
            }
            else
            {
                if (input.ShotToggled && input.Shot)
                    _ranking = false;
            }

            _backgroundView.Renderer = Renderer;
            _backgroundView.Render();
            if (!_ranking)
            {
                Renderer.Draw("title2.png", new Point(0, -40));
                Renderer.Draw("title1.png", new Point(0, -40));
                RenderMenu(Renderer);
            }
            else
            {
                Renderer.Draw("title2.png", new Point(0, -40), 127);
                Renderer.Draw("title1.png", new Point(0, -40), 127);
                Renderer.DrawText("Ranking not found...", new Point(),
                    new Color(255, 255, 255));
            }
        }
Esempio n. 4
0
        public void Update(Input input, bool canShot)
        {
            base.Update();
            if (Life <= 0)
                return;
            byte direction;
            if (_firstTime)
            {
                direction = input.Direction;
                _firstTime = false;
            }
            else
            {
                direction = input.DirectionToggled ? input.Direction : (byte)0;
            }
            bool shot = input.ShotToggled && input.Shot;

            if (direction > 0)
                Direction = new Direction8(direction);
            if (_reloadTime == 0)
            {
                if (canShot && shot)
                {
                    Shot(this, EventArgs.Empty);
                    ShotCount++;
                    _reloadTime = 8;
                }
            }
            else
            {
                _reloadTime--;
            }

            switch (Direction.Value)
            {
                case 7:
                case 4:
                case 1:
                    _point.X -= Speed;
                    break;
                case 9:
                case 6:
                case 3:
                    _point.X += Speed;
                    break;
            }
            switch (Direction.Value)
            {
                case 7:
                case 8:
                case 9:
                    _point.Y -= Speed;
                    break;
                case 1:
                case 2:
                case 3:
                    _point.Y += Speed;
                    break;
            }
            if (_point.Y < EnemyArea)
                _point.Y = EnemyArea;
            if (_point.Y >= Point.Height - SafeArea)
                _point.Y = Point.Height - SafeArea - 1;
            if (_point.X >= Point.Width - SafeArea)
                _point.X = Point.Width - SafeArea - 1;
            if (_point.X < SafeArea)
                _point.X = SafeArea;
        }
Esempio n. 5
0
 public void Update(Input input)
 {
     Player.Update(input, _playerShots.Count < 7);
     if (_random.Next(50) == 0)
     {
         var list = _enemies
             .Where(x => x.State == Enemy.MovingState.Group)
             .Where(x => x.Life > 0).ToArray();
         if (list.Length > 0)
             list.ElementAt(_random.Next(list.Length)).Go();
     }
     foreach (Enemy enemy in _enemies)
     {
         enemy.Update(_player.Point);
     }
     foreach (Shot shot in _playerShots.ToArray())
     {
         shot.Update(_player.Point);
         if (IsOutOfStage(shot))
         {
             _playerShots.Remove(shot);
             continue;
         }
         Enemy hitEnemy = _enemies.FirstOrDefault(x => x.HitTest(shot.Point));
         if (hitEnemy == null)
             continue;
         hitEnemy.Damage();
         _playerShots.Remove(shot);
     }
     foreach (Shot shot in _shots.ToArray())
     {
         shot.Update(_player.Point);
         if (IsOutOfStage(shot))
         {
             _shots.Remove(shot);
             continue;
         }
         if (!_player.HitTest(shot.Point))
             continue;
         _player.Damage();
         _shots.Remove(shot);
     }
     if (_enemies.Any(_player.HitTest))
     {
         _player.Damage();
     }
 }
Esempio n. 6
0
        public void Update(Input input)
        {
            if (Time <= TimeSpan.FromTicks(0))
            {
                Time = TimeSpan.FromTicks(0);
                if (input.TweetToggled && input.Tweet)
                {
                    var text =
                        (_isEx ? "SCARLEX'13 EXTRA" : "SCARLEX'13")
                        + " Score: " + Score
                        + " Level: " + (_allClear ? "★" : "" + StageNo)
                        + " Ratio: " + TotalHitRatioPercent
                        + "% Miss: " + MissCount;
                    Process.Start("https://twitter.com/intent/tweet?text=" + Uri.EscapeUriString(text) + "&hashtags=scarlex13");
                }
                return;
            }
            if (_newWorld)
            {
                CreateWorld();
                _newWorld = false;
            }

            if ( /* ポーズ状態 */ false)
            {
                return;
            }

            if (!Cleared)
            {
                // 1フレームの時間は17ms, 17ms, 16ms
                if (_secondTimeKeeper < 2)
                {
                    Time -= TimeSpan.FromMilliseconds(17);
                }
                else
                {
                    Time -= TimeSpan.FromMilliseconds(16);
                    _secondTimeKeeper = 0;
                }

                World.Update(input);
                if (!Failed)
                    return;
            }
            _intervalFrame++;
            if (Cleared && _intervalFrame > ClearedTime)
            {
                if (StageNo == _stageFactory.LastStage)
                {
                    _allClear = true;
                    new File().SaveExFlag();
                }
                else
                    StageNo++;
                _newWorld = true;
                return;
            }
            if (Failed && _intervalFrame > FailedTime)
            {
                MissCount++;
                Time -= TimeSpan.FromSeconds(10);
                _newWorld = true;
                return;
            }
        }