Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 internal NewFleetNotification(Fleet fleet)
 {
     Fleet = fleet;
 }
Exemplo n.º 3
0
 public void CreateFleet(Fleet fleet)
 {
     _fleets.Add(fleet);
 }
Exemplo n.º 4
0
 public DestroyFleetCommand(Fleet fleet)
 {
     _fleet = fleet;
 }
Exemplo n.º 5
0
 internal FleetMovedNotification(Fleet fleet)
 {
     Fleet = fleet;
 }
Exemplo n.º 6
0
 public static List<Step> CalculatePath(Fleet fleet, Zone destination)
 {
     return CalculatePath((IMovable)fleet, destination);
 }
Exemplo n.º 7
0
 internal NewFleetMoveOrderNotification(Fleet fleet)
 {
     Fleet = fleet;
 }
Exemplo n.º 8
0
 public void CreateFleet(Fleet fleet)
 {
     _fleets.Add(fleet);
 }
Exemplo n.º 9
0
 public MoveFleetCommand(Fleet fleet, List<Step> steps)
 {
     _fleet = fleet;
     _steps = steps;
 }
Exemplo n.º 10
0
 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));
 }
Exemplo n.º 11
0
 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);
 }
Exemplo n.º 12
0
 private void OnFleetUpdate(IContext context, Fleet fleet)
 {
     OnFleetDelete(fleet);
     OnNewFleet(context, fleet);
 }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
 public RenameFleetCommand(Fleet fleet, string newName)
 {
     _fleet = fleet;
     _newName = newName;
 }