Ejemplo n.º 1
0
        public IkonComposite BuildSaveData()
        {
            var lastGameData = new IkonComposite(ClassName);

            if (this.StartConditions != null)
            {
                lastGameData.Add(StartingConditionsKey, this.StartConditions.BuildSaveData());
            }

            if (this.PlayersConfig != null)
            {
                lastGameData.Add(PlayersKey, new IkonArray(this.PlayersConfig));
            }

            if (this.StarPositionerConfig != null)
            {
                lastGameData.Add(StarPositionerKey, this.StarPositionerConfig);
            }

            if (this.StarConnectorConfig != null)
            {
                lastGameData.Add(StarConnectorKey, this.StarConnectorConfig);
            }

            if (this.StarPopulatorConfig != null)
            {
                lastGameData.Add(StarPopulatorKey, this.StarPopulatorConfig);
            }

            return(lastGameData);
        }
Ejemplo n.º 2
0
        public virtual IkonComposite Save(ObjectIndexer indexer)
        {
            var data = new IkonComposite(TableTag);

            data.Add(LocationKey, this.Location.Save(indexer));

            data.Add(OwnerKey, new IkonInteger(indexer.IndexOf(this.Owner)));

            var buildingsData = new IkonArray();

            foreach (var item in this.Buildings)
            {
                var itemData = new IkonComposite(BuildingsTag);
                itemData.Add(BuildingTypeKey, new IkonText(item.Key));
                itemData.Add(BuildingAmountKey, new IkonFloat(item.Value));
                buildingsData.Add(itemData);
            }
            data.Add(BuildingsKey, buildingsData);

            var stockpileData = new IkonArray();

            foreach (var item in this.Stockpile)
            {
                var itemData = new IkonComposite(StockpileTag);
                itemData.Add(StockpileGroupKey, new IkonText(item.Key));
                itemData.Add(StockpileAmountKey, new IkonFloat(item.Value));
                stockpileData.Add(itemData);
            }
            data.Add(StockpileKey, stockpileData);
            return(data);
        }
Ejemplo n.º 3
0
        public IkonComposite BuildSaveData()
        {
            var lastGameData = new IkonComposite(ClassName);

            if (this.StartConditions != null)
            {
                lastGameData.Add(StartingConditionsKey, this.StartConditions.BuildSaveData());                 //TODO(v0.5) check if data is valid before loading
            }
            if (this.StarPositionerConfig != null)
            {
                lastGameData.Add(StarPositionerKey, this.StarPositionerConfig);
            }

            if (this.StarConnectorConfig != null)
            {
                lastGameData.Add(StarConnectorKey, this.StarConnectorConfig);
            }

            if (this.StarPopulatorConfig != null)
            {
                lastGameData.Add(StarPopulatorKey, this.StarPopulatorConfig);
            }

            return(lastGameData);
        }
Ejemplo n.º 4
0
        public IkonComposite Save()
        {
            var data      = new IkonComposite(TableTag);
            var colorData = new IkonArray();

            colorData.Add(new IkonInteger(this.Color.R));
            colorData.Add(new IkonInteger(this.Color.G));
            colorData.Add(new IkonInteger(this.Color.B));
            data.Add(ColorKey, colorData);

            data.Add(SizeKey, new IkonFloat(this.ImageSizeScale));

            data.Add(NameKey, this.Name.Save());

            var positionData = new IkonArray();

            positionData.Add(new IkonFloat(this.Position.X));
            positionData.Add(new IkonFloat(this.Position.Y));
            data.Add(PositionKey, positionData);

            var traitsData = new IkonArray();

            foreach (var item in this.Traits)
            {
                traitsData.Add(item.Save());
            }
            data.Add(TraitsKey, traitsData);
            return(data);
        }
Ejemplo n.º 5
0
        public IkonBaseObject Make()
        {
            //TODO(later) assumes single player
            var player   = this.controller.LocalHumanPlayers().First();
            var starData = new IkonArray();

            foreach (var star in player.Stars)
            {
                var data = new IkonComposite(StarTag);
                data.Add("x", new IkonFloat(star.Position.X));
                data.Add("y", new IkonFloat(star.Position.Y));
                data.Add(ColorKey, new IkonArray(
                             new []
                {
                    new IkonInteger(star.Color.R),
                    new IkonInteger(star.Color.G),
                    new IkonInteger(star.Color.B)
                }
                             ));
                starData.Add(data);
            }

            var previewData = new IkonComposite(Tag);

            previewData.Add(TurnKey, new IkonInteger(player.Turn));
            previewData.Add(StarsKey, starData);

            return(previewData);
        }
