示例#1
0
        public void TestBasicAndConstant()
        {
            v55.ChangeType(constantFactory);
            var fact = ((IVoxel)v55).GetPart <ConstantFactory>();

            fact.Rate            = 1;
            fact.ItemsToGenerate = new[] { items.CropType };

            v57.ChangeType(basicFactory);
            var fact2 = ((IVoxel)v57).GetPart <BasicFactory>();

            fact2.EfficiencySpeedMultiplier = 1;
            fact2.Input = new[]
            {
                items.CropType, items.CropType,
                items.CropType
            };
            fact2.Output = new[] { items.PigmentType };


            v56.ChangeType(types.Get <WarehouseType>());

            v46.ChangeType(pusher);

            v(3, 6).ChangeType(types.Get <RoadType>());
            v(2, 6).ChangeType(puller);
            v(1, 6).ChangeType(types.Get <WarehouseType>());
        }
示例#2
0
        /*public static GodGameOffline CreateGame()
         * {
         *  var world = new Internal.Model.World(100, 10);
         *  buildDemoWorld(world);
         *
         *
         *
         *
         *  var ret = new GodGameOffline(EngineFactory.CreateEngine(), world);
         *
         *  return ret;
         * }*/

        private static void buildDemoWorld(Internal.Model.World world, VoxelTypesFactory typesFactory)
        {
            world.ForEach((v, p) =>
            {
                if (Vector2.Distance(p, new Vector2(100, 100)) < 100)
                {
                    v.Data.Type = typesFactory.Get <LandType>();
                }
                else if (Vector2.Distance(p, new Vector2(8, 8)) < 7)
                {
                    v.Data.Type = typesFactory.Get <LandType>();
                }
                else if (Vector2.Distance(p, new Vector2(25, 25)) < 15)
                {
                    v.Data.Type = typesFactory.Get <LandType>();
                }
                //v.ChangeType(GameVoxelType.Infestation);
                else
                {
                    v.Data.Type = typesFactory.Get <LandType>();
                }
            });


            /*var worldPersister = new WorldPersister(getTypeFromName, getItemFromName);
             * var simpleWorldRenderer = new SimpleWorldRenderer(world);
             * var ret = new GodGameOffline(EngineFactory.CreateEngine(),
             *  world,
             *  new UserInputProcessingService(createPlayerInputs(world).ToArray(), world, worldPersister, simpleWorldRenderer),
             *  worldPersister,
             *  simpleWorldRenderer);
             *
             * return ret;*/
        }
        public AllCommandProvider(WorldPersisterService persister,
                                  Internal.Model.World world,
                                  VoxelTypesFactory typesFactory,
                                  ItemTypesFactory itemTypesFactory,
                                  UserInputProcessingService userInputProcessingService,
                                  GenericDatastore genericDatastore)
        {
            this.typesFactory     = typesFactory;
            this.itemTypesFactory = itemTypesFactory;
            this.genericDatastore = genericDatastore;
            addDummy();

            addPersistence(persister, world);

            addCommand("clearinfestation", () =>
            {
                world.ForEach((v, _) =>
                {
                    if (v.Type != typesFactory.Get <InfestationVoxelType>())
                    {
                        return;
                    }
                    typesFactory.Get <InfestationVoxelType>().CureInfestation(v);
                });

                return("Cleared all infestation!");
            });

            addCommand("helpall", () =>
            {
                return("All Commands: " + string.Join(", ", CommandNames.ToArray()));
            });
            addCommand("help", partialCommand =>
            {
                return("Commands containing '" + partialCommand + "': " + string.Join(", ", CommandNames.Where(c => c.Contains(partialCommand)).ToArray()));
            });
            addCommand("clearWorld", () =>
            {
                genericDatastore.ClearAll();
                world.ForEach((v, _) =>
                {
                    v.Data.Type = typesFactory.Get <LandType>();
                });
                return("World cleared!");
            });
            addCommand("listsaves", () =>
            {
                var saves        = TWDir.GameData.CreateChild("Saves\\GodGame").GetFiles().ToList();
                var outputstring = String.Join(", ", saves.Select(e => e.Name.Substring(0, e.Name.Length - 4)));     // Drop extension
                return("Saved games: \n" + outputstring);
            });

            addCommand("addresource", (typeStr, amountStr) =>
            {
                var itemType = itemTypesFactory.AllTypes.FirstOrDefault(t => t.Name.ToLower() == typeStr.ToLower());
                if (itemType == null)
                {
                    return("Item type not found: " + typeStr);
                }
                var amount = 0;
                if (!int.TryParse(amountStr, out amount))
                {
                    return("Invalid item amount: " + amountStr);
                }

                var target = userInputProcessingService.GetTargetedVoxel();
                if (target == null || target.Type != typesFactory.Get <WarehouseType>())
                {
                    return("Not targeting a warehouse");
                }

                target.Data.Inventory.AddNewItems(itemType, amount);

                return("Added items!");
            });
        }
