start pos

This commit is contained in:
Chris Forbes
2009-12-02 20:49:59 +13:00
parent 7e064fec1a
commit bd5faef639
5 changed files with 32 additions and 23 deletions

View File

@@ -80,6 +80,9 @@ namespace OpenRa.Game
if (Owner != Game.LocalPlayer) if (Owner != Game.LocalPlayer)
return null; return null;
if (!Rules.Map.IsInMap(xy.X, xy.Y))
return null;
var underCursor = Game.UnitInfluence.GetUnitAt( xy ) ?? Game.BuildingInfluence.GetBuildingAt( xy ); var underCursor = Game.UnitInfluence.GetUnitAt( xy ) ?? Game.BuildingInfluence.GetBuildingAt( xy );
return traits.WithInterface<Traits.IOrder>() return traits.WithInterface<Traits.IOrder>()

View File

@@ -36,7 +36,11 @@ namespace OpenRa.Game
public static Player LocalPlayer public static Player LocalPlayer
{ {
get { return players[localPlayerIndex]; } get { return players[localPlayerIndex]; }
set { localPlayerIndex = value.Index; } set
{
localPlayerIndex = value.Index;
viewport.GoToStartLocation();
}
} }
public static BuildingInfluenceMap BuildingInfluence; public static BuildingInfluenceMap BuildingInfluence;
public static UnitInfluenceMap UnitInfluence; public static UnitInfluenceMap UnitInfluence;
@@ -313,7 +317,7 @@ namespace OpenRa.Game
public static bool CanPlaceBuilding(BuildingInfo building, int2 xy, Actor toIgnore, bool adjust) public static bool CanPlaceBuilding(BuildingInfo building, int2 xy, Actor toIgnore, bool adjust)
{ {
return !Footprint.Tiles(building, xy, adjust).Any( return !Footprint.Tiles(building, xy, adjust).Any(
t => Rules.Map.ContainsResource(t) || !Game.IsCellBuildable(t, t => !Rules.Map.IsInMap(t.X, t.Y) || Rules.Map.ContainsResource(t) || !Game.IsCellBuildable(t,
building.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel, building.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel,
toIgnore)); toIgnore));
} }

View File

@@ -84,5 +84,16 @@ namespace OpenRa.Game.Graphics
{ {
return (1 / 24.0f) * (new float2(mi.Location.X, mi.Location.Y) + Location); return (1 / 24.0f) * (new float2(mi.Location.X, mi.Location.Y) + Location);
} }
public void GoToStartLocation()
{
var unit = Game.world.Actors
.FirstOrDefault(a => a.Owner == Game.LocalPlayer);
if (unit == null)
return;
scrollPosition = unit.CenterLocation - .5f * new float2(Width, Height);
}
} }
} }

View File

@@ -38,13 +38,11 @@ namespace OpenRa.Game
{ {
int2 newHere = p.Location + d; int2 newHere = p.Location + d;
if (!Rules.Map.IsInMap(newHere.X, newHere.Y)) continue;
if( cellInfo[ newHere.X, newHere.Y ].Seen ) if( cellInfo[ newHere.X, newHere.Y ].Seen )
continue; continue;
if (ignoreTerrain)
{ if (!ignoreTerrain)
if (!Rules.Map.IsInMap(newHere.X, newHere.Y)) continue;
}
else
{ {
if (passableCost[(int)umt][newHere.X, newHere.Y] == float.PositiveInfinity) if (passableCost[(int)umt][newHere.X, newHere.Y] == float.PositiveInfinity)
continue; continue;
@@ -53,6 +51,7 @@ namespace OpenRa.Game
if (Rules.Map.IsOverlaySolid(newHere)) if (Rules.Map.IsOverlaySolid(newHere))
continue; continue;
} }
if( checkForBlocked && Game.UnitInfluence.GetUnitAt( newHere ) != null ) if( checkForBlocked && Game.UnitInfluence.GetUnitAt( newHere ) != null )
continue; continue;
if (customBlock != null && customBlock(newHere)) if (customBlock != null && customBlock(newHere))
@@ -80,16 +79,13 @@ namespace OpenRa.Game
public void AddInitialCell( int2 location ) public void AddInitialCell( int2 location )
{ {
if (!Rules.Map.IsInMap(location.X, location.Y))
return;
cellInfo[ location.X, location.Y ] = new CellInfo( 0, location, false ); cellInfo[ location.X, location.Y ] = new CellInfo( 0, location, false );
queue.Add( new PathDistance( heuristic( location ), location ) ); queue.Add( new PathDistance( heuristic( location ), location ) );
} }
public static PathSearch FromPoint( int2 from, int2 target, UnitMovementType umt, bool checkForBlocked ) public static PathSearch FromPoint( int2 from, int2 target, UnitMovementType umt, bool checkForBlocked )
{ {
var search = new PathSearch { var search = new PathSearch {

View File

@@ -4,13 +4,8 @@
; and then copy it to all the clients. ; and then copy it to all the clients.
[UNITS] [UNITS]
s0=Multi1,mcv,600,2580,0,Guard,None s0=Multi0,mcv,600,2580,0,Guard,None
s1=Multi2,mcv,600,2582,0,Guard,None s1=Multi1,mcv,600,10900,0,Guard,None
s2=Multi0,mcv,600,2584,0,Guard,None s2=Multi2,mcv,600,2662,0,Guard,None
s3=Multi1,jeep,150,3736,0,Guard,None s3=Multi3,mcv,600,10980,0,Guard,None
s4=Multi1,3tnk,400,2843,0,Guard,None
s5=Multi1,apc,200,2844,0,Guard,None
s6=Multi1,ca,700,2871,0,Guard,None
s7=Multi1,e1,50,3608,0,Guard,None
s8=Multi1,arty,75,3609,0,Guard,None
s9=Multi1,heli,225,3482,0,Guard,None