Ejemplo n.º 6
0
        public IkonComposite Save(ObjectIndexer indexer)
        {
            var data = new IkonComposite(TableTag);

            data.Add(OwnerKey, new IkonInteger(indexer.IndexOf(this.Owner)));

            var positionData = new IkonArray();

            positionData.Add(new IkonFloat(this.Position.X));
            positionData.Add(new IkonFloat(this.Position.Y));
            data.Add(PositionKey, positionData);

            var missionsData = new IkonArray();

            foreach (var item in this.Missions)
            {
                missionsData.Add(item.Save(indexer));
            }
            data.Add(MissionsKey, missionsData);

            var shipsData = new IkonArray();

            foreach (var item in this.Ships)
            {
                shipsData.Add(item.Save(indexer));
            }
            data.Add(ShipsKey, shipsData);
            return(data);
        }
Ejemplo n.º 7
0
        protected virtual void buildSaveData(IkadnWriter writer)
        {
            var baseSettings = new IkonComposite(BaseSettingsTag);

            baseSettings.Add(LanguageKey, new IkonText(this.LanguageId));
            baseSettings.Add(LastGameKey, this.LastGame.BuildSaveData());
            baseSettings.Compose(writer);
        }
Ejemplo n.º 8
0
        public IkonComposite Save(ObjectIndexer indexer)
        {
            var data = new IkonComposite(TableTag);

            data.Add(OwnerKey, new IkonInteger(indexer.IndexOf(this.Owner)));

            data.Add(DestinationKey, new IkonInteger(indexer.IndexOf(this.Destination)));
            return(data);
        }
Ejemplo n.º 9
0
        public IkonComposite Save(ObjectIndexer indexer)
        {
            var data = new IkonComposite(TableTag);

            data.Add(Party1Key, new IkonInteger(indexer.IndexOf(this.Party1)));

            data.Add(Party2Key, new IkonInteger(indexer.IndexOf(this.Party2)));
            return(data);
        }
Ejemplo n.º 10
0
        public IkonComposite Save()
        {
            var data = new IkonComposite(TableTag);

            data.Add(ExploredKey, new IkonFloat(this.Explored));

            data.Add(LastVisitedKey, new IkonInteger(this.LastVisited));
            return(data);
        }
Ejemplo n.º 11
0
        public IkonComposite Save(ObjectIndexer indexer)
        {
            var data = new IkonComposite(TableTag);

            data.Add(FromStarKey, new IkonInteger(indexer.IndexOf(this.FromStar)));

            data.Add(ToStarKey, new IkonInteger(indexer.IndexOf(this.ToStar)));
            return(data);
        }
Ejemplo n.º 12
0
        public Ikadn.IkadnBaseObject Save()
        {
            IkonComposite data = new IkonComposite(SaveTag);

            data.Add(ConstellationKey, new IkonInteger(this.constellation));
            data.Add(DesignationKey, new IkonInteger(this.designation));

            return(data);
        }
Ejemplo n.º 13
0
        public IkadnBaseObject Save(ObjectIndexer indexer)
        {
            var data = new IkonComposite(SaveTag);

            data.Add(CountKey, new IkonInteger(this.TechProgress.CompletedCount));
            data.Add(InvestedKey, new IkonFloat(this.TechProgress.InvestedPoints));
            data.Add(LeftoverKey, new IkonFloat(this.TechProgress.LeftoverPoints));
            data.Add(TopicKey, new IkonInteger(indexer.IndexOf(this.TechProgress.Item)));

            return(data);
        }
Ejemplo n.º 14
0
        public IkonComposite BuildSaveData()
        {
            var lastGameData = new IkonComposite(ClassName);

            lastGameData.Add(ColoniesKey, new IkonInteger(Colonies));
            lastGameData.Add(PopulationKey, new IkonInteger(Population));
            lastGameData.Add(InfrastructureKey, new IkonInteger(Infrastructure));
            lastGameData.Add(NameKey, new IkonText(nameKey));

            return(lastGameData);
        }
Ejemplo n.º 15
0
		public IkonComposite Save(ObjectIndexer indexer) 
		{
			var data = new IkonComposite(TableTag);
			data.Add(DestinationKey, new IkonInteger(indexer.IndexOf(this.Destination)));

			var sourcesData = new IkonArray();
			foreach(var item in this.Sources)
				sourcesData.Add(new IkonInteger(indexer.IndexOf(item)));
			data.Add(SourcesKey, sourcesData);
			return data;
 
		}
