Exemplo n.º 1
0
 public GameRenderer(IPlayerRenderer playerRenderer,
                     IWorldRenderer worldRenderer,
                     ILightMapRenderer lightMapRenderer,
                     IUpdateResolver <IEntity> updateResolver)
 {
     _playerRenderer   = playerRenderer;
     _worldRenderer    = worldRenderer;
     _lightMapRenderer = lightMapRenderer;
     _updateResolver   = updateResolver;
 }
Exemplo n.º 2
0
 public ComputerPlayer(int id, IPlayerRenderer renderer)
 {
     Id       = id;
     Renderer = renderer;
     SetPlayerMark();
 }
Exemplo n.º 3
0
 public HumanPlayer(int id, IPlayerRenderer renderer)
 {
     Id       = id;
     Renderer = renderer;
     SetPlayerMark();
 }
        public void Draw()
        {
            int teamNamePlateDistance = Main.teamNamePlateDistance;

            if (teamNamePlateDistance <= 0)
            {
                return;
            }
            SpriteBatch spriteBatch = Main.spriteBatch;

            spriteBatch.End();
            spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, null, null, Main.UIScaleMatrix);
            PlayerInput.SetZoom_World();
            int     screenWidth    = Main.screenWidth;
            int     screenHeight   = Main.screenHeight;
            Vector2 screenPosition = Main.screenPosition;

            PlayerInput.SetZoom_UI();
            float uIScale = Main.UIScale;
            int   num     = teamNamePlateDistance * 8;

            Player[]         player         = Main.player;
            int              myPlayer       = Main.myPlayer;
            SpriteViewMatrix gameViewMatrix = Main.GameViewMatrix;
            byte             mouseTextColor = Main.mouseTextColor;

            Color[]         teamColor       = Main.teamColor;
            Camera          camera          = Main.Camera;
            IPlayerRenderer playerRenderer  = Main.PlayerRenderer;
            Vector2         screenPosition2 = Main.screenPosition;

            for (int i = 0; i < 255; i++)
            {
                if (!player[i].active || myPlayer == i || player[i].dead || player[myPlayer].team <= 0 || player[myPlayer].team != player[i].team)
                {
                    continue;
                }
                string  name         = player[i].name;
                Vector2 namePlatePos = FontAssets.MouseText.get_Value().MeasureString(name);
                float   num2         = 0f;
                if (player[i].chatOverhead.timeLeft > 0)
                {
                    num2 = (0f - namePlatePos.Y) * uIScale;
                }
                else if (player[i].emoteTime > 0)
                {
                    num2 = (0f - namePlatePos.Y) * uIScale;
                }
                Vector2 value    = new Vector2((float)(screenWidth / 2) + screenPosition.X, (float)(screenHeight / 2) + screenPosition.Y);
                Vector2 position = player[i].position;
                position += (position - value) * (gameViewMatrix.Zoom - Vector2.One);
                float num3           = 0f;
                float num4           = (float)(int)mouseTextColor / 255f;
                Color namePlateColor = new Color((byte)((float)(int)teamColor[player[i].team].R * num4), (byte)((float)(int)teamColor[player[i].team].G * num4), (byte)((float)(int)teamColor[player[i].team].B * num4), mouseTextColor);
                float num5           = position.X + (float)(player[i].width / 2) - value.X;
                float num6           = position.Y - namePlatePos.Y - 2f + num2 - value.Y;
                float num7           = (float)Math.Sqrt(num5 * num5 + num6 * num6);
                int   num8           = screenHeight;
                if (screenHeight > screenWidth)
                {
                    num8 = screenWidth;
                }
                num8 = num8 / 2 - 50;
                if (num8 < 100)
                {
                    num8 = 100;
                }
                if (num7 < (float)num8)
                {
                    namePlatePos.X = position.X + (float)(player[i].width / 2) - namePlatePos.X / 2f - screenPosition.X;
                    namePlatePos.Y = position.Y - namePlatePos.Y - 2f + num2 - screenPosition.Y;
                }
                else
                {
                    num3           = num7;
                    num7           = (float)num8 / num7;
                    namePlatePos.X = (float)(screenWidth / 2) + num5 * num7 - namePlatePos.X / 2f;
                    namePlatePos.Y = (float)(screenHeight / 2) + num6 * num7 + 40f * uIScale;
                }
                Vector2 value2 = FontAssets.MouseText.get_Value().MeasureString(name);
                namePlatePos += value2 / 2f;
                namePlatePos *= 1f / uIScale;
                namePlatePos -= value2 / 2f;
                if (player[myPlayer].gravDir == -1f)
                {
                    namePlatePos.Y = (float)screenHeight - namePlatePos.Y;
                }
                if (num3 > 0f)
                {
                    float num9  = 20f;
                    float num10 = -27f;
                    num10 -= (value2.X - 85f) / 2f;
                    num5   = player[i].Center.X - player[myPlayer].Center.X;
                    num6   = player[i].Center.Y - player[myPlayer].Center.Y;
                    float num11 = (float)Math.Sqrt(num5 * num5 + num6 * num6);
                    if (!(num11 > (float)num))
                    {
                        string  textValue = Language.GetTextValue("GameUI.PlayerDistance", (int)(num11 / 16f * 2f));
                        Vector2 npDistPos = FontAssets.MouseText.get_Value().MeasureString(textValue);
                        npDistPos.X = namePlatePos.X - num10;
                        npDistPos.Y = namePlatePos.Y + value2.Y / 2f - npDistPos.Y / 2f - num9;
                        DrawPlayerName2(spriteBatch, ref namePlateColor, textValue, ref npDistPos);
                        Color   playerHeadBordersColor = Main.GetPlayerHeadBordersColor(player[i]);
                        Vector2 position2 = new Vector2(namePlatePos.X, namePlatePos.Y - num9);
                        position2.X -= 22f + num10;
                        position2.Y += 8f;
                        playerRenderer.DrawPlayerHead(camera, player[i], position2, 1f, 0.8f, playerHeadBordersColor);
                        Vector2 vector = npDistPos + screenPosition2 + new Vector2(26f, 20f);
                        if (player[i].statLife != player[i].statLifeMax2)
                        {
                            Main.instance.DrawHealthBar(vector.X, vector.Y, player[i].statLife, player[i].statLifeMax2, 1f, 1.25f, noFlip: true);
                        }
                        ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.MouseText.get_Value(), name, namePlatePos + new Vector2(0f, -40f), namePlateColor, 0f, Vector2.Zero, Vector2.One);
                    }
                }
                else
                {
                    DrawPlayerName(spriteBatch, name, ref namePlatePos, ref namePlateColor);
                }
            }
        }
        public void Draw()
        {
            int namePlateDistance = Main.teamNamePlateDistance;

            if (namePlateDistance <= 0)
            {
                return;
            }
            SpriteBatch spriteBatch = Main.spriteBatch;

            spriteBatch.End();
            spriteBatch.Begin(SpriteSortMode.Immediate, (BlendState)null, (SamplerState)null, (DepthStencilState)null, (RasterizerState)null, (Effect)null, Main.UIScaleMatrix);
            PlayerInput.SetZoom_World();
            int     screenWidth     = Main.screenWidth;
            int     screenHeight    = Main.screenHeight;
            Vector2 screenPosition1 = Main.screenPosition;

            PlayerInput.SetZoom_UI();
            float uiScale = Main.UIScale;
            int   num1    = namePlateDistance * 8;

            Player[]         player1        = Main.player;
            int              player2        = Main.myPlayer;
            SpriteViewMatrix gameViewMatrix = Main.GameViewMatrix;
            byte             mouseTextColor = Main.mouseTextColor;

            Color[]         teamColor       = Main.teamColor;
            Camera          camera          = Main.Camera;
            IPlayerRenderer playerRenderer  = Main.PlayerRenderer;
            Vector2         screenPosition2 = Main.screenPosition;

            for (int index = 0; index < (int)byte.MaxValue; ++index)
            {
                if (player1[index].active && player2 != index && (!player1[index].dead && player1[player2].team > 0) && player1[player2].team == player1[index].team)
                {
                    string  name         = player1[index].name;
                    Vector2 namePlatePos = FontAssets.MouseText.get_Value().MeasureString(name);
                    float   num2         = 0.0f;
                    if (player1[index].chatOverhead.timeLeft > 0)
                    {
                        num2 = -namePlatePos.Y * uiScale;
                    }
                    else if (player1[index].emoteTime > 0)
                    {
                        num2 = -namePlatePos.Y * uiScale;
                    }
                    Vector2 vector2_1      = new Vector2((float)(screenWidth / 2) + screenPosition1.X, (float)(screenHeight / 2) + screenPosition1.Y);
                    Vector2 position1      = player1[index].position;
                    Vector2 vector2_2      = position1 + (position1 - vector2_1) * (gameViewMatrix.Zoom - Vector2.One);
                    float   num3           = 0.0f;
                    float   num4           = (float)mouseTextColor / (float)byte.MaxValue;
                    Color   namePlateColor = new Color((int)(byte)((double)teamColor[player1[index].team].R * (double)num4), (int)(byte)((double)teamColor[player1[index].team].G * (double)num4), (int)(byte)((double)teamColor[player1[index].team].B * (double)num4), (int)mouseTextColor);
                    float   num5           = vector2_2.X + (float)(player1[index].width / 2) - vector2_1.X;
                    float   num6           = (float)((double)vector2_2.Y - (double)namePlatePos.Y - 2.0) + num2 - vector2_1.Y;
                    float   num7           = (float)Math.Sqrt((double)num5 * (double)num5 + (double)num6 * (double)num6);
                    int     num8           = screenHeight;
                    if (screenHeight > screenWidth)
                    {
                        num8 = screenWidth;
                    }
                    int num9 = num8 / 2 - 50;
                    if (num9 < 100)
                    {
                        num9 = 100;
                    }
                    if ((double)num7 < (double)num9)
                    {
                        namePlatePos.X = (float)((double)vector2_2.X + (double)(player1[index].width / 2) - (double)namePlatePos.X / 2.0) - screenPosition1.X;
                        namePlatePos.Y = (float)((double)vector2_2.Y - (double)namePlatePos.Y - 2.0) + num2 - screenPosition1.Y;
                    }
                    else
                    {
                        num3 = num7;
                        float num10 = (float)num9 / num7;
                        namePlatePos.X = (float)((double)(screenWidth / 2) + (double)num5 * (double)num10 - (double)namePlatePos.X / 2.0);
                        namePlatePos.Y = (float)((double)(screenHeight / 2) + (double)num6 * (double)num10 + 40.0 * (double)uiScale);
                    }
                    Vector2 vector2_3 = FontAssets.MouseText.get_Value().MeasureString(name);
                    namePlatePos += vector2_3 / 2f;
                    namePlatePos *= 1f / uiScale;
                    namePlatePos -= vector2_3 / 2f;
                    if ((double)player1[player2].gravDir == -1.0)
                    {
                        namePlatePos.Y = (float)screenHeight - namePlatePos.Y;
                    }
                    if ((double)num3 > 0.0)
                    {
                        float num10 = 20f;
                        float num11 = -27f - (float)(((double)vector2_3.X - 85.0) / 2.0);
                        float num12 = player1[index].Center.X - player1[player2].Center.X;
                        float num13 = player1[index].Center.Y - player1[player2].Center.Y;
                        float num14 = (float)Math.Sqrt((double)num12 * (double)num12 + (double)num13 * (double)num13);
                        if ((double)num14 <= (double)num1)
                        {
                            string  textValue = Language.GetTextValue("GameUI.PlayerDistance", (object)(int)((double)num14 / 16.0 * 2.0));
                            Vector2 npDistPos = FontAssets.MouseText.get_Value().MeasureString(textValue);
                            npDistPos.X = namePlatePos.X - num11;
                            npDistPos.Y = (float)((double)namePlatePos.Y + (double)vector2_3.Y / 2.0 - (double)npDistPos.Y / 2.0) - num10;
                            LegacyMultiplayerClosePlayersOverlay.DrawPlayerName2(spriteBatch, ref namePlateColor, textValue, ref npDistPos);
                            Color   headBordersColor = Main.GetPlayerHeadBordersColor(player1[index]);
                            Vector2 position2        = new Vector2(namePlatePos.X, namePlatePos.Y - num10);
                            position2.X -= 22f + num11;
                            position2.Y += 8f;
                            playerRenderer.DrawPlayerHead(camera, player1[index], position2, 1f, 0.8f, headBordersColor);
                            Vector2 vector2_4 = npDistPos + screenPosition2 + new Vector2(26f, 20f);
                            if (player1[index].statLife != player1[index].statLifeMax2)
                            {
                                Main.instance.DrawHealthBar(vector2_4.X, vector2_4.Y, player1[index].statLife, player1[index].statLifeMax2, 1f, 1.25f, true);
                            }
                            ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.MouseText.get_Value(), name, namePlatePos + new Vector2(0.0f, -40f), namePlateColor, 0.0f, Vector2.Zero, Vector2.One, -1f, 2f);
                        }
                    }
                    else
                    {
                        LegacyMultiplayerClosePlayersOverlay.DrawPlayerName(spriteBatch, name, ref namePlatePos, ref namePlateColor);
                    }
                }
            }
        }