コード例 #1
0
ファイル: World.cs プロジェクト: dgg5503/The-Chicago-Project
        //Updates the world every frame.
        public void tick(GameTime time)
        {
            Player player = manager.GetPlayer();
            int pX = player.location.IntX / Tile.SIDE_LENGTH; //The actual player location.
            int pY = player.location.IntY / Tile.SIDE_LENGTH; //The actual player location.
            int width = Game1.Instance.GraphicsDevice.Viewport.Width / Tile.SIDE_LENGTH + 10;
            int height = Game1.Instance.GraphicsDevice.Viewport.Height / Tile.SIDE_LENGTH + 10;
            if (playerMap == null) {
                playerMap = new DijkstraMap(this, width, height, pX - 5, pY - 5, 1, new int[] { 5, 5 });
                fleeMap = playerMap.Clone().GenerateFleeMap(this);
            }
            int[] pLoc = playerMap.Goals[0]; //The player location for AI's.
            if (pX != pLoc[0] || pY != pLoc[1]) {
                playerMap = new DijkstraMap(this, width, height, pX - 5, pY - 5, 1, new int[] { 5, 5 });
                fleeMap = playerMap.Clone().GenerateFleeMap(this);
            }

            manager.Update(time);
        }