Ejemplo n.º 16
0
        public IkonComposite Save(ObjectIndexer indexer)
        {
            var data = new IkonComposite(TableTag);

            data.Add(DesignKey, new IkonInteger(indexer.IndexOf(this.Design)));

            data.Add(QuantityKey, new IkonInteger(this.Quantity));

            data.Add(DamageKey, new IkonFloat(this.Damage));

            data.Add(UpgradePointsKey, new IkonFloat(this.UpgradePoints));
            return(data);
        }
Ejemplo n.º 17
0
        public IkonComposite Save(ObjectIndexer indexer)
        {
            var data = new IkonComposite(TableTag);

            data.Add(OwnerKey, new IkonInteger(indexer.IndexOf(this.Owner)));

            data.Add(TopicKey, new IkonText(this.Topic.IdCode));

            data.Add(LevelKey, new IkonInteger(this.Level));

            data.Add(InvestedKey, new IkonFloat(this.InvestedPoints));
            return(data);
        }
Ejemplo n.º 18
0
        public override Ikadn.IkadnBaseObject Save(ObjectIndexer indexer)
        {
            var saveData = new IkonComposite(MissionTag);

            saveData.Add(DestinationKey, new IkonInteger(indexer.IndexOf(this.Destination)));

            if (this.UsedWormhole != null)
            {
                saveData.Add(WormholeKey, new IkonInteger(indexer.IndexOf(this.UsedWormhole)));
            }

            return(saveData);
        }
Ejemplo n.º 19
0
        public IkonBaseObject Save(object obj)
        {
            var session = new SaveSession(getTypeStrategy);

            var mainData       = session.Serialize(obj);
            var referencedData = session.GetSerialzedData();

            var result = new IkonComposite(MainGame.SaveGameTag);

            result.Add("references", new IkonArray(referencedData));
            result.Add(EntryPointKey, mainData);

            return(result);
        }
Ejemplo n.º 20
0
        public IkonComposite Save(ObjectIndexer indexer)
        {
            var data = new IkonComposite(TableTag);

            data.Add(DevelopmentFocusIndexKey, new IkonInteger(this.DevelopmentFocusIndex));

            data.Add(DevelopmentQueueKey, saveDevelopment());

            data.Add(ResearchFocusKey, new IkonText(this.ResearchFocus));

            data.Add(ConstructionPlansKey, saveConstruction(indexer));

            data.Add(ShipOrdersKey, saveShipOrders(indexer));

            data.Add(ColonizationOrdersKey, saveColonizationOrders(indexer));

            data.Add(RefitOrdersKey, saveRefitOrders(indexer));

            var audienceRequestsData = new IkonArray();

            foreach (var item in this.AudienceRequests)
            {
                audienceRequestsData.Add(new IkonInteger(item));
            }
            data.Add(AudienceRequestsKey, audienceRequestsData);
            return(data);
        }
Ejemplo n.º 21
0
        public IkonComposite Save(ObjectIndexer indexer)
        {
            var data = new IkonComposite(TableTag);
            var starKnowledgeData = new IkonArray();

            foreach (var item in this.starKnowledge)
            {
                var itemData = new IkonComposite(StarIntellTag);
                itemData.Add(StarDataKey, new IkonInteger(indexer.IndexOf(item.Key)));
                itemData.Add(StarIntelligenceKey, item.Value.Save(indexer));
                starKnowledgeData.Add(itemData);
            }
            data.Add(StarKnowledgeKey, starKnowledgeData);
            return(data);
        }
Ejemplo n.º 22
0
        public IkonComposite Save(ObjectIndexer indexer)
        {
            var data = new IkonComposite(TableTag);

            data.Add(SpendingRatioKey, new IkonFloat(this.SpendingRatio));

            var queueData = new IkonArray();

            foreach (var item in this.Queue)
            {
                queueData.Add(new IkonText(item.IdCode));
            }
            data.Add(QueueKey, queueData);
            return(data);
        }
Ejemplo n.º 23
0
        private IkadnBaseObject saveConstruction(ObjectIndexer indexer)
        {
            var queue = new IkonArray();

            foreach (var plan in this.ConstructionPlans)
            {
                IkonComposite planData;

                if (plan.Key.Location.Planet == null)
                {
                    planData = new IkonComposite(StellarisConstructionTag);
                    planData.Add(LocationKey, new IkonInteger(indexer.IndexOf((StellarisAdmin)plan.Key)));
                }
                else
                {
                    planData = new IkonComposite(ColonyConstructionTag);
                    planData.Add(LocationKey, new IkonInteger(indexer.IndexOf((Colony)plan.Key)));
                }

                planData.Add(OrdersKey, plan.Value.Save(indexer));
                queue.Add(planData);
            }

            return(queue);
        }
