예제 #1
0
        public Level(Input input, TextureManager textureManager, PersistantGameData gameData)
        {
            _input = input;
            _gameData = gameData;
            _textureManager = textureManager;
            _effectsManager = new EffectsManager(_textureManager);
            _playerCharacter = new PlayerCharacter(_textureManager, _bulletManager);

            // -1300 is bad for two reasons
            // 1. It's a magic number in the middle of the code
            // 2. It's based on the size of the form but doesn't directly reference the size of the form
            // this means duplication and two places to edit the code if the form size changes.
            // The form size and the enemy manager play area size should both get their value
            // from one central place.
            _enemyManager = new EnemyManager(_textureManager, _effectsManager, _bulletManager, _playerCharacter, -1300);


            _background = new ScrollingBackground(textureManager.Get("background"));
            _background.SetScale(2, 2);
            _background.Speed = 0.15f;

            _backgroundLayer = new ScrollingBackground(textureManager.Get("background_layer_1"));
            _backgroundLayer.Speed = 0.1f;
            _backgroundLayer.SetScale(2.0, 2.0);

           
        }
        public SplashScreenState(StateSystem system, TextureManager textureManager, Engine.Font titleFont, SoundManager soundManager)
        {
            _system = system;

            //sound
            _soundManager = soundManager;
            _soundManager.MasterVolume(0.01f);

            //title font
            _title = new Text("Immune Cells vs. Invaders", titleFont);
            _title.SetColor(new Color(0, 0, 0, 1));
            _title.SetPosition(-_title.Width / 2, 300);

            // good guys
            _character1.Texture = textureManager.Get("phagocyte");
            _character1.SetScale(2, 2);
            _character1.SetPosition(-150, 100);

            //bad guys
            _invader1.Texture = textureManager.Get("tatoo_dye");
            _invader1.SetScale(2, 2);
            _invader1.SetPosition(200, 100);

            _invader2.Texture = textureManager.Get("parasite");
            _invader2.SetScale(2, 2);
            _invader2.SetPosition(200, 0);

               // _soundManager.PlaySound("intro_music");
        }
예제 #3
0
        public EnemyManager(TextureManager textureManager, EffectsManager effectsManager, int leftBound)
        {
            _textureManager = textureManager;
            _effectsManager = effectsManager;
            _leftBound = leftBound;

            _textureManager = textureManager;
            _effectsManager = effectsManager;
            _leftBound = leftBound;

            _upComingEnemies.Add(new EnemyDef("cannon_fodder", 30));
            _upComingEnemies.Add(new EnemyDef("cannon_fodder", 29.5));
            _upComingEnemies.Add(new EnemyDef("cannon_fodder", 29));
            _upComingEnemies.Add(new EnemyDef("cannon_fodder", 28.5));

            _upComingEnemies.Add(new EnemyDef("cannon_fodder", 25));
            _upComingEnemies.Add(new EnemyDef("cannon_fodder", 24.5));
            _upComingEnemies.Add(new EnemyDef("cannon_fodder", 24));
            _upComingEnemies.Add(new EnemyDef("cannon_fodder", 23.5));

            _upComingEnemies.Add(new EnemyDef("cannon_fodder", 20));
            _upComingEnemies.Add(new EnemyDef("cannon_fodder", 19.5));
            _upComingEnemies.Add(new EnemyDef("cannon_fodder", 19));
            _upComingEnemies.Add(new EnemyDef("cannon_fodder", 18.5));


            // Sort enemies so the greater launch time appears first.
            _upComingEnemies.Sort(delegate(EnemyDef firstEnemy, EnemyDef secondEnemy)
            {
                return firstEnemy.LaunchTime.CompareTo(secondEnemy.LaunchTime);

            });

        }
