Exemple #1
0
        public void Update(DwarfTime gameTime, ChunkManager chunks, Camera camera)
        {
            // Physics updates this whenever something moves... maybe? Let's see if anything breaks.
            //  What broke: Anything that did not move became invisible.
            //GamePerformance.Instance.StartTrackPerformance("Components - transforms");
            if (RootComponent != null)
            {
                RootComponent.UpdateTransform();
            }
            //GamePerformance.Instance.StopTrackPerformance("Components - transforms");

            GamePerformance.Instance.StartTrackPerformance("Components - update");
            //foreach (var componentType in UpdateableComponents)
            //    foreach (var component in componentType.Value)
            //        if (component.Active)
            //        {
            //            //GamePerformance.Instance.StartTrackPerformance("Component - " + component.GetType().Name);
            //            component.Update(gameTime, chunks, camera);
            //            //GamePerformance.Instance.StopTrackPerformance("Component - " + component.GetType().Name);
            //        }
            foreach (var component in UpdateableComponents)
            {
                component.Update(gameTime, chunks, camera);
            }

            GamePerformance.Instance.StopTrackPerformance("Components - update");

            AddRemove();
        }
Exemple #2
0
    public MainWindow(IEnumerable <string> parameters) : base(Gtk.WindowType.Toplevel)
    {
        Build();

        this.rootComponent = new RootComponent(this, parameters);
        this.rootComponent.ComponentChanged += RootComponentChanged;
    }
Exemple #3
0
        public HlyssApp(RenderWindow window)
        {
            Window = window;

            StyleBank.LoadFromString(Encoding.UTF8.GetString(HlyssUI.Properties.Resources.DefaultStyle));

            Root   = new RootComponent(this);
            _input = new InputManager(this);
            _input.RegisterEvents();

            Theme.OnThemeLoaded += () => Root.StyleChanged = true;
        }
Exemple #4
0
        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            if (context.Instance is RootComponent)
            {
                _component = (RootComponent)context.Instance;
            }

            if (context.PropertyDescriptor.IsReadOnly)
            {
                return(UITypeEditorEditStyle.None);
            }
            return(UITypeEditorEditStyle.Modal);
        }
        private void OnDeserialized(StreamingContext context)
        {
            AdditionMutex = new Mutex();
            RemovalMutex  = new Mutex();
            Removals      = new List <GameComponent>();
            Additions     = new List <GameComponent>();
            World         = (WorldManager)context.Context;
            Vector3 origin  = new Vector3(World.WorldOrigin.X, 0, World.WorldOrigin.Y);
            Vector3 extents = new Vector3(1500, 1500, 1500);

            CollisionManager = new CollisionManager(new BoundingBox(origin - extents, origin + extents)); GameObjectCaching.Reset();
            RootComponent.RefreshCacheTypesRecursive();
        }
Exemple #6
0
    public void Initialize(GameConstants.eEnergyType flower, GameConstants.eEnergyType stem, GameConstants.eEnergyType bse)
    {
        if (!m_IsBeingHeld)
        {
            base.Initialize();
        }

        // use the energy types to zombie together the final plant
        m_FlowerComponent = Instantiate <GameObject>((GameObject)Resources.Load(string.Format(GameConstants.PLANT_COMPONENT_PREFAB_PATH, GameConstants.eSlot.FLOWER, flower)), m_BaseAnchor).GetComponent <FlowerComponent>();
        m_StemComponent   = Instantiate <GameObject>((GameObject)Resources.Load(string.Format(GameConstants.PLANT_COMPONENT_PREFAB_PATH, GameConstants.eSlot.STEM, stem)), m_BaseAnchor).GetComponent <StemComponent>();
        m_RootComponent   = Instantiate <GameObject>((GameObject)Resources.Load(string.Format(GameConstants.PLANT_COMPONENT_PREFAB_PATH, GameConstants.eSlot.ROOT, bse)), m_BaseAnchor).GetComponent <RootComponent>();
        CreatePlant();
    }
