示例#1
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public ShopScreen(Pilot pilot)
 {
     TransitionOnTime = TimeSpan.FromSeconds(0.5);
     TransitionOffTime = TimeSpan.FromSeconds(0.5);
     _controls = new List<Control>();
     _pilot = pilot;
 }
示例#2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public GameScreen(Pilot pilot)
 {
     TransitionOnTime = TimeSpan.FromSeconds(0.5);
     TransitionOffTime = TimeSpan.FromSeconds(0.5);
     _stars = new List<Vector2>();
     _explosions = new List<Explosion>();
     _pilot = pilot;
 }
示例#3
0
        public ShopModules(Texture2D texture, Texture2D texture_buy_off, Texture2D texture_buy_on, SpriteFont font, SpriteFont hintFont, Vector2 position, string text, Pilot pilot)
            : base(position)
        {
            base.Text = text;
            base.Font = font;
            _texture = texture;
            _texture_buy_off = texture_buy_off;
            _texture_buy_on = texture_buy_on;
            _fm = new FileManager();
            _pilot = pilot;
            _bounds = new Rectangle((int)position.X, (int)position.Y, texture.Width, texture.Height);
            _controls = new List<Control>();

            int count = 0;
            foreach (Module module in _pilot.GetModuleListOfShip())
            {
                Module currentModule = _pilot.GetModuleListOfShip()[count];
                ModuleControl _moduleControl = new ModuleControl(
                    _texture_buy_off,
                    _texture_buy_on,
                    new Vector2(base.Position.X + 20, 160 + 140 * count),
                    currentModule);
                _moduleControl.Font = Font;
                _moduleControl.BuyClicked += (sender, args) =>
                {
                    Int32 price = currentModule.Price;
                    if (_pilot.Money >= price && currentModule.size < 3)
                    {
                        _pilot.UpgradeModuleOfShip(currentModule.kind);
                        _pilot.Money -= price;
                    }
                };
                _moduleControl.HintFont = hintFont;
                _controls.Add(_moduleControl);
                count++;
            }
        }
示例#4
0
        /// <summary>
        /// Loads graphics content for this screen. 
        /// </summary>
        public override void LoadContent()
        {
            if(_content == null)
                _content = new ContentManager(ScreenManager.Game.Services, "Content");

            Viewport viewport = ScreenManager.GraphicsDevice.Viewport;
            var fullscreen = new Rectangle(0, 0, viewport.Width, viewport.Height);

            var button_off_bg = _content.Load<Texture2D>("button_off");
            var button_on_bg = _content.Load<Texture2D>("button_on");
            int width = button_off_bg.Width / 2;
            int height = button_off_bg.Height / 2;
            int shift = height * 2 + 10;
            var blank = _content.Load<Texture2D>("blank");
            int topleftX = fullscreen.Center.X - width;
            int topleftY = fullscreen.Center.Y - 100 - height;

            var btn1 = new Controls.Button(button_on_bg, button_off_bg,
                                          new Vector2(
                                            topleftX,
                                            topleftY),
                                          "NEW GAME");
            btn1.Clicked += (sender, args) => {
                Pilot pilot = new Pilot();
                pilot.Init(10.0, 10.0, 172, 54);
                Ship ship = new Ship(172, 54);
                ScreenManager.RemoveScreen(this);
                ScreenManager.AddScreen(new ShopScreen(pilot), ControllingPlayer);
            };
            btn1.Font = _content.Load<SpriteFont>("menufont");
            _controls.Add(btn1);

            var btn2 = new Controls.Button(button_on_bg, button_off_bg,
                                          new Vector2(
                                            topleftX,
                                            topleftY + shift),
                                          "BACK TO MAIN MENU");
            btn2.Clicked += (sender, args) => {
                ScreenManager.RemoveScreen(this);
                ScreenManager.AddScreen(new MainMenu(), ControllingPlayer);
            };
            btn2.Font = _content.Load<SpriteFont>("menufont");
            _controls.Add(btn2);
        }
示例#5
0
 public Game(Pilot pilot)
 {
     _pilot = pilot;
 }
