void HandleBuildLists()
        {
            var player = App.Player;

            if (player == null)
            {
                return;
            }

            var isMine = Body.OwnerID == player.PlayerID;

            if (!isMine)
            {
                return;
            }
            if (mapTab.ZoomControl.Zoom >= 0.1 && !optionRequestSent)
            {
                var service = new PlanetWarsServiceClient();
                service.GetBodyOptionsCompleted += (s, e) =>
                {
                    StructureBuildOptions.ItemsSource = e.Result.NewStructureOptions;
                    StructureBuildOptions.Visibility  = Visibility.Visible;
                    ShipBuildOptions.ItemsSource      = e.Result.NewShipOptions;
                    ShipBuildOptions.Visibility       = Visibility.Visible;
                };
                service.GetBodyOptionsAsync(App.UserName, App.Password, Body.CelestialObjectID);
                optionRequestSent = true;
            }
            if (mapTab.ZoomControl.Zoom < 0.1)
            {
                optionRequestSent = false;
                StructureBuildOptions.Visibility = Visibility.Collapsed;
                ShipBuildOptions.Visibility      = Visibility.Collapsed;
            }
        }
예제 #2
0
 public App()
 {
     Service             = new PlanetWarsServiceClient();
     Startup            += Application_Startup;
     Exit               += Application_Exit;
     UnhandledException += Application_UnhandledException;
     InitializeComponent();
     Service.GetMapDataCompleted    += Service_GetMapDataCompleted;
     Service.GetInvariantsCompleted += Service_GetInvariantsCompleted;
     Service.GetInvariantsAsync();
 }
