示例#1
0
        public bool DrawWhereExitIs(GraphicsDevice graphics)
        {
            Vector focus           = door.Center - camera;
            ThingScreenPosition sp = GetScreenPosition(door.Center);

            switch (sp)
            {
            case ThingScreenPosition.Left:
                if (focus.Y < 16)
                {
                    graphics.DrawImage(GameImage.Hud, 32, 32, 0, 0, 0, 0);
                    graphics.DrawImage(GameImage.Hud, 64, 32, 1, 1, 32, 0);
                }
                else if (focus.Y > Settings.SCREEN_HEIGHT - 16)
                {
                    graphics.DrawImage(GameImage.Hud, 32, 32, 0, 0, 0, Settings.SCREEN_HEIGHT - 32);
                    graphics.DrawImage(GameImage.Hud, 64, 32, 1, 1, 32, Settings.SCREEN_HEIGHT - 32);
                }
                else
                {
                    graphics.DrawImage(GameImage.Hud, 32, 32, 0, 0, 0, (int)Math.Round(focus.Y) - 16);
                    graphics.DrawImage(GameImage.Hud, 64, 32, 1, 1, 32, (int)Math.Round(focus.Y) - 16);
                }
                return(true);

            case ThingScreenPosition.LeftUpper:
                graphics.DrawImage(GameImage.Hud, 32, 32, 0, 1, 0, 0);
                graphics.DrawImage(GameImage.Hud, 64, 32, 1, 1, 32, 32);
                return(true);

            case ThingScreenPosition.Upper:
                if (focus.X < 16)
                {
                    graphics.DrawImage(GameImage.Hud, 32, 32, 0, 2, 0, 0);
                }
                else if (focus.X > Settings.SCREEN_WIDTH - 16)
                {
                    graphics.DrawImage(GameImage.Hud, 32, 32, 0, 2, Settings.SCREEN_WIDTH - 32, 0);
                }
                else
                {
                    graphics.DrawImage(GameImage.Hud, 32, 32, 0, 2, (int)Math.Round(focus.X) - 16, 0);
                }
                if (focus.X < 32)
                {
                    graphics.DrawImage(GameImage.Hud, 64, 32, 1, 1, 0, 32);
                }
                else if (focus.X > Settings.SCREEN_WIDTH - 32)
                {
                    graphics.DrawImage(GameImage.Hud, 64, 32, 1, 1, Settings.SCREEN_WIDTH - 64, 32);
                }
                else
                {
                    graphics.DrawImage(GameImage.Hud, 64, 32, 1, 1, (int)Math.Round(focus.X) - 32, 32);
                }
                return(true);

            case ThingScreenPosition.RightUpper:
                graphics.DrawImage(GameImage.Hud, 32, 32, 0, 3, Settings.SCREEN_WIDTH - 32, 0);
                graphics.DrawImage(GameImage.Hud, 64, 32, 1, 1, Settings.SCREEN_WIDTH - 96, 32);
                return(true);

            case ThingScreenPosition.Right:
                if (focus.Y < 16)
                {
                    graphics.DrawImage(GameImage.Hud, 32, 32, 0, 4, Settings.SCREEN_WIDTH - 32, 0);
                    graphics.DrawImage(GameImage.Hud, 64, 32, 1, 1, Settings.SCREEN_WIDTH - 96, 0);
                }
                else if (focus.Y > Settings.SCREEN_HEIGHT - 16)
                {
                    graphics.DrawImage(GameImage.Hud, 32, 32, 0, 4, Settings.SCREEN_WIDTH - 32, Settings.SCREEN_HEIGHT - 32);
                    graphics.DrawImage(GameImage.Hud, 64, 32, 1, 1, Settings.SCREEN_WIDTH - 96, Settings.SCREEN_HEIGHT - 32);
                }
                else
                {
                    graphics.DrawImage(GameImage.Hud, 32, 32, 0, 4, Settings.SCREEN_WIDTH - 32, (int)Math.Round(focus.Y) - 16);
                    graphics.DrawImage(GameImage.Hud, 64, 32, 1, 1, Settings.SCREEN_WIDTH - 96, (int)Math.Round(focus.Y) - 16);
                }
                return(true);

            case ThingScreenPosition.RightLower:
                graphics.DrawImage(GameImage.Hud, 32, 32, 0, 5, Settings.SCREEN_WIDTH - 32, Settings.SCREEN_HEIGHT - 32);
                graphics.DrawImage(GameImage.Hud, 64, 32, 1, 1, Settings.SCREEN_WIDTH - 96, Settings.SCREEN_HEIGHT - 64);
                return(true);

            case ThingScreenPosition.Lower:
                if (focus.X < 16)
                {
                    graphics.DrawImage(GameImage.Hud, 32, 32, 0, 6, 0, Settings.SCREEN_HEIGHT - 32);
                }
                else if (focus.X > Settings.SCREEN_WIDTH - 16)
                {
                    graphics.DrawImage(GameImage.Hud, 32, 32, 0, 6, Settings.SCREEN_WIDTH - 32, Settings.SCREEN_HEIGHT - 32);
                }
                else
                {
                    graphics.DrawImage(GameImage.Hud, 32, 32, 0, 6, (int)Math.Round(focus.X) - 16, Settings.SCREEN_HEIGHT - 32);
                }
                if (focus.X < 32)
                {
                    graphics.DrawImage(GameImage.Hud, 64, 32, 1, 1, 0, Settings.SCREEN_HEIGHT - 64);
                }
                else if (focus.X > Settings.SCREEN_WIDTH - 32)
                {
                    graphics.DrawImage(GameImage.Hud, 64, 32, 1, 1, Settings.SCREEN_WIDTH - 64, Settings.SCREEN_HEIGHT - 64);
                }
                else
                {
                    graphics.DrawImage(GameImage.Hud, 64, 32, 1, 1, (int)Math.Round(focus.X) - 32, Settings.SCREEN_HEIGHT - 64);
                }
                return(true);

            case ThingScreenPosition.LeftLower:
                graphics.DrawImage(GameImage.Hud, 32, 32, 0, 7, 0, Settings.SCREEN_HEIGHT - 32);
                graphics.DrawImage(GameImage.Hud, 64, 32, 1, 1, 32, Settings.SCREEN_HEIGHT - 64);
                return(true);
            }
            return(false);
        }
