Ejemplo n.º 1
0
            public Facility(string[] floors)
            {
                Elevator = new Elevator(this, 2);

                // Assume that the floors are in order, low to high
                foreach (var floorStr in floors)
                {
                    if (floorStr.EndsWith("nothing relevant."))
                    {
                        Floors.Add(new Floor(this, Floors.Count));
                        continue;
                    }
                    string pattern = @"an? (.+?)( generator|-compatible microchip)";
                    var    matches = Regex.Matches(floorStr, pattern);
                    if (matches.Count == 0)
                    {
                        throw new ArgumentException("cant parse floor");
                    }
                    Floor floor = new Floor(this, Floors.Count);
                    foreach (var match in matches.Cast <Match>())
                    {
                        Element ele = Element.FromName(match.Groups[1].Value);
                        Elements.Add(ele);
                        ItemType iType = match.Groups[2].Value == " generator" ? ItemType.GENERATOR : ItemType.MICROCHIP;
                        floor.Items[iType].Add(ele);
                    }
                    Floors.Add(floor);
                }

                MaxSymbolLength = Elements.Max(ele => ele.Symbol.Length);
                MaxLevelLength  = Floors.Max(floor => floor.Level.ToString().Length);
            }
        public async Task <ActionResult <Floors> > PostFloor(Floors Floors)
        {
            _context.Floors.Add(Floors);
            await _context.SaveChangesAsync();

            return(Ok(Floors));
        }
Ejemplo n.º 3
0
        public override void Tick()
        {
            var openCount = Floors.Count(r => !r.IsFull);

            if (openCount > 0)
            {
                var gateCapacity = (int)(Simulator.Interval.TotalSeconds / 10.0);
                for (int i = 0; i < gateCapacity; i++)
                {
                    var floorsWithRoom = Floors.Where(r => !r.IsFull).ToList();
                    if (InQueue.Count > 0 && floorsWithRoom.Count > 0)
                    {
                        var floor = Simulator.Random.Next(floorsWithRoom.Count);
                        floorsWithRoom[floor].InQueue.Enqueue(InQueue.Dequeue());
                    }
                }
            }
            foreach (var item in Floors)
            {
                item.Tick();
            }
            base.Tick();
            while (OutQueue.Count > 0)
            {
                Parent.OutQueue.Enqueue(OutQueue.Dequeue());
            }
        }
        private void BuildHandle()
        {
            try
            {
                // Checks
                if (Floors.Count < 2)
                {
                    throw new Exception("The simulation model must have at least 2 floors");
                }
                if (Elevators.Count < 1)
                {
                    throw new Exception("The simulation model must have at least 1 elevator");
                }

                ElevatorSimModel simModel = m_model.BuildModel(Floors.ToList(), Elevators.ToList());
                simModel.Log += AddEventLog;

                m_model.LinkStatistics(Floors.Count, Elevators.Count);

                IsBuilded = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK);
            }
        }
