Ejemplo n.º 1
0
        private static void GameLoop()
        {
            var Window = WindowHandler.Initialize();
            var GUI    = GUIHandler.Initialize();
            var Clock  = new Clock();

            new BasicScene();

            while (Window.IsOpen)
            {
                Window.DispatchEvents();
                Window.Clear();

                WorldCollision.CheckCollision();
                World.UpdateEntities();
                GlobalConsole.DrawConsole();
                DrawableHandler.Draw();
                InputHandler.UpdateInputs();

                GUI.Draw();
                Window.Display();

                var DeltaClock = Clock.Restart();
                deltaTime = DeltaClock.AsSeconds();
            }
        }
Ejemplo n.º 2
0
        public override void Start()
        {
            _sprite  = new Sprite();
            Drawable = _sprite;

            DrawableHandler.AddDrawable(_sprite, 0);
        }
Ejemplo n.º 3
0
 public GraphicsHandler(DrawableHandler drawableHandler)
 {
     this.drawableHandler = drawableHandler;
     drawableHandler.Widget.LoadComplete += (s, e) => CreateXamlRenderTarget();
     drawableHandler.Control.Loaded      += (s, e) => CreateXamlRenderTarget();
     //drawableHandler.Control.LayoutUpdated += (s, e) => CreateXamlRenderTarget();
     drawableHandler.Control.SizeChanged += (s, e) => CreateXamlRenderTarget();
 }
Ejemplo n.º 4
0
		public GraphicsHandler(DrawableHandler drawableHandler)
		{
			this.drawableHandler = drawableHandler;
			drawableHandler.Widget.LoadComplete += (s, e) => CreateXamlRenderTarget(); 
			drawableHandler.Control.Loaded += (s, e) => CreateXamlRenderTarget();
			//drawableHandler.Control.LayoutUpdated += (s, e) => CreateXamlRenderTarget();
			drawableHandler.Widget.SizeChanged += (s, e) => CreateXamlRenderTarget();
		}
Ejemplo n.º 5
0
        public GraphicsHandler(DrawableHandler drawable)
        {
            this.drawable = drawable;
            CreateRenderTarget();

            //set hwnd target properties (permit to attach Direct2D to window)
            //target creation
            drawable.Control.SizeChanged += HandleSizeChanged;
        }
Ejemplo n.º 6
0
        private void ColliderOnMouseEnter(object sender, EventArgs e)
        {
            var InformationText = $"Town: {_townName}";
            var MousePosition   = WindowHandler.GetMousePositionRelativeToWindow();
            var TextPosition    = new Vector2f(MousePosition.X + 20, MousePosition.Y);

            _text.DisplayedString = InformationText;
            _text.Position        = TextPosition;

            DrawableHandler.AddDrawable(_text, 1);
        }
Ejemplo n.º 7
0
        public override void Start()
        {
            _townName = Entity.Name;

            _collider = Entity.GetComponent <Collider>();

            _collider.MouseEnter += ColliderOnMouseEnter;
            _collider.MouseOver  += ColliderOnMouseOver;
            _collider.MouseExit  += ColliderOnMouseExit;

            _text = DrawableHandler.CreateDrawableText("munro.ttf", 20, Color.Cyan, Text.Styles.Regular);
        }
Ejemplo n.º 8
0
        public virtual void Destroy()
        {
            for (var i = 0; i < Components.Count; i++)
            {
                var Component = Components[i];

                if (Component.GetType() == typeof(Collider))
                {
                    WorldCollision.RemoveCollider((Collider)Component);
                }

                if (Component.GetType() == typeof(Renderer))
                {
                    var Renderer = (Renderer)Component;

                    DrawableHandler.RemoveDrawable(Renderer.Drawable);
                }
            }

            World.RemoveEntity(this);
        }
Ejemplo n.º 9
0
 private void ColliderOnMouseExit(object sender, EventArgs e)
 {
     DrawableHandler.RemoveDrawable(_text);
 }
Ejemplo n.º 10
0
        public override void Start()
        {
            Drawable = Rectangle;

            DrawableHandler.AddDrawable(Rectangle, 0);
        }
Ejemplo n.º 11
0
 public RectangleRenderer(float width = 0, float height = 0)
 {
     Rectangle = DrawableHandler.CreateDrawableRectangleShape(width, height);
 }