예제 #1
0
    static StartUp()
    {
        GameEnv = new GameEnv();
        GameEnv.Init();
        GameEnv.Load();


        World = new TileWorld(GameEnv.FeatureWorld, 7, 5);
        GameEnv.WFeatureDesert.AddFeature(World[1, 1]);
        Debug.Log($"DataRepresentation of Landform {GameEnv.WFeatureFlatland.DataRepresentation} {GameEnv.WFeatureHills.DataRepresentation} {GameEnv.WFeatureMountains.DataRepresentation} {GameEnv.WFeatureHighMountains.DataRepresentation} bits={GameEnv.WFeatureLandform.DataIdentifier.Bits}");
    }
예제 #2
0
        private static void Main()
        {
            var env = new GameEnv();

            env.Init();
            env.Load();
            Console.WriteLine("Done");
            new Civilization("Kappaland", env.CivilisationRegister);


            //world creation
            var worldMaster = new TileWorld(env.FeatureWorld, 5, 5, WorldHolder.BaseWorld, WorldMode.Master, env.CivilizationManager, true, true);
            var worldSlave  = new TileWorld(env.FeatureWorld, 5, 5, WorldHolder.BaseWorld, WorldMode.Slave, env.CivilizationManager, true, true);
            var syncer      = new SyncWorldInterface(worldSlave);

            worldMaster.RegisterUpdate(syncer.ScheduleUpdate);

            Console.WriteLine("Test start");
            // ReSharper disable once InconsistentNaming
            var tile3_3M = worldMaster[3, 3];
            var tile3_3S = worldSlave[3, 3];



            Console.WriteLine("Testing sync between master and slave");
            Console.WriteLine(env.WFeatureBiome.GetFeature(tile3_3M).Name);
            env.WFeatureDesert.AddFeature(tile3_3M);
            Console.WriteLine(env.WFeatureBiome.GetFeature(tile3_3M).Name);
            Console.WriteLine(env.WFeatureBiome.GetFeature(tile3_3S).Name);
            env.WFeatureHighMountains.AddFeature(tile3_3M);
            Console.WriteLine(env.WFeatureLandform.GetFeature(tile3_3M).Name);
            Console.WriteLine(env.WFeatureLandform.GetFeature(tile3_3S).Name);


            Console.WriteLine("Testing changestate");
            var worldState = new RectChangeState(worldMaster, new Rect(0, 0, 1, 1), env.WFeatureBiome);

            var tile0_0M = worldMaster[0, 0];
            var tile0_0C = worldState[0, 0];
            var tile1_1C = worldState[1, 1];

            env.WFeatureDesert.AddFeature(tile0_0C);
            Console.WriteLine($"Master 0,0: {env.WFeatureBiome.GetFeature(tile0_0M).Name}");
            Console.WriteLine($"Change 0,0: {env.WFeatureBiome.GetFeature(tile0_0C).Name}");
            try {
                env.WFeatureHighMountains.AddFeature(tile0_0C);
                Console.WriteLine("Setting within bound of ChangeState of wrong feature type succeeded, this should not happen");
            } catch (Exception e) {
                Console.WriteLine($"Setting feature not applicable to ChangeState resulted in {e.GetType()}: {e.Message}");
            }
            try {
                env.WFeatureDesert.AddFeature(tile1_1C);
                Console.WriteLine("Setting outside bound of ChangeState succeeded, this should not happen");
            } catch (Exception e) {
                Console.WriteLine($"Setting outside bound of ChangeState resulted in {e.GetType()}: {e.Message}");
            }


            Console.WriteLine("Testing cities");
            var romeM = new City(tile3_3M, "Rome", env.CivilizationRome);

            env.CityManager.AddCity(romeM, true);

            var romeS = env.CityManager.GetCity(tile3_3S);

            Console.WriteLine(romeS.Name);

            romeM.SetName("Neo Roma");
            Console.WriteLine(romeS.Name);
        }