Exemple #1
0
        public void Initialise(GameVM gameVM, StarSystem starSys, Entity viewingFaction)
        {
            _viewingFaction = viewingFaction;

            var listnerblobs = new List <int>();

            listnerblobs.Add(EntityManager.DataBlobTypes[typeof(OwnedDB)]);
            listnerblobs.Add(EntityManager.DataBlobTypes[typeof(PositionDB)]);
            EntityChangeListner changeListner = new EntityChangeListner(starSys, viewingFaction, listnerblobs);

            _changeListner = changeListner;


            IconableEntitys.Clear();
            _iconableEntites.Clear();


            foreach (Entity entity in _changeListner.ListningToEntites)
            {
                AddIconableEntity(entity);
            }
            SystemSubpulse = starSys.ManagerSubpulses;
            //starSys.SystemManager.GetAllEntitiesWithDataBlob<NewtonBalisticDB>(gameVM.CurrentAuthToken);

            OnPropertyChanged(nameof(IconableEntitys));
        }
Exemple #2
0
        public ColonyScreenVM(GameVM gameVM, Entity colonyEntity, StaticDataStore staticData)
        {
            gameVM.Game.GameLoop.GameGlobalDateChangedEvent += GameVM_DateChangedEvent;
            _colonyEntity = colonyEntity;
            _facilities   = new ObservableCollection <FacilityVM>();
            ComponentInstancesDB instaces = colonyEntity.GetDataBlob <ComponentInstancesDB>();

            foreach (var installation in instaces.SpecificInstances)
            {
                //Facilities.Add(new FacilityVM(installation.Key, instaces));
                FacilitesList.Add(new ComponentSpecificDesignVM(installation.Key, installation.Value));
            }


            UpdatePop();

            CommandReferences cmdRef = new CommandReferences(FactionEntity.Guid, _colonyEntity.Guid, gameVM.Game.OrderHandler, _colonyEntity.Manager.ManagerSubpulses);

            CargoStoreVM = new CargoStorageVM(staticData, cmdRef, colonyEntity.GetDataBlob <CargoStorageDB>());

            PlanetMineralDepositVM = new PlanetMineralDepositVM(staticData, _colonyEntity.GetDataBlob <ColonyInfoDB>().PlanetEntity);

            RefineryAbilityVM = new RefineryAbilityVM(staticData, _colonyEntity);

            ConstructionAbilityVM = new ConstructionAbilityVM(staticData, _colonyEntity);

            ColonyResearchVM = new ColonyResearchVM(staticData, _colonyEntity);
        }
Exemple #3
0
        internal static PlanetVM Create(GameVM gameVM, Entity entity, StarVM parent_star)
        {
            var newvm = PlanetVM.Create(gameVM, entity);

            newvm.ParentStar = parent_star;
            return(newvm);
        }
Exemple #4
0
        public ShipOrderVM(GameVM game)
        {
            _gameVM = game;

            FactionInfoDB finfo = _gameVM.CurrentFaction.GetDataBlob <FactionInfoDB>();

            foreach (StarSystem starSystem in _gameVM.StarSystemSelectionViewModel.StarSystems.Keys)
            {
                if (finfo.KnownSystems.Contains(starSystem.Guid))
                {
                    _starSystems.Add(starSystem, starSystem.NameDB.GetName(_gameVM.CurrentFaction));
                }
            }

            _starSystems.SelectedIndex = 0;

            TargetShown     = false;
            TargetAreaWidth = 2;

            RefreshShips(0, 0);

            //PropertyChanged += ShipOrderVM_PropertyChanged;
            SelectedSystem.ManagerSubpulses.SystemDateChangedEvent += UpdateInterface_SystemDateChangedEvent;

            _starSystems.SelectionChangedEvent        += RefreshShips;
            _shipList.SelectionChangedEvent           += RefreshOrders;
            _shipList.SelectionChangedEvent           += RefreshFireControlList;
            _moveOrdersPossible.SelectionChangedEvent += RefreshTarget;
            _moveTargetList.SelectionChangedEvent     += RefreshTargetDistance;
            _fireControlList.SelectionChangedEvent    += RefreshBeamWeaponsList;
            _fireControlList.SelectionChangedEvent    += RefreshFCTarget;

            OnPropertyChanged(nameof(StarSystems));
            OnPropertyChanged(nameof(SelectedSystem));
        }
