Exemplo n.º 1
0
        //门作为设备来处理
        public void Synchronization(DoorEntity entity)
        {
            if (Constant.Sysc)
            {
                try
                {
                    var device = _deviceRepository.GetById(entity.DeviceUUID);
                    if (device == null)
                    {
                        return;
                    }
                    var requestXml = GetXml(entity, device);
                    Log.Debug(this.GetType().ToString(), requestXml);

                    var areaS       = new Lkb.DeviceServiceImplService();
                    var responseXml = areaS.insertDevice(requestXml);
                    Log.Debug(this.GetType().ToString(), responseXml);
                    var resultRes = responseXml.Deserial <ResultResponse>();

                    var syncLog = new SyncLogEntity();
                    syncLog.SyncType    = SyncLogEnum.InsertDevice.ToString();
                    syncLog.ResquestXml = requestXml;
                    syncLog.ResponseXml = responseXml;
                    syncLog.SyncTime    = DateTime.Now;
                    syncLog.SyncResult  = 0;
                    syncLog.CommunityId = entity.CommunityUUID;

                    if (resultRes != null && resultRes.Header != null)
                    {
                        var header = resultRes.Header;
                        if (header.RspCode.Equals("0"))
                        {
                            var entity2 = _doorRepository.GetById(entity.DoorUUID);
                            entity2.SyncVersion += 1;
                            entity2.SyncStatus   = true;
                            _doorRepository.Update(entity2);

                            syncLog.SyncResult = 1;
                        }
                    }
                    _syncService.InsertSyncLog(syncLog);
                }
                catch (Exception ex)
                {
                    Log.Error(null, ex.Message);
                }
            }
        }
Exemplo n.º 2
0
        private string GetXml(DoorEntity door, DeviceEntity device)
        {
            var flag = door.SyncVersion == 0 ? "C" : "U"; //增|删|改,C|D|U

            if (door.Deleted)
            {
                flag = "D";
            }
            var area           = _areaRepository.GetById(door.AreaUUID);
            var DeviceTypeDict = device.DeviceType.HasValue ? _dictService.GetById(device.DeviceType.Value) : null;
            var LockTypeDict   = device.LockType.HasValue ? _dictService.GetById(device.LockType.Value) : null;

            var xmlBuilder = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

            xmlBuilder.Append("<Tpp2Fpp>");
            xmlBuilder.Append("<ReqHeader>");
            xmlBuilder.AppendFormat("<ReqSeqNo>{0}</ReqSeqNo>", Utils.MakeRndName());
            xmlBuilder.AppendFormat("<ReqSPID>{0}</ReqSPID>", DESHelper.Encrypt3Des(Constant.LkbAccount, Constant.DescKeyBytes));
            xmlBuilder.AppendFormat("<ReqCode>{0}</ReqCode>", DESHelper.Encrypt3Des(Constant.LkbPassword, Constant.DescKeyBytes));
            xmlBuilder.Append("</ReqHeader>");
            xmlBuilder.Append("<ReqBody>");
            xmlBuilder.Append("<device>");
            xmlBuilder.AppendFormat("<uuid>{0}</uuid>", door.DoorUUID);
            xmlBuilder.AppendFormat("<name>{0}</name>", device.DeviceName);
            xmlBuilder.AppendFormat("<mac>{0}</mac>", device.Mac);
            xmlBuilder.AppendFormat("<type>{0}</type>", DeviceTypeDict != null ? DeviceTypeDict.DictCode : ""); //设备类型 必传
            xmlBuilder.AppendFormat("<gw_uuid>{0}</gw_uuid>", "");                                              //所属控制器(网关)的uuid
            xmlBuilder.AppendFormat("<status>{0}</status>", door.Status == 1?1:2);                              //文档中未提及
            xmlBuilder.AppendFormat("<area_uuid>{0}</area_uuid>", area.AreaUUID);                               //证件号码(需要加密) 必填
            xmlBuilder.AppendFormat("<area_layercode>{0}</area_layercode>", area.AreaCode);                     //房屋区域层级编码 必填
            xmlBuilder.AppendFormat("<cdate>{0}</cdate>", door.CreateTime.ToString("yyyyMMddHHmmss"));
            xmlBuilder.AppendFormat("<udate>{0}</udate>", door.CreateTime.ToString("yyyyMMddHHmmss"));
            xmlBuilder.AppendFormat("<inner_key>{0}</inner_key>", device.InnerKey);
            xmlBuilder.AppendFormat("<cuser>{0}</cuser>", Constant.LkbAccount);
            xmlBuilder.AppendFormat("<locktype>{0}</locktype>", LockTypeDict != null ? LockTypeDict.DictCode : "");
            xmlBuilder.AppendFormat("<flag>{0}</flag>", flag);
            xmlBuilder.Append("</device>");
            xmlBuilder.Append("</ReqBody>");
            xmlBuilder.Append("</Tpp2Fpp>");
            return(xmlBuilder.ToString());
        }
