Пример #1
0
 public MiniStatusOverlay(PlayerViewport viewport)
     : base(viewport, HorizontalAlignment.Center, VerticalAlignment.Center)
 {
     _player = viewport.Owner;
     _customAlignmentDampBox = new Rectangle(0, 0, 2, 2);
     CustomAlignment = GetCustomAlignment;
 }
Пример #2
0
        private void DrawPlayerInfoDisplay(Vector2 view, SpriteBatch spriteBatch, Player player)
        {
            var weapon = (Weapon)MenuEngine.Game.DataEngine.GetTypeTemplate(player.Weapon2Name);
            var weaponInfo = weapon.DeviceInfo;
            var device = (ShipDevice)MenuEngine.Game.DataEngine.GetTypeTemplate(player.ExtraDeviceName);
            var deviceInfo = device.DeviceInfo;
            var ship = (Ship)MenuEngine.Game.DataEngine.GetTypeTemplate(player.ShipName);
            var shipInfo = ship.ShipInfo;
            var infoDisplayPos = MenuComponent.Pos - view + new Vector2(570, 191);

            var shipPicture = MenuEngine.Game.Content.Load<Texture2D>(shipInfo.PictureName);
            var shipTitlePicture = MenuEngine.Game.Content.Load<Texture2D>(shipInfo.TitlePictureName);
            var weaponPicture = MenuEngine.Game.Content.Load<Texture2D>(weaponInfo.PictureName);
            var weaponTitlePicture = MenuEngine.Game.Content.Load<Texture2D>(weaponInfo.TitlePictureName);
            var devicePicture = MenuEngine.Game.Content.Load<Texture2D>(deviceInfo.PictureName);
            var deviceTitlePicture = MenuEngine.Game.Content.Load<Texture2D>(deviceInfo.TitlePictureName);

            spriteBatch.Draw(shipPicture, infoDisplayPos, null, Color.White, 0,
                new Vector2(0, 0), 0.6f, SpriteEffects.None, 0);
            spriteBatch.DrawString(Content.FontBig, "Ship", (infoDisplayPos + new Vector2(149, 15)).Round(), Color.White);
            spriteBatch.Draw(shipTitlePicture, infoDisplayPos + new Vector2(140, 37), Color.White);

            spriteBatch.Draw(devicePicture, infoDisplayPos + new Vector2(0, 120), null, Color.White, 0,
                new Vector2(0, 0), 0.6f, SpriteEffects.None, 0);
            spriteBatch.DrawString(Content.FontBig, "Ship Modification", (infoDisplayPos + new Vector2(0, 120) + new Vector2(149, 15)).Round(), Color.White);
            spriteBatch.Draw(deviceTitlePicture, infoDisplayPos + new Vector2(0, 120) + new Vector2(140, 37), Color.White);

            spriteBatch.Draw(weaponPicture, infoDisplayPos + new Vector2(0, 240), null, Color.White, 0,
                new Vector2(0, 0), 0.6f, SpriteEffects.None, 0);
            spriteBatch.DrawString(Content.FontBig, "Special Weapon", (infoDisplayPos + new Vector2(0, 240) + new Vector2(149, 15)).Round(), Color.White);
            spriteBatch.Draw(weaponTitlePicture, infoDisplayPos + new Vector2(0, 240) + new Vector2(140, 37), Color.White);
        }
Пример #3
0
 /// <param name="player">The player whose chat messages to display.</param>
 public CombatLogOverlay(PlayerViewport viewport)
     : base(viewport, HorizontalAlignment.Center, VerticalAlignment.Center)
 {
     CustomAlignment = () => new Vector2(0, 300);
     _player = viewport.Owner;
     _messageBeeper = new MessageBeeper(_player.Game, "PlayerMessage", () => Messages.FirstOrDefault());
 }
Пример #4
0
 /// <summary>
 /// Creates an equipment selector for a player with an empty set of possible values.
 /// Subclasses should set the list of values.
 /// </summary>
 /// <param name="player">The player.</param>
 /// <param name="pos">Top left corner of the selector in menu system coordinates</param>
 protected EquipmentSelector(AssaultWingCore game, Player player, PlayerSettingsItem settings, Vector2 pos)
 {
     Values = new List<string>();
     Game = game;
     Player = player;
     Settings = settings;
     Pos = pos;
 }