Exemple #5
0
        public MissileDesignVM(GameVM gameVM)
        {
            List <ChainedSliderVM> chainedSlidersVM = new List <ChainedSliderVM>();

            chainedSlidersVM.Add(new ChainedSliderVM());
            chainedSlidersVM[0].Name = "Payload";
            chainedSlidersVM.Add(new ChainedSliderVM());
            chainedSlidersVM[1].Name = "Engine";
            chainedSlidersVM.Add(new ChainedSliderVM());
            chainedSlidersVM[2].Name = "Agility";
            chainedSlidersVM.Add(new ChainedSliderVM());
            chainedSlidersVM[3].Name = "Fuel";
            chainedSlidersVM.Add(new ChainedSliderVM());
            chainedSlidersVM[4].Name = "EW and Armor";


            ChainedSliders = new ChainedSliders(chainedSlidersVM);


            //TODO: how are we going to define the warheads? can they just be another design entity with just an explosive datablob or something? below is just a placeholder.
            Payload explosive = new Payload();

            explosive.Name   = "Explosive Charge";
            explosive.Damage = 1;
            PayloadTypes.Add(explosive, explosive.Name);


            foreach (var design in gameVM.CurrentFaction.GetDataBlob <FactionInfoDB>().MissileDesigns)
            {
                Payload payload = new Payload(design.Value);
                PayloadTypes.Add(payload, payload.Name);
            }
        }
Exemple #6
0
 public EntityVM(GameVM gamevm)
 {
     _game = gamevm.Game;
     if (gamevm.CurrentFaction != null && gamevm.CurrentFaction.IsValid)
     {
         Init(gamevm.CurrentFaction);
     }
 }
Exemple #7
0
        public ClientConnectionVM(GameVM gameVM)
        {
            _netClient         = new NetworkClient(ServerAddress, PortNum, gameVM);
            NetMessages        = _netClient.Messages;
            gameVM.NetMessages = _netClient.Messages;

            //_connectCMD = new CommandHandler(OnConnectToFactionCMD, false);
        }
Exemple #8
0
        /// <summary>
        /// Creates and fills out the properties of this ViewModel from the provided entity.
        /// </summary>
        public static SystemVM Create(GameVM gameVM, StarSystem starSystem)
        {
            SystemVM newVM = new SystemVM(gameVM, starSystem);

            // Initialize the data.
            newVM.Refresh();

            return(newVM);
        }
Exemple #9
0
 public NewGameCMD(GameVM gameVM)
 {
     ID          = "newgame";
     Image       = Icon.FromResource("Pulsar4X.CrossPlatformUI.Resources.Icons.NewGame.ico");
     MenuText    = "New Game";
     ToolBarText = "New Game";
     Shortcut    = Keys.F11;
     _gameVM     = gameVM;
 }
Exemple #10
0
        /// <summary>
        /// Creates and fills out the properties of this ViewModel from the provided entity.
        /// </summary>
        internal static PlanetVM Create(GameVM gameVM, Entity entity)
        {
            PlanetVM newVM = new PlanetVM(gameVM, entity);

            // Initialize the data.
            newVM.Refresh();

            return(newVM);
        }
Exemple #11
0
        public SystemInfoVM(GameVM gameVM)
        {
            _gameVM = gameVM;

            StarSystems.SelectionChangedEvent += StarSystems_SelectionChangedEvent;
            Entities.SelectionChangedEvent    += Entities_SelectionChangedEvent;
            TreeBlobs.SelectionChangedEvent   += TreeBlobs_SelectionChangedEvent;

            PopulateStarSystemList();
        }