Ejemplo n.º 5
0
        private string FloorHashes()
        {
            var floorHashes = string.Join(", ", Floors.Select(f => string.Join(" ", f.OrderBy(s => s).ToArray())));

//            var floorHashes = string.Join(", ", Floors.Select(f => new string(f.Select(i => i.Last()).OrderBy(c => c).ToArray()))); //Jo's optimization!
            return(floorHashes);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Moves the lift up and down.
        /// </summary>
        /// <param name="currentFloor">The current floor of the lift.</param>
        public void Move(int currentFloor)
        {
            PreviousFloor = CurrentFloor;
            CurrentFloor  = currentFloor;
            int nextFloor;

            DropPassengers(currentFloor);

            if (IsEmpty() && Floors.AreAllDelivered())
            {
                if (currentFloor > 0)
                {
                    currentFloor--;
                    nextFloor = currentFloor;
                    Move(nextFloor);
                }

                AddHistoryRecord(0);
                PrintStatus();
                return;
            }

            PickPassengers(currentFloor);

            nextFloor = NextFloor();

            PrintStatus();

            Move(nextFloor);
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Edit(int id, [Bind("id,name,permalink,ShopsId,isDeleted,deleted_at,deleted_by,created_at,created_by,updated_at,updated_by")] Floors floors)
        {
            if (id != floors.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(floors);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FloorsExists(floors.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(floors));
        }
        public bool CheckSecurityClearence(Floors floor, ClearenceTypes clearence)
        {
            switch (clearence)
            {
            case ClearenceTypes.Confidential:
                if (floor == Floors.G)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

            case ClearenceTypes.Secret:
                if (floor == Floors.G || floor == Floors.S)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

            case ClearenceTypes.TopSecret:
                return(true);

            default:
                return(false);
            }
        }
Ejemplo n.º 9
0
        protected override void OnAfterDelete()
        {
            base.OnAfterDelete();

            Altar  = null;
            Vendor = null;

            BossEarth  = null;
            BossFire   = null;
            BossFrost  = null;
            BossPoison = null;
            BossEnergy = null;

            Bosses.SetAll(i => null);
            Bosses = null;

            TeleportersTo.SetAll(i => null);
            TeleportersTo = null;

            TeleportersFrom.SetAll(i => null);
            TeleportersFrom = null;

            Circles = null;

            Floors.Free(true);
            Floors.SetAll(i => null);
            Floors = null;

            Stage.Free(true);
            Stage = null;
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Creates a house, with empty floors
 /// </summary>
 /// <param name="color">Index of color for house</param>
 /// <param name="floor">floor count</param>
 /// <param name="street">True = Street, False = Avenue</param>
 /// <param name="houseNumber">This House's number on the street</param>
 /// <param name="conRoad">Road parallel to House</param>
 /// <param name="adjRoad">Road adjacent to House</param>
 /// <param name="quad">Relative quadrant of House</param>
 public House(int color, int floor, bool street, int houseNumber, int conRoad, int adjRoad, int quad) : this(color, new List <Floor>(floor), street, houseNumber, conRoad, adjRoad, quad)
 {
     for (int f = 0; f < floor; f++)
     {
         Floors.Add(new Floor());
     }
 }
Ejemplo n.º 11
0
        protected override void OnDelete()
        {
            base.OnDelete();

            if (Altar != null)
            {
                Altar.Delete();
            }

            if (Vendor != null)
            {
                Vendor.Delete();
            }

            foreach (var b in Bosses.Where(b => b != null))
            {
                b.Delete();
            }

            foreach (var t in TeleportersTo.Union(TeleportersFrom).Where(t => t != null))
            {
                t.Delete();
            }

            foreach (var s in Floors.Where(l => l != null).SelectMany(l => l.Where(s => s != null)))
            {
                s.Delete();
            }

            foreach (var s in Stage.Where(s => s != null))
            {
                s.Delete();
            }
        }
Ejemplo n.º 12
0
        public void RemoveFloor(Floor floor)
        {
            if (!Floors.Contains(floor))
            {
                return;
            }

            var index = Floors.IndexOf(floor);

            Floors.Remove(floor);
            floor.Objects.CollectionChanged -= FloorObjectsCollectionChanged;
            floor.RemoveObjects();

            if (index >= Floors.Count - 1)
            {
                CurrentFloor = Floors.LastOrDefault();
            }
            else
            {
                CurrentFloor = Floors[index];
            }

            foreach (var f in Floors)
            {
                f.RefreshTitle();
            }

            evacuationPlan.ComposeRoutes();
        }
Ejemplo n.º 13
0
 internal void Move(Floors dest)
 {
     state_d = DoorState.Close;
     if (dest.Equals(current_floor))
     {
         Console.WriteLine("Elevator is already here.");
         Thread.Sleep(1000);
         state_d = DoorState.Open;
     }
     else
     {
         if (current_floor > dest)
         {
             state_d = DoorState.Close;
             Console.WriteLine("Elevator is going down.");
             Thread.Sleep(1000);
         }
         else
         {
             state_d = DoorState.Close;
             Console.WriteLine("Elevator is going up.");
             Thread.Sleep(1000);
         }
         for (int i = 0; i < Math.Abs(current_floor - dest); i++)
         {
             Console.WriteLine("*");
             Thread.Sleep(1000);
         }
         current_floor = dest;
         Console.WriteLine("Elevator came at " + dest);
         Thread.Sleep(1000);
         state_d = DoorState.Open;
     }
 }
Ejemplo n.º 14
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((ElevatorFloor * 397) ^ (Floors != null ? Floors.Aggregate(13, (s, f) => s * (int)f) : 0));
     }
 }
Ejemplo n.º 15
0
        public void HandleTrap()
        {
            var floors = new Floors()
            {
                { 0, new Floor(1) },
                { 1, new Floor() }
            };

            var game = new Game(floors, 1, 0, 1);

            game.SetGeneralProperties(100, 10);

            var decision = game.TakeDecision(new Clone(0, 3, Direction.Left));

            decision.ShouldBe("WAIT");

            decision = game.TakeDecision(new Clone(0, 2, Direction.Left));
            decision.ShouldBe("WAIT");

            decision = game.TakeDecision(new Clone(0, 1, Direction.Left));
            decision.ShouldBe("WAIT");

            decision = game.TakeDecision(new Clone(0, 0, Direction.Left));
            decision.ShouldBe("ELEVATOR");
        }
        public override IVisualElement Copy()
        {
            VisualRectangularBuilding copy = new VisualRectangularBuilding((IRectangularBuildingEntity)_rectangleSource.Copy());

            copy.CurrentFloor = copy.Floors[Floors.IndexOf(CurrentFloor)];
            return(copy);
        }
Ejemplo n.º 17
0
        public void Set(int index, int x, int y, byte floorSubImage, byte ceilingSubImage, byte wallSubImage, int frame)
        {
            bool isAnimated = Floors.IsAnimated(floorSubImage) || Floors.IsAnimated(ceilingSubImage) || Walls.IsAnimated(wallSubImage);

            if (isAnimated)
            {
                AnimatedTiles.Add(index);
            }
            else
            {
                AnimatedTiles.Remove(index);
            }

            unsafe
            {
                fixed(Tile *tile = &Tiles[index])
                {
                    tile->TilePosition = new Vector2(x, y);
                    tile->Floor        = (byte)Floors.GetSubImageAtTime(floorSubImage, frame);
                    tile->Ceiling      = (byte)Floors.GetSubImageAtTime(ceilingSubImage, frame);
                    tile->Wall         = (byte)Walls.GetSubImageAtTime(wallSubImage, frame);
                    tile->Flags        = 0; // TileFlags.UsePalette;
                    var subImage = Walls.GetSubImageDetails(tile->Wall);

                    tile->WallSize = subImage.TexSize;
                }
            }
        }
Ejemplo n.º 18
0
        public override int GetHashCode()
        {
            int hashCode = 0;

            unchecked {
                hashCode += 1000000007 * Scale1.GetHashCode();
                hashCode += 1000000009 * CameraHeight.GetHashCode();
                hashCode += 1000000021 * CameraAngle.GetHashCode();
                hashCode += 1000000033 * Background.GetHashCode();
                hashCode += 1000000087 * FogDistance.GetHashCode();
                hashCode += 1000000093 * MaxLightStrength.GetHashCode();
                hashCode += 1000000097 * Scale2.GetHashCode();
                hashCode += 1000000103 * ViewDistance.GetHashCode();
                if (Objects != null)
                {
                    hashCode += 1000000123 * Objects.GetHashCode();
                }
                if (Floors != null)
                {
                    hashCode += 1000000181 * Floors.GetHashCode();
                }
                if (ObjectInfos != null)
                {
                    hashCode += 1000000207 * ObjectInfos.GetHashCode();
                }
                if (Walls != null)
                {
                    hashCode += 1000000223 * Walls.GetHashCode();
                }
            }
            return(hashCode);
        }
Ejemplo n.º 19
0
 public void importMaze(bool[,] maze, int[] mazeSize)
 {
     //Debug.Log("importMaze: " + mazeSize[0]+" "+mazeSize[1]);
     floors = new Floors();
     floors.importFloorList(maze, mazeSize);
     Debug.Log(floors.print());
 }
Ejemplo n.º 20
0
 private void LeaveEl()
 {
     Console.WriteLine(Name_Agent + " left the elevator!");
     Thread.Sleep(1000);
     current_floor = elevator_obj.current_floor;
     mutex.ReleaseMutex();
 }
        public async Task <IActionResult> OnPostAsync(int?venueId, int?floorId)
        {
            if (floorId == 0)
            {
                Venues = await _venueService.GetAll();

                Floors = await _floorService.GetAll();

                Floors.Insert(0, new Floor());
                SelectListFloors = new SelectList(Floors.FindAll(floor => floor.VenueId.Equals(venueId) || floor.VenueId == 0), nameof(Floor.FloorId), nameof(Floor.Name));
                NewRoom.VenueId  = (int)venueId;
                VenueId          = (int)venueId;

                ModelState.Clear();
                return(Page());
            }

            NewRoom.VenueId = (int)venueId;
            NewRoom.FloorId = (int)floorId;

            if (!ModelState.IsValid)
            {
                return(RedirectToPage("Index"));
            }

            await _roomService.Create(NewRoom);

            return(RedirectToPage("Index"));
        }
Ejemplo n.º 22
0
 public override void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (Main.CheckControls(leftpanel).Count == 0)
         {
             if (base.edit == 0)//save
             {
                 Floors.floorsInsert(txtFloorName.Text, Convert.ToInt32(cmbFloorNumber.SelectedItem));
                 Main.resetDisable(leftpanel);
                 Floors.floorsSelectAll(grvFloors, FloorIDGV, FloorNameGV, FloorNumberGV);
             }
             else if (edit == 1)//update
             {
                 Floors.floorsUpdate(_FloorID, txtFloorName.Text, Convert.ToInt32(cmbFloorNumber.SelectedItem));
                 Main.resetDisable(leftpanel);
                 Floors.floorsSelectAll(grvFloors, FloorIDGV, FloorNameGV, FloorNumberGV);
             }
         }
         else
         {
             MessageBox.Show("please enter all required fields.", "Users", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         Main.showMessage(ex.Message, "error");
     }
 }
Ejemplo n.º 23
0
 private void FillFromSource()
 {
     foreach (IFloorEntity floor in _buildingSource.Floors)
     {
         Floors.Add((VisualFloor)VisualElementHelper.CreateFromMapEntity(floor));
     }
 }
Ejemplo n.º 24
0
        public virtual IVisualElement Copy()
        {
            VisualPolygonalBuilding copy = new VisualPolygonalBuilding((IBuildingEntity)_buildingSource.Copy());

            copy.CurrentFloor = copy.Floors[Floors.IndexOf(CurrentFloor)];
            return(copy);
        }
Ejemplo n.º 25
0
    // Start is called before the first frame update
    void Start()
    {
        currentFloor = STARTING_FLOOR;
        rb           = GetComponent <Rigidbody2D>();
        direction    = 1;
        speed        = DEFAULT_SPEED;
        stopMove     = false;
        anim         = GetComponent <Animator>();

        catLayer           = LayerMask.NameToLayer("CatLayer");
        floorLayer         = LayerMask.NameToLayer("Default");
        droppablesLayer    = LayerMask.NameToLayer("Droppables");
        brushLayer         = LayerMask.NameToLayer("Brush");
        headLayer          = LayerMask.NameToLayer("Head");
        deadHeadShelfLayer = LayerMask.NameToLayer("DeadHeadShelf");

        Physics2D.IgnoreLayerCollision(catLayer, droppablesLayer, true);
        Physics2D.IgnoreLayerCollision(catLayer, brushLayer, true);
        Physics2D.IgnoreLayerCollision(catLayer, headLayer, true);
        Physics2D.IgnoreLayerCollision(droppablesLayer, brushLayer, true);
        Physics2D.IgnoreLayerCollision(droppablesLayer, headLayer, true);
        Physics2D.IgnoreLayerCollision(floorLayer, brushLayer, true);
        Physics2D.IgnoreLayerCollision(floorLayer, headLayer, false);
        Physics2D.IgnoreLayerCollision(deadHeadShelfLayer, headLayer, false);

        timeToNextJump = Random.Range(1, 10);
        //sounds
        say_meow   = GetComponent <AudioClip>();
        say_murmur = GetComponent <AudioClip>();
    }
Ejemplo n.º 26
0
        private void checkStoreysFacade()
        {
            // проверка этажей в фасаде.
            // не должно быть одинаковых номеров этажей
            var storeysFacade     = Floors.Select(f => f.Storey);
            var storeyNumbersType = storeysFacade.Where(s => s.Type == EnumStorey.Number).ToList();
            var dublicateNumbers  = storeyNumbersType.GroupBy(s => s.Number).Where(g => g.Count() > 1).Select(g => g.Key).ToList();

            if (dublicateNumbers.Count > 0)
            {
                string nums = string.Join(",", dublicateNumbers);
                Inspector.AddError($"Повторяющиеся номера этажей в фасаде. Координата фасада X = {XMin}. " +
                                   $"Повторяющиеся номера этажей определенные по блокам монтажных планов этого фасада {nums}",
                                   icon: System.Drawing.SystemIcons.Error);
            }
            // Ч и П могут быть только по одной штуке
            var storeyUpperType = storeysFacade.Where(s => s.Type == EnumStorey.Upper);

            if (storeyUpperType.Count() > 1)
            {
                Inspector.AddError(string.Format(
                                       "Не должно быть больше одного этажа Чердака в одном фасаде. Для фасада найдено {0} блоков монтажных планов определенных как чердак. Координата фасада X = {1}.",
                                       storeyUpperType.Count(), XMin), icon: System.Drawing.SystemIcons.Error);
            }
            var storeyParapetType = storeysFacade.Where(s => s.Type == EnumStorey.Parapet);

            if (storeyParapetType.Count() > 1)
            {
                Inspector.AddError(string.Format(
                                       "Не должно быть больше одного этажа Парапета в одном фасаде. Для фасада найдено {0} блоков монтажных планов определенных как парапет. Координата фасада X = {1}.",
                                       storeyParapetType.Count(), XMin), icon: System.Drawing.SystemIcons.Error);
            }
        }
Ejemplo n.º 27
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        switch (collision.gameObject.tag)
        {
        case "uppershelf": currentFloor = Floors.UPPER_SHELF; resetMovement(); break;

        case "lowershelf": currentFloor = Floors.LOWER_SHELF; resetMovement(); break;

        case "table": currentFloor = Floors.TABLE; resetMovement(); break;

        case "floor": currentFloor = Floors.GROUND; resetMovement(); break;

        case "windowsilk": currentFloor = Floors.WINDOW_SILK; resetMovement(); break;
        }

        if (collision.gameObject.tag == "wall")
        {
            flip();
        }

        if (collision.gameObject.tag == "droppable")
        {
            collision.gameObject.layer = LayerMask.NameToLayer("Droppables");
            delay = 1f;

            Object myvase = collision.GetComponent <Object>();
            if (myvase != null)
            {
                myvase.DropObject();
                Spawner.Instance.OnItemDropped(myvase.index);
            }

            anim.SetBool("pushing", true);
        }
    }
Ejemplo n.º 28
0
        public void OnlyBuildInRightFloors2()
        {
            var floors = new Floors()
            {
                { 0, new Floor(4) },
                { 1, new Floor() },
                { 2, new Floor() },
                { 3, new Floor(6) },
                { 4, new Floor() }
            };
            var game = new Game(floors, 4, 6, 2);

            game.SetGeneralProperties(100, 10);

            var decision = game.TakeDecision(new Clone(0, 3, Direction.Right));

            decision.ShouldBe("WAIT");

            decision = game.TakeDecision(new Clone(0, 4, Direction.Right));
            decision.ShouldBe("WAIT");

            decision = game.TakeDecision(new Clone(1, 4, Direction.Right));
            decision.ShouldBe("ELEVATOR");

            decision = game.TakeDecision(new Clone(1, 4, Direction.Right));
            decision.ShouldBe("WAIT");

            decision = game.TakeDecision(new Clone(2, 4, Direction.Right));
            decision.ShouldBe("ELEVATOR");
        }
Ejemplo n.º 29
0
        public void PerformanceTest()
        {
            var floors = new Floors();
            var random = new Random();

            var rows    = 12;
            var columns = 68 /*68*/;

            for (int i = 0; i <= rows; i++)
            {
                floors.Add(i, new Floor());
            }

            var game = new Game(floors, rows, columns, 10);

            game.SetGeneralProperties(1000, 100, rows);

            var sw = new Stopwatch();

            sw.Start();
            game.TakeDecision(new Clone(0, 0, Direction.Right));
            sw.Stop();

            sw.ElapsedMilliseconds.ShouldBeLessThan(100);
        }
Ejemplo n.º 30
0
        public void FewClonesTestLastBit()
        {
            var random = new Random();

            var floors = new Floors()
            {
                { 0, new Floor() },
                { 1, new Floor() },
                { 2, new Floor() },
                { 3, new Floor() },
                { 4, new Floor() },
                { 5, new Floor(46) },
                { 6, new Floor(13, 34, 56, 66) },
                { 7, new Floor(17) },
                { 8, new Floor(1, 10, 23, 34, 56, 67) },
                { 9, new Floor() },
                { 10, new Floor(3, 23) },
                { 11, new Floor(4, 11, 13, 38, 43) },
                { 12, new Floor() }
            };

            var game = new Game(floors, 11, 39, 2);

            game.SetGeneralProperties(1000, 100, 68);


            var decision = game.TakeDecision(new Clone(9, 23, Direction.Right));

            decision.ShouldBe("WAIT");
        }
Ejemplo n.º 31
0
        public static Floors ModelToEnity(this FloorsModel model, bool virtualActive = false)
        {
            Floors entity = new Floors()
            {
                 Name= model.Name,
                Id = model.Id,
                IsActive = model.IsActive
            };
            if (virtualActive)
            {
                entity.BlockFloors = model.BlockFloors;

            }
            return entity;
        }
Ejemplo n.º 32
0
        private void InitializeData()
        {
            _floor = new Floors();
            tabFloor.ItemsSource = _floor;

            Languages _languages = new Languages();
            cmb_language.ItemsSource = _languages;
        }