示例#4
0
        public List <IToolSelectionItem> BuildMenu()
        {
            var ret = new List <IToolSelectionItem>();

            ret.Add(createTransportation());

            ret.Add(getVoxelType <RoadType>());
            ret.Add(createCat("Towns",
                              getBuildingSite <HouseType>(),
                              getBuildingSite <MarketType>(),
                              getBuildingSite <TownCenterType>(),
                              getTool <TownBorderTool>()
                              //getBuildingSite<WorshipSiteType>(),

                              ));
            ret.Add(createCat("Industry",
                              getBuildingSite <WoodworkerType>(),
                              getBuildingSite <MinerType>()
                              //getBuildingSite<WorshipSiteType>(),

                              ));

            ret.Add(createCategory("Terrain").Alter(c => c.SelectionItems.AddRange(new[]
            {
                createTypeInput(typesFactory.Get <AirType>()),
                new ChangeHeightTool(world),
                createTypeInput(typesFactory.Get <ForestType>()),
                createTypeInput(typesFactory.Get <InfestationVoxelType>()),
                createTypeInput(typesFactory.Get <WaterType>()),
                createTypeInput(typesFactory.Get <HoleType>()),
                createOreInput(),
                createTypeInput(typesFactory.Get <MonumentType>())
            }.Select(toToolItem))));
            ret.Add(createCategory("Buildings").Alter(c =>
            {
                c.SelectionItems.Add(createCat("Industry", new[]
                {
                    createTypeInput(typesFactory.Get <WarehouseType>()),
                    createTypeInput(typesFactory.Get <MinerType>()),
                    createTypeInput(typesFactory.Get <QuarryType>()),
                    createTypeInput(typesFactory.Get <GrinderType>()),
                    createTypeInput(typesFactory.Get <CropType>()),
                    createTypeInput(typesFactory.Get <FarmType>()),
                    createTypeInput(typesFactory.Get <FisheryType>()),
                    createTypeInput(typesFactory.Get <WoodworkerType>())
                }));
                c.SelectionItems.Add(createCat("Village", new[]
                {
                    createTypeInput(typesFactory.Get <TownCenterType>()),
                    createTypeInput(typesFactory.Get <HouseType>()),
                    createTypeInput(typesFactory.Get <MarketType>()),
                    getPlayerTool[typeof(TownBorderTool)]
                }));
            }));
            ret.Add(createCategory("BuildingSites").Alter(c => c.SelectionItems.AddRange(new[]
            {
                createTypeInput(typesFactory.GetBuildingSite <MarketType>(), "MarketBuildSite"),
                createTypeInput(typesFactory.GetBuildingSite <FisheryType>(), "FisheryBuildSite")
            }.Select(toToolItem))));
            ret.Add(createCategory("Godpowers").Alter(c => c.SelectionItems.AddRange(new PlayerTool[] { new LightGodPowerTool(typesFactory.Get <InfestationVoxelType>()) }.Select(toToolItem))));

            return(ret);
        }