Beispiel #1
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            if (!Visible) return;

            base.Draw(spriteBatch);

            button.Draw(spriteBatch);

            if (!Dropped) return;

            listBox.Draw(spriteBatch);
        }
Beispiel #2
0
        public void Draw(SpriteBatch spriteBatch)
        {
            if (GUI.DisableHUD)
            {
                return;
            }

            infoButton.Draw(spriteBatch);

            if (GameMode != null)
            {
                GameMode.Draw(spriteBatch);
            }
            if (infoFrame != null)
            {
                infoFrame.Draw(spriteBatch);
            }
        }
        public override void Draw(SpriteBatch spriteBatch)
        {
            if (!isRunning || GUI.DisableHUD)
            {
                return;
            }

            CrewManager.Draw(spriteBatch);

            if (Submarine.MainSub == null)
            {
                return;
            }

            Submarine leavingSub = GetLeavingSub();

            if (leavingSub == null)
            {
                endRoundButton.Visible = false;
            }
            else if (leavingSub.AtEndPosition)
            {
                endRoundButton.Text     = ToolBox.LimitString(TextManager.Get("EnterLocation").Replace("[locationname]", Map.SelectedLocation.Name), endRoundButton.Font, endRoundButton.Rect.Width - 5);
                endRoundButton.UserData = leavingSub;
                endRoundButton.Visible  = true;
            }
            else if (leavingSub.AtStartPosition)
            {
                endRoundButton.Text     = ToolBox.LimitString(TextManager.Get("EnterLocation").Replace("[locationname]", Map.CurrentLocation.Name), endRoundButton.Font, endRoundButton.Rect.Width - 5);
                endRoundButton.UserData = leavingSub;
                endRoundButton.Visible  = true;
            }
            else
            {
                endRoundButton.Visible = false;
            }

            endRoundButton.Draw(spriteBatch);
        }