예제 #4
0
 internal static void Save(string path, Scene scene, TextureManager textureManager)
 {
     // Create a big string as the xml data 
     StringBuilder saveData = new StringBuilder();
     saveData.AppendLine("<gamedata>");
     {
         // Save the texture data (at some point associate with scene / when used)
         saveData.AppendLine("\t<texturedata>");
         {
             foreach (var textureEntry in textureManager)
             {
                 saveData.AppendFormat("\t\t<entry key=\"{0}\" value=\"{1}\" />\n",
                     textureEntry.Key, textureEntry.Value.Path);
             }
         }
         saveData.AppendLine("\t</texturedata>");
         // Save the scene
         saveData.AppendLine("\t<scenedata>");
         {
             // there's only one scene
             SaveScene(scene, 2, saveData);
         }
         saveData.AppendLine("\t</scenedata>");
     }
     saveData.AppendLine("</gamedata>");
     System.IO.File.WriteAllText(path, saveData.ToString());
 }
예제 #5
0
     public Enemy(TextureManager textureManager)
 {
     _sprite.Texture = textureManager.Get("enemy_ship");
     _sprite.SetScale(_scale, _scale);
     _sprite.SetRotation(Math.PI); // make it face the player
     _sprite.SetPosition(200, 0); // put it somewhere easy to see
 }
 public PlayerCharacter(TextureManager textureManager, Input input, bool current)
 {
     _input = input;
     _current = current;
     _sprite.Texture = textureManager.Get("phagocyte");
     _sprite.SetScale(_scale, _scale);
 }
예제 #7
0
 public CharacterBoard(TextureManager textureManager)
 {
     _phagocyte.Texture = textureManager.Get("phagocyte");
     //_phagocyte.SetScale(2, 2);
     _phagocyte.SetPosition(0, 325);
        //_phagocyte.SetColor(new Color(1, 1, 1, 0));
 }
예제 #8
0
        public TileMapState(TextureManager textureManager)
        {
            _textureManager = textureManager;
            _tileLookUp = LoadTileDefinitions();

            double currentX = _startX;
            double currentY = _startY;
            int xPosition = 0;
            int yPosition = 0;
            foreach (char c in levelDef)
            {
                if (c == '\n')
                {
                    xPosition = 0;
                    yPosition = yPosition + 1;
                    currentX = _startX;
                    currentY -= _tileWidthHeight;
                    continue;
                }

                Tile t = _tileLookUp[c].CreateTile();
                t.SetPosition(currentX, currentY);
                _tileMap.AddTile(xPosition, yPosition, t);

                xPosition++;
                currentX += _tileWidthHeight;
            }

        }
예제 #9
0
 public Level(Input input, TextureManager textureManager, PersistantGameData gameData)
 {
     _input = input;
     _gameData = gameData;
     _textureManager = textureManager;
     _playerCharacter = new PlayerCharacter(_textureManager);
 }
예제 #10
0
        public PlayerManager(TextureManager textureManager)
        {
            _textureManager = textureManager;

            PlayerCharacter player = new PlayerCharacter(_textureManager, _input, _position);
            _players.Add(player);
        }
예제 #11
0
        public PlayerCharacter(TextureManager textureManager, BulletManager bulletManager)
        {
            _bulletManager = bulletManager;
            _bulletTexture = textureManager.Get("bullet");

            _sprite.Texture = textureManager.Get("player_ship");
            _sprite.SetScale(0.5, 0.5); // spaceship is quite big, scale it down.
        }
예제 #12
0
 public TestWalkState(Input input, ToolStrip toolstrip, Scene scene, TextureManager textureManager)
 {
     _input = input;
     _toolstrip = toolstrip;
     _scene = scene;
     _textureManager = textureManager;
     _playerCharacter = new PlayerCharacter(_textureManager);
 }
예제 #13
0
        double _speed = 512; // pixels per second

        #endregion Fields

        #region Constructors

        public PlayerCharacter(TextureManager textureManager, BulletManager bulletManager)
        {
            _bulletManager = bulletManager;
            _bulletTexture = textureManager.Get("bullet");
            _sprite.Texture = textureManager.Get("player_spaceship");
            _sprite.SetScale(_scale, _scale);
            //_sprite.SetRotation(Math.PI / 2);
        }
        public MultipleTexturesState(TextureManager textureManager)
        {
            _spaceship1.Texture = textureManager.Get("spaceship");
            _spaceship2.Texture = textureManager.Get("spaceship2");

            // Move the first spaceship, so they're not overlapping.
            _spaceship1.SetPosition(-300, 0);
        }
