示例#1
0
 public void RenderInGameLoop(SceneContext context)
 {
     foreach (IRenderInGameloopHudElement he in this.gameloopElemnts)
     {
         he.Render(context);
     }
 }
示例#2
0
        public void Update(GameTime gameTime, SceneContext c)
        {
            KeyboardState kbState = Keyboard.GetState();
            GamePadState  gpState = GamePad.GetState(this.PlayerIndex);  /// TODO: für ander 3 spieler erweitern
            MouseState    mState  = Mouse.GetState();

            foreach (InputAction a in actions)
            {
                a.Update(kbState, gpState, mState);
            }

            foreach (Axis a in this.axises)
            {
                a.Update(gpState, mState, c, gameTime);
            }

            if (this.isMouseAxisAdded && this.MouseGrabbed)  // TODO: wirklich mit dem dass mouse geadded wurde?
            {
                int width  = c.GraphicsDeviceManager.GraphicsDevice.Viewport.Width / 2;
                int height = c.GraphicsDeviceManager.GraphicsDevice.Viewport.Height / 2;
                try
                {
                    Mouse.SetPosition(width, height);   // maus immer zentrieren, damit man das delta berechnen kann
                }
                catch
                {
                    Console.WriteLine("RANZ MAUS SET POSITON FEHLER");
                }
            }
        }
示例#3
0
 public void Render(SceneContext context)
 {
     foreach (IHudElement he in this.elements)
     {
         he.Render(context);
     }
 }
示例#4
0
        /* public void DropItem(EntityContext c, Vector2 pos, float angel, Item def)
         * {
         *   def.AddToWorld(c);
         *   def.Body.Position = pos;
         *
         *   Random r = new Random();
         *
         *   angel -= MathHelper.ToRadians(DROP_ANGLE/2);
         *   angel += (float)r.NextDouble() * MathHelper.ToRadians(DROP_ANGLE);
         *
         *   Vector2 impulse = VectorMath.RotateAroundOrigin(new Vector2(0, 1), angel, false);
         *   impulse *= new Vector2(DROPS_SPEED * (float)r.NextDouble());
         *   def.Body.ApplyForce(ConvertUnits.ToSimUnits(impulse));
         * }*/

        public void Update(SceneContext c, GameTime gameTime)
        {
            this.EntitiesInRange.Clear();
            if (!this.IsEnabled)
            {
                return;
            }

            AABB aabb = new AABB(ConvertUnits.ToSimUnits(this.camera.Position),
                                 ConvertUnits.ToSimUnits(ENTITY_RANGE_X),
                                 ConvertUnits.ToSimUnits(ENTITY_RANGE_Y));

            this.World.QueryAABB(
                (f) => {
                Entity e = f.Body.UserData as Entity;
                if (e != null)
                {
                    this.EntitiesInRange.Add(e);
                }
                return(true);
            },
                ref aabb);

            foreach (Entity e in this.EntitiesInRange)
            {
                // this.updateChildren(e, gc, gameTime);
                e.Update(c, gameTime);
                // e.FinishUpdating(c);
            }

            foreach (Entity e in this.EntitiesInRange)
            {
                // this.updateChildren(e, gc, gameTime);
                e.ClearFlags();
                // e.FinishUpdating(c);
            }

            this.World.Step(Math.Min((float)gameTime.ElapsedGameTime.TotalSeconds, (1f / this.WorldStep)));

            if (this.Map != null)
            {
                this.Map.Update(c, gameTime);
            }

            if (this.toRemove.Count > 0)
            {
                foreach (Body b in this.toRemove)
                {
                    this.World.RemoveBody(b);
                }

                this.toRemove.Clear();
            }
        }
示例#5
0
        public void Update(SceneContext c, GameTime gt)
        {
            foreach (IRenderInGameloopHudElement he in this.gameloopElemnts)
            {
                he.Update(c, gt);
            }

            foreach (IHudElement he in this.elements)
            {
                he.Update(c, gt);
            }
        }