示例#2
0
        public bool DrawWhereEnemyIs(GraphicsDevice graphics)
        {
            double minRange = double.MaxValue;
            Thing  target   = null;
            ThingScreenPosition targetPos = ThingScreenPosition.InScreen;

            foreach (Thing enemy in enemies)
            {
                ThingScreenPosition sp = GetScreenPosition(enemy.Center);
                if (sp == ThingScreenPosition.InScreen)
                {
                    return(false);
                }
                if (enemy is AtField || enemy is EggMachine)
                {
                    continue;
                }
                Vector d     = enemy.Center - player.Center;
                double range = d.X * d.X + d.Y * d.Y;
                if (range < minRange)
                {
                    minRange  = range;
                    target    = enemy;
                    targetPos = sp;
                }
            }
            if (target != null)
            {
                Vector focus = target.Center - camera;
                switch (targetPos)
                {
                case ThingScreenPosition.Left:
                    if (focus.Y < 16)
                    {
                        graphics.DrawImage(GameImage.Hud, 32, 32, 0, 0, 0, 0);
                        graphics.DrawImage(GameImage.Hud, 64, 32, 1, 0, 32, 0);
                    }
                    else if (focus.Y > Settings.SCREEN_HEIGHT - 16)
                    {
                        graphics.DrawImage(GameImage.Hud, 32, 32, 0, 0, 0, Settings.SCREEN_HEIGHT - 32);
                        graphics.DrawImage(GameImage.Hud, 64, 32, 1, 0, 32, Settings.SCREEN_HEIGHT - 32);
                    }
                    else
                    {
                        graphics.DrawImage(GameImage.Hud, 32, 32, 0, 0, 0, (int)Math.Round(focus.Y) - 16);
                        graphics.DrawImage(GameImage.Hud, 64, 32, 1, 0, 32, (int)Math.Round(focus.Y) - 16);
                    }
                    return(true);

                case ThingScreenPosition.LeftUpper:
                    graphics.DrawImage(GameImage.Hud, 32, 32, 0, 1, 0, 0);
                    graphics.DrawImage(GameImage.Hud, 64, 32, 1, 0, 32, 32);
                    return(true);

                case ThingScreenPosition.Upper:
                    if (focus.X < 16)
                    {
                        graphics.DrawImage(GameImage.Hud, 32, 32, 0, 2, 0, 0);
                    }
                    else if (focus.X > Settings.SCREEN_WIDTH - 16)
                    {
                        graphics.DrawImage(GameImage.Hud, 32, 32, 0, 2, Settings.SCREEN_WIDTH - 32, 0);
                    }
                    else
                    {
                        graphics.DrawImage(GameImage.Hud, 32, 32, 0, 2, (int)Math.Round(focus.X) - 16, 0);
                    }
                    if (focus.X < 32)
                    {
                        graphics.DrawImage(GameImage.Hud, 64, 32, 1, 0, 0, 32);
                    }
                    else if (focus.X > Settings.SCREEN_WIDTH - 32)
                    {
                        graphics.DrawImage(GameImage.Hud, 64, 32, 1, 0, Settings.SCREEN_WIDTH - 64, 32);
                    }
                    else
                    {
                        graphics.DrawImage(GameImage.Hud, 64, 32, 1, 0, (int)Math.Round(focus.X) - 32, 32);
                    }
                    return(true);

                case ThingScreenPosition.RightUpper:
                    graphics.DrawImage(GameImage.Hud, 32, 32, 0, 3, Settings.SCREEN_WIDTH - 32, 0);
                    graphics.DrawImage(GameImage.Hud, 64, 32, 1, 0, Settings.SCREEN_WIDTH - 96, 32);
                    return(true);

                case ThingScreenPosition.Right:
                    if (focus.Y < 16)
                    {
                        graphics.DrawImage(GameImage.Hud, 32, 32, 0, 4, Settings.SCREEN_WIDTH - 32, 0);
                        graphics.DrawImage(GameImage.Hud, 64, 32, 1, 0, Settings.SCREEN_WIDTH - 96, 0);
                    }
                    else if (focus.Y > Settings.SCREEN_HEIGHT - 16)
                    {
                        graphics.DrawImage(GameImage.Hud, 32, 32, 0, 4, Settings.SCREEN_WIDTH - 32, Settings.SCREEN_HEIGHT - 32);
                        graphics.DrawImage(GameImage.Hud, 64, 32, 1, 0, Settings.SCREEN_WIDTH - 96, Settings.SCREEN_HEIGHT - 32);
                    }
                    else
                    {
                        graphics.DrawImage(GameImage.Hud, 32, 32, 0, 4, Settings.SCREEN_WIDTH - 32, (int)Math.Round(focus.Y) - 16);
                        graphics.DrawImage(GameImage.Hud, 64, 32, 1, 0, Settings.SCREEN_WIDTH - 96, (int)Math.Round(focus.Y) - 16);
                    }
                    return(true);

                case ThingScreenPosition.RightLower:
                    graphics.DrawImage(GameImage.Hud, 32, 32, 0, 5, Settings.SCREEN_WIDTH - 32, Settings.SCREEN_HEIGHT - 32);
                    graphics.DrawImage(GameImage.Hud, 64, 32, 1, 0, Settings.SCREEN_WIDTH - 96, Settings.SCREEN_HEIGHT - 64);
                    return(true);

                case ThingScreenPosition.Lower:
                    if (focus.X < 16)
                    {
                        graphics.DrawImage(GameImage.Hud, 32, 32, 0, 6, 0, Settings.SCREEN_HEIGHT - 32);
                    }
                    else if (focus.X > Settings.SCREEN_WIDTH - 16)
                    {
                        graphics.DrawImage(GameImage.Hud, 32, 32, 0, 6, Settings.SCREEN_WIDTH - 32, Settings.SCREEN_HEIGHT - 32);
                    }
                    else
                    {
                        graphics.DrawImage(GameImage.Hud, 32, 32, 0, 6, (int)Math.Round(focus.X) - 16, Settings.SCREEN_HEIGHT - 32);
                    }
                    if (focus.X < 32)
                    {
                        graphics.DrawImage(GameImage.Hud, 64, 32, 1, 0, 0, Settings.SCREEN_HEIGHT - 64);
                    }
                    else if (focus.X > Settings.SCREEN_WIDTH - 32)
                    {
                        graphics.DrawImage(GameImage.Hud, 64, 32, 1, 0, Settings.SCREEN_WIDTH - 64, Settings.SCREEN_HEIGHT - 64);
                    }
                    else
                    {
                        graphics.DrawImage(GameImage.Hud, 64, 32, 1, 0, (int)Math.Round(focus.X) - 32, Settings.SCREEN_HEIGHT - 64);
                    }
                    return(true);

                case ThingScreenPosition.LeftLower:
                    graphics.DrawImage(GameImage.Hud, 32, 32, 0, 7, 0, Settings.SCREEN_HEIGHT - 32);
                    graphics.DrawImage(GameImage.Hud, 64, 32, 1, 0, 32, Settings.SCREEN_HEIGHT - 64);
                    return(true);
                }
            }
            return(false);
        }