本文整理汇总了C#中Microsoft.Xna.Framework.Vector2.WalkTo方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2.WalkTo方法的具体用法?C# Vector2.WalkTo怎么用?C# Vector2.WalkTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Vector2
的用法示例。
在下文中一共展示了Vector2.WalkTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TrainingCamp
public TrainingCamp(GameWorld gameWorldRef, GamePlayer playerRef, Point Location)
: base("building6", gameWorldRef, playerRef, Location)
{
// filling the occupied_cells_locations List
// (the purpose is to make these cells not walkable)
#region Occupied Cells Work
const int cellsEast = 3;
const int cellsWest = 4;
Point westIndexer = Location;
Point eastIndexer = Location;
for (int i = 0; i < cellsWest; i++)
{
for (int j = 0; j < cellsEast; j++)
{
OccupiedCellsLocations.Add(eastIndexer);
eastIndexer = eastIndexer.WalkTo(Direction.NE);
}
westIndexer = westIndexer.WalkTo(Direction.NW);
eastIndexer = westIndexer;
}
// add the irregular occupied cells..
Point indexer = Location;
indexer = indexer.WalkTo(Direction.SW);
indexer = indexer.WalkTo(Direction.NW);
indexer = indexer.WalkTo(Direction.NW);
OccupiedCellsLocations.Add(indexer);
indexer = indexer.WalkTo(Direction.NW);
OccupiedCellsLocations.Add(indexer);
// now set the Mapcells at locations found to be not walkable..
foreach (var location in OccupiedCellsLocations)
{
MapRef.MapCellAt(location).Walkable = false;
}
//setting depths of irregular occupied cells..
float irregularDepth1;
float irregularDepth2;
indexer = Location.WalkTo(Direction.SW).WalkTo(Direction.NW).WalkTo(Direction.NW);
irregularDepth1 = MapRef.MapCellAt(indexer).DrawDepth;
indexer = indexer.WalkTo(Direction.NW);
irregularDepth2 = MapRef.MapCellAt(indexer).DrawDepth;
int segIndexer = (ImgSegmentsDepthsOrdered.Count / 2) - 3; // indexes segment no. 3 counting from middle segment leftwards
SegDepth newSegment = new SegDepth(ImgSegmentsDepthsOrdered[segIndexer].SegRect, irregularDepth1);
ImgSegmentsDepthsOrdered[segIndexer] = newSegment;
segIndexer--;
SegDepth newSegment2 = new SegDepth(ImgSegmentsDepthsOrdered[segIndexer].SegRect, irregularDepth1);
ImgSegmentsDepthsOrdered[segIndexer] = newSegment2;
segIndexer--;
SegDepth newSegment3 = new SegDepth(ImgSegmentsDepthsOrdered[segIndexer].SegRect, irregularDepth2);
ImgSegmentsDepthsOrdered[segIndexer] = newSegment3;
#endregion
#region Generating Custom Built Units Locations
//remove last location
BuiltUnitsLocations.RemoveAt(BuiltUnitsLocations.Count-1);
//get the new last location
var loc = BuiltUnitsLocations[BuiltUnitsLocations.Count-1];
Vector2 cell = new Vector2(MapRef.WorldToMapCell(loc).X,
MapRef.WorldToMapCell(loc).Y);
cell = cell.WalkTo(Direction.SW);
BuiltUnitsLocations.Add(MapRef.MapCellAt(cell).CenterPosition);
cell = cell.WalkTo(Direction.NW);
BuiltUnitsLocations.Add(MapRef.MapCellAt(cell).CenterPosition);
cell = cell.WalkTo(Direction.NW);
BuiltUnitsLocations.Add(MapRef.MapCellAt(cell).CenterPosition);
#endregion
// making smoke on the roof
#region smoke
_smoke = new SpriteAnimation(GameGraphics.GetTexture("smoke").SourceTexture);
_smoke.AddAnimation("normal", 0, 0, 30, 64, 16, 0.1f);
_smoke.Position = Camera.WorldToScreen(new Vector2( this.BuildingOrigin.X+85, this.BuildingOrigin.Y-60));
_smoke.CurrentAnimation = "normal";
_smoke.DrawDepth = BuildingInfo.SmokeDrawDepth;
_smoke.IsAnimating = true;
#endregion
selectionGroup = GroupMapper.CampGroup;
SelectionLineTexture = GameGraphics.GetTexture("camp_selection_line");
#region Setting Entity Properties
MaxHealth = 800;
MaxDefense = 300;
MaxAttack = 0;
Health = MaxHealth;
Defense = MaxDefense;
Attack = MaxAttack;
#endregion
}