public void MoveElevator(IMotor motor, ICabin cabin, IFloor floor) { DoorState tempstate = cabin.GetDoorState(); if (tempstate == DoorState.open) { _timerSensor.Stop(); cabin.UpdateDoorState(DoorState.close); floor.UpdateDoorState(DoorState.close); } if (_requestManager.HasAnyRequest()) { _elevatorDirection = _directionManager.EnsureDirection(_currentLevel, _elevatorDirection, _requestManager); _motionSensor.MoveCabin(motor, cabin, _elevatorDirection); _currentLevel = floor.GetLevel(cabin, _elevatorDirection, _currentLevel); cabin.ShowLevel(_currentLevel); floor.ShowLevel(_currentLevel); if (_requestManager.FloorHaveRequest(_currentLevel, _elevatorDirection)) { cabin.changeColorCabinButton(_currentLevel.ToString()); cabin.UpdateDoorState(DoorState.open); _levelSensor.NotifyArrival(_txtElevator, _currentLevel); } } }
public void CreateBoard(int _currentFloor) { if (boardHolder == null) { boardHolder = new GameObject("GameFloor"); } if (_currentFloor <= 0) // Floor must be > 0 { return; } IFloor temp = CTDungeon.Instance.GetFloorData(_currentFloor, isBossLevel); if (!temp.Generated) { temp.Name = "Floor_" + currFloor; temp.InitNewLevel(currFloor, columns, rows, rooms, gridSize, roomWidth, roomHeight, corridorLength); } Debug.Log("CurrLevel is " + _currentFloor + " act " + CTDungeon.Instance.currentFloor); InstantiateTiles(temp.Tiles); InstantiateStairs(temp.StairsForward, temp.StairsBack); InstantiateCPExit(temp.Checkpoint, temp.ExitPortal); Debug.Log("Board Created"); }
public string UpdatePlayerMovmentType(Player player) { ICollider playerCollider = new Physic.Point(player.Position); IFloor standFloor = null; foreach (var collisionPath in MapPath) { //Tak jak się umówiłem sam ze sobą Pierw powinno być bezwładność,odwrócone ślizganie,ślizganie,chodzenie normalne if (collisionPath.FloorPolygon.IsCollide(playerCollider)) { if (typeof(NormalControll) == collisionPath.GetType() || (standFloor == null)) { standFloor = collisionPath; } } } if (standFloor == null) { return("jebanycheater"); } else { player.SetControllType(standFloor.ControllType); return(standFloor.GetType().ToString()); ; } }
protected override void TouchedFloor(IFloor floor) { onGround = true; slopeSlow = floor.GetSlopeSlow(); slopeSign = floor.GetSlopeSign(); base.TouchedFloor(floor); }
public bool BuildElevator(int startingX, int floorNumber, IFloor floor) { var elevatorCount = floor.Transportations.Count; floor.AddElevator(startingX, floorNumber); return(elevatorCount + 1 == floor.Transportations.Count); }
public Elevator(TextBox txtElevator) { _txtElevator = txtElevator; _cabin = new Cabin(txtElevator, 0); _floor = new Floor(txtElevator); _director = new Director(txtElevator); _motor = new Motor(txtElevator); }
public void Update(IBaseModel model) { IFloor floor = (IFloor)model; this.Id = floor.Id; this.FloorName = floor.FloorName; this.HallId = floor.HallId; }
public async Task Add(IFloor floor) { await this.floorService.addFloorAsync(new addFloorRequest { flrName = floor.FloorName, halId = floor.HallId, halIdSpecified = true, }); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); ContentContainer.LoadContent(Content); objectInspector = new ObjectInspector(this); gameEffect = Content.Load <Effect>("Effect\\effect"); tex = Content.Load <Texture2D>("character"); font = Content.Load <SpriteFont>("File"); Map = new Map(Content, GraphicsDevice); SetUpVertices(); player = new Player(Vector2.Zero); Engine.GameUtility.Physic.Point circle = new Engine.GameUtility.Physic.Point(new Vector2(positionOnPlane.X, positionOnPlane.Z)); player.CollisionObject = circle; player.CollisionObject.OnCollision += new CollideDetected(delegate(ICollider item) { if (item.GetType() == typeof(Polygon)) { MessageBox.Show("Collide", "Circle<>Linse", new string[] { "walsiw" }); } }); player.CollisionObject.OnCollision += new CollideDetected(EventMethod); Director.InstanceDirector.Camera.SetDevice(this.GraphicsDevice); model = Content.Load <Model>("robot"); BiStableKey tempKey = new BiStableKey(Keys.Space); tempKey.action += new ClickTrigger(delegate { IMapElement el = Map.GetMapElementByName <IMapElement>(objectInspector.selectedID); if (el != null) { Map.GetMapElementByName <IMapElement>(objectInspector.selectedID).Position = new Vector2(positionOnPlane.X, positionOnPlane.Z); } else { IFloor floor = Map.GetMapElementByName <IFloor>(objectInspector.selectedID); floor.FloorPolygon .AddPoint(new VertexPositionColor(positionOnPlane + new Vector3(0, 1, 0), Color.BlueViolet)); } }); keys.Add(tempKey); // MapWriter.Write(jsonSerialize); }
private static void GoToFloorWithRandomElevator(IList <IElevator> elevators, IFloor floor) { var random = new Random(); var randomElevatorIndex = random.Next(elevators.Count); var elevator = elevators[randomElevatorIndex]; if (elevator != null && !elevator.DestinationQueue.Contains(floor.FloorNum)) { elevator.GoToFloor(floor.FloorNum); } }
private void InitFloors(int minFloorId, int maxFloorId) { FloorFactory fact = new FloorFactory(); for (int i = minFloorId; i <= maxFloorId; i++) { IFloor flr = fact.GetFloor(); flr.FloorId = i; Floors.Add(flr); } }
public static bool IsFloorRangePreexisting(Range range, IFloor floor) { if (range.StartX >= floor.Range.StartX) { if (range.EndX >= floor.Range.EndX) { return(false); } } return(true); }
protected virtual void MoveY() { this.position.Y += this.velocity.Y; IFloor floorHit = null; foreach (Block b in room.blocks) { if (b.IntersectsWith(this)) { if (!b.topSolidOnly) { // If it is a regular block. if (this.velocity.Y > 0) { this.Bottom = (int)b.Top; floorHit = b; } else { this.velocity.Y = 0; this.Top = (int)b.Bottom; } } else { // If it is a block that is only solid on the top. if (this.velocity.Y > 0 && this.Top - this.velocity.Y > b.Top) { this.Bottom = (int)b.Top; floorHit = b; } } } } // This foreach (Floor floor in room.floors) { float?line = floor.FindYLineAboveFloor(this); if (line != null && this.Bottom > (float)line && this.Top <= (float)line) { this.Bottom = (int)(float)line; floorHit = floor; } } if (floorHit != null) { TouchedFloor(floorHit); } }
public IFloor GetParentFloor(IFloor floor) { if (this.Floors.IndexOf(floor) == 0) { return(null); } if (this.Floors.Count < (this.Floors.IndexOf(floor) - 1)) { return(null); } return(this.Floors[(this.Floors.IndexOf(floor) - 1)]); }
private void ChangeFloor(IFloor floor) { if (Floor != null) { DeleteConnections(Floor); } Floor = floor; if (Floor != null) { SetupConnections(Floor); } UpdateView(); }
public async Task <IFloor> Merge(IFloor floor) { var result = await this.floorService.mergeFloorAsync(new mergeFloorRequest { flrId = floor.Id, flrIdSpecified = true, flrName = floor.FloorName, halId = floor.HallId, halIdSpecified = true, }); return(this.ToFloor(result.@return)); }
static void Build(IHouseFactory factory) { IFloor floor = factory.CreateFloor(); IWall wall = factory.CreateWall(); IDoor door = factory.CreateDoor(); IWindow window = factory.CreateWindow(); ICeiling ceiling = factory.CreateCeiling(); floor.Display(); wall.Display(); door.Display(); window.Display(); ceiling.Display(); }
private IPerson GeneratePerson(IFloor floor) { var otherFloors = _building.GetFloorsExcept(floor); var otherFloorList = otherFloors.ToList(); if (!otherFloorList.Any()) { throw new InvalidOperationException(nameof(otherFloors)); } var targetFloor = otherFloorList.GetRandomElement(); return(new Person(floor.FloorNumber, targetFloor.FloorNumber)); }
private IElevator GetOptimalElevator1(IFloor floor, List <IElevator> elevators) { Dictionary <int, int> distances = new Dictionary <int, int>(); //know the distance of each elevator (not in hold) from the current floor foreach (IElevator elevator in elevators.FindAll(e => e.CurrentDirection != Direction.Hold)) { distances.Add(Math.Abs(floor.FloorId - elevator.CurrentFloorId), elevator.ElevatorId); } //find the nearest elevator int optimalElevatorId = distances[distances.Min(x => x.Key)]; return(elevators.Find(x => x.ElevatorId == optimalElevatorId)); }
public void PlayerSendsElevatorToFloorWhereFloorButtonIsPressed() { // Arrange var elevator = new MockElevator(); var elevators = new IElevator[] { elevator }; var floors = new IFloor[] { new MockFloor(1), new MockFloor(2) }; yourPlayer.Init(elevators, floors); // Act (floors[1] as MockFloor)?.TestInvokeDownButtonPressedEvent(elevators); // Assert Assert.True(elevator.CalledMethods.Contains("GoToFloor(2)")); }
private IElevator GetOptimalElevator(IFloor floor, List <IElevator> elevators) { Dictionary <int, int> distances = new Dictionary <int, int>(); //know the distance of each elevator (not in hold) from the current floor foreach (IElevator elevator in elevators.FindAll(e => e.CurrentDirection != Direction.Hold)) { distances.Add(elevator.ElevatorId, Math.Abs(floor.FloorId - elevator.CurrentFloorId)); } //find the nearest elevator int optimalElevatorId = distances.OrderBy(k => k.Value).ThenBy(k => k.Key).FirstOrDefault().Key; return(elevators.Find(x => x.ElevatorId == optimalElevatorId)); }
static int PressButtonFromAFloor(IBuilding building, int floorId, Direction direction) { IFloor floor = building.GetFloors().Find(X => X.FloorId == floorId); int result = 0; if (direction == Direction.UP) { result = floor.UpButton.Press(floor, building.GetElevators()); } else { result = floor.DownButton.Press(floor, building.GetElevators()); } return(result); }
protected void Page_Load(object sender, EventArgs e) { try { iFloor = ServiceAgent.getInstance().GetObjectByName<IFloor>(WebConstant.CommonObject); if (!this.IsPostBack) { if (isPercentage) { if (Convert.ToInt32(width) > 100) { this.drpFloor.Width = Unit.Percentage(100); } else { drpFloor.Width = Unit.Percentage(Convert.ToDouble(width)); } } else { drpFloor.Width = Unit.Parse(width); } this.drpFloor.CssClass = cssClass; this.drpFloor.Enabled = enabled; if (enabled) { initFloor(); } else { this.drpFloor.Items.Add(new ListItem("", "")); } } } catch (FisException ex) { showCmbErrorMessage(ex.mErrmsg); } catch (Exception ex) { showCmbErrorMessage(ex.Message); } }
public void Visit(IFloor floor) { if (floor.Panel == null) { return; } if (floor.Panel.Up.State == ButtonState.Engaged) { EngagedUpButtons.Add(floor.Identifier); } if (floor.Panel.Down.State == ButtonState.Engaged) { EngagedDownButtons.Add(floor.Identifier); } }
public string Press(IFloor floor, List <IElevator> elevators) { try { //gets the optimal elevator IElevator optimalElevator = GetOptimalElevator(floor, elevators); //move the elevator to the required floor optimalElevator.MoveTo(floor.FloorId, ButtonDirection); return(optimalElevator.ElevatorName); } catch (Exception ex) { Logger.Log(string.Format("Message: {0}; StackTrace: {1}", ex.Message, ex.StackTrace), LogType.Error); } return(string.Empty); }
public bool TryEnterOnFloorToWaitElevator(IPerson person, IFloor floor) { if (floor.IsFull) { return(false); } if (person.State != PersonState.Unknown) { return(false); } if (floor.TryAttachToFloor(person)) { person.SetState(PersonState.WaitElevator); person.SetFloor(floor.FloorNumber); PersonObservable.OnNext(new PersonAction(person, floor, PersonActionType.WaitingForElevator)); return(true); } return(false); }
private string GetButtonLabel(IFloor floor) { if (Direction == ElevatorDirection.Up) return "^"; if (Direction == ElevatorDirection.Down) return "v"; return floor.FloorNumber.ToString(); }
public ValuesController(IFloor floor) { _floor = floor; }
protected virtual void DeleteConnections(IFloor floor) { }
protected virtual void SetupConnections(IFloor floor) { }
private bool LoadBooks(IPacket packet) { if (!ValidateHeader(packet, PacketSignatureBooks)) { return(false); } var mdct = _factory.CreateMdct(); var huffman = _factory.CreateHuffman(); // read the books var books = new ICodebook[packet.ReadBits(8) + 1]; for (var i = 0; i < books.Length; i++) { books[i] = _factory.CreateCodebook(); books[i].Init(packet, huffman); } // Vorbis never used this feature, so we just skip the appropriate number of bits var times = (int)packet.ReadBits(6) + 1; packet.SkipBits(16 * times); // read the floors var floors = new IFloor[packet.ReadBits(6) + 1]; for (var i = 0; i < floors.Length; i++) { floors[i] = _factory.CreateFloor(packet); floors[i].Init(packet, _channels, _block0Size, _block1Size, books); } // read the residues var residues = new IResidue[packet.ReadBits(6) + 1]; for (var i = 0; i < residues.Length; i++) { residues[i] = _factory.CreateResidue(packet); residues[i].Init(packet, _channels, books); } // read the mappings var mappings = new IMapping[packet.ReadBits(6) + 1]; for (var i = 0; i < mappings.Length; i++) { mappings[i] = _factory.CreateMapping(packet); mappings[i].Init(packet, _channels, floors, residues, mdct); } // read the modes _modes = new IMode[packet.ReadBits(6) + 1]; for (var i = 0; i < _modes.Length; i++) { _modes[i] = _factory.CreateMode(); _modes[i].Init(packet, _channels, _block0Size, _block1Size, mappings); } // verify the closing bit if (!packet.ReadBit()) { throw new InvalidDataException("Book packet did not end on correct bit!"); } // save off the number of bits to read to determine packet mode _modeFieldBits = Utils.ilog(_modes.Length - 1); _stats.AddPacket(-1, packet.BitsRead, packet.BitsRemaining, packet.ContainerOverheadBits); return(true); }
public void SetFloor(IFloor floor) { this.floor = floor; }
protected virtual void TouchedFloor(IFloor floor) { this.velocity.Y = 0; }