示例#6
0
 public void Render(SceneContext c)
 {
     if (this.Map != null)
     {
         this.Map.RenderGround(c);
     }
     foreach (Entity e in this.EntitiesInRange)
     {
         e.Render(c);
     }
     if (this.Map != null)
     {
         this.Map.RenderTop(c);
     }
 }
示例#7
0
        internal void Update(GamePadState gpState, MouseState mState, SceneContext c, GameTime gameTime)
        {
            //  float oldDX = this.DX;
            //  float oldDY = this.DY;

            switch (this.Type)
            {
            case AxisType.LeftThumbStick:
                this.DX = -gpState.ThumbSticks.Left.X;
                this.DY = gpState.ThumbSticks.Left.Y;
                break;

            case AxisType.RightThumbStick:
                this.DX = -gpState.ThumbSticks.Right.X;
                this.DY = gpState.ThumbSticks.Right.Y;
                break;

            case AxisType.Mouse:
                if (!this.parent.MouseGrabbed)
                {
                    this.DX = 0;
                    this.DY = 0;
                    break;
                }

                float width  = c.GraphicsDeviceManager.GraphicsDevice.Viewport.Width * 0.5f;
                float height = c.GraphicsDeviceManager.GraphicsDevice.Viewport.Height * 0.5f;

                // da die maus zentriert ist kann man einfach von der hälfte der bildschirmgröße die neue mausposition abziehen und hat so das neue mausdelta

                float dx = width - mState.X;
                float dy = (height - mState.Y);

                // mouse grabben

                //  mState.X = (int)width;
                //  mState.Y = (int)height;
                try
                {
                    Mouse.SetPosition((int)width, (int)height);         //TODO wirklich hier? warum ruckelt des so - voll ranzig
                }
                catch
                {
                    Console.WriteLine("ranz maus setz position in input manager spackt wieder rum weils spiel beendet wurde");
                }
                if (dx > MouseDeltaRange)
                {
                    dx = MouseDeltaRange;
                }
                if (dx < -MouseDeltaRange)
                {
                    dx = -MouseDeltaRange;
                }

                if (dy > MouseDeltaRange)
                {
                    dy = MouseDeltaRange;
                }
                if (dy < -MouseDeltaRange)
                {
                    dy = -MouseDeltaRange;
                }

                this.DX = dx / MouseDeltaRange;
                this.DY = dy / MouseDeltaRange;

                break;
            }


            // this.DX *= gameTime.ElapsedGameTime.Milliseconds;
            // this.DY *= gameTime.ElapsedGameTime.Milliseconds;

            this.DX *= this.Sensitivity;
            this.DY *= this.Sensitivity;

            // wenn nicht gleich null beide dann event schickn dass sich was bewegen soll
            if (this.DX != 0 || this.DY != 0)
            {
                this.WasMoved = true;
                //     this.parent.sendEvent(new BasicEvent(this));
            }
            else
            {
                this.WasMoved = false;
            }
        }
示例#8
0
 public abstract void OpenHudSpritebatch(SceneContext context);
示例#9
0
 public void OnStart(SceneContext ec, Scene previous = null)
 {
     //TODO:
 }
示例#10
0
 public void Initialize(SceneContext context)
 {
     this.camera = context.GetComponent <ProtoCamera>();
 }
示例#11
0
 public void LoadContent(SceneContext c)
 {
     debug.LoadContent(c.GraphicsDeviceManager.GraphicsDevice, c.SceneResourceManager.Content);
 }
示例#12
0
        public void RenderDebug(SceneContext c)
        {
#if DEBUG
            this.debug.RenderDebugData(this.camera.SimProjection, this.camera.SimView);
#endif
        }
示例#13
0
 public void OnPause(SceneContext e, Scene next = null)
 {
     //TODO:
 }