Пример #5
0
 public void Setup()
 {
     _player1 = new Player(null, "Player 1", CanonicalString.Null, CanonicalString.Null, CanonicalString.Null, new UI.PlayerControls());
     _player2 = new Player(null, "Player 2", CanonicalString.Null, CanonicalString.Null, CanonicalString.Null, new UI.PlayerControls());
     _arena = new Arena();
     _source = new Gob { ID = 1, Owner = _player1, MaxDamageLevel = 100, Arena = _arena, Pos = Vector2.Zero };
     _hostileGob1 = new Gob { ID = 2, Owner = _player2, MaxDamageLevel = 100, Arena = _arena };
     _hostileGob2 = new Gob { ID = 3, Owner = _player2, MaxDamageLevel = 100, Arena = _arena };
     _neutralGob = new Gob { ID = 4, Owner = null, MaxDamageLevel = 100, Arena = _arena };
     _friendlyGob = new Gob { ID = 5, Owner = _player1, MaxDamageLevel = 100, Arena = _arena };
     _targetSelector = new TargetSelector(700);
 }
Пример #6
0
 public void Setup()
 {
     Spectator.CreateStatsData = spectator => new MockStats();
     _gameplayMode = new GameplayMode(lifeScore: 1, killScore: 4, deathScore: -2, damageCombatPoints: 0, bonusesCombatPoints: 0);
     _team1 = new Team("Avengers", null) { ID = 11 };
     _team2 = new Team("X-Men", null) { ID = 12 };
     _team3 = new Team("Autobots", null) { ID = 13 };
     _team4 = new Team("Decepticons", null) { ID = 14 };
     _player1 = new Player(null, "Player 1", CanonicalString.Null, CanonicalString.Null, CanonicalString.Null, new UI.PlayerControls()) { ID = 1 };
     _player2 = new Player(null, "Player 2", CanonicalString.Null, CanonicalString.Null, CanonicalString.Null, new UI.PlayerControls()) { ID = 2 };
     _player3 = new Player(null, "Player 3", CanonicalString.Null, CanonicalString.Null, CanonicalString.Null, new UI.PlayerControls()) { ID = 3 };
     _player4 = new Player(null, "Player 4", CanonicalString.Null, CanonicalString.Null, CanonicalString.Null, new UI.PlayerControls()) { ID = 4 };
     _player5 = new Player(null, "Player 5", CanonicalString.Null, CanonicalString.Null, CanonicalString.Null, new UI.PlayerControls()) { ID = 5 };
     _player6 = new Player(null, "Player 6", CanonicalString.Null, CanonicalString.Null, CanonicalString.Null, new UI.PlayerControls()) { ID = 6 };
 }
Пример #7
0
 public void Setup()
 {
     CanonicalString.IsForLocalUseOnly = true;
     Spectator.CreateStatsData = spectator => new MockStats();
     _arena = new Arena();
     _ship1 = new Ship((CanonicalString)"Bugger") { Owner = _player1, MaxDamageLevel = 100, Arena = _arena };
     _ship2 = new Ship((CanonicalString)"Bugger") { Owner = _player2, MaxDamageLevel = 100, Arena = _arena };
     _ship3 = new Ship((CanonicalString)"Bugger") { Owner = _player3, MaxDamageLevel = 100, Arena = _arena };
     _avengers = new Team("Avengers", null);
     _xmen = new Team("X-Men", null);
     _player1 = new Player(null, "Player 1", CanonicalString.Null, CanonicalString.Null, CanonicalString.Null, new UI.PlayerControls());
     _player2 = new Player(null, "Player 2", CanonicalString.Null, CanonicalString.Null, CanonicalString.Null, new UI.PlayerControls());
     _player3 = new Player(null, "Player 3", CanonicalString.Null, CanonicalString.Null, CanonicalString.Null, new UI.PlayerControls());
     SeizeShip(_player1, _ship1);
     SeizeShip(_player2, _ship2);
     SeizeShip(_player3, _ship3);
 }
