コード例 #1
0
        /// <summary>
        /// Loads the textures
        /// </summary>
        /// <param name="game">Game with content manager</param>
        public static void Load(SiegeGame game)
        {
            menuBackground = new Graphic("Backgrounds/menu_screen", game);
            gameBackground = new Graphic("Backgrounds/game_screen", game);

            defencePanelUI   = new Graphic("UI/Panels/defence_panel", game);
            pauseMenuPanelUI = new Graphic("UI/Panels/pausemenu_panel", game);
            endGamePanelUI   = new Graphic("UI/Panels/endgame_panel", game);

            blankButtonUI = new Graphic("UI/Buttons/blankButton", game);

            emptyTile = new Graphic("Tile/empty_tile", game);
            spawnTile = new Graphic("Tile/null_tile", game);

            crownDef     = new Graphic("Tile/Defence/crown_defence", game);
            stoneWallDef = new Graphic("Tile/Defence/stone_wall_defence", game);
            guardDef     = new Graphic("Tile/Defence/guard_defence", game);
            archerDef    = new Graphic("Tile/Defence/archer_defence", game);
            catapultDef  = new Graphic("Tile/Defence/catapult_defence", game);

            peasantEnemy_Left  = new Graphic("Enemies/peasant_enemy_left", game);
            peasantEnemy_Right = new Graphic("Enemies/peasant_enemy_right", game);
            //testAnimation = new Animation(new String[] { "Enemies/Left", "Enemies/Right" }, game);

            shieldEnemy_Left  = new Graphic("Enemies/shield_enemy_left", game);
            shieldEnemy_Right = new Graphic("Enemies/shield_enemy_right", game);


            arial16 = new Font("Fonts/default16", game);
            arial24 = new Font("Fonts/default24", game);
            arial32 = new Font("Fonts/default32", game);
        }
コード例 #2
0
        public GameScreen gameScreen;  //Instance of the game screen

        public ScreenManager(GraphicsDevice gd, SiegeGame game)
        {
            menuScreen = new MenuScreen(game); //Creates new instance of the menu screen
            gameScreen = new GameScreen(game); //Creates new instance of the game screen

            currentScreen = Screens.MAIN_MENU; //Sets the current screen to the menu
        }
コード例 #3
0
ファイル: World.cs プロジェクト: JWBentley/Siege-On-Windsor
        public World(SiegeGame game, string[] setup)
        {
            this.Game    = game;               //Sets game
            this.Enemies = new List <Enemy>(); //New list of enemies

            string[] worldSetup = setup[0].Split(',');

            if (worldSetup.Length == 4)
            {
                this.WaveController = new WaveController(this)
                {
                    WaveNumber = int.Parse(worldSetup[0])
                };

                //Money
                this.Money = int.Parse(worldSetup[1]);

                //Grid size
                worldSetup[2] = worldSetup[2].Trim(new Char[] { '[', ']' });
                this.CreateGrid(int.Parse(worldSetup[2].Substring(0, worldSetup[2].IndexOf("|"))), int.Parse(worldSetup[2].Remove(0, worldSetup[2].IndexOf("|") + 1)));

                //Total kills
                this.TotalKills = int.Parse(worldSetup[3]);
            }

            for (int i = 1; i < setup.Length; i++)
            {
                List <string> defenceInfo = new List <string>(setup[i].Split(','));

                if (defenceInfo[0] == new CrownDef().GetType().ToString())
                {
                    this.GetTileAt(this.GetCrownLocation()).Defence.Health = int.Parse(defenceInfo[2]);
                }
                else
                {
                    foreach (Defence d in Defence.Types)
                    {
                        if (defenceInfo[0] == d.GetType().ToString())
                        {
                            Defence defence = (Defence)Activator.CreateInstance(d.GetType());
                            defenceInfo[1] = defenceInfo[1].Trim(new Char[] { '[', ']' });
                            this.GetTileAt(int.Parse(defenceInfo[1].Substring(0, defenceInfo[1].IndexOf("|"))), int.Parse(defenceInfo[1].Remove(0, defenceInfo[1].IndexOf("|") + 1))).SetDefence(defence);
                            defenceInfo.RemoveRange(0, 2);
                            defence.LoadData(defenceInfo.ToArray());
                        }
                    }
                }
            }

            this.UpdateRiskMap(); //Updates the risk map


            //Testing def panel
            //this.defenceSelectPanel = new DefenceSelectPanel(this, new Rectangle(0, 0, 202, 390), new List<Defence>() { new StoneWallDef(), new GuardDef(), new DummyDef(Graphics.Graphics.archerDef), new DummyDef(Graphics.Graphics.catapultDef) });
            this.IsRunning = true;
            this.isPaused  = false;
        }
コード例 #4
0
 public GameScreen(SiegeGame game) : base(game)
 {
     this.game  = game;                 //Sets the game
     this.world = new World(this.game); //Creates a new world
 }
コード例 #5
0
ファイル: Screen.cs プロジェクト: JWBentley/Siege-On-Windsor
        protected UIController uiController; //Controller for all UI elements

        public Screen(SiegeGame g)
        {
            this.game         = g;
            this.spriteBatch  = new SpriteBatch(this.game.GraphicsDevice); //Creates sprite batch
            this.uiController = new UIController(this.game.Graphics.PreferredBackBufferWidth, this.game.Graphics.PreferredBackBufferHeight, this.spriteBatch);
        }