Ejemplo n.º 24
0
        private IkadnBaseObject saveColonizationOrders(ObjectIndexer indexer)
        {
            var queue = new IkonArray();

            foreach (var order in this.ColonizationOrders)
            {
                IkonComposite orderData;

                orderData = new IkonComposite(ColonizationOrdersTag);
                orderData.Add(ColonizationDestinationTag, new IkonInteger(indexer.IndexOf(order.Value.Destination)));
                orderData.Add(ColonizationSourcesTag, new IkonArray(order.Value.Sources.Select(x => new IkonInteger(indexer.IndexOf(x)))));
                queue.Add(orderData);
            }

            return(queue);
        }
Ejemplo n.º 25
0
        public Ikadn.IkadnBaseObject Save()
        {
            var data = new IkonComposite(PlayerType.AiControllerTag);

            data.Add(PlayerType.FactoryIdKey, new IkonText(DefaultAIFactory.FactoryId));

            return(data);
        }
Ejemplo n.º 26
0
        public override IkadnBaseObject Save(ObjectIndexer indexer)
        {
            var saveData = new IkonComposite(MissionTag);

            saveData.Add(TargetKey, new IkonInteger(indexer.IndexOf(this.Target)));

            return(saveData);
        }
Ejemplo n.º 27
0
        public Ikadn.IkadnBaseObject Save()
        {
            IkonComposite data = new IkonComposite(SaveTag);

            data.Add(IndexKey, new IkonInteger(this.properNameIndex));

            return(data);
        }
Ejemplo n.º 28
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Usage: TextureAtlas <folder> [options]");
                return;
            }
            else
            {
                ReadParameters(args);
            }

            var builder = new AtlasBuilder(
                items.Select(x => new KeyValuePair <string, Size>(x.Key, x.Value.Size)).ToArray(),
                margin, new Size(width, heigth)
                );

            var atlasIkon  = new IkonComposite(compositeTag);
            var atlasImage = new Bitmap(width, heigth);

            using (Graphics g = Graphics.FromImage(atlasImage))
                foreach (var x in builder.Build())
                {
                    Console.WriteLine(x.Key + " " + x.Value);
                    string[] nameParams = x.Key.Split('-');

                    var bounds = x.Value;
                    foreach (var param in nameParams)
                    {
                        if (param.StartsWith("hStretch"))
                        {
                            int amount;
                            if (!int.TryParse(param.Substring("hStretch".Length), out amount))
                            {
                                amount = 1;
                            }
                            bounds.Inflate(-amount, 0);
                        }
                    }

                    var textureCoords = new IkonArray();
                    textureCoords.Add(serializeRectangle(bounds.Left, bounds.Top));
                    textureCoords.Add(serializeRectangle(bounds.Right, bounds.Top));
                    textureCoords.Add(serializeRectangle(bounds.Right, bounds.Bottom));
                    textureCoords.Add(serializeRectangle(bounds.Left, bounds.Bottom));

                    atlasIkon.Add(nameParams[0], textureCoords);
                    var destRect = new Rectangle(x.Value.Location, x.Value.Size);
                    g.DrawImage(items[x.Key], destRect);
                }

            using (var outStream = new StreamWriter(outputIkonPath)) {
                var writer = new IkadnWriter(outStream);
                atlasIkon.Compose(writer);
            }

            atlasImage.Save(outputImagePath, ImageFormat.Png);
        }
Ejemplo n.º 29
0
        public IkonComposite Save(ObjectIndexer indexer)
        {
            var data = new IkonComposite(TableTag);

            data.Add(LastVisitedKey, new IkonInteger(this.LastVisited));

            var planetsData = new IkonArray();

            foreach (var item in this.Planets)
            {
                var itemData = new IkonComposite(PlanetIntellTag);
                itemData.Add(PlanetKey, new IkonInteger(indexer.IndexOf(item.Key)));
                itemData.Add(PlanetIntelligenceKey, item.Value.Save());
                planetsData.Add(itemData);
            }
            data.Add(PlanetsKey, planetsData);
            return(data);
        }
Ejemplo n.º 30
0
        private IkadnBaseObject saveShipOrders(ObjectIndexer indexer)
        {
            var queue = new IkonArray();

            foreach (var order in this.ShipOrders)
            {
                var orderData = new IkonComposite(ShipOrderTag);

                orderData.Add(Position, new IkonArray().
                              Add(new IkonFloat(order.Key.X)).
                              Add(new IkonFloat(order.Key.Y))
                              );

                orderData.Add(Fleets, new IkonArray(order.Value.Select(x => x.Save(indexer))));
                queue.Add(orderData);
            }

            return(queue);
        }