Exemple #12
0
        //public Dictionary<IDrawIconMethod, List<AIconData<BaseDataBlob>>> IconsDictionary = new Dictionary<IDrawIconMethod, List<AIconData<BaseDataBlob>>>();

        public void InitializeForGM(GameVM gameVM, StarSystem starSys)
        {
            _changeListner = new EntityChangeListnerSM(starSys);

            foreach (var entityWithPosition in starSys.GetAllEntitiesWithDataBlob <PositionDB>())
            {
                AddIconableEntity(entityWithPosition);
                _changeListner.ListningToEntites.Add(entityWithPosition);
            }
        }
Exemple #13
0
        Entity CreateNewSpecies(GameVM gameVM)
        {
            NameDB    name    = new NameDB(Name);
            SpeciesDB species = new SpeciesDB(BaseGravity.Value,
                                              MinGravity.Value, MaxGravity.Value,
                                              BasePressure.Value, MinPressure.Value,
                                              MaxPressure.Value, BaseTemprature.Value,
                                              MinTemprature.Value, MaxTemprature.Value);

            return(SpeciesFactory.CreateSpeciesFromBlobs(gameVM.CurrentFaction, gameVM.Game.GlobalManager, name, species));
        }
Exemple #14
0
        /// <summary>
        /// Creates and fills out the properties of this ViewModel from the provided entity.
        /// </summary>
        public static StarVM Create(GameVM gameVM, Entity entity, SystemVM systemVM)
        {
            StarVM newVM = new StarVM(gameVM, entity);

            // Initialize the data.
            newVM.Init(systemVM);

            newVM.Refresh();

            return(newVM);
        }
 public PlayerOptionsVM(GameVM gameVM)
 {
     _gameVM = gameVM;
     Players.Add(_gameVM.Game.SpaceMaster, _gameVM.Game.SpaceMaster.Name);
     foreach (var player in gameVM.Game.Players)
     {
         Players.Add(player, player.Name);
     }
     Players.SelectedIndex          = 0;
     Players.SelectionChangedEvent += Factions_SelectionChangedEvent;
 }
Exemple #16
0
 public SaveGame(GameVM gameVM)
 {
     _gameVM                  = gameVM;
     ID                       = "savegame";
     Image                    = Icon.FromResource("Pulsar4X.CrossPlatformUI.Resources.Icons.NewGame.ico");
     MenuText                 = "Save Game";
     ToolBarText              = "Save Game";
     Shortcut                 = Keys.F6;
     Enabled                  = _gameVM.HasGame;
     _gameVM.PropertyChanged += GameVMPropertyChanged;
 }
Exemple #17
0
        //private int viewport_width;
        //private int viewport_height;

        public StarSystemSelectionVM(GameVM gameVM, Game game, Entity factionEntity)
        {
            _gameVM = gameVM;
            foreach (var item in game.GetSystems(gameVM.CurrentAuthToken))
            {
                StarSystems.Add(item, item.NameDB.GetName(factionEntity));
            }
            StarSystems.SelectedIndex                  = 0;
            StarSystems.SelectionChangedEvent         += StarSystems_SelectionChangedEvent;
            StarSystems.DisplayList.CollectionChanged += DisplayList_CollectionChanged;
            //_gameVM.StarSystems.CollectionChanged += StarSystems_CollectionChanged;
        }
