コード例 #1
0
ファイル: Character.cs プロジェクト: yaelatletl/Barotrauma
 public void DrawHUD(SpriteBatch spriteBatch, Camera cam, bool drawHealth = true)
 {
     CharacterHUD.Draw(spriteBatch, this, cam);
     if (drawHealth)
     {
         CharacterHealth.DrawHUD(spriteBatch);
     }
 }
コード例 #2
0
ファイル: Character.cs プロジェクト: yaelatletl/Barotrauma
 public virtual void AddToGUIUpdateList()
 {
     if (controlled == this)
     {
         CharacterHUD.AddToGUIUpdateList(this);
         CharacterHealth.AddToGUIUpdateList();
     }
 }
コード例 #3
0
 public virtual void AddToGUIUpdateList()
 {
     if (spied == this)
     {
         CharacterHUD.AddToGUIUpdateList(this);
     }
     else if (spied == null && controlled == this)
     {
         CharacterHUD.AddToGUIUpdateList(this);
     }
 }
コード例 #4
0
 partial void DamageHUD(float amount)
 {
     if (spied == this)
     {
         CharacterHUD.TakeDamage(amount);
     }
     else if (controlled == this)
     {
         CharacterHUD.TakeDamage(amount);
     }
 }
コード例 #5
0
ファイル: EditMapScreen.cs プロジェクト: Faerdan/Barotrauma
        public override void AddToGUIUpdateList()
        {
            if (tutorial != null)
            {
                tutorial.AddToGUIUpdateList();
            }

            if (MapEntity.SelectedList.Count == 1)
            {
                MapEntity.SelectedList[0].AddToGUIUpdateList();
            }
            if (MapEntity.HighlightedListBox != null)
            {
                MapEntity.HighlightedListBox.AddToGUIUpdateList();
            }

            leftPanel.AddToGUIUpdateList();
            topPanel.AddToGUIUpdateList();

            if (wiringMode)
            {
                wiringToolPanel.AddToGUIUpdateList();
            }

            if ((characterMode || wiringMode) && dummyCharacter != null)
            {
                CharacterHUD.AddToGUIUpdateList(dummyCharacter);
                if (dummyCharacter.SelectedConstruction != null)
                {
                    dummyCharacter.SelectedConstruction.AddToGUIUpdateList();
                }
            }
            else
            {
                if (loadFrame != null)
                {
                    loadFrame.AddToGUIUpdateList();
                }
                else if (saveFrame != null)
                {
                    saveFrame.AddToGUIUpdateList();
                }
                else if (selectedTab > -1)
                {
                    GUItabs[selectedTab].AddToGUIUpdateList();
                }
            }

            GUI.AddToGUIUpdateList();
        }
コード例 #6
0
ファイル: Character.cs プロジェクト: kachnov/Barotrauma
        partial void UpdateControlled(float deltaTime, Camera cam)
        {
            if (controlled != this)
            {
                return;
            }

            ControlLocalPlayer(deltaTime, cam);

            Lights.LightManager.ViewTarget = this;
            CharacterHUD.Update(deltaTime, this);

            foreach (HUDProgressBar progressBar in hudProgressBars.Values)
            {
                progressBar.Update(deltaTime);
            }

            foreach (var pb in hudProgressBars.Where(pb => pb.Value.FadeTimer <= 0.0f).ToList())
            {
                hudProgressBars.Remove(pb.Key);
            }
        }
