예제 #1
0
        //Initialises a new drone object in the world
        private void CreateDrone()
        {
            var update = _droneLogic.AddDrone();

            if (!update.Value)
            {
                return;
            }
            var model = Content.Load <Model>("Models/Drones/drone", ContentManagerLoaderSettings.Default);
            var drone = new Entity(new Vector3(update.Key.Route.First().XPosition, update.Key.Route.First().YPosition,
                                               update.Key.Route.First().ZPosition), update.Key.Name);

            drone.Components.Add(new ModelComponent(model));
            drone.Transform.Scale = new Vector3(update.Key.Scale.XPosition, update.Key.Scale.YPosition,
                                                update.Key.Scale.ZPosition);
            drone.Transform.Rotation = Quaternion.Identity;
            update.Key.Route.RemoveAt(0);
            Speeds.Add(update.Key.Id, update.Key.Speed);
            _waypointIndexes.Add(update.Key.Id, 0);
            if (Drones.IsNullOrEmpty())
            {
                Drones = new Dictionary <int, Entity>();
            }
            Drones.Add(update.Key.Id, drone);
            DistanceTravelled.Add(update.Key.Id, 0);
            TotalDroneCount++;
            _routes.Add(update.Key.Id, update.Key.Route.Select(x => new Vector3(x.XPosition, x.YPosition, x.ZPosition)).ToList());
            SceneSystem.SceneInstance.RootScene.Entities.Add(drone);
        }
예제 #2
0
        public FighterCarrier(Texture2D texture, Vector2 location, SpriteBatch spriteBatch, Texture2D droneTexture)
            : base(texture, location, spriteBatch)
        {
            //UseCenterAsOrigin = true;

            //Init drones
            Drones.Add(new Drone(droneTexture, location, spriteBatch, this)
            {
                DroneState = CoreTypes.DroneState.Stowed
            });
            Drones[0].Rotation.Radians = MathHelper.Pi;

            Drones.Add(new Drone(droneTexture, location, spriteBatch, this)
            {
                DroneState = CoreTypes.DroneState.Stowed
            });
            Drones[1].Rotation.Radians = MathHelper.TwoPi;

            BulletTexture     = GameContent.GameAssets.Images.Ships.Bullets[ShipType.FighterCarrier, ShipTier.Tier1];
            DelayBetweenShots = TimeSpan.FromMilliseconds(100);
            DamagePerShot     = 2;
            _initHealth       = 100;
            MovementSpeed     = Vector2.One;
            this.TierChanged += new EventHandler(FighterCarrier_TierChanged);
            DamagePerShot     = 2;
            this.PlayerType   = PlayerType.Ally;
        }
예제 #3
0
 private void AddDroneCommand_Executed()
 {
     Drones.Add(
         new DroneViewModel(
             new Drone()
     {
         Name = "Drone " + Drones.Count(), Battery = 100
     }
             )
         );
     RefreshViews();
 }
예제 #4
0
 private void SetDrones(int count)
 {
     Drones.Clear();
     for (int i = 0; i < count; i++)
     {
         Drone drone = new Drone()
         {
             Name = "Drone " + i, Battery = 100
         };
         DroneViewModel DroneVM = new DroneViewModel(drone);
         Drones.Add(DroneVM);
     }
 }
예제 #5
0
        public Ship(XElement ship)
            : base(ship)
        {
            this._crew              = new ObservableCollection <CMember>();
            this._tradeQueue        = new ObservableCollection <XElement>();
            this._constructionWares = new ObservableCollection <XElement>();
            this._drones            = new ObservableCollection <XElement>();

            if (ship.Attribute("name") == null)
            {
                EntityValueConverter conv = new EntityValueConverter();
                XAttribute           name = new XAttribute("name", conv.Convert(ship.Attribute("macro").Value, null, null, null));
                ship.Add(name);
            }

            IEnumerable <XElement> crewquery =
                from crew in this.Data.Descendants().Elements("component")
                where (string)crew.Attribute("class") == "npc"
                select crew;

            foreach (XElement person in crewquery)
            {
                Crew.Add(new CMember(person));
            }

            foreach (XElement trade in this.Data.Elements("trade").Elements("shopping").Elements("trade"))
            {
                TradeQueue.Add(trade);
            }

            IEnumerable <XElement> buildmodulesQuery =
                from buildmodules in this.Data.Descendants().Elements("connection")
                where (string)buildmodules.Attribute("macro") == "connection_buildmodule01"
                select buildmodules;

            IEnumerable <XElement> constructionWaresQuery =
                from wares in buildmodulesQuery.Descendants <XElement>().Elements("resources").Elements("ware")
                select wares;

            foreach (XElement ware in constructionWaresQuery)
            {
                ConstructionWares.Add(ware);
            }

            foreach (XElement drone in this.Data.Elements("ammunition").Elements("available").Elements("item"))
            {
                Drones.Add(drone);
            }


            IEnumerable <XElement> cargoList =
                from cargo in this.Data.Descendants().Elements("component")
                where (string)cargo.Attribute("class") == "storage" & (string)cargo.Attribute("macro") != "unit_player_ship_storage_macro"
                select cargo;

            foreach (XElement cargoType in cargoList)
            {
                string cargoTypeName = cargoType.Attribute("macro").Value;
                switch (cargoTypeName)
                {
                case "storage_ship_l_bulk_01_macro":
                case "storage_ship_m_bulk_01_macro":
                case "storage_ship_l_bulk_02_macro":
                case "storage_ship_l_bulk_03_macro":
                case "storage_ship_l_bulk_04_macro":
                case "storage_ship_xl_bulk_01_macro":
                    BulkCargo = cargoType;
                    break;

                case "storage_ship_l_container_01_macro":
                case "storage_ship_l_container_02_macro":
                case "storage_ship_m_container_01_macro":
                case "storage_ship_xl_container_01_macro":
                    ContainerCargo = cargoType;
                    break;

                case "storage_ship_l_energy_01_macro":
                case "storage_ship_l_energy_02_macro":
                case "storage_ship_xl_energy_01_macro":
                case "storage_ship_m_energy_01_macro":
                    EnergyCargo = cargoType;
                    break;

                case "storage_ship_l_fuel_01_macro":
                case "storage_ship_xl_fuel_01_macro":
                    FuelCargo = cargoType;
                    break;

                case "storage_ship_l_liquid_01_macro":
                case "storage_ship_l_liquid_02_macro":
                case "storage_ship_l_liquid_03_macro":
                case "storage_ship_xl_liquid_01_macro":
                case "storage_ship_m_liquid_01_macro":
                    LiquidCargo = cargoType;
                    break;

                case "storage_ship_xl_universal_01_macro":
                case "storage_ship_xs_universal_01_macro":
                case "storage_temp_huge_macro":
                    UniversalCargo = cargoType;
                    break;
                }
            }

            Gravidar = this.Data.Element("gravidar");

            LoadDetails();
        }