コード例 #1
0
        public AnimationManager(Player player, GameContent content, SpriteBatch spriteBatch, 
                                RoundManager roundManager, AudioManager audioManager)
        {
            _player = player;
            _roundManager = roundManager;
            _spriteBatch = spriteBatch;
            _audioManager = audioManager;

            _charTex = content.Luigi;
            _lift = content.Lift;
            _font = content.GameFont;
            _bridge = content.Bridge;
            _lineTex = content.LineTexture;

            SetPlayerRectanglesAndColor();

            _textPosition = new Vector2();

            _liftRect1 = new Rectangle(1148, 528, 90, 20);
            _liftRect2 = new Rectangle(43, 400, 90, 20);
            _liftRect3 = new Rectangle(1148, 270, 90, 20);

            _lineRect1 = new Rectangle();
            _lineRect2 = new Rectangle();
            _lineRect3 = new Rectangle();

            CreateAndUpdateAnimationStates();
            this.AnimationIsCompleted = true;
            _charOrigin = new Vector2();

            _bridge1Rect = new Rectangle(309, 392, 30, 30);
            _bridge2Rect = new Rectangle(869, 263, 30, 30);
        }
コード例 #2
0
        public Player(Vector2 scorePosition, int playerNumber, GameContent content,
                      Point gunCasePos, int viewWidth, int viewHeight, SpriteBatch sb, FlyingObjectManager flyingObjMgr,
                      AudioManager audioManager)
        {
            _scoreTextPosition = scorePosition;
            _playerName = "Player " + playerNumber.ToString();
            _playerNumber = playerNumber;
            _font = content.GameFont;
            _spriteBatch = sb;
            _gun = CreateGun(content, gunCasePos, viewWidth, viewHeight, flyingObjMgr, audioManager);

            _bridgeTex = content.Bridge;
            _bridgeRect = new Rectangle((int)_scoreTextPosition.X + 140, (int)_scoreTextPosition.Y, 40, 20);
        }
コード例 #3
0
        public FlyingObjectManager(TargetBuildHelper targetBuildHelper, SpriteBatch sb, 
                                    Texture2D particle, int viewWidth, int viewHeight, AudioManager audioManager)
        {
            _bulletList = new List<Bullet>();
            _targetList = new List<TargetObject>();
            _bulletsToRemove = new List<Bullet>();
            _targetsToRemove = new List<TargetObject>();
            _explosionList = new List<Explosion>();
            _explosionToRemove = new List<Explosion>();

            _targetBuildHelper = targetBuildHelper;
            _spriteBatch = sb;
            _particle = particle;
            _viewWidth = viewWidth;
            _viewHeight = viewHeight;
            _audioManager = audioManager;
        }
コード例 #4
0
        protected override void Initialize()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);
            _isPaused = false;
            _gameContent = new GameContent(Content, GraphicsDevice);
            _audioManager = new AudioManager(_gameContent);

            int ht = _graphics.GraphicsDevice.Viewport.Height;
            int wt = _graphics.GraphicsDevice.Viewport.Width;

            float heightRatio = HEIGHT / (float)ht;
            float widthRatio = WIDTH / (float)wt;

            _backgroundRect = new Rectangle(0, 0, wt, ht);
            TargetBuildHelper targetHelper = new TargetBuildHelper(_gameContent, wt, ht, _spriteBatch);
            _flyingObjManager = new FlyingObjectManager(targetHelper, _spriteBatch, _gameContent.Particle, wt, ht, _audioManager);

            int gunCaseX = (int)(350 * widthRatio);
            int gunCaseY = (int)(600 * heightRatio); //black line is at 630
            _gunCaseLeftRect = new Rectangle(gunCaseX, gunCaseY, 60, 30);
            _gunCaseRightRect = new Rectangle(wt - gunCaseX - 60, gunCaseY, 60, 30);

            _player1 = new Player(new Vector2(10, ht - 50), 1, _gameContent, new Point(gunCaseX, gunCaseY), wt, ht, _spriteBatch, _flyingObjManager, _audioManager);
            _player2 = new Player(new Vector2(wt - 190, ht - 50), 2, _gameContent, new Point(wt - gunCaseX - 60, gunCaseY), wt, ht, _spriteBatch, _flyingObjManager, _audioManager);

            _roundManager = new RoundManager(new Vector2(wt / 2 - 100, ht - 50), _player1, _player2, _gameContent, _spriteBatch, _flyingObjManager);

            _player1Animation = new AnimationManager(_player1, _gameContent, _spriteBatch, _roundManager, _audioManager);
            _player2Animation = new AnimationManager(_player2, _gameContent, _spriteBatch, _roundManager, _audioManager);

            _centeredPromptRect = new Rectangle(340, 200, 600, 300);
            _winMessage = new Rectangle(520, 570, _gameContent.Player1Won.Width, _gameContent.Player1Won.Height);
            _roundMessage = new Rectangle(520, 570, _gameContent.RoundStarting.Width, _gameContent.RoundStarting.Height);

            _audioManager.StartBackground();
            base.Initialize();
        }
コード例 #5
0
 private Gun CreateGun(GameContent content, Point gunCasePos, int viewWidth, int viewHeight, FlyingObjectManager flyingObjMgr, AudioManager audioManager)
 {
     if (_playerNumber == 1)
     {
         return new Gun(gunCasePos.X, gunCasePos.Y, content, Keys.A, Keys.D, Keys.S, this, viewWidth, viewHeight, _spriteBatch, flyingObjMgr, audioManager);
     }
     else
     {
         return new Gun(gunCasePos.X, gunCasePos.Y, content, Keys.NumPad4, Keys.NumPad6, Keys.NumPad5, this, viewWidth, viewHeight, _spriteBatch, flyingObjMgr, audioManager);
     }
 }