public override void Update(KeyboardDevice keyboard)
        {
            PipeZone zone = GetUnderlyingZone();

            if (zone == null)
            {
                if (hasConnected)
                {
                    hasFinished = true;
                    zone        = GetUnderlyingZone();
                }
            }
            else
            {
                hasConnected = true;
                if (!zone.IsDirection(direction))
                {
                    direction = zone.GetOneDirection();
                }
                speed = zone.GetSpeed();
            }

            Vec2d delta = PipeZone.GetVectorForDirection(direction);

            delta.SetLength(speed);

            if (direction == PipeDirection.SOUTH || direction == PipeDirection.NORTH)
            {
                double corr = GetXCorrection();
                delta.X += Math.Min(Math.Abs(corr), Math.Abs(speed * PIPECORRECTION_SPEEDFACTOR)) * Math.Sign(corr);
            }

            if (direction == PipeDirection.EAST || direction == PipeDirection.WEST)
            {
                double corr = GetYCorrection();
                delta.Y += Math.Min(Math.Abs(corr), Math.Abs(speed * PIPECORRECTION_SPEEDFACTOR)) * Math.Sign(corr);
            }

            ent.position += delta;
            ent.DoCollisions();

            deltaCache = delta;
        }
예제 #2
0
        private void TestForPipe(PipeDirection d)
        {
            Vec2i blockpos = (Vec2i)(GetMiddle() / Block.BLOCK_SIZE);

            blockpos += PipeZone.GetVectorForDirection(d);

            List <Trigger> triggerlist = owner.getTriggerList(blockpos.X, blockpos.Y);

            if (triggerlist != null)
            {
                foreach (Trigger t in owner.getTriggerList(blockpos.X, blockpos.Y))
                {
                    if (t is PipeZone && (t as PipeZone).IsDirection(d) && (t as PipeZone).CanEnter())
                    {
                        AddController(new PipePlayerController(this, d));
                    }
                }
            }
        }