Exemple #18
0
        public void Initialise(GameVM gameVM)
        {
            _gameVM   = gameVM;
            _timeloop = gameVM.Game.GamePulse;

            OnPropertyChanged(nameof(TickLength));
            OnPropertyChanged(nameof(TickMultiplier));
            OnPropertyChanged(nameof(TickFreq));
            OnPropertyChanged(nameof(CurrentGameDate));

            _timeloop.GameGlobalDateChangedEvent += OnTimeDateChange;
        }
 /// <summary>
 /// Constructor for empty VM
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="gameVM"></param>
 public ComponentTemplateMainPropertiesVM(ComponentTemplateParentVM parent, GameVM gameVM) : base(parent)
 {
     _staticData       = gameVM.Game.StaticData;
     SubControlInFocus = FocusedControl.MassControl;
     foreach (var item in Enum.GetValues(typeof(ComponentMountType)))
     {
         if ((ComponentMountType)item != ComponentMountType.None)
         {
             MountType.Add((ComponentMountType)item, false);
         }
     }
 }
Exemple #20
0
 public NewGameOptionsVM(GameVM gameVM)
 {
     _gameVM             = gameVM;
     CreatePlayerFaction = true;
     DefaultStart        = true;
     FactionName         = "United Earth Federation";
     FactionPassword     = "";
     GmPassword          = "";
     NumberOfSystems     = 50;
     AvailableModList    = new ObservableCollection <DataVersionInfo>(StaticDataManager.AvailableData());
     SelectedModList     = new ObservableCollection <DataVersionInfo>();
 }
Exemple #21
0
        public ComponentDesignVM(GameVM gameVM)
        {
            _gameVM        = gameVM;
            _staticData    = gameVM.Game.StaticData;
            _factionEntity = gameVM.CurrentFaction;
            _factionTech   = gameVM.CurrentFaction.GetDataBlob <FactionTechDB>();


            foreach (var componentSD in gameVM.Game.StaticData.ComponentTemplates.Values)
            {
                ComponentTypes.Add(componentSD.Name, componentSD.ID);
            }
            ComponentTypes.SelectedIndex = 0;
        }
Exemple #22
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="gameVM"></param>
        public ComponentTemplateParentVM(GameVM gameVM)
        {
            _staticData   = gameVM.Game.StaticData;
            _gameVM       = gameVM;
            FormulaEditor = new FormulaEditorVM(this, _staticData);

            foreach (var item in _staticData.ComponentTemplates.Values)
            {
                Components.Add(item, item.Name);
            }
            SelectedComponent = new ComponentTemplateMainPropertiesVM(this, _gameVM);
            Components.SelectionChangedEvent += Components_SelectionChangedEvent;
            Components.SelectedIndex          = 0;
        }
Exemple #23
0
        /// <summary>
        /// Creates and fills out the properties of this ViewModel from the entity with the provided ID.
        /// </summary>
        /// <exception cref="InvalidOperationException">Cannot create a Planet ViewModel without an initialized game.</exception>
        /// <exception cref="GuidNotFoundException">Thrown when the supplied ID is not found in the game.</exception>
        internal static StarVM Create(GameVM gameVM, Guid guid, SystemVM systemVM)
        {
            if (gameVM.Game == null)
            {
                throw new InvalidOperationException("Cannot create a StarVM without an initialized game.");
            }

            Entity entity;

            if (!gameVM.Game.GlobalManager.FindEntityByGuid(guid, out entity))
            {
                throw new GuidNotFoundException(guid);
            }

            return(Create(gameVM, entity, systemVM));
        }
