ResourceID toTextureID(Aircraft.Type type)
        {
            switch(type)
                {
                case Aircraft.Type.Eagle:
                    return ResourceID.Eagle;
                case Aircraft.Type.Raptor:
                    return ResourceID.Raptor;
                default:
                    return 0;
                }

        }
Exemple #2
0
        public World(State.Context context)
        {
            mWindow = context.window;
            mWorldView = mWindow.DefaultView;
            mWorldBounds = new IntRect(0, 0, (int)mWorldView.Size.X, 4000); //have to explcitly cast Size.X from float to int because of cast issues between IntRect and FloatRect later on
            mSpawnPosition = new Vector2f(mWorldView.Size.X / 2, mWorldBounds.Height - mWorldView.Size.Y); //original code is mWorldBounds.Height - mWorldView.Size, but caused error
            mScrollSpeed = -50; //this is not included in book but in source code
            mSceneLayers = new SceneNode[(int)Layer.LayerCount];
            mTextures = context.textures;
            mSceneGraph = new SceneNode();
            mPlayerAircraft = null;
            mCommandQueue = new CommandQueue();
            mEnemySpawnPoints = new List<SpawnPoint>();
            mFonts = context.fonts;

            mWorldView.Center = mSpawnPosition;

            loadTextures();
            buildScene();



        }
Exemple #3
0
 public void addEnemy(Aircraft.Type type, float relX, float relY)
 {
     SpawnPoint spawn = new SpawnPoint(type, mSpawnPosition.X + relX, mSpawnPosition.Y - relY);
     mEnemySpawnPoints.Add(spawn);
 }
Exemple #4
0
        public void spawnEnemies()
        {
            
            while (mEnemySpawnPoints.Count != 0 && mEnemySpawnPoints.Last().y > getBattlefieldBounds().Top)
            {

                SpawnPoint spawn = mEnemySpawnPoints.Last();
                Aircraft enemy = new Aircraft(spawn.type, mTextures, mFonts);
                enemy.Position = new Vector2f(spawn.x, spawn.y);
                enemy.Rotation = 180;
                Console.WriteLine("Spawning Aircraft at:" + enemy.Position);

                mSceneLayers[(int)Layer.Air].attachChild(enemy);

                mEnemySpawnPoints.RemoveAt(mEnemySpawnPoints.Count - 1);//should remove final spawn
            }
        }
Exemple #5
0
        private void buildScene()
        {
            for (int i = 0; i < (int)Layer.LayerCount; i++)
            {
                SceneNode layer = new SceneNode();
                mSceneLayers[i] = layer;

                mSceneGraph.attachChild(layer);


            }

            //background code
            Texture texture = mTextures.get(ResourceID.Desert);
            IntRect textureRect = mWorldBounds;
            texture.Repeated = true;

            SpriteNode backgroundSprite = new SpriteNode(texture, textureRect);

            backgroundSprite.Position = new Vector2f(mWorldBounds.Left, mWorldBounds.Top);
            mSceneLayers[(int)Layer.Background].attachChild(backgroundSprite);

            //AIRPLANES!
            Aircraft leader = new Aircraft(Aircraft.Type.Eagle, mTextures,mFonts);

            mPlayerAircraft = leader;
            mPlayerAircraft.Position = mSpawnPosition;
            mPlayerAircraft.setVelocity(0, mScrollSpeed); //should be mScrolSpeed
            mSceneLayers[(int)Layer.Air].attachChild(leader);

            addEnemies();
        }
Exemple #6
0
 public SpawnPoint(Aircraft.Type type, float x, float y) 
 {
     this.type = type;
     this.x = x;
     this.y = y;
 }