Beispiel #4
0
        public static void Draw(SpriteBatch spriteBatch, Character character, Camera cam)
        {
            if (statusIcons == null)
            {
                statusIcons = new Sprite("Content/UI/statusIcons.png", Vector2.Zero);
            }

            if (noiseOverlay == null)
            {
                noiseOverlay = new Sprite("Content/UI/noise.png", Vector2.Zero);
            }

            if (damageOverlay == null)
            {
                damageOverlay = new Sprite("Content/UI/damageOverlay.png", Vector2.Zero);
            }

            if (GUI.DisableHUD)
            {
                return;
            }

            if (character.Inventory != null)
            {
                for (int i = 0; i < character.Inventory.Items.Length - 1; i++)
                {
                    var item = character.Inventory.Items[i];
                    if (item == null || CharacterInventory.limbSlots[i] == InvSlotType.Any)
                    {
                        continue;
                    }

                    foreach (ItemComponent ic in item.components)
                    {
                        if (ic.DrawHudWhenEquipped)
                        {
                            ic.DrawHUD(spriteBatch, character);
                        }
                    }
                }
            }

            DrawStatusIcons(spriteBatch, character);

            if (!character.IsUnconscious && character.Stun <= 0.0f)
            {
                if (character.Inventory != null && !character.LockHands && character.Stun >= -0.1f)
                {
                    character.Inventory.DrawOffset = Vector2.Zero;
                    character.Inventory.DrawOwn(spriteBatch);
                }

                if (character.SelectedCharacter != null && character.SelectedCharacter.Inventory != null)
                {
                    character.SelectedCharacter.Inventory.DrawOffset = new Vector2(320.0f, 0.0f);
                    character.SelectedCharacter.Inventory.DrawOwn(spriteBatch);

                    if (cprButton == null)
                    {
                        cprButton = new GUIButton(
                            new Rectangle(character.SelectedCharacter.Inventory.SlotPositions[0].ToPoint() + new Point(320, -30), new Point(130, 20)), "Perform CPR", "");

                        cprButton.OnClicked = (button, userData) =>
                        {
                            if (Character.Controlled == null || Character.Controlled.SelectedCharacter == null)
                            {
                                return(false);
                            }

                            Character.Controlled.AnimController.Anim = (Character.Controlled.AnimController.Anim == AnimController.Animation.CPR) ?
                                                                       AnimController.Animation.None : AnimController.Animation.CPR;

                            foreach (Limb limb in Character.Controlled.SelectedCharacter.AnimController.Limbs)
                            {
                                limb.pullJoint.Enabled = false;
                            }

                            if (GameMain.Client != null)
                            {
                                GameMain.Client.CreateEntityEvent(Character.Controlled, new object[] { NetEntityEvent.Type.Repair });
                            }

                            return(true);
                        };
                    }

                    //cprButton.Visible = character.GetSkillLevel("Medical") > 20.0f;

                    if (cprButton.Visible)
                    {
                        cprButton.Draw(spriteBatch);
                    }
                }

                if (character.ClosestCharacter != null && character.ClosestCharacter.CanBeSelected)
                {
                    Vector2 startPos = character.DrawPosition + (character.ClosestCharacter.DrawPosition - character.DrawPosition) * 0.7f;
                    startPos = cam.WorldToScreen(startPos);

                    Vector2 textPos = startPos;
                    textPos -= new Vector2(GUI.Font.MeasureString(character.ClosestCharacter.Info.Name).X / 2, 20);

                    GUI.DrawString(spriteBatch, textPos, character.ClosestCharacter.Info.Name, Color.White, Color.Black, 2);
                }
                else if (character.SelectedCharacter == null && character.ClosestItem != null && character.SelectedConstruction == null)
                {
                    var hudTexts = character.ClosestItem.GetHUDTexts(character);

                    Vector2 startPos = new Vector2((int)(GameMain.GraphicsWidth / 2.0f), GameMain.GraphicsHeight);
                    startPos.Y -= 50 + hudTexts.Count * 25;

                    Vector2 textPos = startPos;
                    textPos -= new Vector2((int)GUI.Font.MeasureString(character.ClosestItem.Name).X / 2, 20);

                    GUI.DrawString(spriteBatch, textPos, character.ClosestItem.Name, Color.White, Color.Black * 0.7f, 2);

                    textPos.Y += 30.0f;
                    foreach (ColoredText coloredText in hudTexts)
                    {
                        textPos.X = (int)(startPos.X - GUI.SmallFont.MeasureString(coloredText.Text).X / 2);

                        GUI.DrawString(spriteBatch, textPos, coloredText.Text, coloredText.Color, Color.Black * 0.7f, 2, GUI.SmallFont);

                        textPos.Y += 25;
                    }
                }

                foreach (HUDProgressBar progressBar in character.HUDProgressBars.Values)
                {
                    progressBar.Draw(spriteBatch, cam);
                }
            }

            if (Screen.Selected == GameMain.EditMapScreen)
            {
                return;
            }

            if (character.IsUnconscious || (character.Oxygen < 80.0f && !character.IsDead))
            {
                Vector2 offset = Rand.Vector(noiseOverlay.size.X);
                offset.X = Math.Abs(offset.X);
                offset.Y = Math.Abs(offset.Y);

                float alpha = character.IsUnconscious ? 1.0f : Math.Min((80.0f - character.Oxygen) / 50.0f, 0.8f);

                noiseOverlay.DrawTiled(spriteBatch, Vector2.Zero - offset, new Vector2(GameMain.GraphicsWidth, GameMain.GraphicsHeight) + offset,
                                       Vector2.Zero,
                                       Color.White * alpha);
            }
            else
            {
                if (suicideButton != null)
                {
                    suicideButton.Visible = false;
                }
            }

            if (damageOverlayTimer > 0.0f)
            {
                damageOverlay.Draw(spriteBatch, Vector2.Zero, Color.White * damageOverlayTimer, Vector2.Zero, 0.0f,
                                   new Vector2(GameMain.GraphicsWidth / damageOverlay.size.X, GameMain.GraphicsHeight / damageOverlay.size.Y));
            }

            if (character.IsUnconscious && !character.IsDead)
            {
                if (suicideButton == null)
                {
                    suicideButton = new GUIButton(
                        new Rectangle(new Point(GameMain.GraphicsWidth / 2 - 60, 20), new Point(120, 20)), "Give in", "");


                    suicideButton.ToolTip = GameMain.NetworkMember == null ?
                                            "The character can no longer be revived if you give in." :
                                            "Let go of your character and enter spectator mode (other players will no longer be able to revive you)";

                    suicideButton.OnClicked = (button, userData) =>
                    {
                        GUIComponent.ForceMouseOn(null);
                        if (Character.Controlled != null)
                        {
                            if (GameMain.Client != null)
                            {
                                GameMain.Client.CreateEntityEvent(Character.Controlled, new object[] { NetEntityEvent.Type.Status });
                            }
                            else
                            {
                                Character.Controlled.Kill(Character.Controlled.CauseOfDeath);
                                Character.Controlled = null;
                            }
                        }
                        return(true);
                    };
                }

                suicideButton.Visible = true;
                suicideButton.Draw(spriteBatch);
            }
        }