Exemple #24
0
        private SystemVM(GameVM gameVM, StarSystem starSystem)
        {
            _gameVM           = gameVM;
            _name             = starSystem.NameDB.DefaultName;
            StarSystem        = starSystem;
            _stars            = new BindingList <StarVM>();
            _planets          = new BindingList <PlanetVM>();
            _starDictionary   = new Dictionary <Guid, StarVM>();
            _planetDictionary = new Dictionary <Guid, PlanetVM>();
            //find most massive star, this is the parent.
            Entity parentStar   = starSystem.GetFirstEntityWithDataBlob <StarInfoDB>(gameVM.CurrentAuthToken);
            StarVM parentstarVM = StarVM.Create(_gameVM, parentStar, this);

            foreach (var star in starSystem.GetAllEntitiesWithDataBlob <StarInfoDB>(gameVM.CurrentAuthToken))
            {
                StarVM starVM = StarVM.Create(_gameVM, star, this);
                if (!_stars.Contains(starVM))
                {
                    _stars.Add(starVM);
                }
                if (!_starDictionary.ContainsKey(star.Guid))
                {
                    _starDictionary.Add(star.Guid, starVM);
                }
                if (star.GetDataBlob <MassVolumeDB>().Mass > parentStar.GetDataBlob <MassVolumeDB>().Mass)
                {
                    parentStar   = star;
                    parentstarVM = starVM;
                }
            }
            _parentStar = parentstarVM;
            ID          = _parentStar.Entity.Guid;
            foreach (var planet in starSystem.GetAllEntitiesWithDataBlob <SystemBodyInfoDB>(gameVM.CurrentAuthToken))
            {
                PlanetVM planetVM = PlanetVM.Create(_gameVM, planet, parentstarVM);
                if (!_planets.Contains(planetVM))
                {
                    _planets.Add(planetVM);
                }
                if (!_planetDictionary.ContainsKey(planet.Guid))
                {
                    _planetDictionary.Add(planet.Guid, planetVM);
                }
            }
        }
Exemple #25
0
        /// <summary>
        /// Creates and fills out the properties of this ViewModel from the entity with the provided ID.
        /// </summary>
        /// <exception cref="InvalidOperationException">Cannot create a Planet ViewModel without an initialized game.</exception>
        /// <exception cref="GuidNotFoundException">Thrown when the supplied ID is not found in the game.</exception>
        internal static SystemVM Create(GameVM gameVM, Guid starSystemGuid)
        {
            if (gameVM.Game == null)
            {
                throw new InvalidOperationException("Cannot create a StarVM without an initialized game.");
            }

            List <StarSystem> systems = gameVM.Game.GetSystems(gameVM.CurrentAuthToken);

            foreach (StarSystem system in systems)
            {
                if (system.Guid == starSystemGuid)
                {
                    return(Create(gameVM, system));
                }
            }
            throw new GuidNotFoundException(starSystemGuid);
        }
Exemple #26
0
        public LogViewerVM(GameVM gameVM)
        {
            _gameVM = gameVM;
            if (Game != null && Auth != null)
            {
                foreach (var item in StaticRefLib.EventLog.GetAllEvents(Auth))
                {
                    EventsDict.Add(new EventVM(item, _gameVM.CurrentFaction, _gameVM));
                }
            }


            foreach (var kvp in gameVM.CurrentPlayer.HaltsOnEvent)
            {
                EventTypes.Add(new EventTypeBoolPair(gameVM.CurrentPlayer, kvp.Key));
            }


            _gameVM.Game.GameLoop.GameGlobalDateChangedEvent += GameLoop_GameGlobalDateChangedEvent;
        }
 /// <summary>
 /// Constructor for VM filled with componentSD
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="gameData"></param>
 /// <param name="designSD"></param>
 public ComponentTemplateMainPropertiesVM(ComponentTemplateParentVM parent, GameVM gameData, ComponentTemplateSD designSD) : this(parent, gameData)
 {
     SetDesignSD(designSD);
 }
Exemple #28
0
 private StarVM(GameVM gameVM, Entity entity)
 {
     Entity  = entity;
     _gameVM = gameVM;
     _name   = entity.GetDataBlob <NameDB>().DefaultName;
 }
 public void NewGame()
 {
     _gameVM = new GameVM();
     //_newGameOptions = NewGameOptionsVM.Create(_gameVM);
     //Assert.DoesNotThrow(() => _gameVM.CreateGame(_newGameOptions));
 }
Exemple #30
0
        /// < @todo add runis data.

        #endregion

        #region Functions

        #region Construction

        private PlanetVM(GameVM gameVM, Entity entity)
        {
            _gameVM = gameVM;
            Entity  = entity;
        }