示例#1
0
        public static void CrMon(CrMod CM, bool del)
        {
            MouseState ms = Mouse.GetState();

            float     x = CM.CrV.X + (-WinWIDTH / 2) + ms.X; float y = CM.CrV.Y + (-WinHEIGHT / 2) + ms.Y;
            Rectangle R = new Rectangle((int)x, (int)y, width, height);
            bool      isInter = false; Monster m = new Monster(Vector2.Zero);
            bool      fl = false;

            foreach (Monster en in enemies)
            {
                if (R.Intersects(en.rec))
                {
                    isInter = true;
                    if (del == true && en.rec.Contains(new Vector2(ms.X, ms.Y) + CM.CrV - new Vector2(WinWIDTH / 2, WinHEIGHT / 2)))
                    {
                        fl = true; m = en; break;
                    }
                }
            }
            if (!isInter)
            {
                Monster mon = new Monster(new Vector2(x, y));
                enemies.Add(mon);
            }
            else if (del && fl)
            {
                enemies.Remove(m);
            }
        }
示例#2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            map       = new Map(); map.MapGener(70, 70);
            camera    = new Camera(GraphicsDevice.Viewport);
            WinWIDTH  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
            WinHEIGHT = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
            //  CellWIDTH = WinWIDTH / NumCellWIDTH;
            // CellHEIGHT = WinHEIGHT / NumCellHEIGHT;
            CellWIDTH = 60; CellHEIGHT = 60;
            CM        = new CrMod();

            MonsteR = Content.Load <Texture2D>("monster");
            enemies = new List <Monster>();
            graphics.PreferredBackBufferWidth  = WinWIDTH;
            graphics.PreferredBackBufferHeight = WinHEIGHT;

            Window.Position = new Point(0, 0);
            //graphics.IsFullScreen = true;
            graphics.ApplyChanges();
            IsMouseVisible = true;
            base.Initialize();
        }