Пример #8
0
 public void Setup()
 {
     Spectator.CreateStatsData = spectator => new MockStats();
     Coroner.ResetPhraseSets();
     _avengers = new Team("Avengers", null);
     _player1 = new Player(null, "Player 1", CanonicalString.Null, CanonicalString.Null, CanonicalString.Null, new UI.PlayerControls());
     _player2 = new Player(null, "Player 2", CanonicalString.Null, CanonicalString.Null, CanonicalString.Null, new UI.PlayerControls());
     _player3 = new Player(null, "Player 3", CanonicalString.Null, CanonicalString.Null, CanonicalString.Null, new UI.PlayerControls());
     _player4 = new Player(null, "Player 4", CanonicalString.Null, CanonicalString.Null, CanonicalString.Null, new UI.PlayerControls());
     _player1.AssignTeam(_avengers);
     _player4.AssignTeam(_avengers);
     _arena = new Arena();
     _gob1 = new Gob { Owner = _player1, MaxDamageLevel = 100, Arena = _arena };
     _gob1DamagedBy2 = new Gob { Owner = _player1, MaxDamageLevel = 100, Arena = _arena };
     _gob2 = new Gob { Owner = _player2, MaxDamageLevel = 100, Arena = _arena };
     _gob2Nature = new Gob { Owner = null };
     _gob4 = new Gob { Owner = _player4, MaxDamageLevel = 100, Arena = _arena };
     _arena.TotalTime = TimeSpan.FromSeconds(10);
     _gob1DamagedBy2.InflictDamage(10, new DamageInfo(_gob2));
 }
Пример #9
0
 /// <param name="player">Which player the viewport will follow.</param>
 /// <param name="onScreen">Where on screen is the viewport located.</param>
 /// <param name="getPostprocessEffectNames">Provider of names of postprocess effects.</param>
 public PlayerViewport(Player player, Rectangle onScreen, Func<IEnumerable<CanonicalString>> getPostprocessEffectNames)
     : base(player.Game, onScreen, getPostprocessEffectNames)
 {
     _player = player;
     _shakeSign = -1;
     _lookAtController = new PIDController2(() => LookAtTarget, () => CurrentLookAt)
     {
         ProportionalGain = 2,
         IntegralGain = 0,
         DerivativeGain = 0,
         OutputMaxAmplitude = 1200,
     };
     AddOverlayComponent(new MiniStatusOverlay(this));
     AddOverlayComponent(new CombatLogOverlay(this));
     AddOverlayComponent(new RadarOverlay(this));
     AddOverlayComponent(new BonusListOverlay(this));
     AddOverlayComponent(new PlayerStatusOverlay(this));
     AddOverlayComponent(new ScoreOverlay(this));
     GobTracker = new GobTrackerOverlay(this);
     AddOverlayComponent(GobTracker);
     foreach (var customOverlayCreator in CustomOverlayCreators) AddOverlayComponent(customOverlayCreator(this));
 }
Пример #10
0
 public void Setup()
 {
     _arena = new Arena();
     _avengers = new Team("Avengers", null);
     _player1 = new Player(null, "Player 1", CanonicalString.Null, CanonicalString.Null, CanonicalString.Null, new UI.PlayerControls());
     _player2 = new Player(null, "Player 2", CanonicalString.Null, CanonicalString.Null, CanonicalString.Null, new UI.PlayerControls());
     _player3 = new Player(null, "Player 3", CanonicalString.Null, CanonicalString.Null, CanonicalString.Null, new UI.PlayerControls());
     _player2.AssignTeam(_avengers);
     _player3.AssignTeam(_avengers);
     _gob1 = new Gob { ID = 10, Owner = _player1, MaxDamageLevel = 100, Arena = _arena };
     _gob1DamagedBy2 = new Gob { ID = 11, Owner = _player1, MaxDamageLevel = 100, Arena = _arena };
     _gob2 = new Gob { ID = 2, Owner = _player2, MaxDamageLevel = 100, Arena = _arena };
     _gob3 = new Gob { ID = 3, Owner = _player3, MaxDamageLevel = 100, Arena = _arena };
     _gobNature = new Gob { ID = 4, Owner = null, MaxDamageLevel = 100, Arena = _arena };
     _info1Hit1 = new DamageInfo(_gob1).Bind(_gob1);
     _info2Hit1 = new DamageInfo(_gob2).Bind(_gob1);
     _info3Hit2 = new DamageInfo(_gob3).Bind(_gob2);
     _infoNatureHit1 = new DamageInfo(_gobNature).Bind(_gob1);
     _arena.TotalTime = TimeSpan.FromSeconds(10);
     _gob1DamagedBy2.InflictDamage(10, new DamageInfo(_gob2));
     _info1DamagedBy2 = DamageInfo.Unspecified.Bind(_gob1DamagedBy2);
 }
