Beispiel #1
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()
        {
            GameCode.Graphics.Tile.m_base      = Content.Load <Texture2D>("sheet");
            GameCode.Graphics.Tile.SpriteCount = new Point(19, 13);

            m_touch = new TouchInputManager();
            m_map   = new List <Level>();
            m_map.Add(new Town(Android.OS.Build.Serial.GetHashCode() + CurrentFloor));

            GeneratingFloor++;

            m_manager = new Thread(() => ThreadMap());
            m_manager.Start();

            m_cam        = new Camera(GraphicsDevice.Viewport);
            m_minimap    = new minimap(m_map[0].Map.GetLength(0));
            m_ui         = new Ui(new Vector2(graphics.PreferredBackBufferWidth / 6, graphics.PreferredBackBufferHeight - graphics.PreferredBackBufferHeight / 5), (graphics.PreferredBackBufferWidth / 20));
            m_p.Position = new Vector2(m_map[0].m_StartPos.X * TILESIZE, m_map[0].m_StartPos.Y * TILESIZE);

            m_p.VirtualPosition = m_map[0].m_StartPos;
            m_minimap.UpdateMap(m_map[0]);
            m_minimap.ShowAll();

            base.Initialize();
        }
Beispiel #2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            m_touch.UpdateMe();
            if (new Rectangle(m_p.Position.ToPoint(), new Point(TILESIZE, TILESIZE)).Intersects(
                    new Rectangle(m_map[0].m_WinPos.X * TILESIZE, m_map[0].m_WinPos.Y * TILESIZE, TILESIZE, TILESIZE)))
            {
                CurrentFloor++;
                GeneratingFloor++;

                m_manager.Join();
                m_map.RemoveAt(0);
                m_manager = new Thread(new ThreadStart(ThreadMap));
                m_manager.Start();
                m_p.Position        = new Vector2(m_map[0].m_StartPos.X * TILESIZE, m_map[0].m_StartPos.Y * TILESIZE);
                m_p.VirtualPosition = m_map[0].m_StartPos;
                m_minimap.UpdateMap(m_map[0]);
                if (CurrentFloor % TownNumber == 0)
                {
                    m_minimap.ShowAll();
                }
            }
            if (CurrentFloor % TownNumber != 0)
            {
                m_minimap.UpdateMe(gameTime, m_p, m_map[0]);
            }
            m_ui.UpdateMe(m_touch);
            if (PlayerTurn)
            {
                m_p.TakeTurn(m_ui);
            }
            m_p.UpdateMe(gameTime, m_map[0], m_ui, m_touch);

            m_map[0].UpdateMe(gameTime, m_p, m_touch);

            m_cam.UpdateMe(m_p.Position, new Point(TILESIZE * m_map[0].Map.GetLength(0), TILESIZE * m_map[0].Map.GetLength(1)));
            //m_cam.UpdateMe(m_touch.m_Touches[0].Position, new Point(0, 0));


            base.Update(gameTime);
        }