예제 #15
0
 public Block(TextureManager manager, string blockType)
 {
     _sprite.Texture = manager.Get(blockType);
     DropSpeed = 30.0;
     Direction = new Vector(0, -1, 0);
     KeepAlive = true;
     _moveDistance = _sprite.GetWidth();
 }
예제 #16
0
파일: Scoreboard.cs 프로젝트: beamery/bTris
 public Scoreboard(GameData gameData, TextureManager textureManager)
 {
     this.gameData = gameData;
     font = new Font(textureManager.Get("effects_font"), FontParser.Parse("effectsFont.fnt"));
     level = new Text("Level: " + gameData.Level.ToString(), font);
     score = new Text("Score : " + gameData.Score.ToString(), font);
     position = new Point((float)Block.WIDTH * 7, -30);
     UpdateWidth();
 }
예제 #17
0
파일: Block.cs 프로젝트: beamery/bTris
 public Block(TextureManager textureManager, Engine.Color color, int gridPosX, int gridPosY)
 {
     sprite = new Sprite();
     sprite.Texture = textureManager.Get("block");
     sprite.SetScale(0.625, 0.625);
     sprite.SetColor(color);
     this.gridPosX = gridPosX;
     this.gridPosY = gridPosY;
 }
예제 #18
0
 public InnerGameState(StateSystem system, Input input, TextureManager textureManager,
     PersistentGameData gameData)
 {
     _system = system;
     _input = input;
     _textureManager = textureManager;
     _gameData = gameData;
     OnGameStart();
 }
예제 #19
0
        public EnemyManager(TextureManager textureManager, EffectsManager effectsManager, int leftBound)
        {
            _textureManager = textureManager;
            _effectsManager = effectsManager;
            _leftBound = leftBound;

            // Add a test enemy.
            Enemy enemy = new Enemy(_textureManager, _effectsManager);
            _enemies.Add(enemy);
        }
예제 #20
0
        public Enemy(TextureManager textureManager, EffectsManager effectsManager)
        {
            _effectsManager = effectsManager;
            Health = 50; // default health value.

            _sprite.Texture = textureManager.Get("enemy_ship");
            _sprite.SetScale(_scale, _scale);
            _sprite.SetRotation(Math.PI); // make it face the player
            _sprite.SetPosition(200, 0); // put it somewhere easy to see
        }
예제 #21
0
        public TetrominoManager(Level level, TextureManager textureManager, GameData gameData)
        {
            this.level = level;
            this.textureManager = textureManager;
            this.gameData = gameData;

            holdArea = new HoldArea(level, this, textureManager);
            positionChanged = false;
            minoQueue = new MinoQueue(this, level, textureManager);
        }
예제 #22
0
 public InnerGameState(StateSystem system, Input input, TextureManager textureManager,
                         PersistantGameData gameData, Font generalFont)
 {
     _textureManager = textureManager;
     _input = input;
     _system = system;
     _gameData = gameData;
     _generalFont = generalFont;
     OnGameStart();
 }
예제 #23
0
파일: HoldArea.cs 프로젝트: beamery/bTris
 public HoldArea(Level level, TetrominoManager minoManager, TextureManager textureManager)
 {
     this.level = level;
     this.minoManager = minoManager;
     this.textureManager = textureManager;
     position.X = (float)(level.grid[0, 0].X - Block.WIDTH);
     position.Y = (float)(level.grid[0, 0].Y);
     grid = new GridPosition[5, 5];
     InitGrid();
 }
예제 #24
0
 public Block(TextureManager manager, string blockType, Vector scaler, Vector position)
 {
     _sprite.Texture = manager.Get(blockType);
     DropSpeed = 30.0;
     Direction = new Vector(0, -1, 0);
     KeepAlive = true;
     _sprite.SetScale(scaler.X, scaler.Y);
     _sprite.SetPosition(position.X, position.Y);
     _moveDistance = _sprite.GetWidth();
 }
예제 #25
0
        public InnerGameState(Input input, StateSystem stateSystem, TextureManager textureManager,
            GameData gameData, EffectsManager effectsManager)
        {
            this.input = input;
            this.stateSystem = stateSystem;
            this.textureManager = textureManager;
            this.gameData = gameData;
            this.effectsManager = effectsManager;

            OnGameStart();
        }