Exemplo n.º 3
0
        protected bool RunCubeBlockReflectionTests()
        {
            bool result = true;

            if (!CubeBlockEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("CubeBlockEntity reflection validation failed!");
            }

            if (!TerminalBlockEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("TerminalBlockEntity reflection validation failed!");
            }

            if (!FunctionalBlockEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("FunctionalBlockEntity reflection validation failed!");
            }

            if (!ProductionBlockEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("ProductionBlockEntity reflection validation failed!");
            }

            if (!LightEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("LightEntity reflection validation failed!");
            }

            if (!BatteryBlockEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("BatteryBlockEntity reflection validation failed!");
            }

            if (!BatteryBlockNetworkManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("BatteryBlockNetworkManager reflection validation failed!");
            }

            if (!DoorEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("DoorEntity reflection validation failed!");
            }

            if (!GravityBaseEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("GravityBaseEntity reflection validation failed!");
            }

            if (!GravityGeneratorEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("GravityGeneratorEntity reflection validation failed!");
            }

            if (!GravitySphereEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("GravitySphereEntity reflection validation failed!");
            }

            if (!BeaconEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("BeaconEntity reflection validation failed!");
            }

            if (!AntennaEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("AntennaEntity reflection validation failed!");
            }

            if (!ThrustEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("ThrustEntity reflection validation failed!");
            }

            if (!ThrustNetworkManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("ThrustNetworkManager reflection validation failed!");
            }

            if (!GyroEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("GyroEntity reflection validation failed!");
            }

            if (!GyroNetworkManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("GyroNetworkManager reflection validation failed!");
            }

            if (!CockpitEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("CockpitEntity reflection validation failed!");
            }

            if (!TurretBaseEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("TurretBaseEntity reflection validation failed!");
            }

            if (!TurretNetworkManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("TurretNetworkManager reflection validation failed!");
            }

            if (!LandingGearEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("LandingGearEntity reflection validation failed!");
            }

            if (!LandingGearNetworkManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("LandingGearNetworkManager reflection validation failed!");
            }

            if (!ReactorEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("ReactorEntity reflection validation failed!");
            }

            if (!SolarPanelEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("SolarPanelEntity reflection validation failed!");
            }

            if (!SmallGatlingGunEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("SmallGatlingGunEntity reflection validation failed!");
            }

            if (!MergeBlockEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("MergeBlockEntity reflection validation failed!");
            }

            if (!PistonEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("PistonEntity reflection validation failed!");
            }

            if (!PistonNetworkManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("PistonNetworkManager reflection validation failed!");
            }

            if (!RotorEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("RotorEntity reflection validation failed!");
            }

            if (!VirtualMassEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("VirtualMassEntity reflection validation failed!");
            }

            if (!CameraBlockEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("CameraBlockEntity reflection validation failed!");
            }

            if (!OreDetectorEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("OreDetectorEntity reflection validation failed!");
            }

            if (!ButtonPanelEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("ButtonPanelEntity reflection validation failed!");
            }

            if (!ShipControllerEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("ShipControllerEntity reflection validation failed!");
            }

            if (!ShipControllerNetworkManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("ShipControllerNetworkManager reflection validation failed!");
            }

            if (result)
            {
                Console.WriteLine("All block types passed reflection unit tests!");
            }

            return(result);
        }