示例#6
0
        public ShopPlayer(Texture2D texture, Texture2D texture_plus_off, Texture2D texture_plus_on, Texture2D texture_minus_off, Texture2D texture_minus_on, SpriteFont font, SpriteFont hintFont, Vector2 position, string text, Pilot pilot)
            : base(position)
        {
            base.Text = text;
            base.Font = font;
            _hintFont = hintFont;
            _texture = texture;
            _pilot = pilot;
            _bounds = new Rectangle((int)position.X, (int)position.Y, texture.Width, texture.Height);
            _texture_plus_off = texture_plus_off;
            _texture_plus_on = texture_plus_on;
            _texture_minus_off = texture_minus_off;
            _texture_minus_on = texture_minus_on;
            _controls = new List<Control>();

            // Damage control.
            StatControl _damageControl = new StatControl(
                _texture_plus_off,
                _texture_plus_on,
                _texture_minus_off,
                _texture_minus_on,
                new Vector2(base.Position.X + 20, 160),
                "DAMAGE",
                _pilot.Damage);
            _damageControl.Font = this.Font;
            _damageControl.HintFont = hintFont;
            _damageControl.BuyPrice = DamagePrice(_pilot.Damage);
            _damageControl.SellPrice = DamagePrice(_pilot.Damage - 1);
            _damageControl.PlusClicked += (sender, args) =>
            {
                int price = DamagePrice(_pilot.Damage);
                if (_pilot.Exp - price >= 0)
                {
                    _pilot.Damage += 1;
                    _damageControl.Value += 1;
                    _pilot.Exp -= price;
                    _damageControl.BuyPrice = DamagePrice(_pilot.Damage);
                    _damageControl.SellPrice = DamagePrice(_pilot.Damage - 1);
                }
            };
            _damageControl.MinusClicked += (sender, args) =>
            {
                int price = DamagePrice(_pilot.Damage - 1);
                if (_pilot.Damage > 1)
                {
                    _pilot.Damage -= 1;
                    _damageControl.Value -= 1;
                    _pilot.Exp += price;
                    _damageControl.BuyPrice = DamagePrice(_pilot.Damage);
                    _damageControl.SellPrice = DamagePrice(_pilot.Damage-1);
                }
            };
            _controls.Add(_damageControl);

            // Health control.
            StatControl _healthControl = new StatControl(
                _texture_plus_off,
                _texture_plus_on,
                _texture_minus_off,
                _texture_minus_on,
                new Vector2(base.Position.X + 20, 240),
                "HEALTH",
                _pilot.Health);
            _healthControl.Font = this.Font;
            _healthControl.HintFont = hintFont;
            _healthControl.BuyPrice = HealthPrice(_pilot.Health);
            _healthControl.SellPrice = HealthPrice(_pilot.Health - 1);
            _healthControl.PlusClicked += (sender, args) =>
            {
                int price = HealthPrice(_pilot.Health);
                if (_pilot.Exp - price >= 0)
                {
                    _pilot.Health += 1;
                    _healthControl.Value += 1;
                    _pilot.Exp -= price;
                    _healthControl.BuyPrice = HealthPrice(_pilot.Health);
                    _healthControl.SellPrice = HealthPrice(_pilot.Health - 1);
                }
            };
            _healthControl.MinusClicked += (sender, args) =>
            {
                int price = HealthPrice(_pilot.Health - 1);
                if (_pilot.Health > 1)
                {
                    _pilot.Health -= 1;
                    _healthControl.Value -= 1;
                    _pilot.Exp += price;
                    _healthControl.BuyPrice = HealthPrice(_pilot.Health);
                    _healthControl.SellPrice = HealthPrice(_pilot.Health - 1);
                }
            };
            _controls.Add(_healthControl);

            // Shield control.
            StatControl _shieldControl = new StatControl(
                _texture_plus_off,
                _texture_plus_on,
                _texture_minus_off,
                _texture_minus_on,
                new Vector2(base.Position.X + 20, 320),
                "SHIELD",
                _pilot.Shield);
            _shieldControl.Font = this.Font;
            _shieldControl.HintFont = hintFont;
            _shieldControl.BuyPrice = ShieldPrice(_pilot.Health);
            _shieldControl.SellPrice = ShieldPrice(_pilot.Shield - 1);
            _shieldControl.PlusClicked += (sender, args) =>
            {
                int price = ShieldPrice(_pilot.Shield);
                if (_pilot.Exp - price >= 0)
                {
                    _pilot.Shield += 1;
                    _shieldControl.Value += 1;
                    _pilot.Exp -= price;
                    _shieldControl.BuyPrice = ShieldPrice(_pilot.Shield);
                    _shieldControl.SellPrice = ShieldPrice(_pilot.Shield - 1);
                }
            };
            _shieldControl.MinusClicked += (sender, args) =>
            {
                int price = ShieldPrice(_pilot.Shield - 1);
                if (_pilot.Shield > 0)
                {
                    _pilot.Shield -= 1;
                    _shieldControl.Value -= 1;
                    _pilot.Exp += price;
                    _shieldControl.BuyPrice = ShieldPrice(_pilot.Shield);
                    _shieldControl.SellPrice = ShieldPrice(_pilot.Shield - 1);
                }
            };
            _controls.Add(_shieldControl);
        }