예제 #26
0
 public PlayerCharacter(TextureManager textureManager, MissileManager missileManager)
 {
     _missileManager = missileManager;
     _missileTexture = textureManager.Get("heart_missile");
     Sprite.Texture = textureManager.Get("pixela_down");
     _upTexture = textureManager.Get("pixela_up");
     _downTexture = textureManager.Get("pixela_down");
     _leftTexture = textureManager.Get("pixela_left");
     _rightTexture = textureManager.Get("pixela_right");
     Sprite.SetScale(Scale, Scale);
     Health = 20;
 }
예제 #27
0
 public BlockManager(TextureManager manager, double rightSide, double topSide, Vector scaleVector)
 {
     _textureManager = manager;
     _scalingVector = scaleVector;
     _currentBlock = new Block(_textureManager, "pickle_block", _scalingVector);
     _blockHeight = _currentBlock.GetHeight();
     _blockWidth = _currentBlock.GetWidth();
     _previewBottomBound = (topSide / 2) - _blockHeight * 6;
     _previewLeftBound = (rightSide / 2) - _blockWidth * 5;
     _previewTetro = new Tetromino();
     _currentTetro = new Tetromino();
     _shadowTetro = new Tetromino();
 }
예제 #28
0
파일: MinoQueue.cs 프로젝트: beamery/bTris
        public MinoQueue(TetrominoManager minoManager, Level level, TextureManager textureManager)
        {
            this.minoManager = minoManager;
            this.level = level;
            this.textureManager = textureManager;

            CreateNewMinoList();
            AddMino();
            AddMino();
            AddMino();

            position = new Point(leftEdge, topEdge);
            blockPointer = position;
        }
예제 #29
0
파일: Enemy.cs 프로젝트: Drahkir/Shooter
 public Enemy(TextureManager textureManager, EffectsManager effectsManager, BulletManager bulletManager)
 {
     Health = 50;
     _sprite.Texture = textureManager.Get("enemy_ship");
     _sprite.SetScale(_scale, _scale);
     _sprite.SetRotation(Math.PI);
     _sprite.SetPosition(200, 0);
     _effectsManager = effectsManager;
     _bulletManager = bulletManager;
     _bulletTexture = textureManager.Get("bullet");
     MaxTimeToShoot = 12;
     MinTimeToShoot = 1;
     RestartShootCountDown();
 }
예제 #30
0
        public EnemyManager(TextureManager textureManager, EffectsManager effectsManager, BulletManager bulletManager, PlayerCharacter playerCharacter, int leftBound)
        {
            _playerCharacter = playerCharacter;
            _bulletManager = bulletManager;
            _textureManager = textureManager;
            _effectsManager = effectsManager;
            _leftBound = leftBound;

            _upComingEnemies.Add(new EnemyDef("cannon_fodder", 30));
            _upComingEnemies.Add(new EnemyDef("cannon_fodder", 29.5));
            _upComingEnemies.Add(new EnemyDef("cannon_fodder", 29));
            _upComingEnemies.Add(new EnemyDef("cannon_fodder", 28.5));

            _upComingEnemies.Add(new EnemyDef("cannon_fodder_low", 30));
            _upComingEnemies.Add(new EnemyDef("cannon_fodder_low", 29.5));
            _upComingEnemies.Add(new EnemyDef("cannon_fodder_low", 29));
            _upComingEnemies.Add(new EnemyDef("cannon_fodder_low", 28.5));

            _upComingEnemies.Add(new EnemyDef("cannon_fodder", 25));
            _upComingEnemies.Add(new EnemyDef("cannon_fodder", 24.5));
            _upComingEnemies.Add(new EnemyDef("cannon_fodder", 24));
            _upComingEnemies.Add(new EnemyDef("cannon_fodder", 23.5));

            _upComingEnemies.Add(new EnemyDef("cannon_fodder_low", 20));
            _upComingEnemies.Add(new EnemyDef("cannon_fodder_low", 19.5));
            _upComingEnemies.Add(new EnemyDef("cannon_fodder_low", 19));
            _upComingEnemies.Add(new EnemyDef("cannon_fodder_low", 18.5));

            _upComingEnemies.Add(new EnemyDef("cannon_fodder_straight", 16));
            _upComingEnemies.Add(new EnemyDef("cannon_fodder_straight", 15.8));
            _upComingEnemies.Add(new EnemyDef("cannon_fodder_straight", 15.6));
            _upComingEnemies.Add(new EnemyDef("cannon_fodder_straight", 15.4));


            _upComingEnemies.Add(new EnemyDef("up_l", 10));
            _upComingEnemies.Add(new EnemyDef("down_l", 9));
            _upComingEnemies.Add(new EnemyDef("up_l", 8));
            _upComingEnemies.Add(new EnemyDef("down_l", 7));
            _upComingEnemies.Add(new EnemyDef("up_l", 6));



            // Sort enemies so the greater launch time appears first.
            _upComingEnemies.Sort(delegate(EnemyDef firstEnemy, EnemyDef secondEnemy)
            {
                return firstEnemy.LaunchTime.CompareTo(secondEnemy.LaunchTime);

            });

        }