Beispiel #5
0
        public static void Draw(SpriteBatch spriteBatch, Character character, Camera cam)
        {
            if (statusIcons == null)
            {
                statusIcons = new Sprite("Content/UI/statusIcons.png", Vector2.Zero);
            }

            if (noiseOverlay == null)
            {
                noiseOverlay = new Sprite("Content/UI/noise.png", Vector2.Zero);
            }

            if (damageOverlay == null)
            {
                damageOverlay = new Sprite("Content/UI/damageOverlay.png", Vector2.Zero);
            }

            if (GUI.DisableHUD)
            {
                return;
            }

            if (character.Inventory != null)
            {
                for (int i = 0; i < character.Inventory.Items.Length - 1; i++)
                {
                    var item = character.Inventory.Items[i];
                    if (item == null || CharacterInventory.limbSlots[i] == InvSlotType.Any)
                    {
                        continue;
                    }

                    foreach (ItemComponent ic in item.components)
                    {
                        if (ic.DrawHudWhenEquipped)
                        {
                            ic.DrawHUD(spriteBatch, character);
                        }
                    }
                }
            }

            DrawStatusIcons(spriteBatch, character);

            if (!character.IsUnconscious && character.Stun <= 0.0f)
            {
                if (character.IsHumanoid && character.SelectedCharacter != null && character.SelectedCharacter.Inventory != null)
                {
                    if (cprButton == null)
                    {
                        cprButton = new GUIButton(
                            new Rectangle(character.SelectedCharacter.Inventory.SlotPositions[0].ToPoint() + new Point(320, -30), new Point(130, 20)), "Perform CPR", "");

                        cprButton.OnClicked = (button, userData) =>
                        {
                            if (Character.Controlled == null || Character.Controlled.SelectedCharacter == null)
                            {
                                return(false);
                            }

                            Character.Controlled.AnimController.Anim = (Character.Controlled.AnimController.Anim == AnimController.Animation.CPR) ?
                                                                       AnimController.Animation.None : AnimController.Animation.CPR;

                            Character.Controlled.SelectedCharacter.AnimController.ResetPullJoints();

                            if (GameMain.Client != null)
                            {
                                GameMain.Client.CreateEntityEvent(Character.Controlled, new object[] { NetEntityEvent.Type.Repair });
                            }

                            return(true);
                        };
                    }

                    if (grabHoldButton == null)
                    {
                        grabHoldButton = new GUIButton(
                            new Rectangle(character.SelectedCharacter.Inventory.SlotPositions[0].ToPoint() + new Point(320, -60), new Point(130, 20)),
                            TextManager.Get("Grabbing") + ": " + TextManager.Get(character.AnimController.GrabLimb == LimbType.None ? "Hands" : character.AnimController.GrabLimb.ToString()), "");

                        grabHoldButton.OnClicked = (button, userData) =>
                        {
                            if (Character.Controlled == null || Character.Controlled.SelectedCharacter == null)
                            {
                                return(false);
                            }

                            Character.Controlled.AnimController.GrabLimb = Character.Controlled.AnimController.GrabLimb == LimbType.None ? LimbType.Torso : LimbType.None;

                            Character.Controlled.SelectedCharacter.AnimController.ResetPullJoints();

                            if (GameMain.Client != null)
                            {
                                GameMain.Client.CreateEntityEvent(Character.Controlled, new object[] { NetEntityEvent.Type.Control });
                            }

                            grabHoldButton.Text = TextManager.Get("Grabbing") + ": " + TextManager.Get(character.AnimController.GrabLimb == LimbType.None ? "Hands" : character.AnimController.GrabLimb.ToString());
                            return(true);
                        };
                    }

                    if (cprButton.Visible)
                    {
                        cprButton.Draw(spriteBatch);
                    }
                    if (grabHoldButton.Visible)
                    {
                        grabHoldButton.Draw(spriteBatch);
                    }

                    character.SelectedCharacter.Inventory.DrawOffset = new Vector2(320.0f, 0.0f);
                    character.SelectedCharacter.Inventory.DrawOwn(spriteBatch);
                }

                if (character.Inventory != null && !character.LockHands && character.Stun >= -0.1f)
                {
                    character.Inventory.DrawOffset = Vector2.Zero;
                    character.Inventory.DrawOwn(spriteBatch);
                }
                if (character.Inventory != null && !character.LockHands && character.Stun >= -0.1f)
                {
                    Inventory.DrawDragging(spriteBatch);
                }

                if (character.FocusedCharacter != null && character.FocusedCharacter.CanBeSelected)
                {
                    Vector2 startPos = character.DrawPosition + (character.FocusedCharacter.DrawPosition - character.DrawPosition) * 0.7f;
                    startPos = cam.WorldToScreen(startPos);

                    string focusName = character.FocusedCharacter.SpeciesName;
                    if (character.FocusedCharacter.Info != null)
                    {
                        focusName = character.FocusedCharacter.Info.DisplayName;
                    }
                    Vector2 textPos = startPos;
                    textPos -= new Vector2(GUI.Font.MeasureString(focusName).X / 2, 20);

                    GUI.DrawString(spriteBatch, textPos, focusName, Color.White, Color.Black, 2);
                }
                else if (character.SelectedCharacter == null && character.FocusedItem != null && character.SelectedConstruction == null)
                {
                    var hudTexts = character.FocusedItem.GetHUDTexts(character);

                    Vector2 startPos = new Vector2((int)(GameMain.GraphicsWidth / 2.0f), GameMain.GraphicsHeight);
                    startPos.Y -= 50 + hudTexts.Count * 25;

                    Vector2 textPos = startPos;
                    textPos -= new Vector2((int)GUI.Font.MeasureString(character.FocusedItem.Name).X / 2, 20);

                    GUI.DrawString(spriteBatch, textPos, character.FocusedItem.Name, Color.White, Color.Black * 0.7f, 2);

                    textPos.Y += 30.0f;
                    foreach (ColoredText coloredText in hudTexts)
                    {
                        textPos.X = (int)(startPos.X - GUI.SmallFont.MeasureString(coloredText.Text).X / 2);

                        GUI.DrawString(spriteBatch, textPos, coloredText.Text, coloredText.Color, Color.Black * 0.7f, 2, GUI.SmallFont);

                        textPos.Y += 25;
                    }
                }

                foreach (HUDProgressBar progressBar in character.HUDProgressBars.Values)
                {
                    progressBar.Draw(spriteBatch, cam);
                }
            }

            if (Screen.Selected == GameMain.SubEditorScreen)
            {
                return;
            }

            if (character.IsUnconscious || (character.Oxygen < 80.0f && !character.IsDead))
            {
                Vector2 offset = Rand.Vector(noiseOverlay.size.X);
                offset.X = Math.Abs(offset.X);
                offset.Y = Math.Abs(offset.Y);

                float alpha = character.IsUnconscious ? 1.0f : Math.Min((80.0f - character.Oxygen) / 50.0f, 0.8f);

                noiseOverlay.DrawTiled(spriteBatch, Vector2.Zero - offset, new Vector2(GameMain.GraphicsWidth, GameMain.GraphicsHeight) + offset,
                                       color: Color.White * alpha);
            }
            else
            {
                if (suicideButton != null)
                {
                    suicideButton.Visible = false;
                }
            }

            if (damageOverlayTimer > 0.0f)
            {
                damageOverlay.Draw(spriteBatch, Vector2.Zero, Color.White * damageOverlayTimer, Vector2.Zero, 0.0f,
                                   new Vector2(GameMain.GraphicsWidth / damageOverlay.size.X, GameMain.GraphicsHeight / damageOverlay.size.Y));
            }

            if (character.IsUnconscious && !character.IsDead)
            {
                if (suicideButton == null)
                {
                    suicideButton = new GUIButton(
                        new Rectangle(new Point(GameMain.GraphicsWidth / 2 - 60, 20), new Point(120, 20)), TextManager.Get("GiveInButton"), "");


                    suicideButton.ToolTip = TextManager.Get(GameMain.NetworkMember == null ? "GiveInHelpSingleplayer" : "GiveInHelpMultiplayer");

                    suicideButton.OnClicked = (button, userData) =>
                    {
                        GUIComponent.ForceMouseOn(null);
                        if (Character.Controlled != null)
                        {
                            if (GameMain.Client != null)
                            {
                                GameMain.Client.CreateEntityEvent(Character.Controlled, new object[] { NetEntityEvent.Type.Status });
                            }
                            else
                            {
                                Character.Controlled.Kill(Character.Controlled.CauseOfDeath);
                                Character.Controlled = null;
                            }
                        }
                        return(true);
                    };
                }

                suicideButton.Visible = true;
                suicideButton.Draw(spriteBatch);
            }
        }