예제 #1
0
            public IEnumerable <int> Run()
            {
                world.GetVoxel(new Point2(4, 4)).ChangeType(townCenterType);
                yield return(0);

                world.GetVoxel(new Point2(2, 2)).ChangeType(minerType);
                yield return(0);

                var town = townCenterService.GetTownForVoxel(world.GetVoxel(new Point2(4, 4)));

                town.AddVoxel(world.GetVoxel(new Point2(4, 5)));
                yield return(0);
            }
 public void ApplyVoxels(Internal.Model.World world, GameplayObjectsSerializer objectSerializer)
 {
     foreach (var voxel in Voxels)
     {
         var target = world.GetVoxel(new Point2(voxel.X, voxel.Y));
         voxel.ToVoxel(target, objectSerializer);
     }
 }
        public void ForwardReceivedInputs()
        {
            while (transporter.PacketAvailable)
            {
                var p = transporter.Receive();
                switch (p.Method)
                {
                case "OnSave":
                    handler.OnSave();
                    break;

                case "OnNextTool":
                    handler.OnNextTool();
                    break;

                case "OnPreviousTool":
                    handler.OnPreviousTool();
                    break;

                case "OnLeftClick":
                    handler.OnLeftClick(world.GetVoxel(new Point2(p.VoxelCoordX, p.VoxelCoordY)));
                    break;

                case "OnRightClick":
                    handler.OnRightClick(world.GetVoxel(new Point2(p.VoxelCoordX, p.VoxelCoordY)));
                    break;

                case "OnKeyPressed":
                    handler.OnKeyPressed(world.GetVoxel(new Point2(p.VoxelCoordX, p.VoxelCoordY)), (Key)p.Key);
                    break;

                default:
                    throw new InvalidOperationException("Unknown input method: " + p.Method);
                }
            }
        }
예제 #4
0
        public void Setup()
        {
            var builder = new ContainerBuilder();

            builder.RegisterModule <OfflineGameModule>();
            builder.RegisterType <Internal.Model.World>().SingleInstance().AsSelf()
            .OnActivating(args =>
            {
                args.Instance.Initialize(10, 10);

                var land = args.Context.Resolve <LandType>();
                args.Instance.ForEach((v, p) => v.ChangeType(land));
            });


            var cont = builder.Build();

            var offline = cont.Resolve <GodGameOffline>();

            offline.AddSimulatorsToEngine(EngineFactory.CreateEngine());
            world = offline.World;
            types = cont.Resolve <VoxelTypesFactory>();
            items = cont.Resolve <ItemTypesFactory>();

            basicFactory    = new GenericVoxelType <BasicFactory>(v => new BasicFactory(v));
            constantFactory = new GenericVoxelType <ConstantFactory>(v => new ConstantFactory(v));
            pusher          = new GenericVoxelType <Pusher>(v => new Pusher(v));
            puller          = new GenericVoxelType <Puller>(v => new Puller(v));

            v55 = world.GetVoxel(new Point2(5, 5));
            v56 = world.GetVoxel(new Point2(5, 6));
            v57 = world.GetVoxel(new Point2(5, 7));

            v46 = world.GetVoxel(new Point2(4, 6));
            v36 = world.GetVoxel(new Point2(3, 6));
        }
예제 #5
0
        public object DeserializeReference(XElement obj)
        {
            switch (obj.Name.LocalName)
            {
            case "Record":
                return(GetRecord(int.Parse(obj.Attribute("id").Value)));

            case "BoundObject":
                return(GetRecord(int.Parse(obj.Attribute("id").Value)));

            case "Voxel":
                return(world.GetVoxel(new Point2(int.Parse(obj.Attribute("x").Value), int.Parse(obj.Attribute("y").Value))));

            default:
                throw new InvalidOperationException("Can't deserialize xml reference object: " + obj);
            }
        }
예제 #6
0
 public void ToWorld(Internal.Model.World world, GameplayObjectsSerializer gameplayObjectsSerializer)
 {
     foreach (var el in Voxels)
     {
         var v = world.GetVoxel(new Point2(el.X, el.Y));
         if (v == null)
         {
             //Console.WriteLine("Deserializing voxel but world to small: " + el.X + ", " + el.Y);
             continue;
         }
         try
         {
             el.ToVoxel(v, gameplayObjectsSerializer);
         }
         catch (Exception ex)
         {
             DI.Get <IErrorLogger>().Log(ex, "Can't load voxel in serializedworld");
         }
     }
 }
예제 #7
0
 private GameVoxel v(int x, int y)
 {
     return(world.GetVoxel(new Point2(x, y)));
 }