コード例 #6
0
ファイル: World.cs プロジェクト: JWBentley/Siege-On-Windsor
        //Testing for playing the game
        //public Vector2 SelectedTile; //Testing placing
        //KeyboardState prevState = Keyboard.GetState();
        //public Button spawnEnemy;
        //public Button buildWall;
        //public Button deployGuard;

        //public DefenceSelectPanel defenceSelectPanel; //Testing atm

        public World(SiegeGame g)
        {
            this.Game    = g;                  //Sets game
            this.Enemies = new List <Enemy>(); //New list of enemies
            this.CreateGrid(17, 17);           //Creates grid of size 17x17
            this.Money = 0;

            //this.GetTileAt(9, 8).AddDefence(new GuardDef());
            //this.GetTileAt(8, 9).AddDefence(new GuardDef());
            //this.GetTileAt(8, 7).AddDefence(new GuardDef());
            //this.GetTileAt(7, 8).AddDefence(new GuardDef());


            this.UpdateRiskMap();                           //Updates the risk map

            this.WaveController = new WaveController(this); //Instanciates

            //TESTING of spawning enemies
            //((SpawnTile)this.GetTileAt(16, 16)).SpawnEnemy(new PeasantEnemy(this), this.GetCrownLocation());
            //((SpawnTile)this.GetTileAt(16, 4)).SpawnEnemy(new PeasantEnemy(this), this.GetCrownLocation());
            //((SpawnTile)this.GetTileAt(0,0)).SpawnEnemy(new PeasantEnemy(this), this.GetCrownLocation());
            //((SpawnTile)this.GetTileAt(16, 16)).SpawnEnemy(new PeasantEnemy(this), this.GetCrownLocation());
            //((SpawnTile)this.GetTileAt(7, 9)).SpawnEnemy(new PeasantEnemy(this), this.GetCrownLocation());
            //((SpawnTile)this.GetTileAt(18, 19)).SpawnEnemy(new PeasantEnemy(this), this.GetCrownLocation());

            /*
             * //TESTING - Creates buttons for placing: peasants, walls and guards
             * //this.SelectedTile = new Vector2(0, 0);
             * //this.spawnEnemy = new Button(this.Game.Content.Load<Texture2D>("UI/Buttons/blankButton"), this.Game.Content.Load<SpriteFont>("Fonts/default32"))
             * //{
             * //    Position = new Vector2(970, 300),
             * //   Text = "Spawn Enemy"
             * };
             *
             * this.spawnEnemy.Click += (o, i) => { if(this.GetTileAt(this.SelectedTile) is SpawnTile)
             *      ((SpawnTile)this.GetTileAt(this.SelectedTile)).SpawnEnemy(new PeasantEnemy(this), this.GetCrownLocation()); }; //Spawns enemy on selected tile
             *
             * this.buildWall = new Button(this.Game.Content.Load<Texture2D>("UI/Buttons/blankButton"), this.Game.Content.Load<SpriteFont>("Fonts/default32"))
             * {
             *  Position = new Vector2(970, 400),
             *  Text = "Build Wall"
             * };
             *
             * this.buildWall.Click += (o, i) => { if (!(this.GetTileAt(this.SelectedTile) is SpawnTile) && this.GetTileAt(this.SelectedTile).Defence == null)
             *      this.GetTileAt(this.SelectedTile).AddDefence(new StoneWallDef()); }; //Places wall
             *
             * this.deployGuard = new Button(this.Game.Content.Load<Texture2D>("UI/Buttons/blankButton"), this.Game.Content.Load<SpriteFont>("Fonts/default32"))
             * {
             *  Position = new Vector2(970, 500),
             *  Text = "Deploy Guard"
             * };
             *
             * this.deployGuard.Click += (o, i) => { if (!(this.GetTileAt(this.SelectedTile) is SpawnTile) && this.GetTileAt(this.SelectedTile).Defence == null)
             *      this.GetTileAt(this.SelectedTile).AddDefence(new GuardDef()); }; //Places guard
             */

            //Testing def panel
            //this.defenceSelectPanel = new DefenceSelectPanel(this, new Rectangle(0, 0, 202, 390), new List<Defence>() { new StoneWallDef(), new GuardDef(), new DummyDef(Graphics.Graphics.archerDef), new DummyDef(Graphics.Graphics.catapultDef) });
            this.IsRunning = true;
            this.isPaused  = false;

            //Adds starting money
            this.AddMoney(3000);
            this.TotalKills = 0;
        }
コード例 #7
0
 public Visual(String s, SiegeGame game)
 {
     this.Name = s;
     //game.LoadBuffer.Add(this); //Calls for the game to load the image from the string ref
     this.Object = game.Content.Load <T>(this.Name);
 }
コード例 #8
0
 public Font(string s, SiegeGame game) : base(s, game)
 {
 }
コード例 #9
0
 public Graphic(string s, SiegeGame game) : base(s, game)
 {
 }
コード例 #10
0
 public MenuScreen(SiegeGame game) : base(game)
 {
 }