Exemplo n.º 4
0
        //Reads in a paint image and adds all entities to the level.
        public void readImage(Level level)
        {
            for (int y = 0; y < img.Height; y++)
            {
                for (int x = 0; x < img.Width; x++)
                {
                    //Get the color of the pixel
                    Color col = img.GetPixel(x, y);

                    float levelX = x;
                    float levelY = y;

                    //First check for cases which have some variation in possible color values
                    //i.e. something identified with only it's RG, or GB, or RB, or just R or G or B
                    if (col.R == switchReserveRed)
                    {
                        Entity s = null;

                        if (col.G == permSwitchG)
                        {
                            s = new SwitchEntity(level, rand.Next(Int32.MinValue, Int32.MaxValue), levelX * tileWidth, levelY * tileHeight);
                        }
                        else if (col.G == presSwitchG)
                        {
                            //Pressure Switch
                            s = new PressureSwitchEntity(level, rand.Next(Int32.MinValue, Int32.MaxValue), levelX * tileWidth, levelY * tileWidth);
                            TimedSwitchComponent timeComp = ( TimedSwitchComponent )s.getComponent(GlobalVars.TIMED_SWITCH_COMPONENT_NAME);
                            timeComp.baseTime = 0;
                        }
                        else
                        {
                            s = new TimedSwitchEntity(level, rand.Next(Int32.MinValue, Int32.MaxValue), levelX * tileWidth, levelY * tileWidth);
                            TimedSwitchComponent timeComp = ( TimedSwitchComponent )s.getComponent(GlobalVars.TIMED_SWITCH_COMPONENT_NAME);
                            timeComp.baseTime = col.G / 10;
                        }
                        s.isStartingEntity = true;
                        adjustLocation(s, level);
                        switches.Add(col.B, s);
                        level.addEntity(s.randId, s);
                    }
                    else if (col.R == spikeSwitchReserveRed)
                    {
                        float time = -1;
                        if (col.G < 255)
                        {
                            time = col.G / 10;
                        }
                        Entity s = new SpikeSwitchEntity(level, rand.Next(Int32.MinValue, Int32.MaxValue), levelX * tileWidth, levelY * tileHeight, time);

                        s.isStartingEntity = true;
                        adjustLocation(s, level);
                        switches.Add(col.B, s);
                        level.addEntity(s.randId, s);
                    }
                    else if (col.R == shooterRedUp || col.R == shooterRedRight || col.R == shooterRedDown || col.R == shooterRedLeft)
                    {
                        float betweenBursts = ( float )col.B / ( float )10;
                        int   switchId      = col.G;

                        TimedShooterEntity shooter = new TimedShooterEntity(level, rand.Next(Int32.MinValue, Int32.MaxValue), levelX * tileWidth, levelY * tileHeight, betweenBursts, 1, col.R - 110, switchId);
                        if (switchId == 0)
                        {
                            shooter.removeComponent(GlobalVars.SWITCH_LISTENER_COMPONENT_NAME);
                        }
                        else
                        {
                            SwitchListenerComponent slComp = ( SwitchListenerComponent )shooter.getComponent(GlobalVars.SWITCH_LISTENER_COMPONENT_NAME);
                            if (switches.ContainsKey(switchId))
                            {
                                slComp.switchId = switches[switchId].randId;
                            }
                            else
                            {
                                unmachedSwitchListeners.Add(slComp, switchId);
                            }
                        }
                        adjustLocation(shooter, level);
                        shooter.isStartingEntity = true;
                        level.addEntity(shooter);
                    }
                    else if (col.R == smushRed && (col.B - 4 <= 0))
                    {
                        int switchId           = col.G;
                        SmushBlockEntity smush = new SmushBlockEntity(level, rand.Next(Int32.MinValue, Int32.MaxValue), levelX * tileWidth, levelY * tileHeight, col.B, switchId);

                        if (switchId == 0)
                        {
                            smush.removeComponent(GlobalVars.SWITCH_LISTENER_COMPONENT_NAME);
                        }
                        else
                        {
                            SwitchListenerComponent slComp = ( SwitchListenerComponent )smush.getComponent(GlobalVars.SWITCH_LISTENER_COMPONENT_NAME);
                            if (switches.ContainsKey(switchId))
                            {
                                slComp.switchId = switches[switchId].randId;
                            }
                            else
                            {
                                unmachedSwitchListeners.Add(slComp, switchId);
                            }
                        }

                        adjustLocation(smush, level);
                        smush.isStartingEntity = true;
                        level.addEntity(smush);
                    }
                    else if (col.G == tallDoorReserveGreen || col.G == wideDoorReserveGreen || col.G == openTallDoorReserveGreen || col.G == openWideDoorReserveGreen)
                    {
                        float width  = tallDoorWidth;
                        float height = tallDoorHeight;

                        if (col.G == wideDoorReserveGreen || col.G == openWideDoorReserveGreen)
                        {
                            width  = wideDoorWidth;
                            height = wideDoorHeight;
                        }

                        DoorEntity door = new DoorEntity(level, rand.Next(Int32.MinValue, Int32.MaxValue), levelX * tileWidth, levelY * tileHeight, width, height, (col.G % 100 == 0 || col.G % 100 == 1));
                        adjustLocation(door, level);
                        SwitchListenerComponent slComp = ( SwitchListenerComponent )door.getComponent(GlobalVars.SWITCH_LISTENER_COMPONENT_NAME);
                        door.isStartingEntity = true;
                        //check for its switch
                        if (switches.ContainsKey(col.B))
                        {
                            slComp.switchId = switches[col.B].randId;
                        }
                        else
                        {
                            unmachedSwitchListeners.Add(slComp, col.B);
                        }
                        level.addEntity(door);
                    }
                    else if (col.R == spikeRed && col.G == spikeGreen && (col.B - 4 <= 0))
                    {
                        SpikeEntity spike = new SpikeEntity(level, rand.Next(Int32.MinValue, Int32.MaxValue), levelX * tileWidth, levelY * tileHeight, col.B);
                        adjustLocation(spike, level);
                        spike.isStartingEntity = true;
                        level.addEntity(spike);
                    }
                    else if (col.R == signRed && col.G == signGreen)
                    {
                        SignEntity signEnt = new SignEntity(level, rand.Next(Int32.MinValue, Int32.MaxValue), levelX * tileWidth, levelY * tileHeight, col.B);
                        adjustLocation(signEnt, level);
                        signEnt.isStartingEntity = true;
                        level.addEntity(signEnt);
                    }

                    //Now just check for the specific colors
                    else if (col == playerCol)
                    {
                        Player player = new Player(level, rand.Next(Int32.MinValue, Int32.MaxValue), levelX * tileWidth, levelY * tileHeight);
                        adjustLocation(player, level);
                        PositionComponent posComp = ( PositionComponent )player.getComponent(GlobalVars.POSITION_COMPONENT_NAME);
                        level.getMovementSystem().teleportToNoCollisionCheck(posComp, posComp.x, posComp.y - GlobalVars.MIN_TILE_SIZE / 2);
                        posComp.setCurrentLocToStartingLoc();
                        player.isStartingEntity = true;
                        level.addEntity(player.randId, player);
                    }
                    else if (col == movePlatformTurn)
                    {
                        PlatformTurnEntity platTurn = new PlatformTurnEntity(level, rand.Next(Int32.MinValue, Int32.MaxValue), levelX * tileWidth, levelY * tileHeight);
                        adjustLocation(platTurn, level);
                        platTurn.isStartingEntity = true;
                        level.addEntity(platTurn.randId, platTurn);
                    }
                    else if (col == basicGroundCol)
                    {
                        float groundX     = (levelX) * tileWidth;
                        float groundWidth = tileWidth;

                        BasicGround ground = new BasicGround(level, rand.Next(Int32.MinValue, Int32.MaxValue), groundX, (levelY) * tileHeight, groundWidth, tileHeight);
                        adjustLocation(ground, level);
                        ground.isStartingEntity = true;
                        level.addEntity(ground.randId, ground);

                        if (!GlobalVars.fullForegroundImage)
                        {
                            //If no ground above it, change to a grass sprite
                            List <Entity> above = level.getCollisionSystem().findObjectAtPoint((levelX) * tileWidth, (levelY - 1) * tileWidth);
                            if (above.Count <= 0 || !(above[0] is BasicGround))
                            {
                                ground.changeSprite(false);
                            }
                        }
                    }
                    else if (col == testEntityColor)
                    {
                        float      xLoc = (levelX) * tileWidth;
                        float      yLoc = (levelY) * tileHeight;
                        int        id   = rand.Next(Int32.MinValue, Int32.MaxValue);
                        TestEntity test = new TestEntity(level, id, xLoc, yLoc);
                        adjustLocation(test, level);
                        test.isStartingEntity = true;
                        level.addEntity(test.randId, test);
                    }
                    else if (col == simpleEnemyColor)
                    {
                        float             xLoc  = (levelX) * tileWidth;
                        float             yLoc  = (levelY) * tileHeight;
                        int               id    = rand.Next(Int32.MinValue, Int32.MaxValue);
                        SimpleEnemyEntity enemy = new SimpleEnemyEntity(level, id, xLoc, yLoc, false);
                        adjustLocation(enemy, level);
                        enemy.isStartingEntity = true;
                        level.addEntity(enemy.randId, enemy);
                    }
                    else if (col == flyingEnemyColor)
                    {
                        float             xLoc  = (levelX) * tileWidth;
                        float             yLoc  = (levelY) * tileHeight;
                        int               id    = rand.Next(Int32.MinValue, Int32.MaxValue);
                        FlyingEnemyEntity enemy = new FlyingEnemyEntity(level, id, xLoc, yLoc, false);
                        adjustLocation(enemy, level);
                        enemy.isStartingEntity = true;
                        level.addEntity(enemy.randId, enemy);
                    }
                    else if (col == shieldWalkingEnemyColor)
                    {
                        float             xLoc  = (levelX) * tileWidth;
                        float             yLoc  = (levelY) * tileHeight;
                        int               id    = rand.Next(Int32.MinValue, Int32.MaxValue);
                        SimpleEnemyEntity enemy = new SimpleEnemyEntity(level, id, xLoc, yLoc, true);
                        adjustLocation(enemy, level);
                        enemy.isStartingEntity = true;
                        level.addEntity(enemy.randId, enemy);
                    }
                    else if (col == shieldFlyingEnemyColor)
                    {
                        float             xLoc  = (levelX) * tileWidth;
                        float             yLoc  = (levelY) * tileHeight;
                        int               id    = rand.Next(Int32.MinValue, Int32.MaxValue);
                        FlyingEnemyEntity enemy = new FlyingEnemyEntity(level, id, xLoc, yLoc, true);
                        adjustLocation(enemy, level);
                        enemy.isStartingEntity = true;
                        level.addEntity(enemy.randId, enemy);
                    }
                    else if (col == checkPointCollider)
                    {
                        CheckPointEntity checkEnt = new CheckPointEntity(level, rand.Next(Int32.MinValue, Int32.MaxValue), levelX * tileWidth, levelY * tileHeight);
                        adjustLocation(checkEnt, level);
                        checkEnt.isStartingEntity = true;
                        level.addEntity(checkEnt.randId, checkEnt);
                    }/*else if ( col == checkPointCollider ) {
                      *
                      * float xLoc = ( levelX ) * tileWidth;
                      * float yLoc = ( levelY ) * tileHeight;
                      * int id = rand.Next( Int32.MinValue, Int32.MaxValue );
                      * EndLevelEntity lvlEnd = new EndLevelEntity( level, id, xLoc, yLoc );
                      * adjustLocation( lvlEnd, level );
                      * lvlEnd.isStartingEntity = true;
                      * level.addEntity( lvlEnd.randId, lvlEnd );
                      *
                      * }*/
                    else if (col == vertMovPlatCol)
                    {
                        float xLoc = (levelX) * tileWidth;
                        float yLoc = (levelY) * tileHeight;
                        int   id   = rand.Next(Int32.MinValue, Int32.MaxValue);

                        MovingPlatformEntity plat = new MovingPlatformEntity(level, id, xLoc, yLoc);
                        adjustLocation(plat, level);

                        plat.isStartingEntity = true;
                        level.addEntity(plat);
                    } /*else if ( col == horizMovPlatCol ) {
                       *
                       * float xLoc = ( levelX ) * tileWidth;
                       * float yLoc = ( levelY ) * tileHeight;
                       * int id = rand.Next( Int32.MinValue, Int32.MaxValue );
                       *
                       * MovingPlatformEntity plat = new MovingPlatformEntity( level, id, xLoc, yLoc );
                       * adjustLocation( plat, level );
                       *
                       * plat.isStartingEntity = true;
                       * MovingPlatformComponent movPlatComp = ( MovingPlatformComponent )plat.getComponent( GlobalVars.MOVING_PLATFORM_COMPONENT_NAME );
                       * movPlatComp.vertical = false;
                       * VelocityComponent velComp = ( VelocityComponent )plat.getComponent( GlobalVars.VELOCITY_COMPONENT_NAME );
                       * velComp.y = 0;
                       * level.addEntity( plat );
                       *
                       * }*/
                    else if (col == bouncePickup)
                    {
                        float xLoc = (levelX) * tileWidth;
                        float yLoc = (levelY) * tileHeight;
                        int   id   = rand.Next(Int32.MinValue, Int32.MaxValue);

                        PowerupPickupEntity pickup = new PowerupPickupEntity(level, id, xLoc, yLoc, GlobalVars.BOUNCE_NUM);
                        adjustLocation(pickup, level);

                        pickup.isStartingEntity = true;
                        level.addEntity(pickup);
                    }
                    else if (col == speedyPickup)
                    {
                        float xLoc = (levelX) * tileWidth;
                        float yLoc = (levelY) * tileHeight;
                        int   id   = rand.Next(Int32.MinValue, Int32.MaxValue);

                        PowerupPickupEntity pickup = new PowerupPickupEntity(level, id, xLoc, yLoc, GlobalVars.SPEED_NUM);
                        adjustLocation(pickup, level);

                        pickup.isStartingEntity = true;
                        level.addEntity(pickup);
                    }
                    else if (col == jmpPickup)
                    {
                        float xLoc = (levelX) * tileWidth;
                        float yLoc = (levelY) * tileHeight;
                        int   id   = rand.Next(Int32.MinValue, Int32.MaxValue);

                        PowerupPickupEntity pickup = new PowerupPickupEntity(level, id, xLoc, yLoc, GlobalVars.JMP_NUM);
                        adjustLocation(pickup, level);

                        pickup.isStartingEntity = true;
                        level.addEntity(pickup);
                    }
                    else if (col == glidePickup)
                    {
                        float xLoc = (levelX) * tileWidth;
                        float yLoc = (levelY) * tileHeight;
                        int   id   = rand.Next(Int32.MinValue, Int32.MaxValue);

                        PowerupPickupEntity pickup = new PowerupPickupEntity(level, id, xLoc, yLoc, GlobalVars.GLIDE_NUM);
                        adjustLocation(pickup, level);

                        pickup.isStartingEntity = true;
                        level.addEntity(pickup);
                    }
                    else if (col == spawnPickup)
                    {
                        float xLoc = (levelX) * tileWidth;
                        float yLoc = (levelY) * tileHeight;
                        int   id   = rand.Next(Int32.MinValue, Int32.MaxValue);

                        PowerupPickupEntity pickup = new PowerupPickupEntity(level, id, xLoc, yLoc, GlobalVars.SPAWN_NUM);
                        adjustLocation(pickup, level);

                        pickup.isStartingEntity = true;
                        level.addEntity(pickup);
                    }
                    else if (col == grapPickup)
                    {
                        float xLoc = (levelX) * tileWidth;
                        float yLoc = (levelY) * tileHeight;
                        int   id   = rand.Next(Int32.MinValue, Int32.MaxValue);

                        PowerupPickupEntity pickup = new PowerupPickupEntity(level, id, xLoc, yLoc, GlobalVars.GRAP_NUM);
                        adjustLocation(pickup, level);

                        pickup.isStartingEntity = true;
                        level.addEntity(pickup);
                    }
                    else if (col == visionOrbUnlock)
                    {
                        float xLoc = (levelX) * tileWidth;
                        float yLoc = (levelY) * tileHeight;
                        int   id   = rand.Next(Int32.MinValue, Int32.MaxValue);

                        VisionOrbUnlock visUnlock = new VisionOrbUnlock(level, id, xLoc, yLoc);
                        adjustLocation(visUnlock, level);

                        visUnlock.isStartingEntity = true;
                        level.addEntity(visUnlock);
                    }
                }
            }

            //Match any unmatched switch listeners to their switch
            foreach (SwitchListenerComponent sc in unmachedSwitchListeners.Keys)
            {
                if (switches.ContainsKey(unmachedSwitchListeners[sc]))
                {
                    SwitchListenerComponent slComp = sc;
                    slComp.switchId = switches[unmachedSwitchListeners[sc]].randId;
                }
                else
                {
                    Console.WriteLine("Unmatched Switch Listener - B: " + unmachedSwitchListeners[sc]);
                }
            }
        }
        public void updateDoorPanel(DoorEntity hbObjEntity)
        {
            var apt    = hbObjEntity.HBObject;
            var layout = new DynamicLayout {
            };

            layout.Spacing        = new Size(5, 5);
            layout.Padding        = new Padding(10);
            layout.DefaultSpacing = new Size(2, 2);


            layout.AddSeparateRow(new Label {
                Text = $"ID: {apt.Name}"
            });

            layout.AddSeparateRow(new Label {
                Text = "Name:"
            });
            var nameTBox = new TextBox()
            {
            };

            apt.DisplayName = apt.DisplayName ?? string.Empty;
            nameTBox.TextBinding.Bind(apt, m => m.DisplayName);
            layout.AddSeparateRow(nameTBox);


            layout.AddSeparateRow(new Label {
                Text = "Glass:"
            });
            var operableCBox = new CheckBox();

            operableCBox.CheckedBinding.Bind(apt, v => v.IsGlass);
            layout.AddSeparateRow(operableCBox);


            layout.AddSeparateRow(new Label {
                Text = "Boundary Condition: (WIP)"
            });
            var bcTBox = new TextBox()
            {
            };

            bcTBox.Enabled = false;
            bcTBox.TextBinding.Bind(apt, m => m.BoundaryCondition.Obj.GetType().Name);
            layout.AddSeparateRow(bcTBox);


            layout.AddSeparateRow(new Label {
                Text = "Properties:"
            });
            var faceRadPropBtn = new Button {
                Text = "Radiance Properties (WIP)"
            };

            faceRadPropBtn.Click += (s, e) => Dialogs.ShowMessage("Work in progress", "Honeybee");
            layout.AddSeparateRow(faceRadPropBtn);
            var faceEngPropBtn = new Button {
                Text = "Energy Properties"
            };

            faceEngPropBtn.Click += (s, e) => PropBtn_Click(hbObjEntity);
            layout.AddSeparateRow(faceEngPropBtn);



            layout.AddSeparateRow(new Label {
                Text = "IndoorShades:"
            });
            var inShadesListBox = new ListBox();

            inShadesListBox.Height = 50;
            var inShds = apt.IndoorShades;

            if (inShds != null)
            {
                var idShds = inShds.Select(_ => new ListItem()
                {
                    Text = _.DisplayName ?? _.Name, Tag = _
                });
                inShadesListBox.Items.AddRange(idShds);
            }
            layout.AddSeparateRow(inShadesListBox);

            layout.AddSeparateRow(new Label {
                Text = "OutdoorShades:"
            });
            var outShadesListBox = new ListBox();

            outShadesListBox.Height = 50;
            var outShds = apt.OutdoorShades;

            if (outShds != null)
            {
                var outShdItems = outShds.Select(_ => new ListItem()
                {
                    Text = _.DisplayName ?? _.Name, Tag = _
                });
                outShadesListBox.Items.AddRange(outShdItems);
            }
            layout.AddSeparateRow(outShadesListBox);


            layout.Add(null);
            var data_button = new Button {
                Text = "Honeybee Data"
            };

            data_button.Click += (sender, e) => Dialogs.ShowEditBox("Honeybee Data", "Honeybee Data can be shared across all platforms.", apt.ToJson(), true, out string outJson);
            layout.AddSeparateRow(data_button, null);


            this.Content = layout;
            //layout.up

            void PropBtn_Click(Entities.DoorEntity ent)
            {
                var energyProp = ent.HBObject.Properties.Energy ?? new DoorEnergyPropertiesAbridged();

                energyProp = DoorEnergyPropertiesAbridged.FromJson(energyProp.ToJson());
                var dialog = new UI.Dialog_DoorEnergyProperty(energyProp);

                dialog.RestorePosition();
                var dialog_rc = dialog.ShowModal(RhinoEtoApp.MainWindow);

                dialog.SavePosition();
                if (dialog_rc != null)
                {
                    //replace brep in order to add an undo history
                    var undo = Rhino.RhinoDoc.ActiveDoc.BeginUndoRecord("Set Honeybee door energy properties");

                    var dup = ent.HostObjRef.Brep().DuplicateBrep();
                    dup.TryGetDoorEntity().HBObject.Properties.Energy = dialog_rc;
                    Rhino.RhinoDoc.ActiveDoc.Objects.Replace(ent.HostObjRef.ObjectId, dup);

                    Rhino.RhinoDoc.ActiveDoc.EndUndoRecord(undo);
                }
            }
        }
