コード例 #1
0
ファイル: FleetMoveOrderRenderer.cs プロジェクト: ndech/Alpha
 private void NewMoveOrder(IContext context, Fleet fleet)
 {
     if (_items.ContainsKey(fleet))
     {
         _items[fleet].Dispose();
     }
     if (fleet.MoveOrder == null)
     {
         _items.Remove(fleet);
         return;
     }
     List<Step> steps = fleet.MoveOrder.Steps.ToList();
     List<VertexDefinition.Path> vertices = new List<VertexDefinition.Path>();
     int index = 0;
     Vector3 prevPosition = (Vector3) steps[0].Source.Center;
     float totalDistance = 0.0f;
     for(int i = 0; i<steps.Count ; i++)
     {
         Vector3 middlePoint = (Vector3)steps[i].Destination.Adjacencies.Single(a => a.Neighbourg == steps[i].Source).PassingPoints.First();
         Vector3 startPoint = (Vector3)steps[i].Source.Center;
         Vector3 endPoint = (Vector3)steps[i].Destination.Center;
         Vector3 prevPoint = i == 0 ? startPoint :
             (Vector3)steps[i].Source.Adjacencies.Single(a => a.Neighbourg == steps[i - 1].Source).PassingPoints.First();
         Vector3 nextPoint = i == steps.Count -1 ? endPoint :
             (Vector3)steps[i].Destination.Adjacencies.Single(a => a.Neighbourg == steps[i + 1].Destination).PassingPoints.First();
         //First part of the arc
         for (int j = 0; j < ArcSubdivisions; j++)
         {
             Vector3 position = Vector3.CatmullRom(prevPoint, startPoint, middlePoint, endPoint, (1.0f * j) / ArcSubdivisions);
             float arcLength = Vector3.Distance(prevPosition, position);
             vertices.Add(new VertexDefinition.Path
             {
                 fillingIndex = (uint)(++index),
                 position = position,
                 pathLength = new Vector2(totalDistance, arcLength)
             });
             totalDistance += arcLength;
             prevPosition = position;
         }
         //Second part of the arc
         for (int j = 0; j < ArcSubdivisions; j++)
         {
             Vector3 position = Vector3.CatmullRom(startPoint, middlePoint, endPoint, nextPoint, (1.0f * j) / ArcSubdivisions);
             float arcLength = Vector3.Distance(prevPosition, position);
             vertices.Add(new VertexDefinition.Path
             {
                 fillingIndex = (uint)(++index),
                 position = position,
                 pathLength = new Vector2(totalDistance, arcLength)
             });
             totalDistance += arcLength;
             prevPosition = position;
         }
     }
     _items[fleet] = new MoveOrderRenderingItem(
         vertices.Count,
         Buffer.Create(context.DirectX.Device, BindFlags.VertexBuffer, vertices.ToArray()),
         fleet.Speed);
 }
コード例 #2
0
ファイル: NewFleetNotification.cs プロジェクト: ndech/Alpha
 internal NewFleetNotification(Fleet fleet)
 {
     Fleet = fleet;
 }
コード例 #3
0
ファイル: FleetManager.cs プロジェクト: ndech/Alpha
 public void CreateFleet(Fleet fleet)
 {
     _fleets.Add(fleet);
 }
コード例 #4
0
ファイル: DestroyFleetCommand.cs プロジェクト: ndech/Alpha
 public DestroyFleetCommand(Fleet fleet)
 {
     _fleet = fleet;
 }
コード例 #5
0
ファイル: FleetMovedNotification.cs プロジェクト: ndech/Alpha
 internal FleetMovedNotification(Fleet fleet)
 {
     Fleet = fleet;
 }
コード例 #6
0
ファイル: PathFinder.cs プロジェクト: ndech/Alpha
 public static List<Step> CalculatePath(Fleet fleet, Zone destination)
 {
     return CalculatePath((IMovable)fleet, destination);
 }
コード例 #7
0
 internal NewFleetMoveOrderNotification(Fleet fleet)
 {
     Fleet = fleet;
 }
コード例 #8
0
ファイル: FleetManager.cs プロジェクト: ndech/Alpha
 public void CreateFleet(Fleet fleet)
 {
     _fleets.Add(fleet);
 }
コード例 #9
0
ファイル: MoveFleetCommand.cs プロジェクト: ndech/Alpha
 public MoveFleetCommand(Fleet fleet, List<Step> steps)
 {
     _fleet = fleet;
     _steps = steps;
 }
コード例 #10
0
ファイル: FleetRenderer.cs プロジェクト: ndech/Alpha
 public FleetRenderingInfo(IContext context, Fleet fleet, Vector2I size)
 {
     WorldPosition = (Vector3)fleet.Location.Center;
     WorldMatrix = Matrix.RotationY(-(float) (Math.PI/2))*Matrix.Translation(WorldPosition);
     ShipCount = fleet.ShipCount;
     Fleets = new List<Fleet> { fleet };
     if(fleet.Owner.Equals(context.Realm))
         CurrentStatus = Status.Mine;
     else
         CurrentStatus = new List<Status> {Status.Ally, Status.Enemy, Status.Neutral}.RandomItem();
     Text = context.TextManager.Create("Courrier", 14, RandomGenerator.Get(1,2000).ToString(CultureInfo.InvariantCulture),
         new Vector2I(size.X-8, size.Y), Color.Wheat, HorizontalAlignment.Center, VerticalAlignment.Middle, new Padding(2));
 }
コード例 #11
0
ファイル: FleetRenderer.cs プロジェクト: ndech/Alpha
 private void OnNewFleet(IContext context, Fleet fleet)
 {
     if(_fleetRenderingInfos.ContainsKey(fleet.Location))
         _fleetRenderingInfos[fleet.Location].Fleets.Add(fleet);
     else
         _fleetRenderingInfos[fleet.Location] = new FleetRenderingInfo(context, fleet, _baseOverlay.Size);
 }
コード例 #12
0
ファイル: FleetRenderer.cs プロジェクト: ndech/Alpha
 private void OnFleetUpdate(IContext context, Fleet fleet)
 {
     OnFleetDelete(fleet);
     OnNewFleet(context, fleet);
 }
コード例 #13
0
ファイル: FleetRenderer.cs プロジェクト: ndech/Alpha
        private void OnFleetDelete(Fleet fleet)
        {
            var info = _fleetRenderingInfos.Single(kvp => kvp.Value.Fleets.Contains(fleet));
            if (info.Value.FleetCount == 1)
            {
                info.Value.Dispose();
                _fleetRenderingInfos.Remove(info.Key);

            }
            else info.Value.Fleets.Remove(fleet);
        }
コード例 #14
0
ファイル: RenameFleetCommand.cs プロジェクト: ndech/Alpha
 public RenameFleetCommand(Fleet fleet, string newName)
 {
     _fleet = fleet;
     _newName = newName;
 }