コード例 #7
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        public override void Update(double deltaTime)
        {
#if CLIENT
            if (Character.Spied != null)
            {
                if ((PlayerInput.KeyDown(InputType.Up) || PlayerInput.KeyDown(InputType.Down) || PlayerInput.KeyDown(InputType.Left) || PlayerInput.KeyDown(InputType.Right)) && !DebugConsole.IsOpen)
                {
                    if (GameMain.NetworkMember != null && !GameMain.NetworkMember.chatMsgBox.Selected)
                    {
                        if (Character.Controlled != null)
                        {
                            cam.Position = Character.Controlled.WorldPosition;
                        }
                        else
                        {
                            cam.Position = Character.Spied.WorldPosition;
                        }
                        Character.Spied = null;
                        cam.UpdateTransform(true);
                    }
                }
            }
#endif

#if DEBUG && CLIENT
            if (GameMain.GameSession != null && GameMain.GameSession.Level != null && GameMain.GameSession.Submarine != null &&
                !DebugConsole.IsOpen && GUIComponent.KeyboardDispatcher.Subscriber == null)
            {
                /*
                 * var closestSub = Submarine.FindClosest(cam.WorldViewCenter);
                 * if (closestSub == null) closestSub = GameMain.GameSession.Submarine;
                 *
                 * Vector2 targetMovement = Vector2.Zero;
                 * if (PlayerInput.KeyDown(Keys.I)) targetMovement.Y += 1.0f;
                 * if (PlayerInput.KeyDown(Keys.K)) targetMovement.Y -= 1.0f;
                 * if (PlayerInput.KeyDown(Keys.J)) targetMovement.X -= 1.0f;
                 * if (PlayerInput.KeyDown(Keys.L)) targetMovement.X += 1.0f;
                 *
                 * if (targetMovement != Vector2.Zero)
                 *  closestSub.ApplyForce(targetMovement * closestSub.SubBody.Body.Mass * 100.0f);
                 */
            }
#endif

#if CLIENT
            GameMain.NilModProfiler.SWMapEntityUpdate.Start();
#endif

            foreach (MapEntity e in MapEntity.mapEntityList)
            {
                e.IsHighlighted = false;
            }

#if CLIENT
            GameMain.NilModProfiler.SWMapEntityUpdate.Stop();

            if (GameMain.GameSession != null)
            {
                GameMain.NilModProfiler.SWGameSessionUpdate.Start();
                GameMain.GameSession.Update((float)deltaTime);
                GameMain.NilModProfiler.RecordGameSessionUpdate();
            }

            GameMain.NilModProfiler.SWParticleManager.Start();

            GameMain.ParticleManager.Update((float)deltaTime);

            GameMain.NilModProfiler.RecordParticleManager();
            GameMain.NilModProfiler.SWLightManager.Start();

            GameMain.LightManager.Update((float)deltaTime);

            GameMain.NilModProfiler.RecordLightManager();
#endif

            if (Level.Loaded != null)
            {
#if CLIENT
                GameMain.NilModProfiler.SWLevelUpdate.Start();
#endif
                Level.Loaded.Update((float)deltaTime, cam);
#if CLIENT
                GameMain.NilModProfiler.RecordLevelUpdate();
#endif
            }

#if CLIENT
            if (Character.Controlled != null && Character.Controlled.SelectedConstruction != null && Character.Controlled.CanInteractWith(Character.Controlled.SelectedConstruction))
            {
                Character.Controlled.SelectedConstruction.UpdateHUD(cam, Character.Controlled);
            }
            GameMain.NilModProfiler.SWCharacterUpdate.Start();
#endif

            Character.UpdateAll((float)deltaTime, cam);

#if CLIENT
            //NilMod spy Code
            if (Character.Spied != null)
            {
                Character.ViewSpied((float)deltaTime, Cam, true);
                Lights.LightManager.ViewTarget = Character.Spied;
                CharacterHUD.Update((float)deltaTime, Character.Spied);

                foreach (HUDProgressBar progressBar in Character.Spied.HUDProgressBars.Values)
                {
                    progressBar.Update((float)deltaTime);
                }

                foreach (var pb in Character.Spied.HUDProgressBars)
                {
                    if (pb.Value.FadeTimer <= 0.0f)
                    {
                        Character.Spied.HUDProgressBars.Remove(pb.Key);
                    }
                }
            }

            GameMain.NilModProfiler.SWCharacterUpdate.Stop();
            GameMain.NilModProfiler.RecordCharacterUpdate();
            GameMain.NilModProfiler.SWStatusEffect.Start();
#endif
            StatusEffect.UpdateAll((float)deltaTime);

#if CLIENT
            GameMain.NilModProfiler.RecordStatusEffect();
            if ((Character.Controlled != null && Lights.LightManager.ViewTarget != null) || (Character.Spied != null && Lights.LightManager.ViewTarget != null))
            {
                cam.TargetPos = Lights.LightManager.ViewTarget.WorldPosition;
            }
#endif

            cam.MoveCamera((float)deltaTime);
#if CLIENT
            GameMain.NilModProfiler.SWSetTransforms.Start();
#endif
            foreach (Submarine sub in Submarine.Loaded)
            {
                sub.SetPrevTransform(sub.Position);
            }

            foreach (PhysicsBody pb in PhysicsBody.List)
            {
                pb.SetPrevTransform(pb.SimPosition, pb.Rotation);
            }
#if CLIENT
            GameMain.NilModProfiler.RecordSetTransforms();
            GameMain.NilModProfiler.SWMapEntityUpdate.Start();
#endif
            MapEntity.UpdateAll((float)deltaTime, cam);
#if CLIENT
            GameMain.NilModProfiler.RecordMapEntityUpdate();
            GameMain.NilModProfiler.SWCharacterAnimUpdate.Start();
#endif
            Character.UpdateAnimAll((float)deltaTime);
#if CLIENT
            GameMain.NilModProfiler.RecordCharacterAnimUpdate();
            GameMain.NilModProfiler.SWRagdollUpdate.Start();
#endif
            Ragdoll.UpdateAll((float)deltaTime, cam);
#if CLIENT
            GameMain.NilModProfiler.RecordRagdollUpdate();
            GameMain.NilModProfiler.SWSubmarineUpdate.Start();
#endif
            foreach (Submarine sub in Submarine.Loaded)
            {
                sub.Update((float)deltaTime);
            }

#if CLIENT
            GameMain.NilModProfiler.RecordSubmarineUpdate();
            GameMain.NilModProfiler.SWCharacterUpdate.Start();
#endif

#if CLIENT
            GameMain.NilModProfiler.RecordCharacterUpdate();
            GameMain.NilModProfiler.SWPhysicsWorldStep.Start();
#endif
            GameMain.World.Step((float)deltaTime);
#if CLIENT
            GameMain.NilModProfiler.RecordPhysicsWorldStep();

            if (!PlayerInput.LeftButtonHeld())
            {
                Inventory.draggingSlot = null;
                Inventory.draggingItem = null;
            }
#endif
        }