Exemplo n.º 6
0
 public static DoorEntity ToEntity(this DoorDto model, DoorEntity destination)
 {
     return(model.MapTo(destination));
 }
Exemplo n.º 7
0
 public static DoorDto ToModel(this DoorEntity entity)
 {
     return(entity.MapTo <DoorEntity, DoorDto>());
 }
Exemplo n.º 8
0
        protected bool RunCubeBlockReflectionTests()
        {
            bool result = true;

            if (!LightEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("LightEntity reflection validation failed!");
            }

            if (!BatteryBlockEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("BatteryBlockEntity reflection validation failed!");
            }

            if (!DoorEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("DoorEntity reflection validation failed!");
            }

            if (!GravityBaseEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("GravityBaseEntity reflection validation failed!");
            }

            if (!GravityGeneratorEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("GravityGeneratorEntity reflection validation failed!");
            }

            if (!GravitySphereEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("GravitySphereEntity reflection validation failed!");
            }

            if (!BeaconEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("BeaconEntity reflection validation failed!");
            }

            if (!AntennaEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("AntennaEntity reflection validation failed!");
            }

            if (!ThrustEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("ThrustEntity reflection validation failed!");
            }

            if (!ThrustNetworkManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("ThrustNetworkManager reflection validation failed!");
            }

            if (!GyroEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("GyroEntity reflection validation failed!");
            }

            if (!GyroNetworkManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("GyroNetworkManager reflection validation failed!");
            }

            if (result)
            {
                Console.WriteLine("All block types passed reflection unit tests!");
            }

            return(result);
        }