예제 #3
0
        private void RenderDebug(Vec2i offset)
        {
            GL.Disable(EnableCap.Texture2D);

            if (Program.vectorDebugViewSwitch.Value)
            {
                #region Render Trigger

                for (int x = 0; x < model.mapBlockWidth; x++)
                {
                    for (int y = 0; y < model.mapBlockHeight; y++)
                    {
                        List <Trigger> tlist = model.getTriggerList(x, y);

                        if (tlist != null)
                        {
                            foreach (Trigger t in tlist)
                            {
                                RenderColoredRectangle(t.GetPosition(), Entity.DISTANCE_DEBUG_ZONE, Color.FromArgb(128, t.GetTriggerColor()));

                                if (t is PipeZone)
                                {
                                    PipeZone z = t as PipeZone;

                                    RenderColoredBox(t.GetPosition(), Entity.DISTANCE_DEBUG_ZONE, t.GetTriggerColor());

                                    Vec2d     start    = t.GetPosition().GetMiddle();
                                    Vec2d     arr      = Vec2d.Zero;
                                    const int arrlen   = 5;
                                    Color4    arrcolor = z.CanEnter() ? Color.Red : Color.Black;
                                    switch (z.GetRealDirection())
                                    {
                                    case PipeDirection.NORTH:
                                        start.Y -= Block.BLOCK_HEIGHT / 4.0;
                                        arr      = new Vec2d(0, Block.BLOCK_HEIGHT / 2.0);
                                        RenderArrow(start, arr, Entity.DISTANCE_DEBUG_ZONE - 1, arrlen, arrcolor);
                                        break;

                                    case PipeDirection.EAST:
                                        start.X -= Block.BLOCK_HEIGHT / 4.0;
                                        arr      = new Vec2d(Block.BLOCK_WIDTH / 2.0, 0);
                                        RenderArrow(start, arr, Entity.DISTANCE_DEBUG_ZONE - 1, arrlen, arrcolor);
                                        break;

                                    case PipeDirection.SOUTH:
                                        start.Y += Block.BLOCK_WIDTH / 4.0;
                                        arr      = new Vec2d(0, -Block.BLOCK_HEIGHT / 2.0);
                                        RenderArrow(start, arr, Entity.DISTANCE_DEBUG_ZONE - 1, arrlen, arrcolor);
                                        break;

                                    case PipeDirection.WEST:
                                        start.X += Block.BLOCK_WIDTH / 4.0;
                                        arr      = new Vec2d(-Block.BLOCK_WIDTH / 2.0, 0);
                                        RenderArrow(start, arr, Entity.DISTANCE_DEBUG_ZONE - 1, arrlen, arrcolor);
                                        break;

                                    case PipeDirection.NORTHSOUTH:
                                        arr = new Vec2d(0, Block.BLOCK_HEIGHT / 4.0);
                                        RenderArrow(start, arr, Entity.DISTANCE_DEBUG_ZONE - 1, arrlen, arrcolor);
                                        arr = new Vec2d(0, -Block.BLOCK_HEIGHT / 4.0);
                                        RenderArrow(start, arr, Entity.DISTANCE_DEBUG_ZONE - 1, arrlen, arrcolor);
                                        break;

                                    case PipeDirection.EASTWEST:
                                        arr = new Vec2d(Block.BLOCK_WIDTH / 4.0, 0);
                                        RenderArrow(start, arr, Entity.DISTANCE_DEBUG_ZONE - 1, arrlen, arrcolor);
                                        arr = new Vec2d(-Block.BLOCK_WIDTH / 4.0, 0);
                                        RenderArrow(start, arr, Entity.DISTANCE_DEBUG_ZONE - 1, arrlen, arrcolor);
                                        break;

                                    case PipeDirection.ANY:
                                        arr = new Vec2d(0, Block.BLOCK_HEIGHT / 4.0);
                                        RenderArrow(start, arr, Entity.DISTANCE_DEBUG_ZONE - 1, arrlen, arrcolor);
                                        arr = new Vec2d(0, -Block.BLOCK_HEIGHT / 4.0);
                                        RenderArrow(start, arr, Entity.DISTANCE_DEBUG_ZONE - 1, arrlen, arrcolor);
                                        arr = new Vec2d(Block.BLOCK_WIDTH / 4.0, 0);
                                        RenderArrow(start, arr, Entity.DISTANCE_DEBUG_ZONE - 1, arrlen, arrcolor);
                                        arr = new Vec2d(-Block.BLOCK_WIDTH / 4.0, 0);
                                        RenderArrow(start, arr, Entity.DISTANCE_DEBUG_ZONE - 1, arrlen, arrcolor);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }

                #endregion Render Trigger

                #region CollsionBoxes && MovementVectors

                foreach (DynamicEntity e in model.dynamicEntityList)
                {
                    RenderColoredBox(e.GetPosition(), Entity.DISTANCE_DEBUG_MARKER, Color.FromArgb(200, 0, 0, 255));

                    RenderArrow(e.GetMiddle(), e.GetMovement() * 8, Entity.DISTANCE_DEBUG_MARKER, 7, Color.FromArgb(200, 0, 0, 255));
                }

                #endregion CollsionBoxes && MovementVectors

                #region OffsetBox

                RenderColoredBox(((GameWorld)model).offset.GetOffsetBox(INIT_RESOLUTION_WIDTH, INIT_RESOLUTION_HEIGHT), Entity.DISTANCE_DEBUG_MARKER, Color.FromArgb(200, 255, 0, 0));

                #endregion OffsetBox
            }

            if (Program.minimapViewSwitch.Value)
            {
                #region Minimap


                RenderMinimap(offset, Entity.DISTANCE_DEBUG_MINIMAP);

                #endregion Minimap
            }

            #region DebugTexts

            int    foy = 3;
            Color4 col = Color.FromArgb(0, 0, 0);
            Player pl  = ((GameWorld)model).player;
            RenderFont(offset, new Vec2d(5, 5 + foy++ *12), DebugFont, String.Format("FPS: {0} / {1}", (int)fps_counter.Frequency, window.TargetRenderFrequency), col);
            RenderFont(offset, new Vec2d(5, 5 + foy++ *12), DebugFont, String.Format("UPS: {0} / {1}", (int)ups_counter.Frequency, window.TargetUpdateFrequency), col);
            RenderFont(offset, new Vec2d(5, 5 + foy++ *12), DebugFont, String.Format("dyn. Entities: {0}", model.dynamicEntityList.Count), col);
            RenderFont(offset, new Vec2d(5, 5 + foy++ *12), DebugFont, String.Format("Optical Particles: {0}/{1}", Particle.GetGlobalParticleCount(), Particle.MAX_PARTICLE_COUNT), col);
            RenderFont(offset, new Vec2d(5, 5 + foy++ *12), DebugFont, String.Format("Player: [int] {0}", (Vec2i)pl.position), col);
            RenderFont(offset, new Vec2d(5, 5 + foy++ *12), DebugFont, String.Format("Offset: [int] {0}", (Vec2i)offset), col);
            RenderFont(offset, new Vec2d(5, 5 + foy++ *12), DebugFont, String.Format("Player -> : [int] {0}", (Vec2i)pl.GetMovement()), col);
            RenderFont(offset, new Vec2d(5, 5 + foy++ *12), DebugFont, String.Format("Avg R-Time: {0}", ((int)(render_watch.Duration * 10)) / 10.0), col);
            RenderFont(offset, new Vec2d(5, 5 + foy++ *12), DebugFont, String.Format("Avg U-Time: {0}", ((int)(update_watch.Duration * 10)) / 10.0), col);
            RenderFont(offset, new Vec2d(5, 5 + foy++ *12), DebugFont, String.Format("Delayed Actions: {0}", model.delayedActionList.Count), col);
            RenderFont(offset, new Vec2d(5, 5 + foy++ *12), DebugFont, String.Format("World: {0}-{1}", (model as GameWorld).mapWorld, (model as GameWorld).mapLevel), col);
            RenderFont(offset, new Vec2d(5, 5 + foy++ *12), DebugFont, String.Format("Controller ({0}): {1}", pl.GetControllerStack().Count, pl.GetControllerStack().Count > 0 ? pl.GetControllerStack().Peek().GetType().Name : "null"), col);

            #endregion DebugTexts

            if (Program.debugKeyBindingSwitch.Value)
            {
                #region CheatTexts

                int    foy2 = 1;
                int    dfcx = INIT_RESOLUTION_WIDTH * zoom - 115;
                Color4 col2 = Color.FromArgb(255, 0, 0);
                RenderFont(offset, new Vec2d(dfcx, 5 + foy2++ *12), DebugFont, "[F1] ", col2);
                RenderFont(offset, new Vec2d(dfcx, 5 + foy2++ *12), DebugFont, "[F2] Lifes", col2);
                RenderFont(offset, new Vec2d(dfcx, 5 + foy2++ *12), DebugFont, "[F3] Power", col2);
                RenderFont(offset, new Vec2d(dfcx, 5 + foy2++ *12), DebugFont, "[F4] Coins", col2);
                RenderFont(offset, new Vec2d(dfcx, 5 + foy2++ *12), DebugFont, "[F5] Suicide", col2);
                RenderFont(offset, new Vec2d(dfcx, 5 + foy2++ *12), DebugFont, "[F6] DebugWorld", col2);
                RenderFont(offset, new Vec2d(dfcx, 5 + foy2++ *12), DebugFont, "[F7] Particles", col2);
                RenderFont(offset, new Vec2d(dfcx, 5 + foy2++ *12), DebugFont, "[F8] MinimapView", col2);
                RenderFont(offset, new Vec2d(dfcx, 5 + foy2++ *12), DebugFont, "[F9] VectorView", col2);
                RenderFont(offset, new Vec2d(dfcx, 5 + foy2++ *12), DebugFont, "[F10] DebugView", col2);
                RenderFont(offset, new Vec2d(dfcx, 5 + foy2++ *12), DebugFont, "[F11] KeySheet", col2);
                RenderFont(offset, new Vec2d(dfcx, 5 + foy2++ *12), DebugFont, "[F12] ", col2);
                RenderFont(offset, new Vec2d(dfcx, 5 + foy2++ *12), DebugFont, "[Ctrl] Fly", col2);
                RenderFont(offset, new Vec2d(dfcx, 5 + foy2++ *12), DebugFont, "[Shift] NoClip", col2);

                #endregion DebugTexts
            }

            GL.Enable(EnableCap.Texture2D);
        }