コード例 #8
0
ファイル: Character.cs プロジェクト: kachnov/Barotrauma
 public void DrawHUD(SpriteBatch spriteBatch, Camera cam)
 {
     CharacterHUD.Draw(spriteBatch, this, cam);
 }
コード例 #9
0
ファイル: EditMapScreen.cs プロジェクト: Faerdan/Barotrauma
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        public override void Update(double deltaTime)
        {
            if (tutorial != null)
            {
                tutorial.Update((float)deltaTime);
            }

            hullVolumeFrame.Visible = MapEntity.SelectedList.Any(s => s is Hull);

            cam.MoveCamera((float)deltaTime, true, GUIComponent.MouseOn == null);

            if (characterMode || wiringMode)
            {
                if (dummyCharacter == null || Entity.FindEntityByID(dummyCharacter.ID) != dummyCharacter)
                {
                    ToggleCharacterMode(null, null);
                }
                else
                {
                    foreach (MapEntity me in MapEntity.mapEntityList)
                    {
                        me.IsHighlighted = false;
                    }

                    if (wiringMode && dummyCharacter.SelectedConstruction == null)
                    {
                        List <Wire> wires = new List <Wire>();
                        foreach (Item item in Item.ItemList)
                        {
                            var wire = item.GetComponent <Wire>();
                            if (wire != null)
                            {
                                wires.Add(wire);
                            }
                        }
                        Wire.UpdateEditing(wires);
                    }

                    if (dummyCharacter.SelectedConstruction == null)
                    {
                        Vector2 mouseSimPos = FarseerPhysics.ConvertUnits.ToSimUnits(dummyCharacter.CursorPosition);
                        foreach (Limb limb in dummyCharacter.AnimController.Limbs)
                        {
                            limb.body.SetTransform(mouseSimPos, 0.0f);
                        }
                        dummyCharacter.AnimController.Collider.SetTransform(mouseSimPos, 0.0f);
                    }

                    dummyCharacter.ControlLocalPlayer((float)deltaTime, cam, false);
                    dummyCharacter.Control((float)deltaTime, cam);

                    dummyCharacter.Submarine = Submarine.MainSub;

                    cam.TargetPos = Vector2.Zero;
                }
            }
            else
            {
                MapEntity.UpdateSelecting(cam);
            }

            //GUIComponent.ForceMouseOn(null);

            if (!characterMode && !wiringMode)
            {
                if (MapEntityPrefab.Selected != null)
                {
                    MapEntityPrefab.Selected.UpdatePlacing(cam);
                }

                MapEntity.UpdateEditor(cam);
            }

            leftPanel.Update((float)deltaTime);
            topPanel.Update((float)deltaTime);

            if (wiringMode)
            {
                if (!dummyCharacter.SelectedItems.Any(it => it != null && it.HasTag("Wire")))
                {
                    wiringToolPanel.GetChild <GUIListBox>().Deselect();
                }
                wiringToolPanel.Update((float)deltaTime);
            }

            if (loadFrame != null)
            {
                loadFrame.Update((float)deltaTime);
                if (PlayerInput.RightButtonClicked())
                {
                    loadFrame = null;
                }
            }
            else if (saveFrame != null)
            {
                saveFrame.Update((float)deltaTime);
            }
            else if (selectedTab > -1)
            {
                GUItabs[selectedTab].Update((float)deltaTime);
                if (PlayerInput.RightButtonClicked())
                {
                    selectedTab = -1;
                }
            }


            if ((characterMode || wiringMode) && dummyCharacter != null)
            {
                dummyCharacter.AnimController.FindHull(dummyCharacter.CursorWorldPosition, false);

                foreach (Item item in dummyCharacter.SelectedItems)
                {
                    if (item == null)
                    {
                        continue;
                    }

                    item.SetTransform(dummyCharacter.SimPosition, 0.0f);
                    item.Update((float)deltaTime, cam);
                    item.SetTransform(item.body.SimPosition, 0.0f);
                }

                if (dummyCharacter.SelectedConstruction != null)
                {
                    if (dummyCharacter.SelectedConstruction != null)
                    {
                        dummyCharacter.SelectedConstruction.UpdateHUD(cam, dummyCharacter);
                    }

                    if (PlayerInput.KeyHit(InputType.Select) && dummyCharacter.FocusedItem != dummyCharacter.SelectedConstruction)
                    {
                        dummyCharacter.SelectedConstruction = null;
                    }
                }

                CharacterHUD.Update((float)deltaTime, dummyCharacter);
            }

            GUI.Update((float)deltaTime);
        }