예제 #31
0
        /// <summary>
        /// Create a font object from a .fnt file (and associated textures)
        /// </summary>
        /// <param name="path">Path to the .fnt file.</param>
        /// <param name="textureManager">Texture manager to load font textures</param>
        /// <returns>Font as described by the .fnt file.</returns>
        public static Font CreateFont(string path, TextureManager textureManager)
        {
            List <Texture>                   _texturePages  = new List <Texture>();
            Dictionary <KernKey, int>        kernDictionary = new Dictionary <KernKey, int>();
            Dictionary <char, CharacterData> charDictionary = new Dictionary <char, CharacterData>();

            string[] lines = File.ReadAllLines(path);

            int texturePageInfo = HeaderSize;

            while (lines[texturePageInfo].StartsWith("page"))
            {
                string   line           = lines[texturePageInfo];
                string[] typesAndValues = line.Split(" ".ToCharArray(),
                                                     StringSplitOptions.RemoveEmptyEntries);
                string textureString = GetTextValue(typesAndValues[2]).Trim('"');
                string textureId     = Path.GetFileNameWithoutExtension(textureString);

                if (textureManager.Exists(textureId))
                {
                    // Really textures should never be loaded twice so it's worth warning the user
                    Console.Error.WriteLine("WARNING: Tried to load a texture that had been already been loaded. "
                                            + "[" + textureString + "] when loading font [" + path + "]");
                }
                else
                {
                    // Assume texture files are in the same path as the .fnt file.
                    string directory = Path.GetDirectoryName(path);
                    if (string.IsNullOrEmpty(directory) == false)
                    {
                        directory += "\\";
                    }
                    textureManager.LoadTexture(textureId, directory + textureString);
                }

                _texturePages.Add(textureManager.Get(textureId));

                texturePageInfo++;
            }

            texturePageInfo++; // jump over number of characters data.

            for (int i = texturePageInfo; i < lines.Length; i += 1)
            {
                string   line           = lines[i];
                string[] typesAndValues = line.Split(" ".ToCharArray(),
                                                     StringSplitOptions.RemoveEmptyEntries);

                // Some fonts have kerning data at the end
                if (line.StartsWith("kernings"))
                {
                    ParseKernData(i + 1, lines, kernDictionary);
                    break;
                }

                // All the data comes in a certain order,
                // used to make the parser shorter
                CharacterData charData = new CharacterData
                {
                    Id       = GetValue(typesAndValues[1]),
                    X        = GetValue(typesAndValues[2]),
                    Y        = GetValue(typesAndValues[3]),
                    Width    = GetValue(typesAndValues[4]),
                    Height   = GetValue(typesAndValues[5]),
                    XOffset  = GetValue(typesAndValues[6]),
                    YOffset  = GetValue(typesAndValues[7]),
                    XAdvance = GetValue(typesAndValues[8])
                };
                charDictionary.Add((char)charData.Id, charData);
            }

            return(new Font(_texturePages.FirstOrDefault(), charDictionary, kernDictionary));
        }