Exemple #7
0
        private static void TestRobot()
        {
            RobotEntity robot;
            BoardEntity board;

            var scene = new RootComponent()
                        .Attach(board = new BoardEntity())
                        .Attach(robot = new RobotEntity());

            robot.Place(new Vector(3f, 3f, 0f), CardinalDirection.South);
            robot.Move();
            robot.Move();

            Console.WriteLine($"Robot position: {robot.GetPosition().X}, {robot.GetPosition().Y}");
            Console.WriteLine($"Robot orientation: {Orientation.FromVector(robot.GetOrientation()).CardinalDirection}");

            robot.RotateLeft();
            robot.RotateLeft();
            robot.Move();

            Console.WriteLine($"Robot position: {robot.GetPosition().X}, {robot.GetPosition().Y}");
            Console.WriteLine($"Robot orientation: {Orientation.FromVector(robot.GetOrientation()).CardinalDirection}");

            robot.Move();

            Console.WriteLine($"Robot position: {robot.GetPosition().X}, {robot.GetPosition().Y}");
            Console.WriteLine($"Robot orientation: {Orientation.FromVector(robot.GetOrientation()).CardinalDirection}");

            // Console.WriteLine($"Robot is spawned: {robot.IsSpawned}");

            robot.RotateLeft();
            Console.WriteLine($"Robot orientation: {Orientation.FromVector(robot.GetOrientation()).CardinalDirection}");

            robot.RotateLeft();
            Console.WriteLine($"Robot orientation: {Orientation.FromVector(robot.GetOrientation()).CardinalDirection}");
            robot.RotateLeft();
            Console.WriteLine($"Robot orientation: {Orientation.FromVector(robot.GetOrientation()).CardinalDirection}");
            robot.RotateLeft();
            Console.WriteLine($"Robot orientation: {Orientation.FromVector(robot.GetOrientation()).CardinalDirection}");

            robot.RotateRight();
            Console.WriteLine($"Robot orientation: {Orientation.FromVector(robot.GetOrientation()).CardinalDirection}");

            robot.RotateRight();
            Console.WriteLine($"Robot orientation: {Orientation.FromVector(robot.GetOrientation()).CardinalDirection}");
            robot.RotateRight();
            Console.WriteLine($"Robot orientation: {Orientation.FromVector(robot.GetOrientation()).CardinalDirection}");
            robot.RotateRight();
            Console.WriteLine($"Robot orientation: {Orientation.FromVector(robot.GetOrientation()).CardinalDirection}");
        }
        public InterfaceManager(Game game)
        {
            if (game == null)
            {
                throw new ArgumentNullException("The InterfaceManager class must be created with a non-null Game reference.");
            }

            this.game                 = game;
            this.graphics             = new GraphicsDeviceManager(this.game);
            this.batch                = new SpriteBatch(GraphicsDevice);
            this.input                = new InputManager();
            this.rootComponent        = new RootComponent(this);
            this.rootComponent.Bounds = new Rectangle(0, 0, this.graphics.PreferredBackBufferWidth, this.graphics.PreferredBackBufferHeight);
        }
Exemple #9
0
        private object DoPlace(PlaceOptions options, RootComponent scene)
        {
            if (_robot == null)
            {
                _robot = new RobotEntity();
                _robot.AttachTo(scene);
            }

            _robot.Place(new Vector(options.PosX, options.PosY, 0f), options.Facing);

            Console.WriteLine($"Robot is at {_robot.GetPosition().X}, {_robot.GetPosition().Y} " +
                              $"facing {Orientation.FromVector(_robot.GetOrientation()).CardinalDirection}");

            return(null);
        }
Exemple #10
0
        public App()
        {
            mKeyboardState = new Foundation.KeyboardState();
            mMouseState    = new Foundation.MouseState();
            // Enable antialiasing
            mWindow       = new GameWindow(1, 1, new OpenTK.Graphics.GraphicsMode(32, 0, 8, 8));
            mWindow.VSync = VSyncMode.Off;

            mWindow.Load += OnLoad;

            mWindow.Resize      += OnResize;
            mWindow.UpdateFrame += OnUpdateFrame;
            mWindow.RenderFrame += OnRenderFrame;

            mWindow.KeyDown  += OnKeyDown;
            mWindow.KeyUp    += OnKeyUp;
            mWindow.KeyPress += OnKeyPress;

            mWindow.MouseDown  += OnMouseDown;
            mWindow.MouseUp    += OnMouseUp;
            mWindow.MouseWheel += OnMouseWheel;
            mWindow.MouseMove  += OnMouseMove;
            mWindow.MouseEnter += OnMouseEnter;
            mWindow.MouseLeave += OnMouseLeave;

            mRoot = new RootComponent
            {
                BackgroundColor = Color.FromArgb(0, 0, 0, 0),
                BorderColor     = Color.FromArgb(0, 0, 0, 0),
                BorderWidth     = 0,
            };
            OnKeyboard += mRoot.KeyboardHandler;
            OnMouse    += mRoot.MouseHandler;

            //mPerformanceLabel = new Label()
            //{
            //    HorizontalAlignment = HorizontalAlignment.Right,
            //    VerticalAlignment = VerticalAlignment.Bottom,
            //    ClickThrough = true,
            //    //FontFamily = "Arial",
            //    //FontSize = 12,
            //    //FontColor = Color.Orange
            //};
            //AddComponent(mPerformanceLabel);
        }
        public ComponentSaveData GetSaveData()
        {
            // Just in case the root was tagged unserializable for whatever reason.
            RootComponent.SetFlag(GameComponent.Flag.ShouldSerialize, true);

            foreach (var component in Components)
            {
                component.Value.PrepareForSerialization();
            }

            var serializableComponents = Components.Where(c => c.Value.IsFlagSet(GameComponent.Flag.ShouldSerialize)).Select(c => c.Value).ToList();

            return(new ComponentSaveData
            {
                SaveableComponents = serializableComponents,
                RootComponent = RootComponent.GlobalID
            });
        }