예제 #3
0
 public App()
 {
     Service = new PlanetWarsServiceClient();
     Startup += Application_Startup;
     Exit += Application_Exit;
     UnhandledException += Application_UnhandledException;
     InitializeComponent();
     Service.GetMapDataCompleted += Service_GetMapDataCompleted;
     Service.GetInvariantsCompleted += Service_GetInvariantsCompleted;
     Service.GetInvariantsAsync();
 }
        void CreateFleetButton_Click(object sender, RoutedEventArgs _e)
        {
            var service = new PlanetWarsServiceClient();
            var fleet   = new ObservableCollection <ShipTypeCount>();

            foreach (var item in Body.CelestialObjectShips.Select(s => new ShipTypeCount {
                Count = s.Count, ShipTypeID = s.ShipTypeID
            }))
            {
                fleet.Add(item);
            }
            service.CreateFleetCompleted += (s, e) => MessageBox.Show("Done");
            service.CreateFleetAsync(App.UserName, App.Password, Body.CelestialObjectID, fleet);
        }
 void SellButton_Click(object sender, RoutedEventArgs _e)
 {
     var button = (Button)sender;
     var structure = (MothershipStructure)button.DataContext;
     var service = new PlanetWarsServiceClient();
     service.SellMotherhipModuleCompleted += (s, e) =>
         {
             MessageBox.Show(e.Result.Response.ToString());
             if (e.Result.Response == BuildResponse.Ok) {
                 PodBuildList.ItemsSource = e.Result.NewStructureOptions;
                 App.Player = e.Result.Player;
             }
         };
     service.SellMotherhipModuleAsync(App.UserName, App.Password, structure.StructureType.StructureTypeID);
 }
        void StructureSellButton_Click(object sender, RoutedEventArgs _e)
        {
            var button            = (Button)sender;
            var selectedStructure = (CelestialObjectStructure)button.DataContext;
            var service           = new PlanetWarsServiceClient();

            service.SellStructureCompleted += (s, e) =>
            {
                MessageBox.Show(e.Result.Response.ToString());
                if (e.Result.Response == BuildResponse.Ok)
                {
                    PostBuildUpdates(e.Result);
                }
            };
            service.SellStructureAsync(App.UserName, App.Password, Body.CelestialObjectID, selectedStructure.StructureType.StructureTypeID);
        }
        void ShipBuyButton_Click(object sender, RoutedEventArgs _e)
        {
            var button  = (Button)sender;
            var option  = (ShipOption)button.DataContext;
            var service = new PlanetWarsServiceClient();

            service.BuildShipCompleted += (s, e) =>
            {
                MessageBox.Show(e.Result.Response.ToString());
                if (e.Result.Response == BuildResponse.Ok)
                {
                    PostBuildUpdates(e.Result);
                }
            };
            service.BuildShipAsync(App.UserName, App.Password, Body.CelestialObjectID, option.ShipType.ShipTypeID, 1);
        }
        void SellButton_Click(object sender, RoutedEventArgs _e)
        {
            var button    = (Button)sender;
            var structure = (MothershipStructure)button.DataContext;
            var service   = new PlanetWarsServiceClient();

            service.SellMotherhipModuleCompleted += (s, e) =>
            {
                MessageBox.Show(e.Result.Response.ToString());
                if (e.Result.Response == BuildResponse.Ok)
                {
                    PodBuildList.ItemsSource = e.Result.NewStructureOptions;
                    App.Player = e.Result.Player;
                }
            };
            service.SellMotherhipModuleAsync(App.UserName, App.Password, structure.StructureType.StructureTypeID);
        }
        void GoButton_Click(object sender, RoutedEventArgs _e)
        {
            var destination = (CelestialObject)DestinationBox.SelectedItem;

            if (destination == null)
            {
                MessageBox.Show("No destination selected");
                return;
            }
            var service = new PlanetWarsServiceClient();

            service.OrderFleetCompleted += (s, e) =>
            {
                transit.Fleets = e.Result;
                MessageBox.Show("Set sail!");
            };
            service.OrderFleetAsync(App.UserName, App.Password, transit.Fleets.FleetID, destination.CelestialObjectID, 0); // todo offset future?
        }
        void mapTab_MouseLeftButtonDown(object sender, MouseButtonEventArgs _)
        {
            mapTab.MapCanvas.MouseLeftButtonDown     -= mapTab_MouseLeftButtonDown;
            Application.Current.RootVisual.MouseMove -= mapTab_MouseMove;
            cursorPosition = null;
            if (cursorPlanet == null)
            {
                return;
            }
            var destination = cursorPlanet;

            cursorPlanet = null;
            var service = new PlanetWarsServiceClient();

            service.OrderFleetCompleted += (s, e) =>
            {
                transit.Fleets = e.Result;
                MessageBox.Show(cursorPlanet.Name + " called, they want their transit back!");
            };
            service.OrderFleetAsync(App.UserName, App.Password, transit.Fleets.FleetID, destination.Body.CelestialObjectID, 0);
        }
 void mapTab_MouseLeftButtonDown(object sender, MouseButtonEventArgs _)
 {
     mapTab.MapCanvas.MouseLeftButtonDown -= mapTab_MouseLeftButtonDown;
     Application.Current.RootVisual.MouseMove -= mapTab_MouseMove;
     cursorPosition = null;
     if (cursorPlanet == null) return;
     var destination = cursorPlanet;
     cursorPlanet = null;
     var service = new PlanetWarsServiceClient();
     service.OrderFleetCompleted += (s, e) =>
         {
             transit.Fleets = e.Result;
             MessageBox.Show(cursorPlanet.Name + " called, they want their transit back!");
         };
     service.OrderFleetAsync(App.UserName, App.Password, transit.Fleets.FleetID, destination.Body.CelestialObjectID, 0);
 }
 void GoButton_Click(object sender, RoutedEventArgs _e)
 {
     var destination = (CelestialObject)DestinationBox.SelectedItem;
     if (destination == null)
     {
         MessageBox.Show("No destination selected");
         return;
     }
     var service = new PlanetWarsServiceClient();
     service.OrderFleetCompleted += (s, e) =>
         {
             transit.Fleets = e.Result;
             MessageBox.Show("Set sail!");
         };
     service.OrderFleetAsync(App.UserName, App.Password, transit.Fleets.FleetID, destination.CelestialObjectID, 0); // todo offset future?
 }