示例#1
0
        public Map(Golf game, TileSet tileSet, MapLayer layer1, MapLayer layer2, int columns, int rows, Vector2 start, Side startStartSide, int startLayer, Vector2 end, Side endEndSide, int endLayer, List <Player> players, int currentPlayer, Procedure <Map> endLevel)
        {
            Game       = game;
            EndLevel   = endLevel;
            ColorTween = new Tween(new TimeSpan(0, 0, 0, 1), 0.0f, 0.8f, true);
            //TileSet = tileSet;
            Layer1           = layer1;
            Layer2           = layer2;
            Columns          = columns;
            Start            = start;
            StartSide        = startStartSide;
            StartLayer       = startLayer;
            StartWorldCenter =
                new Vector2(Math.Max(Start.X, 0) * TileSet.TileWidth,
                            Math.Max(Start.Y, 0) * TileSet.TileHeight) + WorldHelpers.GetStartOffset(StartSide);
            End            = end;
            EndSide        = endEndSide;
            EndLayer       = endLayer;
            EndWorldCenter =
                new Vector2(Math.Max(End.X, 0) * TileSet.TileWidth,
                            Math.Max(End.Y, 0) * TileSet.TileHeight) + WorldHelpers.GetEndOffset(EndSide);

            Players       = players;
            CurrentPlayer = currentPlayer;
            Rows          = rows;

            Camera = new Camera2D();
            if (!Players.Any())
            {
                return;
            }
            foreach (var p in Players)
            {
                p.Node              = new Node(new Vector2(Math.Max(Start.X, 0) * tileSet.TileWidth, Math.Max(Start.Y, 0) * tileSet.TileHeight) + WorldHelpers.GetStartOffset(StartSide), 2.5f, 1, Vector2.Zero, Vector2.Zero, startLayer);
                p.LastTile          = GetPlayerTile(p);
                p.PreviousTile      = p.LastTile;
                p.Layer             = startLayer;
                p.Node.OnCollision += PlayBounce;
                p.State             = PlayerState.Finished;
                p.Par = -1;
            }
            Camera.Focus = Game.Center - Players[CurrentPlayer].Position;
            Players[CurrentPlayer].Start();
        }