public override void Update(double deltaTime)
        {
            cam.MoveCamera((float)deltaTime, true, GUIComponent.MouseOn == null);

            guiRoot.Update((float)deltaTime);

            if (selectedPrefab != null)
            {
                emitter.EmitTimer  += (float)deltaTime;
                emitter.BurstTimer += (float)deltaTime;


                if (emitter.ParticlesPerSecond > 0)
                {
                    float emitInterval = 1.0f / emitter.ParticlesPerSecond;
                    while (emitter.EmitTimer > emitInterval)
                    {
                        Emit(Vector2.Zero);
                        emitter.EmitTimer -= emitInterval;
                    }
                }

                if (emitter.BurstTimer > emitter.ParticleBurstInterval)
                {
                    for (int i = 0; i < emitter.ParticleBurstAmount; i++)
                    {
                        Emit(Vector2.Zero);
                    }
                    emitter.BurstTimer = 0.0f;
                }
            }

            GameMain.ParticleManager.Update((float)deltaTime);
        }
Exemplo n.º 2
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)
        {
            cam.MoveCamera((float)deltaTime);

            GUIpanel.Update((float)deltaTime);

            if (physicsEnabled)
            {
                Character.UpdateAnimAll((float)deltaTime);

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

                GameMain.World.Step((float)deltaTime);
            }
        }
Exemplo n.º 3
0
        private void UpdateChildrenRect(float deltaTime)
        {
            int x = rect.X, y = rect.Y;

            if (!scrollBarHidden)
            {
                if (scrollBar.IsHorizontal)
                {
                    x -= (int)((totalSize - rect.Width) * scrollBar.BarScroll);
                }
                else
                {
                    y -= (int)((totalSize - rect.Height) * scrollBar.BarScroll);
                }
            }

            for (int i = 0; i < children.Count; i++)
            {
                GUIComponent child = children[i];
                if (child == frame || !child.Visible)
                {
                    continue;
                }

                child.Rect = new Rectangle(x, y, child.Rect.Width, child.Rect.Height);
                if (scrollBar.IsHorizontal)
                {
                    x += child.Rect.Width + spacing;
                }
                else
                {
                    y += child.Rect.Height + spacing;
                }

                if (deltaTime > 0.0f)
                {
                    child.Update(deltaTime);
                }
                if (enabled && child.CanBeFocused &&
                    (MouseOn == this || (MouseOn != null && this.IsParentOf(MouseOn))) && child.Rect.Contains(PlayerInput.MousePosition))
                {
                    child.State = ComponentState.Hover;
                    if (PlayerInput.LeftButtonClicked())
                    {
                        Select(i);
                    }
                }
                else if (selected.Contains(child))
                {
                    child.State = ComponentState.Selected;

                    if (CheckSelected != null)
                    {
                        if (CheckSelected() != child.UserData)
                        {
                            selected.Remove(child);
                        }
                    }
                }
                else
                {
                    child.State = ComponentState.None;
                }
            }
        }
Exemplo n.º 4
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 (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);
        }