Пример #11
0
 public override void Draw3D(Matrix view, Matrix projection, Player viewer)
 {
     var gfx = Game.GraphicsDeviceService.GraphicsDevice;
     gfx.BlendState = AW2.Graphics.GraphicsEngineImpl.AdditiveBlendPremultipliedAlpha;
     var effect = Game.GraphicsEngine.GameContent.LightningEffect;
     effect.Projection = projection;
     effect.View = view;
     effect.Alpha = Alpha;
     effect.Texture = Texture;
     var vertexData = CreateMesh();
     foreach (var pass in effect.CurrentTechnique.Passes)
     {
         pass.Apply();
         gfx.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleStrip, vertexData, 0, vertexData.Length - 2);
     }
 }
Пример #12
0
 private bool IsPlayerNameEditable(Player player)
 {
     return MenuEngine.Game.NetworkMode != NetworkMode.Standalone && !player.GetStats().IsLoggedIn;
 }
Пример #13
0
 public override void Draw2D(Matrix gameToScreen, SpriteBatch spriteBatch, float scale, Player viewer)
 {
     // Draw player name
     if (Owner == null || Owner.IsLocal) return;
     var screenPos = Vector2.Transform(Pos + DrawPosOffset, gameToScreen);
     var playerNameSize = PlayerNameFont.MeasureString(Owner.Name);
     var playerNamePos = new Vector2(screenPos.X - playerNameSize.X / 2, screenPos.Y + 35);
     var nameAlpha = (IsHiding ? Alpha : 1) * 0.8f;
     var nameColor = Color.Multiply(Owner.Color, nameAlpha);
     spriteBatch.DrawString(PlayerNameFont, Owner.Name, playerNamePos.Round(), nameColor);
 }
Пример #14
0
 public void SendMessageToAllPlayers(string text, Player from)
 {
     var messageContent = text.Trim();
     if (messageContent == "") return;
     var preText = from.Name + ">";
     var textColor = from.Color;
     var message = new PlayerMessage(preText, messageContent, textColor);
     switch (NetworkMode)
     {
         case NetworkMode.Server:
             foreach (var plr in DataEngine.Players) plr.Messages.Add(message);
             break;
         case NetworkMode.Client:
             foreach (var plr in DataEngine.Players.Where(plr => plr.IsLocal)) plr.Messages.Add(message);
             NetworkEngine.GameServerConnection.Send(new PlayerMessageMessage
             {
                 PlayerID = -1,
                 Message = message,
             });
             break;
         default: throw new InvalidOperationException("Text messages not supported in mode " + NetworkMode);
     }
 }
Пример #15
0
 public Weapon2Selector(AssaultWingCore game, Player player, PlayerSettingsItem settings, Vector2 pos)
     : base(game, player, settings, pos)
 {
     Values = game.DataEngine.GameplayMode.Weapon2Types;
     CurrentValue = Values.IndexOf(player.Weapon2Name);
 }
Пример #16
0
 public ExtraDeviceSelector(AssaultWingCore game, Player player, PlayerSettingsItem settings, Vector2 pos)
     : base(game, player, settings, pos)
 {
     Values = game.DataEngine.GameplayMode.ExtraDeviceTypes;
     CurrentValue = Values.IndexOf(player.ExtraDeviceName);
 }
