예제 #1
0
        public ProjectileHitTestResult HitTest(PlayerMissile playerMissile)
        {
            if (playerMissile.Row != _row)
            {
                return(new ProjectileHitTestResult());
            }

            // Adjust the missile's column to take into account the rotation of the force field.
            var adjCol = playerMissile.Col + _rotateStart;

            if (adjCol >= SpeccyEngine.ScreenCols)
            {
                adjCol = adjCol - SpeccyEngine.ScreenCols;
            }

            switch (_forceField[adjCol])
            {
            case BlockStrength.Unbreakable:
                return(new ProjectileHitTestResult {
                    ProjectileStopped = true
                });

            case BlockStrength.Normal:
                _forceField[adjCol] = BlockStrength.Missing;
                return(new ProjectileHitTestResult {
                    ProjectileStopped = true, Score = 10
                });

            default:
                return(new ProjectileHitTestResult());
            }
        }
예제 #2
0
        public void Draw()
        {
            _speccy.Print(_row, Col - 1, "   ");

            // Handle keypress (remember the "ship" is three characters wide).
            if (_speccy.LastKeyPress == Key.Left && Col > 1)
            {
                Col--;
            }
            else if (_speccy.LastKeyPress == Key.Right && Col < 58)
            {
                Col++;
            }
            else if (_speccy.LastKeyPress == Key.Space && Missile == null)
            {
                // Launch a new missile if there isn't already one in flight.
                Missile = new PlayerMissile(_speccy, _row, Col);
            }

            _speccy.Pen = Colors.Cyan;
            _speccy.Print(_row, Col - 1, "¬J¬K¬I");

            Missile?.Draw();
            if (Missile?.Row == -1)
            {
                Missile = null;
            }
        }
예제 #3
0
        public ProjectileHitTestResult HitTest(PlayerMissile playerMissile)
        {
            var rowAdj = playerMissile.Row - _firstRow;

            if (rowAdj < 0 || rowAdj >= _blockData.GetLength(0))
            {
                return(new ProjectileHitTestResult());
            }

            switch (_blockData[rowAdj, playerMissile.Col])
            {
            case BlockTypes.Solid:
                _blockData[rowAdj, playerMissile.Col] = BlockTypes.Broken;
                return(new ProjectileHitTestResult {
                    ProjectileStopped = true, Score = 10
                });

            case BlockTypes.Broken:
                _blockData[rowAdj, playerMissile.Col] = BlockTypes.Missing;
                return(new ProjectileHitTestResult {
                    ProjectileStopped = true, Score = 10
                });

            case BlockTypes.Reactor:
                return(new ProjectileHitTestResult {
                    ProjectileStopped = true, HitEnemyReactor = true, Score = 100
                });

            default:
                return(new ProjectileHitTestResult());
            }
        }
예제 #4
0
 public void StopMissile()
 {
     Missile = null;
 }