Exemple #12
0
        public Component Find(string FullPath)
        {
            // ------------------------------------------------------
            // Locates a component with the specified full path
            // e.g. /RootComponent/Child/SubChild
            // ------------------------------------------------------

            if (FullPath == "")
            {
                throw new Exception("Cannot call Find with a blank path");
            }
            if (FullPath[0] != Component.Delimiter)
            {
                throw new Exception("Path must be fully qualified: " + FullPath);
            }

            int    Pos = FullPath.IndexOf(Component.Delimiter, 1);
            string RootName, NamePath;

            if (Pos == -1)
            {
                RootName = FullPath.Substring(1);
                NamePath = "";
            }
            else
            {
                RootName = FullPath.Substring(1, Pos - 1);
                NamePath = FullPath.Substring(Pos + 1);
            }
            if (RootName.ToLower() != RootComponent.Name.ToLower())
            {
                return(null);
            }
            if (NamePath == "")
            {
                return(RootComponent);
            }
            else
            {
                return(RootComponent.Find(NamePath));
            }
        }
Exemple #13
0
        public void Update(DwarfTime time)
        {
            RootComponent.LocalBounds = new Rectangle(0, 0, GameState.Game.GraphicsDevice.Viewport.Width, GameState.Game.GraphicsDevice.Viewport.Height);
            ToolTipManager.Update(time);

            if (!IsMouseVisible)
            {
                return;
            }

            if (FocusComponent == null)
            {
                RootComponent.Update(time);
            }
            else
            {
                FocusComponent.Update(time);
            }

            LastScrollWheel = Mouse.GetState().ScrollWheelValue;
        }
Exemple #14
0
        public bool UpdateInput()
        {
            bool usedInput = false;

            if (NextFocusAction())
            {
                FocusNext();
                usedInput = true;
            }
            if (PrevFocusAction())
            {
                FocusPrev();
                usedInput = true;
            }

            if (!usedInput)
            {
                usedInput = RootComponent.UpdateInput();
            }

            return(usedInput);
        }
        public void Update(DwarfTime gameTime, ChunkManager chunks, Camera camera)
        {
            GamePerformance.Instance.StartTrackPerformance("Update Transforms");
            if (RootComponent != null)
            {
                RootComponent.UpdateTransformsRecursive(null);
            }
            GamePerformance.Instance.StopTrackPerformance("Update Transforms");

            GamePerformance.Instance.StartTrackPerformance("Factions");
            Factions.Update(gameTime);
            GamePerformance.Instance.StopTrackPerformance("Factions");

            GamePerformance.Instance.TrackValueType("Component Count", Components.Count);
            GamePerformance.Instance.TrackValueType("Updateable Count", UpdateableComponents.Count);
            GamePerformance.Instance.TrackValueType("Renderable Count", RenderableComponents.Count);

            GamePerformance.Instance.StartTrackPerformance("Update Components");
            foreach (var componentType in UpdateableComponents)
            {
                foreach (var component in componentType.Value)
                {
                    //component.Manager = this;

                    if (component.IsActive)
                    {
                        //GamePerformance.Instance.StartTrackPerformance("Component Update " + component.GetType().Name);
                        component.Update(gameTime, chunks, camera);
                        //GamePerformance.Instance.StopTrackPerformance("Component Update " + component.GetType().Name);
                    }
                }
            }

            GamePerformance.Instance.StopTrackPerformance("Update Components");

            HandleAddRemoves();
        }
Exemple #16
0
 public void Update()
 {
     RootComponent.Update();
 }
Exemple #17
0
 public bool IsMouseOver()
 {
     return(RootComponent.IsMouseOverRecursive());
 }
Exemple #18
0
 public void PreRender(DwarfTime time, SpriteBatch sprites)
 {
     RootComponent.PreRender(time, sprites);
 }
Exemple #19
0
        // Group: Public Functions

        public void UpdateSetup()
        {
            RootComponent.UpdateSetup();
        }