Пример #17
0
 public BonusListOverlay(PlayerViewport viewport)
     : base(viewport, HorizontalAlignment.Right, VerticalAlignment.Center)
 {
     _player = viewport.Owner;
     _displayQueue.Add(new BonusOverlay(null));
 }
Пример #18
0
 private void CheckIfChatPlayerChanged()
 {
     if (ChatPlayer == _previousChatPlayer) return;
     if (_previousChatPlayer != null) _previousChatPlayer.Messages.NewChatMessage -= AddMessage;
     _items.Clear();
     ChatPlayer.Messages.NewChatMessage += AddMessage;
     _previousChatPlayer = ChatPlayer;
 }
Пример #19
0
 public override void Draw2D(Matrix gameToScreen, SpriteBatch spriteBatch, float scale, Player viewer)
 {
     if (_backgroundTexture == null) return;
     var screenCenter = Vector2.Transform(Pos + DrawPosOffset, gameToScreen);
     var drawRotation = -(Rotation + DrawRotationOffset); // negated, because screen Y coordinates are reversed
     var color = Color.Multiply(Color.White, Alpha * _backgroundAlpha);
     spriteBatch.Draw(_backgroundTexture, screenCenter, null, color, drawRotation,
         new Vector2(_backgroundTexture.Width, _backgroundTexture.Height) / 2, _backgroundScale,
         SpriteEffects.None, 0.5f);
 }
Пример #20
0
 public override void Draw3D(Matrix view, Matrix projection, Player viewer)
 {
     if (!Arena.IsForPlaying)
     {
         base.Draw3D(view, projection, viewer);
         return;
     }
     var gfx = Game.GraphicsDeviceService.GraphicsDevice;
     Effect.World = WorldMatrix;
     Effect.Projection = projection;
     Effect.View = view;
     Effect.Texture = Texture;
     Arena.PrepareEffect(Effect);
     foreach (var pass in Effect.CurrentTechnique.Passes)
     {
         pass.Apply();
         gfx.DrawUserIndexedPrimitives<VertexPositionNormalTexture>(
             PrimitiveType.TriangleList, _vertexData, 0, _vertexData.Length, _indexData, 0, _indexData.Length / 3);
     }
 }
Пример #21
0
 public override void Draw3D(Matrix view, Matrix projection, Player viewer)
 {
     var gfx = Game.GraphicsDeviceService.GraphicsDevice;
     gfx.BlendState = AW2.Graphics.GraphicsEngineImpl.AdditiveBlendPremultipliedAlpha;
     var effect = Game.GraphicsEngine.GameContent.TriforceEffect;
     effect.Projection = projection;
     effect.World = WorldMatrix;
     effect.View = view;
     effect.Alpha = Alpha * GetAlphaByAge();
     effect.Texture = _texture;
     foreach (var pass in effect.CurrentTechnique.Passes)
     {
         pass.Apply();
         gfx.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleList, _vertexData, 0, _vertexData.Length / 3);
     }
 }
Пример #22
0
 private void SendPlayerMessageToRemoteSpectator(PlayerMessage message, Player player)
 {
     if (!player.IsRemote) return;
     try
     {
         var messageMessage = new PlayerMessageMessage { PlayerID = player.ID, Message = message };
         NetworkEngine.GetGameClientConnection(player.ConnectionID).Send(messageMessage);
     }
     catch (InvalidOperationException)
     {
         // The connection of the player doesn't exist any more. Just don't send the message then.
     }
 }
Пример #23
0
 public ScoreOverlay(PlayerViewport viewport)
     : base(viewport, HorizontalAlignment.Left, VerticalAlignment.Bottom)
 {
     _player = viewport.Owner;
 }
Пример #24
0
 /// <summary>
 /// Like <see cref="Player.SeizeShip"/> but does less so that an AssaultWingCore instance isn't required.
 /// </summary>
 private void SeizeShip(Player player, Ship ship)
 {
     player.Ship = ship;
     ship.Owner = player;
 }
Пример #25
0
 private string[] GetHelpMessages(Player player)
 {
     return new[]
     {
         string.Format("Moving: {0}, {1}, {2}", player.Controls.Thrust, player.Controls.Left, player.Controls.Right),
         string.Format("Firing: {0}, {1}, {2}", player.Controls.Fire1, player.Controls.Fire2, player.Controls.Extra),
         string.Format("Chat: {0}; Equip ship: Esc; Quick help: F1", Settings.Controls.Chat),
     };
 }
Пример #26
0
 public RadarOverlay(PlayerViewport viewport)
     : base(viewport, HorizontalAlignment.Left, VerticalAlignment.Top)
 {
     _player = viewport.Owner;
 }
Пример #27
0
        public override void Draw2D(Matrix gameToScreen, SpriteBatch spriteBatch, float scale, Player viewer)
        {
            if (VisibilityLimitedTo != null && VisibilityLimitedTo != viewer) return;
            Func<Particle, Vector2> getParticleCenterInGameWorld;
            Func<Particle, float> getDrawRotation;
            GetPosAndRotationAccessors(out getParticleCenterInGameWorld, out getDrawRotation);
            if (_particlePosesTemp == null || _particlePosesTemp.Length < _particles.Count)
                _particlePosesTemp = new Vector2[_particles.Count * 2]; // allocate extra reserve for future
            for (int i = 0; i < _particles.Count; i++)
                _particlePosesTemp[i] = getParticleCenterInGameWorld(_particles[i]);
            Vector2.Transform(_particlePosesTemp, 0, ref gameToScreen, _particlePosesTemp, 0, _particles.Count);
            var pengColor = Color.Multiply(Color, BaseAlpha);
            for (int index = 0; index < _particles.Count; index++)
            {
                var particle = _particles[index];
                var screenCenter = _particlePosesTemp[index];
                var drawRotation = -getDrawRotation(particle); // negated, because screen Y coordinates are reversed

                // Sprite depth will be our given depth layer slightly adjusted by
                // particle's position in its lifespan.
                float layerDepth = MathHelper.Clamp(DepthLayer2D * 0.99f + 0.0098f * particle.LayerDepth, 0, 1);

                var texture = particle.Texture;
                var color = Color.Multiply(pengColor, particle.Alpha);
                spriteBatch.Draw(texture, screenCenter, null, color, drawRotation,
                    new Vector2(texture.Width, texture.Height) / 2, particle.Scale * scale,
                    SpriteEffects.None, layerDepth);
            }
        }
Пример #28
0
 public PlayerStatusOverlay(PlayerViewport viewport)
     : base(viewport, HorizontalAlignment.Center, VerticalAlignment.Top)
 {
     _player = viewport.Owner;
 }
Пример #29
0
 public override void Draw2D(Matrix gameToScreen, SpriteBatch spriteBatch, float scale, Player viewer)
 {
     var backgroundPos = Vector2.Transform(Pos + DrawPosOffset, gameToScreen);
     var finalScale = _scaleCurve.Evaluate(AgeInGameSeconds) * scale;
     var origin = new Vector2(IconBackground.Width, IconBackground.Height) / 2;
     var iconPos = backgroundPos + new Vector2(-origin.X + 6, -_icon.Height / 2 - 1) * finalScale;
     var textPos = backgroundPos + new Vector2(_icon.Width + 1, 0) / 2 * finalScale;
     var textOrigin = Font.MeasureString(Message) / 2;
     var drawColor = Color.Multiply(DrawColor, _alphaCurve.Evaluate(AgeInGameSeconds));
     if (AgeInGameSeconds > _scaleCurve.Keys.Last().Position)
     {
         textPos = textPos.Round();
         textOrigin = textOrigin.Round();
     }
     var spriteDepth = 0.1f + (0.1f * ID) / Gob.MAX_ID; // Between 0.1 and 0.2
     spriteBatch.Draw(IconBackground, backgroundPos, null, drawColor,
         0, origin, finalScale, SpriteEffects.None, spriteDepth + 1E-7f);
     spriteBatch.Draw(_icon, iconPos, null, drawColor,
         0, Vector2.Zero, finalScale, SpriteEffects.None, spriteDepth);
     spriteBatch.DrawString(Font, Message, textPos, drawColor, 0f, textOrigin, finalScale, SpriteEffects.None, 0f);
 }