Inheritance: MonoBehaviour
Exemplo n.º 1
0
    public void GenerateStairsPerimeter(Stairs stairs)
    {
        foreach (CellLocation location in PossibleStairsPerimeterLocations (stairs)) {

            AddStairsPerimeter (location);
        }
    }
Exemplo n.º 2
0
 public RenderTileData(Brush bg)
 {
     this.Brush = bg;
     this.G = 0;
     this.H = 0;
     this.From = Direction.None;
     this.Weight = 0;
     this.Stairs = Stairs.None;
 }
Exemplo n.º 3
0
 public void ClearTile()
 {
     this.Brush = Brushes.Black;
     this.G = 0;
     this.H = 0;
     this.From = Direction.None;
     this.Weight = 0;
     this.Stairs = Stairs.None;
 }
Exemplo n.º 4
0
    public void AddStairsUp(Stairs stairs)
    {
        stairs.stairsUp = true;

        allStairs.Add (stairs);
        allStairsUp.Add (stairs);

        dungeonGenerator.cellTypeGrid[stairs.location.x, stairs.location.y, stairs.location.z] = CellType.StairsUp;

        entranceGenerator.GenerateEntranceToStairs (stairs);
        perimeterGenerator.GenerateStairsPerimeter (stairs);
    }
Exemplo n.º 5
0
    public void GenerateStairsUp(Floor floor)
    {
        if (floor.floorNumber != 0) {

            foreach (Stairs stairsDown in dungeonGenerator.floors[dungeonGenerator.floorNumber - 1].allStairsDown) {

                CellLocation location = new CellLocation (stairsDown.location.x, dungeonGenerator.floorNumber, stairsDown.location.z);

                Stairs stairsUp = new Stairs (location, 0);

                stairsUp.direction = stairsDown.direction;
                stairsUp.rotation = stairsDown.rotation;

                AddStairsUp (stairsUp);
            }
        }
    }
Exemplo n.º 6
0
    public void GenerateStairsDown(Floor floor)
    {
        for (int i = 0; i < NumStairsDown; i++) {

            int randomIndex = Random.Range (1, PossibleStairsLocations ().Count) - 1;

            CellLocation chosenLocation = PossibleStairsLocations ()[randomIndex];

            Stairs stairs = new Stairs (chosenLocation, 0);

            stairs.direction = RandomDirection (stairs);
            if (stairs.direction == Dir.North) stairs.rotation = 0;
            else if (stairs.direction == Dir.East) stairs.rotation = 90;
            else if (stairs.direction == Dir.South) stairs.rotation = 180;
            else stairs.rotation = 270;

        AddStairsDown (stairs);

        }
    }
Exemplo n.º 7
0
    private void Start()
    {
        if (dungeon == null)
        {
            dungeon = DungeonManager.Instance;
        }

        int siblingIndex = transform.parent.parent.GetSiblingIndex();
        int offset       = 0;

        switch (direction)
        {
        case StairType.GOES_UP:
            offset = 1;
            break;

        case StairType.GOES_DOWN:
            offset = -1;
            break;
        }

        int offsetFloorIndex = siblingIndex + offset;

        Stairs[] stairsOnOffsetFloor = dungeon.GetFloor(offsetFloorIndex).GetComponentsInChildren <Stairs>();
        foreach (Stairs stairs in stairsOnOffsetFloor)
        {
            if (stairs.Direction != this.Direction)
            {
                if (destination != null)
                {
                    Util.Assert(false, "Multiple stair destinations detected for {0}", destination.name);
                }
                destination = stairs;
            }
        }
        Util.Assert(destination != null, "Unable to find respective stairs on floor {0}", offsetFloorIndex);
    }
Exemplo n.º 8
0
        private static IntVec findEndPoints(__FloorPlan floorPlan, GridBoundList <IInteractable> interactableEnvironment, Random rand)
        {
            int entryRoom = rand.Next(floorPlan.hallstart);

            while (floorPlan.rooms[entryRoom].type != __FloorPlan.__Room.__RoomType.FOYER && floorPlan.rooms[entryRoom].type != __FloorPlan.__Room.__RoomType.TREASURE_ROOM)
            {
                entryRoom = (entryRoom + 1) % floorPlan.hallstart;
            }
            __FloorPlan.__Room start      = floorPlan.rooms[entryRoom];
            IntVec             startPoint = start.GetCenter();

            Engine.Engine.Log(string.Format("Start point: <{0}, {1}>", startPoint.X, startPoint.Y));
            floorPlan.isFloor[startPoint.X, startPoint.Y] = false;
            floorPlan.rooms[entryRoom].type = __FloorPlan.__Room.__RoomType.EMPTY;

            int endRoom = (entryRoom + floorPlan.hallstart / 2) % floorPlan.hallstart;

            while (floorPlan.rooms[endRoom].type != __FloorPlan.__Room.__RoomType.FOYER && floorPlan.rooms[endRoom].type != __FloorPlan.__Room.__RoomType.TREASURE_ROOM)
            {
                endRoom = (endRoom + 1) % floorPlan.hallstart;
            }
            __FloorPlan.__Room end = floorPlan.rooms[endRoom];
            floorPlan.rooms[endRoom].type = __FloorPlan.__Room.__RoomType.EMPTY;
            Engine.Engine.Log(string.Format("End point: <{0}, {1}>", end.GetCenter().X, end.GetCenter().Y));
            floorPlan.isFloor[end.GetCenter().X, end.GetCenter().Y] = false;
            try
            {
                Stairs s = new Stairs();
            }
            catch (Exception e)
            {
                Console.WriteLine("");
            }
            interactableEnvironment.Add(new Stairs(), end.GetCenter());
            return(startPoint);
        }
Exemplo n.º 9
0
        public Tile GetTile(StairsTileData t)
        {
            SetMinimapTile(Color.Yellow);
            StairsInitializer stairsInitializer = new StairsInitializer {
                Down = t.Direction == VerticalDirection.Down
            };

            var res = new Stairs(stairsInitializer);

            SetupStairsSides(stairsInitializer, res);
            if (t.Direction == VerticalDirection.Down)
            {
                var upperStairsEntry = FindStairsEntryDirection(tilePosition.ToGrid(), -(int)tilePosition.Y);
                var lowerStairsEntry = FindStairsEntryDirection(tilePosition.ToGrid(), -(int)tilePosition.Y + 1);
                res.Renderer = builder.Factories.RenderersSource.GetUpperStairsTileRenderer(upperStairsEntry, lowerStairsEntry, res, builder.WallTexture);
            }
            else
            {
                res.Renderer = builder.Factories.RenderersSource.GetLowerStairsTileRenderer(res, builder.WallTexture);
            }

            this.initializer = stairsInitializer;
            return(res);
        }
        public void Execute(UIApplication app)
        {
            //Get current active document
            UIDocument uiDoc = app.ActiveUIDocument;

            //Get all elements in active document
            //https://thebuildingcoder.typepad.com/blog/2010/06/filter-for-all-elements.html
            FilteredElementCollector coll = new FilteredElementCollector(uiDoc.Document);

            coll.OfClass(typeof(Stairs));

            //Setup info string to append text to display on TaskDialog
            String info = "Ids of selected elements in the document are: ";

            foreach (Stairs s in coll)
            {
                info += "\n\t" + s.Name + " " + s.Id;

                //Cast as Stairs object
                Stairs stair = uiDoc.Document.GetElement(s.Id) as Stairs;

                info += "\n\t" + "Number of steps: " + stair.ActualRisersNumber.ToString();
                info += "\n\t";
            }

            //Display on TaskDialog
            // TaskDialog.Show("Revit", info);
            Window window = new Window()
            {
                Title   = "Results",
                Content = new MellowWindow(app, getStairViewMapping(app)),
                Width   = 350, Height = 450
            };

            window.Show();
        }
Exemplo n.º 11
0
        //bu method kioskun bulunduğu noktadan hedefe olan uzaklığını x ve y koordinatı olarak hesaplar her iki kattaki koordinatları tuple tipi ile verir
        public Tuple <Point, Point> FindShortestPath(Node target)
        {
            Point firstPath;
            Point secondPath;
            var   floorPath = target.Floor - Floor;

            if (floorPath != 0)
            {
                var stairs           = new Stairs();
                var stairsFirstPath  = Math.Abs(stairs.Column - Column) + Math.Abs(stairs.Row - Row);               //ilk kattaki yolun uzunluğu (merdivenli yol)
                var stairsSecondPath = Math.Abs(target.Column - stairs.Column) + Math.Abs(target.Row - stairs.Row); //ikinci kattaki yolun uzunluğu (merdivenli yol)
                var stairsTotalPath  = stairsFirstPath + stairsSecondPath;                                          //merdivenli yolun toplam uzuluğu

                var elevator           = new Elevator();
                var elevatorFirstPath  = Math.Abs(elevator.Column - Column) + Math.Abs(elevator.Row - Row);               //ilk kattaki yolun uzunluğu (asansörlü yol)
                var elevatorSecondPath = Math.Abs(target.Column - elevator.Column) + Math.Abs(target.Row - elevator.Row); //ikinci kattaki yolun uzunluğu (asansörlü yol)
                var elevatorTotalPath  = elevatorFirstPath + elevatorSecondPath;                                          //asansörlü yolun toplam uzuluğu
                if (elevatorTotalPath <= stairsTotalPath)                                                                 //yol eşitsede asansörü kullansın yorulmasın =)
                {
                    firstPath  = new Point(elevator.Column - Column, elevator.Row - Row);
                    secondPath = new Point(target.Column - elevator.Column, target.Row - elevator.Row);
                }
                else
                {
                    firstPath  = new Point(stairs.Column - Column, stairs.Row - Row);
                    secondPath = new Point(target.Column - stairs.Column, target.Row - stairs.Row);
                }
                return(new Tuple <Point, Point>(firstPath, secondPath));
            }
            else
            {
                firstPath  = new Point(target.Column - Column, target.Row - Row);
                secondPath = new Point();
                return(new Tuple <Point, Point>(firstPath, secondPath));
            }
        }
Exemplo n.º 12
0
 void Awake()
 {
     nextfloor = new NextFloorHandler(nextFloor);
     unloaddungeon = new UnloadDungeonHundler(unloadDungeon);
     Stairs stairs = new Stairs(this);
     Stairs.Entity = stairs;
     Stairs.gotoNext = gotoNextFloor;
     GameControlProxy.add(this);
     GameController.GameActionEvent.UnloadDungeon += unloaddungeon;
 }
Exemplo n.º 13
0
    protected List<CellLocation> PotentialStairsPerimeterLocations(Stairs stairs)
    {
        List<CellLocation> potentialStairsPerimeterLocations = new List<CellLocation> ();

        for (var i = stairs.location.x - 1; i < stairs.location.x + 2; i++) {

            potentialStairsPerimeterLocations.Add (new CellLocation(i, stairs.location.y, stairs.location.z - 1));
            potentialStairsPerimeterLocations.Add (new CellLocation(i, stairs.location.y, stairs.location.z + 1));
        }

        for (var j = stairs.location.z; j < stairs.location.z + 1; j ++) {

            potentialStairsPerimeterLocations.Add (new CellLocation(stairs.location.x - 1, stairs.location.y, j));
            potentialStairsPerimeterLocations.Add (new CellLocation(stairs.location.x + 1, stairs.location.y, j));
        }

        return potentialStairsPerimeterLocations;
    }
Exemplo n.º 14
0
 /// <summary>
 /// Initialize the properties of the menuform
 /// </summary>
 /// <param name="hotel"></param>
 /// <param name="cleaners"></param>
 /// <param name="customers"></param>
 /// <param name="persons"></param>
 /// <param name="stairs"></param>
 /// <param name="simplePath"></param>
 public MenuForm(Hotel hotel, List <Cleaner> cleaners, List <Customer> customers, List <IPerson> persons, Stairs stairs, SimplePath simplePath)
 {
     Customers  = customers;
     Cleaners   = cleaners;
     Persons    = persons;
     Hotel      = hotel;
     Stairs     = stairs;
     SimplePath = simplePath;
     InitializeComponent();
     InitMenu();
     MovieTime   = 50;
     EatingSpeed = 10;
     CleanSpeed  = 10;
 }
Exemplo n.º 15
0
 protected virtual void OnStairsUpCreated(Stairs stairs)
 {
     //throw new NotImplementedException();
 }
Exemplo n.º 16
0
 public void VasyaAndStairsTest6()
 {
     Assert.AreEqual(10, Stairs.NumberOfSteps(18, 10));
 }
Exemplo n.º 17
0
 public void SetStairs(IntPoint3 p, Stairs stairs)
 {
     this.Grid[p.Z, p.Y, p.X].Stairs = stairs;
 }
Exemplo n.º 18
0
 protected Stairs(Stairs other)
 {
     this.Loc = other.Loc;
 }
Exemplo n.º 19
0
        public void Initialize()
        {
            gameOverPosition.X = 320;
            gameOverPosition.Y = 130;

            device = graphics.GraphicsDevice;

            gameState = new GameState();
            gameStart = new GameStart(device.PresentationParameters.BackBufferWidth, device.PresentationParameters.BackBufferHeight);
            gameState.setState(GameState.state.Start);

            board = new GameBoard(new Vector2(33, 25), new Vector2(device.PresentationParameters.BackBufferWidth, device.PresentationParameters.BackBufferHeight));
            darwin = new Darwin(board);
            //firstZombie = new Zombie(10, 10, 15, 5, 15, 5, board);
            //secondZombie = new Zombie(10, 16, 15, 5, 15, 5, board);
            //thirdZombie = new Zombie(12, 10, 15, 5, 15, 5, board);

            Vector2[] myPath = new Vector2[4];
            myPath[0] = new Vector2(8, 4);
            myPath[1] = new Vector2(8, 19);
            myPath[2] = new Vector2(25, 19);
            myPath[3] = new Vector2(25, 4);

            leaderZombie = new CongaLeaderZombie(8, 4, board.getNumSquaresX(), 0, board.getNumSquaresY(), 0, myPath, darwin, board);

            followerZombies = new List<CongaFollowerZombie>();

            // all conga paths for the different conga zombies are created here along with all conga zombies
            myPath = new Vector2[8];
            myPath[0] = new Vector2(8,4);
            myPath[1] = new Vector2(8, 12);
            myPath[2] = new Vector2(8,19);
            myPath[3] = new Vector2(17, 19);
            myPath[4] = new Vector2(25,19);
            myPath[5] = new Vector2(25, 12);
            myPath[6] = new Vector2(25,4);
            myPath[7] = new Vector2(17, 4);

            followerZombies.Add(new CongaFollowerZombie(10,4,board.getNumSquaresX(),0,board.getNumSquaresY(),0,myPath,leaderZombie,darwin,board));
            followerZombies.Add(new CongaFollowerZombie(12, 4, board.getNumSquaresX(), 0, board.getNumSquaresY(), 0, myPath, leaderZombie,darwin, board));
            followerZombies.Add(new CongaFollowerZombie(14, 4, board.getNumSquaresX(), 0, board.getNumSquaresY(), 0, myPath, leaderZombie,darwin, board));

            myPath = new Vector2[8];
            myPath[2] = new Vector2(8, 4);
            myPath[3] = new Vector2(8, 12);
            myPath[4] = new Vector2(8, 19);
            myPath[5] = new Vector2(17, 19);
            myPath[6] = new Vector2(25, 19);
            myPath[7] = new Vector2(25, 12);
            myPath[0] = new Vector2(25, 4);
            myPath[1] = new Vector2(17, 4);

            followerZombies.Add(new CongaFollowerZombie(25, 8, board.getNumSquaresX(), 0, board.getNumSquaresY(), 0, myPath,leaderZombie, darwin, board));
            followerZombies.Add(new CongaFollowerZombie(25, 10, board.getNumSquaresX(), 0, board.getNumSquaresY(), 0, myPath,leaderZombie, darwin, board));
            followerZombies.Add(new CongaFollowerZombie(25, 14, board.getNumSquaresX(), 0, board.getNumSquaresY(), 0, myPath,leaderZombie, darwin, board));

            myPath = new Vector2[8];
            myPath[4] = new Vector2(8, 4);
            myPath[5] = new Vector2(8, 12);
            myPath[6] = new Vector2(8, 19);
            myPath[7] = new Vector2(17, 19);
            myPath[0] = new Vector2(25, 19);
            myPath[1] = new Vector2(25, 12);
            myPath[2] = new Vector2(25, 4);
            myPath[3] = new Vector2(17, 4);

            followerZombies.Add(new CongaFollowerZombie(22, 19, board.getNumSquaresX(), 0, board.getNumSquaresY(), 0, myPath,leaderZombie, darwin, board));
            followerZombies.Add(new CongaFollowerZombie(16, 19, board.getNumSquaresX(), 0, board.getNumSquaresY(), 0, myPath,leaderZombie, darwin, board));
            followerZombies.Add(new CongaFollowerZombie(14, 19, board.getNumSquaresX(), 0, board.getNumSquaresY(), 0, myPath,leaderZombie, darwin, board));

            myPath = new Vector2[8];
            myPath[6] = new Vector2(8, 4);
            myPath[7] = new Vector2(8, 12);
            myPath[0] = new Vector2(8, 19);
            myPath[1] = new Vector2(17, 19);
            myPath[2] = new Vector2(25, 19);
            myPath[3] = new Vector2(25, 12);
            myPath[4] = new Vector2(25, 4);
            myPath[5] = new Vector2(17, 4);

            followerZombies.Add(new CongaFollowerZombie(8, 12, board.getNumSquaresX(), 0, board.getNumSquaresY(), 0, myPath,leaderZombie, darwin, board));
            followerZombies.Add(new CongaFollowerZombie(8, 15, board.getNumSquaresX(), 0, board.getNumSquaresY(), 0, myPath,leaderZombie, darwin, board));

            myPath = new Vector2[8];

            myPath[3] = new Vector2(8, 4);
            myPath[4] = new Vector2(8, 12);
            myPath[5] = new Vector2(8, 19);
            myPath[6] = new Vector2(17, 19);
            myPath[7] = new Vector2(25, 19);
            myPath[0] = new Vector2(25, 16);
            myPath[1] = new Vector2(25, 4);
            myPath[2] = new Vector2(17, 4);

            followerZombies.Add(new CongaFollowerZombie(29, 17, board.getNumSquaresX(), 0, board.getNumSquaresY(), 0, myPath,leaderZombie, darwin, board));
            followerZombies.Add(new CongaFollowerZombie(29, 15, board.getNumSquaresX(), 0, board.getNumSquaresY(), 0, myPath,leaderZombie, darwin, board));
            followerZombies.Add(new CongaFollowerZombie(29, 16, board.getNumSquaresX(), 0, board.getNumSquaresY(), 0, myPath,leaderZombie, darwin, board));
            followerZombies.Add(new CongaFollowerZombie(29, 13, board.getNumSquaresX(), 0, board.getNumSquaresY(), 0, myPath,leaderZombie, darwin, board));

            myPath = new Vector2[8];
            myPath[7] = new Vector2(8, 4);
            myPath[0] = new Vector2(8, 7);
            myPath[1] = new Vector2(8, 19);
            myPath[2] = new Vector2(17, 19);
            myPath[3] = new Vector2(25, 19);
            myPath[4] = new Vector2(25, 12);
            myPath[5] = new Vector2(25, 4);
            myPath[6] = new Vector2(17, 4);

            followerZombies.Add(new CongaFollowerZombie(4, 7, board.getNumSquaresX(), 0, board.getNumSquaresY(), 0, myPath,leaderZombie, darwin, board));
            followerZombies.Add(new CongaFollowerZombie(4, 9, board.getNumSquaresX(), 0, board.getNumSquaresY(), 0, myPath,leaderZombie, darwin, board));
            followerZombies.Add(new CongaFollowerZombie(4, 8, board.getNumSquaresX(), 0, board.getNumSquaresY(), 0, myPath,leaderZombie, darwin, board));
            followerZombies.Add(new CongaFollowerZombie(4, 10, board.getNumSquaresX(), 0, board.getNumSquaresY(), 0, myPath,leaderZombie, darwin, board));

            leaderZombie.setFollowers(followerZombies);

            String zombieString = "This a zombie,\n don't near him \nas a human!!";
            zombieMessage = new MessageBox(board.getPosition(12, 8).X, board.getPosition(10, 10).Y, zombieString);

            String darwinString = "This is darwin,\n move with arrows, \n z to transform, \n a for actions";
            darwinMessage = new MessageBox(board.getPosition(12, 8).X, board.getPosition(10, 10).Y, darwinString);

            String switchString = "This is a switch\n face it and press A\n to see what happens!!";
            switchMessage = new MessageBox(board.getPosition(12, 8).X, board.getPosition(10, 10).Y, switchString);

            stairs = new Stairs(board);

            BasicObject[] removableWalls = setRemovableWallsSwitchOne();

            BasicObject switchSquare = new BasicObject(board);
            switchSquare.X = 31;
            switchSquare.Y = 8;

            firstSwitch = new Switch(switchSquare, board, removableWalls);

            BasicObject[] removableWalls2 = setRemovableWallsSwitchTwo();

            BasicObject switchSquare2 = new BasicObject(board);
            switchSquare2.X = 1;
            switchSquare2.Y = 15;

            secondSwitch = new Switch(switchSquare2, board, removableWalls2);

            // Initial starting position
            darwin.setGridPosition(16, 22);

            if (board.isGridPositionOpen(darwin))
            {
                board.setGridPositionOccupied(darwin.X, darwin.Y);
                darwin.setPosition(board.getPosition(darwin).X, board.getPosition(darwin).Y);
            }

            // Darwin's lag movement
            counterReady = counter = 5;

            if (board.isGridPositionOpen(16, 1))
            {
                stairs.setGridPosition(16, 1);
                stairs.setDestination(board.getPosition(16, 1));
            }

            zTime = new ZombieTime(board);
            zTimeReset = new ZombieTime(board);

            setPotionPosition(28, 7);
            setPotion2Position(1, 7);

            setWallsInLevelFour();

            setDanceFloor();
        }
Exemplo n.º 20
0
 public StairsFixer()
 {
     this.Stairs = new Stairs();
 }
Exemplo n.º 21
0
        /// <summary>
        /// Prompt user to pick a face and paint it
        /// with the given material. If the face belongs
        /// to a stair run or landing, paint that part
        /// of the stair specifically.
        /// </summary>
        void PaintSelectedFace(UIDocument uidoc, Material mat)
        {
            Document      doc    = uidoc.Document;
            Selection     sel    = uidoc.Selection;
            List <String> errors = new List <string>();
            //FaceSelectionFilter filter = new FaceSelectionFilter();
            Reference pickedRef = sel.PickObject(
                ObjectType.PointOnElement,
                //filter,
                "Please select a face to paint");

            Element elem = doc.GetElement(pickedRef);

            GeometryObject geoObject = elem
                                       .GetGeometryObjectFromReference(pickedRef);

            Face selected_face = geoObject as Face;

            using (Transaction transaction = new Transaction(doc))
            {
                transaction.Start("Paint Selected Face");

                if (elem.Category.Id.IntegerValue.Equals(
                        (int)BuiltInCategory.OST_Stairs))
                {
                    Stairs str    = elem as Stairs;
                    bool   IsLand = false;

                    ICollection <ElementId> landings = str.GetStairsLandings();
                    ICollection <ElementId> runs     = str.GetStairsRuns();

                    foreach (ElementId id in landings)
                    {
                        Element      land   = doc.GetElement(id);
                        List <Solid> solids = GetElemSolids(
                            land.get_Geometry(new Options()));

                        IsLand = SolidsContainFace(solids, selected_face);

                        if (IsLand)
                        {
                            break;
                        }
                    }

                    if (IsLand)
                    {
                        foreach (ElementId id in landings)
                        {
                            doc.Paint(id, selected_face, mat.Id);
                            break;
                        }
                    }
                    else
                    {
                        foreach (ElementId id in runs)
                        {
                            doc.Paint(id, selected_face, mat.Id);
                            break;
                        }
                    }
                }
                else
                {
                    try
                    {
                        doc.Paint(elem.Id, selected_face, mat.Id);
                    }
                    catch (Exception ex)
                    {
                        TaskDialog.Show("Error painting selected face",
                                        ex.Message);
                    }
                }
                transaction.Commit();
            }
        }
Exemplo n.º 22
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            Document doc = commandData.Application.ActiveUIDocument.Document;


            //因為樓層數會影響一些標準的高度,所以先把樓層高度找出來
            FilteredElementCollector levelCollector = new FilteredElementCollector(doc);
            ElementCategoryFilter    levelFilter    = new ElementCategoryFilter(BuiltInCategory.OST_Levels);

            List <Element> levels = levelCollector.WherePasses(levelFilter).ToElements().ToList();

            int floor_count = 0;

            foreach (Element elem in levels)
            {
                if (elem.get_Parameter(BuiltInParameter.ELEM_FAMILY_PARAM).AsValueString() == "樓層")
                {
                    //在地表的樓層才算,Elevation>=0,屋突好像也不算,名字P開頭的不行
                    Level level = elem as Level;
                    if (level.Name.ToList()[0] != 'P' & level.Name.ToList()[0] != 'G')
                    {
                        if (level.Elevation >= 0)
                        {
                            floor_count += 1;
                        }
                    }
                }
            }
            if (floor_count >= 10)
            {
                regulation_railing_height = 120;
            }
            else
            {
                regulation_railing_height = 110;
            }



            string        newFileName = @"C:\Users\8014\Desktop\BIM模型檢核.csv";
            StringBuilder sb          = new StringBuilder();

            sb.AppendLine("5.樓梯垂直淨空高度檢核");
            sb.AppendLine("規範:樓梯之垂直淨空距離不得小於 190 公分");
            sb.AppendLine("樓梯名稱\t樓梯高度(cm)\t規範高度(cm)\t是否符合規範");

            form_list5.Add(new string[] { "5.樓梯垂直淨空高度檢核" });
            form_list5.Add(new string[] { "規範:樓梯之垂直淨空距離不得小於 190 公分" });


            //先把全部的樓梯抓出來,有分室外梯以及室內梯,不過好像不用特別分室外跟室內耶

            FilteredElementCollector stairsCollector = new FilteredElementCollector(doc);
            ElementCategoryFilter    stairsFilter    = new ElementCategoryFilter(BuiltInCategory.OST_Stairs);

            List <Element> all_stairs = stairsCollector.WherePasses(stairsFilter).WhereElementIsNotElementType().ToElements().ToList();

            //List<Element> indoor_stairs = new List<Element>();

            //foreach(Element elem in all_stairs)
            //{
            //    if (elem.get_Parameter(BuiltInParameter.ELEM_TYPE_PARAM).AsValueString().Contains("室內RC"))
            //        indoor_stairs.Add(elem);
            //}

            foreach (Element elem in all_stairs)
            {
                Stairs stairs        = elem as Stairs;
                double stairs_height = Convert.ToDouble(stairs.get_Parameter(BuiltInParameter.STAIRS_STAIRS_HEIGHT).AsValueString());
                string s             = stairs.get_Parameter(BuiltInParameter.ELEM_FAMILY_AND_TYPE_PARAM).AsValueString() + "\t" + stairs_height.ToString() + "\t"
                                       + regulation_stairs_height.ToString() + "\t"
                                       + (stairs_height >= regulation_stairs_height).ToString();
                sb.AppendLine(s);

                string[] row = new string[] { stairs.Id.ToString(), stairs.get_Parameter(BuiltInParameter.ELEM_FAMILY_AND_TYPE_PARAM).AsValueString(), stairs_height.ToString(), regulation_stairs_height.ToString(), "無", (stairs_height >= regulation_stairs_height).ToString() };
                form_list5.Add(row);
            }

            sb.AppendLine();
            sb.AppendLine();
            File.AppendAllText(newFileName, sb.ToString(), Encoding.Unicode);

            form_list5.Add(new string[] { });
            form_list5.Add(new string[] { });



            StringBuilder sb2 = new StringBuilder();

            sb2.AppendLine("6.欄杆扶手高度檢核:");
            sb2.AppendLine("規範:設置於露臺、陽臺、室外走廊、室外樓梯、平屋頂及室內天井部 分等之欄桿扶手高度欄桿扶手高度,不得小於1.1公尺,十層以上者,不得小於1.2公尺");
            sb2.AppendLine("欄杆名稱\t欄杆高度(cm)\t規範高度(cm)\t是否符合規範");

            form_list6.Add(new string[] { "6.欄杆扶手高度檢核:" });
            form_list6.Add(new string[] { "規範:設置於露臺、陽臺、室外走廊、室外樓梯、平屋頂及室內天井部 分等之欄桿扶手高度欄桿扶手高度,不得小於1.1公尺,十層以上者,不得小於1.2公尺" });


            //接下來要取欄杆高度
            //樓梯用的扶手、欄杆是900mm的,跟女兒牆的布一樣
            //要扣除掉女兒牆的欄杆的
            FilteredElementCollector railingCollector = new FilteredElementCollector(doc);
            ElementCategoryFilter    railingFilter    = new ElementCategoryFilter(BuiltInCategory.OST_StairsRailing);

            List <Element> railings = railingCollector.WherePasses(railingFilter).WhereElementIsNotElementType().ToElements().ToList();


            foreach (Element elem in railings)
            {
                if (!(elem.Name.Contains("900mm")))
                {
                    continue;
                }
                Railing     railing        = elem as Railing;
                ElementType elementType    = doc.GetElement(railing.GetTypeId()) as ElementType;
                double      railing_height = Convert.ToDouble(elementType.get_Parameter(BuiltInParameter.STAIRS_RAILING_HEIGHT).AsValueString());
                string      s = railing.Name + "\t" + railing_height.ToString() + "\t" + regulation_railing_height.ToString()
                                + "\t" + (railing_height >= regulation_railing_height).ToString();
                sb2.AppendLine(s);

                string[] row = new string[] { railing.Id.ToString(), railing.Name, railing_height.ToString(), regulation_railing_height.ToString(), "無", (railing_height >= regulation_railing_height).ToString() };
                form_list6.Add(row);
            }

            sb2.AppendLine();
            sb2.AppendLine();

            File.AppendAllText(newFileName, sb2.ToString(), Encoding.Unicode);

            form_list6.Add(new string[] { });
            form_list6.Add(new string[] { });



            return(Result.Succeeded);
        }
        /// <summary>
        /// Calculates number of risers for a stair.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="extrusionCreationData">The IFCExtrusionCreationData.</param>
        /// <param name="element">The element to calculate the value.</param>
        /// <param name="elementType">The element type.</param>
        /// <returns>True if the operation succeed, false otherwise.</returns>
        public override bool Calculate(ExporterIFC exporterIFC, IFCExtrusionCreationData extrusionCreationData, Element element, ElementType elementType)
        {
            bool valid = true;

            if (CurrentElement != element)
            {
                CurrentElement = element;
                if (StairsExporter.IsLegacyStairs(element))
                {
                    int    numberOfRisers, numberOfTreads;
                    double riserHeight, treadLength, treadLengthAtInnerSide, nosingLength, waistThickness;

                    ExporterIFCUtils.GetLegacyStairsProperties(exporterIFC, element,
                                                               out numberOfRisers, out numberOfTreads,
                                                               out riserHeight, out treadLength, out treadLengthAtInnerSide,
                                                               out nosingLength, out waistThickness);

                    NumberOfRisers         = numberOfRisers;
                    NumberOfTreads         = numberOfTreads;
                    RiserHeight            = riserHeight;
                    TreadLength            = treadLength;
                    TreadLengthAtInnerSide = treadLengthAtInnerSide;
                    NosingLength           = nosingLength;
                    WaistThickness         = waistThickness;

                    TreadLengthAtOffset = TreadLength;
                    WalkingLineOffset   = WaistThickness / 2.0;
                }
                else if (element is Stairs)
                {
                    Stairs stairs = element as Stairs;
                    NumberOfRisers = stairs.ActualRisersNumber;
                    NumberOfTreads = stairs.ActualTreadsNumber;
                    RiserHeight    = UnitUtil.ScaleLength(stairs.ActualRiserHeight);
                    TreadLength    = UnitUtil.ScaleLength(stairs.ActualTreadDepth);
                }
                else if (element is StairsRun)
                {
                    StairsRun     stairsRun     = element as StairsRun;
                    StairsRunType stairsRunType = stairsRun.Document.GetElement(stairsRun.GetTypeId()) as StairsRunType;
                    Stairs        stairs        = stairsRun.GetStairs();
                    StairsType    stairsType    = stairs.Document.GetElement(stairs.GetTypeId()) as StairsType;

                    NumberOfRisers      = stairs.ActualRisersNumber;
                    NumberOfTreads      = stairs.ActualTreadsNumber;
                    RiserHeight         = UnitUtil.ScaleLength(stairs.ActualRiserHeight);
                    TreadLength         = UnitUtil.ScaleLength(stairs.ActualTreadDepth);
                    TreadLengthAtOffset = TreadLength;
                    NosingLength        = UnitUtil.ScaleLength(stairsRunType.NosingLength);
                    WaistThickness      = UnitUtil.ScaleLength(stairsRun.ActualRunWidth);
                    WalkingLineOffset   = WaistThickness / 2.0;

                    double treadLengthAtInnerSide;
                    if (ParameterUtil.GetDoubleValueFromElement(stairsType,
                                                                BuiltInParameter.STAIRSTYPE_MINIMUM_TREAD_WIDTH_INSIDE_BOUNDARY, out treadLengthAtInnerSide) != null)
                    {
                        TreadLengthAtInnerSide = UnitUtil.ScaleLength(treadLengthAtInnerSide);
                    }
                    else
                    {
                        TreadLengthAtInnerSide = 0.0;
                    }
                }
                else
                {
                    valid = false;
                }
            }
            return(valid);
        }
Exemplo n.º 24
0
 public void VasyaAndStairsTest7()
 {
     Assert.AreEqual(-1, Stairs.NumberOfSteps(1, 2));
 }
Exemplo n.º 25
0
 public void VasyaAndStairsTest3()
 {
     Assert.AreEqual(5000, Stairs.NumberOfSteps(9999, 2));
 }
Exemplo n.º 26
0
        public void testThreeActOnSwichToObject()
        {
            bool passed = false;

            bob = new Mage();
            stair = new Stairs();

            stair.actOn(bob);

            if (stair.calledNextLevel == true)
            {
                passed = true;
            }

            if (!passed)
            {
                throw new System.ArgumentException("Switch acting on object", "testThreeActOnSwichToObject");
            }
        }
Exemplo n.º 27
0
    protected Dir RandomDirection(Stairs stairs)
    {
        int randomInt = Random.Range (1, 5);
        Dir randomDirection;

        if (randomInt == 1) randomDirection = Dir.North;
        else if (randomInt == 2) randomDirection = Dir.South;
        else if (randomInt == 3) randomDirection = Dir.East;
        else randomDirection = Dir.West;

        return randomDirection;
    }
Exemplo n.º 28
0
 public void SetStairs(IntVector3 p, Stairs stairs)
 {
     this.Grid[p.Z, p.Y, p.X].Stairs = stairs;
 }
Exemplo n.º 29
0
        public void testOneCreatingStair()
        {
            bool passed = false;

            stair = new Stairs();

            if (stair != null)
            {
                passed = true;
            }

            if (!passed)
            {
                throw new System.ArgumentException("Swiches was not created", "testOneCreatingSwich");
            }
        }
Exemplo n.º 30
0
 public void VasyaAndStairsTest4()
 {
     Assert.AreEqual(5004, Stairs.NumberOfSteps(9999, 9));
 }
Exemplo n.º 31
0
 // Use this for initialization
 void Start()
 {
     for (int i = 0; i < mapSize; i++)
     {
         for (int j = 0; j < mapSize; j++)
         {
             mapLocs[i, j]       = Instantiate(spawner, new Vector3((i * 8.4f), (j * 8.4f), 0f), Quaternion.identity);
             mapLocs[i, j].gridX = i;
             mapLocs[i, j].gridY = j;
         }
     }
     //initializeMap();
     altInitMap();
     while (!stairsPlaced)
     {
         for (int i = 0; i < mapSize; i++)
         {
             for (int j = 0; j < mapSize; j++)
             {
                 if (!stairsPlaced)
                 {
                     spawnStairs(mapLocs[i, j]);
                 }
             }
         }
     }
     while (!pSpawnPlaced)
     {
         for (int i = 0; i < mapSize; i++)
         {
             for (int j = 0; j < mapSize; j++)
             {
                 if (!pSpawnPlaced)
                 {
                     genPSpawn(mapLocs[i, j]);
                 }
             }
         }
     }
     for (int i = 0; i < mapSize; i++)
     {
         for (int j = 0; j < mapSize; j++)
         {
             makeRoom(mapLocs[i, j]);
             seedChestsAndEnemies(mapLocs[i, j]);
         }
     }
     for (int i = 0; i < mapSize; i++)
     {
         for (int j = 0; j < mapSize; j++)
         {
             swapCorners(mapLocs[i, j]);
         }
     }
     for (int i = 0; i < mapSize; i++)
     {
         for (int j = 0; j < mapSize; j++)
         {
             if (mapLocs[i, j].exitRoom)
             {
                 Stairs stairwell = Instantiate(stairway, mapLocs[i, j].transform.position, Quaternion.identity);
             }
             if (mapLocs[i, j].playerSpawn)
             {
                 PlayerControls.pc.transform.position = mapLocs[i, j].transform.position;
             }
         }
     }
 }
Exemplo n.º 32
0
    public override void updateAI()
    {
        //Das Selbe wie in der Wander State
        //Charakter hat Ort erreicht
        if (stateMachine.Enemy.getCharacterPath().Length == 0)
        {
            Vector3 distance = stateMachine.Enemy.transform.position - fleeSpot.transform.position;
            if (distance.magnitude <= 0.5f)
            {
                stateMachine.changeState(StateType.IDLE_STATE);
            }
        }
        //Charakter bewegt sich zu einem Ort
        else
        {
            if (movingComponent.finishedAction)
            {
                if (!movingToTransition)
                {
                    nextTarget = stateMachine.Enemy.popNextTarget();
                    if (nextTarget.GetComponent <Door>() != null || nextTarget.GetComponent <Stairs>() != null)
                    {
                        movingToTransition = true;
                    }

                    movingComponent.goToObject(nextTarget);
                }
                else
                {
                    if (nextTarget.GetComponent <Door>() != null)
                    {
                        Door door = nextTarget.GetComponent <Door>();
                        door.use(movingComponent);
                        for (int i = 0; i < door.connectedRooms.Length; ++i)
                        {
                            if (!door.connectedRooms[i].Equals(stateMachine.Enemy.currentLocation))
                            {
                                stateMachine.Enemy.currentLocation = door.connectedRooms[i];
                                break;
                            }
                        }
                        movingToTransition = false;
                    }
                    else
                    {
                        Stairs stairs = nextTarget.GetComponent <Stairs>();
                        if (stairs.level == 1)
                        {
                            stairs.goUpstairs(stateMachine.Enemy.gameObject);
                            stateMachine.Enemy.currentLocation = stairs.upperMainFloor;
                        }
                        else
                        {
                            stairs.goDownstairs(stateMachine.Enemy.gameObject);
                            stateMachine.Enemy.currentLocation = stairs.lowerMainFloor;
                        }
                        movingToTransition = false;
                    }
                }
            }
        }
    }
Exemplo n.º 33
0
        /// <summary>
        /// Certain Categories like Stairs contain elements of different Categories, that are hosted
        /// to them. We need to handle these approprietely.
        /// </summary>
        /// <param name="doc">Document</param>
        /// <param name="catInfo">Category Info object.</param>
        /// <param name="element">Element to check.</param>
        private static void RunCategoryAction(Document doc, CategoryInfo catInfo, Element element)
        {
            try
            {
                switch (catInfo.BltCategory)
                {
                case BuiltInCategory.OST_Topography:
                    var surface      = (TopographySurface)element;
                    var subRegionIds = surface.GetHostedSubRegionIds();
                    if (subRegionIds?.Count > 0)
                    {
                        foreach (var eId in subRegionIds)
                        {
                            var subRegion = doc.GetElement(eId);
                            if (null != subRegion)
                            {
                                CreateDirectShape(doc, subRegion);
                            }
                        }
                    }
                    break;

                case BuiltInCategory.OST_Stairs:
                    if (Stairs.IsByComponent(doc, element.Id))
                    {
                        var stair      = (Stairs)element;
                        var railingIds = stair.GetAssociatedRailings();
                        if (railingIds.Count > 0)
                        {
                            foreach (var eId in railingIds)
                            {
                                var railing = doc.GetElement(eId);
                                if (null != railing)
                                {
                                    CreateDirectShape(doc, railing);
                                }
                            }
                        }
                    }
                    else
                    {
                        var railings = new FilteredElementCollector(doc)
                                       .OfClass(typeof(Railing))
                                       .WhereElementIsNotElementType()
                                       .Cast <Railing>()
                                       .Where(x => x.HasHost && x.HostId == element.Id)
                                       .ToList();

                        if (railings.Any())
                        {
                            foreach (var railing in railings)
                            {
                                CreateDirectShape(doc, railing);
                            }
                        }
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                Log.AppendLog(LogMessageType.EXCEPTION, ex.Message + "-" + element.Id);
            }
        }
Exemplo n.º 34
0
        /// <summary>
        /// Creates a new instance of StairsSingleStraightRun at a given location and orientation.
        /// </summary>
        /// <param name="stairs">The stairs element.</param>
        /// <param name="bottomLevel">The bottom level of the configuration.</param>
        /// <param name="transform">The transform (containing location and orientation).</param>
        public StairsSingleStraightRun(Stairs stairs, Level bottomLevel, Transform transform)
        {
            StairsType stairsType = stairs.Document.GetElement(stairs.GetTypeId()) as StairsType;

            m_runConfigurations.Add(new StraightStairsRunComponent(stairs.DesiredRisersNumber, bottomLevel.Elevation, stairsType.MinTreadDepth, stairsType.MinRunWidth, transform));
        }
Exemplo n.º 35
0
 /// <summary>
 ///     Destroy a stairs by destroying gameobject and set data to null
 /// </summary>
 /// <param name="s">The stairs</param>
 public void DestroyStairs(Stairs s)
 {
     m_stairs.Remove(s);
     Destroy(s.associated2DObject);
     Destroy(s.associated3DObject);
 }
        private static void SpawnFromString(IRoom room, SpriteBatch spriteBatch, string spawnType, int offsetX, int offsetY, int gridX, int gridY)
        {
            int         posX     = offsetX + gridX * RoomConstants.TileLength;
            int         posY     = offsetY + gridY * RoomConstants.TileLength;
            Point       position = new Point(posX, posY);
            IBlock      blockType;
            INpc        npcType;
            IItem       itemType;
            IBackground backgroundType;

            switch (spawnType)
            {
            //Blocks
            case RoomConstants.Block:
                blockType = new Square(spriteBatch, position);
                room.AllObjects.Spawn(blockType);
                break;

            case RoomConstants.BrickTile:
                blockType = new BrickTile(spriteBatch, position);
                room.AllObjects.Spawn(blockType);
                break;

            case RoomConstants.GapTile:
                blockType = new GapTile(spriteBatch, position);
                room.AllObjects.Spawn(blockType);
                break;

            case RoomConstants.Fire:
                position.X += RoomConstants.TileLength / 2;
                blockType   = new Fire(spriteBatch, position);
                room.AllObjects.Spawn(blockType);
                break;

            case RoomConstants.LadderTile:
                backgroundType = new LadderTile(spriteBatch, position);
                room.AllObjects.Spawn(backgroundType);
                break;

            case RoomConstants.Stairs:
                blockType = new Stairs(spriteBatch, position);
                room.AllObjects.Spawn(blockType);
                break;

            case RoomConstants.FishStatue:
                blockType = new FishStatues(spriteBatch, position);
                room.AllObjects.Spawn(blockType);
                break;

            case RoomConstants.DragonStatue:
                blockType = new DragonStatues(spriteBatch, position);
                room.AllObjects.Spawn(blockType);
                break;

            case RoomConstants.BlueGrass:
                backgroundType = new TileBlueGrass(spriteBatch, position);
                room.AllObjects.Spawn(backgroundType);
                break;

            case RoomConstants.Water:
                blockType = new TileWater(spriteBatch, position);
                room.AllObjects.Spawn(blockType);
                break;

            case RoomConstants.MovableBlock:
                blockType = new MovableSquare(spriteBatch, position);
                ((RoomWithMovableSquare)room).AddMovableSquare((MovableSquare)blockType);
                room.AllObjects.Spawn(blockType);
                break;

            //Npcs
            case RoomConstants.Aquamentus:
                position.Y += RoomConstants.TileLength / 2;
                npcType     = new Aquamentus(spriteBatch, position, room.AllObjects);
                room.AllObjects.Spawn(npcType);
                break;

            case RoomConstants.Bat:
                npcType = new Bat(spriteBatch, position);
                room.AllObjects.Spawn(npcType);
                break;

            case RoomConstants.Goriya:
                npcType = new Goriya(spriteBatch, position, room.AllObjects);
                room.AllObjects.Spawn(npcType);
                break;

            case RoomConstants.Hand:
                npcType = new Hand(spriteBatch, position, ((RoomWallMaster)room).GetWallMasterRoomToJumpTo());
                room.AllObjects.Spawn(npcType);
                break;

            case RoomConstants.Jelly:
                npcType = new Jelly(spriteBatch, position);
                room.AllObjects.Spawn(npcType);
                break;

            case RoomConstants.OldMan:
                position.X += RoomConstants.TileLength / 2;
                npcType     = new OldMan(spriteBatch, position);
                room.AllObjects.Spawn(npcType);
                break;

            case RoomConstants.Skeleton:
                npcType = new Skeleton(spriteBatch, position);
                room.AllObjects.Spawn(npcType);
                break;

            case RoomConstants.SpikeTrap:
                npcType = new SpikeTrap(spriteBatch, position, room.AllObjects.GetPlayer(0));
                room.AllObjects.Spawn(npcType);
                break;

            //Items
            case RoomConstants.Compass:
                itemType = new CompassItem(spriteBatch, position);
                room.AllObjects.Spawn(itemType);
                break;

            case RoomConstants.Heart:
                position.X += (int)(4 * RoomConstants.SpriteMultiplier);
                position.Y += (int)(4 * RoomConstants.SpriteMultiplier);
                itemType    = new HeartItem(spriteBatch, position);
                room.AllObjects.Spawn(itemType);
                break;

            case RoomConstants.Key:
                itemType = new KeyItem(spriteBatch, position);
                room.AllObjects.Spawn(itemType);
                break;

            case RoomConstants.Map:
                itemType = new MapItem(spriteBatch, position);
                room.AllObjects.Spawn(itemType);
                break;

            case RoomConstants.Triforce:
                position.X += (int)(12 * RoomConstants.SpriteMultiplier);
                position.Y += (int)(2 * RoomConstants.SpriteMultiplier);
                itemType    = new TriforceItem(spriteBatch, position);
                room.AllObjects.Spawn(itemType);
                break;

            case RoomConstants.HeartContainer:
                itemType = new HeartContainerItem(spriteBatch, position);
                room.AllObjects.Spawn(itemType);
                break;

            case RoomConstants.Bow:
                itemType = new BowItem(spriteBatch, position);
                room.AllObjects.Spawn(itemType);
                break;

            default:
                break;
            }
        }
Exemplo n.º 37
0
        /// <summary>
        /// Exports a staircase to IfcStair, composing into separate runs and landings.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="ifcEnumType">The stairs type.</param>
        /// <param name="stair">The stairs element.</param>
        /// <param name="geometryElement">The geometry element.</param>
        /// <param name="numFlights">The number of flights for a multistory staircase.</param>
        /// <param name="productWrapper">The IFCProductWrapper.</param>
        public static void ExportStairsAsContainer(ExporterIFC exporterIFC, string ifcEnumType, Stairs stair, GeometryElement geometryElement,
            int numFlights, IFCProductWrapper productWrapper)
        {
            if (stair == null || geometryElement == null)
                return;

            Document doc = stair.Document;
            Autodesk.Revit.ApplicationServices.Application app = doc.Application;
            IFCFile file = exporterIFC.GetFile();
            Options geomOptions = GeometryUtil.GetIFCExportGeometryOptions();
            ElementId categoryId = CategoryUtil.GetSafeCategoryId(stair);

            using (IFCTransaction tr = new IFCTransaction(file))
            {
                using (IFCPlacementSetter placementSetter = IFCPlacementSetter.Create(exporterIFC, stair))
                {
                    HashSet<ElementId> materialIds = new HashSet<ElementId>();

                    List<IFCAnyHandle> componentHandles = new List<IFCAnyHandle>();
                    IList<IFCExtrusionCreationData> componentExtrusionData = new List<IFCExtrusionCreationData>();

                    IFCAnyHandle contextOfItemsFootPrint = exporterIFC.Get3DContextHandle("FootPrint");

                    Transform trf = ExporterIFCUtils.GetUnscaledTransform(exporterIFC, placementSetter.GetPlacement());
                    Plane boundaryPlane = new Plane(trf.BasisX, trf.BasisY, trf.Origin);
                    XYZ boundaryProjDir = trf.BasisZ;

                    IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
                    string stairGUID = ExporterIFCUtils.CreateGUID(stair);
                    string origStairName = exporterIFC.GetName();
                    string stairName = NamingUtil.GetNameOverride(stair, origStairName);
                    string stairDescription = NamingUtil.GetDescriptionOverride(stair, null);
                    string stairObjectType = NamingUtil.GetObjectTypeOverride(stair, NamingUtil.CreateIFCObjectName(exporterIFC, stair));
                    IFCAnyHandle stairLocalPlacement = placementSetter.GetPlacement();
                    string stairElementTag = NamingUtil.CreateIFCElementId(stair);
                    IFCStairType stairType = GetIFCStairType(ifcEnumType);

                    IFCAnyHandle stairContainerHnd = IFCInstanceExporter.CreateStair(file, stairGUID, ownerHistory, stairName,
                        stairDescription, stairObjectType, stairLocalPlacement, null, stairElementTag, stairType);
                    productWrapper.AddElement(stairContainerHnd, placementSetter.GetLevelInfo(), null, LevelUtil.AssociateElementToLevel(stair));

                    // Get List of runs to export their geometry.
                    ICollection<ElementId> runIds = stair.GetStairsRuns();
                    int index = 0;
                    foreach (ElementId runId in runIds)
                    {
                        index++;
                        StairsRun run = doc.GetElement(runId) as StairsRun;

                        using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
                        {
                            ecData.AllowVerticalOffsetOfBReps = false;
                            ecData.SetLocalPlacement(placementSetter.GetPlacement());
                            ecData.ReuseLocalPlacement = false;

                            GeometryElement runGeometryElement = run.get_Geometry(geomOptions);

                            BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
                            BodyData bodyData = BodyExporter.ExportBody(app, exporterIFC, run, categoryId, runGeometryElement,
                                bodyExporterOptions, ecData);

                            IFCAnyHandle bodyRep = bodyData.RepresentationHnd;
                            if (IFCAnyHandleUtil.IsNullOrHasNoValue(bodyRep))
                            {
                                ecData.ClearOpenings();
                                continue;
                            }

                            foreach (ElementId materialId in bodyData.MaterialIds)
                                materialIds.Add(materialId);

                            IList<IFCAnyHandle> reps = new List<IFCAnyHandle>();
                            reps.Add(bodyRep);

                            Transform runBoundaryTrf = trf.Multiply(bodyData.BrepOffsetTransform);
                            Plane runBoundaryPlane = new Plane(runBoundaryTrf.BasisX, runBoundaryTrf.BasisY, runBoundaryTrf.Origin);
                            XYZ runBoundaryProjDir = runBoundaryTrf.BasisZ;

                            CurveLoop boundary = run.GetFootprintBoundary();
                            IFCAnyHandle boundaryHnd = ExporterIFCUtils.CreateCurveFromCurveLoop(exporterIFC, boundary,
                                runBoundaryPlane, runBoundaryProjDir);
                            if (!IFCAnyHandleUtil.IsNullOrHasNoValue(boundaryHnd))
                            {
                                HashSet<IFCAnyHandle> geomSelectSet = new HashSet<IFCAnyHandle>();
                                geomSelectSet.Add(boundaryHnd);

                                HashSet<IFCAnyHandle> boundaryItems = new HashSet<IFCAnyHandle>();
                                boundaryItems.Add(IFCInstanceExporter.CreateGeometricSet(file, geomSelectSet));

                                IFCAnyHandle boundaryRep = RepresentationUtil.CreateGeometricSetRep(exporterIFC, run, categoryId, "FootPrint",
                                    contextOfItemsFootPrint, boundaryItems);
                                reps.Add(boundaryRep);
                            }

                            CurveLoop walkingLine = run.GetStairsPath();
                            IFCAnyHandle walkingLineHnd = ExporterIFCUtils.CreateCurveFromCurveLoop(exporterIFC, walkingLine,
                                runBoundaryPlane, runBoundaryProjDir);
                            if (!IFCAnyHandleUtil.IsNullOrHasNoValue(walkingLineHnd))
                            {
                                HashSet<IFCAnyHandle> geomSelectSet = new HashSet<IFCAnyHandle>();
                                geomSelectSet.Add(walkingLineHnd);

                                HashSet<IFCAnyHandle> walkingLineItems = new HashSet<IFCAnyHandle>();
                                walkingLineItems.Add(IFCInstanceExporter.CreateGeometricSet(file, geomSelectSet));

                                IFCAnyHandle walkingLineRep = RepresentationUtil.CreateGeometricSetRep(exporterIFC, run, categoryId, "Axis",
                                    contextOfItemsFootPrint, walkingLineItems);
                                reps.Add(walkingLineRep);
                            }

                            IFCAnyHandle representation = IFCInstanceExporter.CreateProductDefinitionShape(exporterIFC.GetFile(), null, null, reps);

                            string runGUID = ExporterIFCUtils.CreateGUID(run);
                            string origRunName = origStairName + " Run " + index;
                            string runName = NamingUtil.GetNameOverride(run, origRunName);
                            string runDescription = NamingUtil.GetDescriptionOverride(run, stairDescription);
                            string runObjectType = NamingUtil.GetObjectTypeOverride(run, stairObjectType);
                            IFCAnyHandle runLocalPlacement = ecData.GetLocalPlacement();
                            string runElementTag = NamingUtil.CreateIFCElementId(run);

                            IFCAnyHandle stairFlightHnd = IFCInstanceExporter.CreateStairFlight(file, runGUID, ownerHistory,
                                runName, runDescription, runObjectType, runLocalPlacement, representation, runElementTag,
                                run.ActualRisersNumber, run.ActualTreadsNumber, stair.ActualRiserHeight, stair.ActualTreadDepth);

                            componentHandles.Add(stairFlightHnd);
                            componentExtrusionData.Add(ecData);

                            productWrapper.AddElement(stairFlightHnd, placementSetter.GetLevelInfo(), ecData, false);

                            ExporterCacheManager.HandleToElementCache.Register(stairFlightHnd, run.Id);
                        }
                    }

                    // Get List of landings to export their geometry.
                    ICollection<ElementId> landingIds = stair.GetStairsLandings();
                    index = 0;
                    foreach (ElementId landingId in landingIds)
                    {
                        index++;
                        StairsLanding landing = doc.GetElement(landingId) as StairsLanding;

                        using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
                        {
                            ecData.AllowVerticalOffsetOfBReps = false;
                            ecData.SetLocalPlacement(placementSetter.GetPlacement());
                            ecData.ReuseLocalPlacement = false;

                            GeometryElement landingGeometryElement = landing.get_Geometry(geomOptions);

                            BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
                            BodyData bodyData = BodyExporter.ExportBody(app, exporterIFC, landing, categoryId, landingGeometryElement,
                                bodyExporterOptions, ecData);

                            IFCAnyHandle bodyRep = bodyData.RepresentationHnd;
                            if (IFCAnyHandleUtil.IsNullOrHasNoValue(bodyRep))
                            {
                                ecData.ClearOpenings();
                                continue;
                            }

                            foreach (ElementId materialId in bodyData.MaterialIds)
                                materialIds.Add(materialId);

                            // create Boundary rep.
                            IList<IFCAnyHandle> reps = new List<IFCAnyHandle>();
                            reps.Add(bodyRep);

                            Transform landingBoundaryTrf = trf.Multiply(bodyData.BrepOffsetTransform);
                            Plane landingBoundaryPlane = new Plane(landingBoundaryTrf.BasisX, landingBoundaryTrf.BasisY, landingBoundaryTrf.Origin);
                            XYZ landingBoundaryProjDir = landingBoundaryTrf.BasisZ;

                            CurveLoop boundary = landing.GetFootprintBoundary();
                            IFCAnyHandle boundaryHnd = ExporterIFCUtils.CreateCurveFromCurveLoop(exporterIFC, boundary,
                                landingBoundaryPlane, landingBoundaryProjDir);
                            if (!IFCAnyHandleUtil.IsNullOrHasNoValue(boundaryHnd))
                            {
                                HashSet<IFCAnyHandle> geomSelectSet = new HashSet<IFCAnyHandle>();
                                geomSelectSet.Add(boundaryHnd);

                                HashSet<IFCAnyHandle> boundaryItems = new HashSet<IFCAnyHandle>();
                                boundaryItems.Add(IFCInstanceExporter.CreateGeometricSet(file, geomSelectSet));

                                IFCAnyHandle boundaryRep = RepresentationUtil.CreateGeometricSetRep(exporterIFC, landing, categoryId, "FootPrint",
                                    contextOfItemsFootPrint, boundaryItems);
                                reps.Add(boundaryRep);
                            }

                            CurveLoop walkingLine = landing.GetStairsPath();
                            IFCAnyHandle walkingLineHnd = ExporterIFCUtils.CreateCurveFromCurveLoop(exporterIFC, walkingLine,
                                landingBoundaryPlane, landingBoundaryProjDir);
                            if (!IFCAnyHandleUtil.IsNullOrHasNoValue(walkingLineHnd))
                            {
                                HashSet<IFCAnyHandle> geomSelectSet = new HashSet<IFCAnyHandle>();
                                geomSelectSet.Add(walkingLineHnd);

                                HashSet<IFCAnyHandle> walkingLineItems = new HashSet<IFCAnyHandle>();
                                walkingLineItems.Add(IFCInstanceExporter.CreateGeometricSet(file, geomSelectSet));

                                IFCAnyHandle walkingLineRep = RepresentationUtil.CreateGeometricSetRep(exporterIFC, landing, categoryId, "Axis",
                                    contextOfItemsFootPrint, walkingLineItems);
                                reps.Add(walkingLineRep);
                            }

                            string landingGUID = ExporterIFCUtils.CreateGUID(landing);
                            string origLandingName = origStairName + " Landing " + index;
                            string landingName = NamingUtil.GetNameOverride(landing, origLandingName);
                            string landingDescription = NamingUtil.GetDescriptionOverride(landing, stairDescription);
                            string landingObjectType = NamingUtil.GetObjectTypeOverride(landing, stairObjectType);
                            IFCAnyHandle landingLocalPlacement = ecData.GetLocalPlacement();
                            string landingElementTag = NamingUtil.CreateIFCElementId(landing);

                            IFCAnyHandle representation = IFCInstanceExporter.CreateProductDefinitionShape(exporterIFC.GetFile(), null, null, reps);

                            IFCAnyHandle landingHnd = IFCInstanceExporter.CreateSlab(file, landingGUID, ownerHistory,
                                landingName, landingDescription, landingObjectType, landingLocalPlacement, representation, landingElementTag,
                                IFCSlabType.Landing);

                            componentHandles.Add(landingHnd);
                            componentExtrusionData.Add(ecData);

                            productWrapper.AddElement(landingHnd, placementSetter.GetLevelInfo(), ecData, false);
                            ExporterCacheManager.HandleToElementCache.Register(landingHnd, landing.Id);
                        }
                    }

                    // Get List of supports to export their geometry.  Supports are not exposed to API, so export as generic Element.
                    ICollection<ElementId> supportIds = stair.GetStairsSupports();
                    index = 0;
                    foreach (ElementId supportId in supportIds)
                    {
                        index++;
                        Element support = doc.GetElement(supportId);

                        using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
                        {
                            ecData.SetLocalPlacement(placementSetter.GetPlacement());
                            ecData.ReuseLocalPlacement = false;

                            GeometryElement supportGeometryElement = support.get_Geometry(geomOptions);
                            BodyData bodyData;
                            BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
                            IFCAnyHandle representation = RepresentationUtil.CreateBRepProductDefinitionShape(app, exporterIFC,
                                support, categoryId, supportGeometryElement, bodyExporterOptions, null, ecData, out bodyData);

                            if (IFCAnyHandleUtil.IsNullOrHasNoValue(representation))
                            {
                                ecData.ClearOpenings();
                                continue;
                            }

                            foreach (ElementId materialId in bodyData.MaterialIds)
                                materialIds.Add(materialId);

                            string supportGUID = ExporterIFCUtils.CreateGUID(support);
                            string origSupportName = origStairName + " Stringer " + index;
                            string supportName = NamingUtil.GetNameOverride(support, origSupportName);
                            string supportDescription = NamingUtil.GetDescriptionOverride(support, stairDescription);
                            string supportObjectType = NamingUtil.GetObjectTypeOverride(support, stairObjectType);
                            IFCAnyHandle supportLocalPlacement = ecData.GetLocalPlacement();
                            string supportElementTag = NamingUtil.CreateIFCElementId(support);

                            IFCAnyHandle type = GetMemberTypeHandle(exporterIFC, support);

                            IFCAnyHandle supportHnd = IFCInstanceExporter.CreateMember(file, supportGUID, ownerHistory,
                                supportName, supportDescription, supportObjectType, supportLocalPlacement, representation, supportElementTag);

                            componentHandles.Add(supportHnd);
                            componentExtrusionData.Add(ecData);

                            productWrapper.AddElement(supportHnd, placementSetter.GetLevelInfo(), ecData, false);

                            ExporterCacheManager.TypeRelationsCache.Add(type, supportHnd);
                        }
                    }

                    StairRampContainerInfo stairRampInfo = new StairRampContainerInfo(stairContainerHnd, componentHandles, null);
                    ExporterCacheManager.StairRampContainerInfoCache.AddStairRampContainerInfo(stair.Id, stairRampInfo);

                    CategoryUtil.CreateMaterialAssociations(stair.Document, exporterIFC, stairContainerHnd, materialIds);

                    ExportMultistoryStair(exporterIFC, stair, numFlights, stairContainerHnd, componentHandles, componentExtrusionData,
                         materialIds, placementSetter, productWrapper);
                }
                tr.Commit();
            }
        }
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Document      doc   = uidoc.Document;

            // Retrieve selected multistory stairs, or all
            // such elements, if nothing is pre-selected:

            List <Element> msss = new List <Element>();

            if (!Util.GetSelectedElementsOrAll(
                    msss, uidoc, typeof(MultistoryStairs)))
            {
                Selection sel = uidoc.Selection;
                message = (0 < sel.GetElementIds().Count)
          ? "Please select some floor elements."
          : "No floor elements found.";
                return(Result.Failed);
            }

            int n = msss.Count;

            Debug.Print("{0} multi story stair{1} selected{2}",
                        n, Util.PluralSuffix(n), Util.DotOrColon(n));

            foreach (MultistoryStairs mss in msss)
            {
                // Get the stairs by `GetAllStairsIds`, then
                // call `Element.GetSubelements` to get the
                // subelements of each stair.

                ISet <ElementId> ids = mss.GetAllStairsIds();

                n = ids.Count;

                Debug.Print(
                    "Multi story stair '{0}' has {1} stair instance{2}{3}",
                    Util.ElementDescription(mss),
                    n, Util.PluralSuffix(n), Util.DotOrColon(n));

                foreach (ElementId id in ids)
                {
                    Element e = doc.GetElement(id);

                    Stairs stair = e as Stairs;

                    Debug.Assert(null != stair,
                                 "expected a stair element");

                    IList <Subelement> ses = e.GetSubelements();

                    n = ses.Count;

                    Debug.Print(
                        "Multi story stair instance '{0}' has {1} subelement{2}{3}",
                        Util.ElementDescription(e),
                        n, Util.PluralSuffix(n), Util.DotOrColon(n));

                    foreach (Subelement se in ses)
                    {
                        Debug.Print(
                            "Subelement {0} of type {1}",
                            se.UniqueId, se.TypeId.IntegerValue);

                        Element           e2  = doc.GetElement(se.UniqueId); // null
                        Element           e2t = doc.GetElement(se.TypeId);   // StairsType
                        IList <ElementId> ps  = se.GetAllParameters();       // 24 parameters
                        GeometryObject    geo = se.GetGeometryObject(null);
                    }
                }
            }
            return(Result.Succeeded);
        }
Exemplo n.º 39
0
        //kendi toollarımızıda formun constructorunda initialize ettim aslında bunu partial class ta da yapabilirdim daha temiz olurdu fakat design file ının bozulmaması için burada yaptım.
        public Form1()
        {
            InitializeComponent();
            Ktn      ktn      = new Ktn();
            Lcw      lcw      = new Lcw();
            Stb      stb      = new Stb();
            Bgr      bgr      = new Bgr();
            Elevator elevator = new Elevator();
            Stairs   stairs   = new Stairs();
            Kiosk    kiosk1   = new Kiosk(1);
            Kiosk    kiosk2   = new Kiosk(2);
            Kiosk    kiosk3   = new Kiosk(3);

            ways.Add(ktn);
            ways.Add(lcw);
            ways.Add(stb);
            ways.Add(bgr);
            ways.Add(elevator);
            ways.Add(stairs);
            ways.Add(kiosk1);
            ways.Add(kiosk2);
            ways.Add(kiosk3);

            comboBox.Location = new Point(panel1.Width * 3 / 2 - 25, 100);
            comboBox.Items.Add(kiosk1);
            comboBox.Items.Add(kiosk2);
            comboBox.Items.Add(kiosk3);
            comboBox.SelectedIndex = 0;
            panel1.Controls.Add(comboBox);

            comboBox2.Location = new Point(panel1.Width * 3 / 2 - 25, 200);
            comboBox2.Items.Add(ktn);
            comboBox2.Items.Add(lcw);
            comboBox2.Items.Add(stb);
            comboBox2.Items.Add(bgr);
            comboBox2.SelectedIndex = 0;
            panel1.Controls.Add(comboBox2);

            button.Location = new Point(panel1.Width * 3 / 2, 250);
            button.Size     = new Size(75, 75);
            button.Text     = "YOLU GÖSTER";
            button.Click   += Button_Click;
            panel1.Controls.Add(button);

            bFloor1.Location = new Point(panel1.Width * 3 / 2 - 200, 200);
            bFloor1.Size     = new Size(75, 75);
            bFloor1.Text     = "1.KAT";
            bFloor1.Click   += BFloor1_Click;
            panel1.Controls.Add(bFloor1);

            bFloor2.Location = new Point(panel1.Width * 3 / 2 - 200, 100);
            bFloor2.Size     = new Size(75, 75);
            bFloor2.Text     = "2.KAT";
            bFloor2.Click   += BFloor2_Click;
            panel1.Controls.Add(bFloor2);


            label.Location = new Point(panel1.Width * 3 / 2 - 25, 350);
            label.AutoSize = true;
            panel1.Controls.Add(label);
        }
Exemplo n.º 40
0
 public void SetStairs(Stairs stairs)
 {
     this.stairs = stairs;
 }
Exemplo n.º 41
0
    protected List<CellLocation> PossibleStairsPerimeterLocations(Stairs stairs)
    {
        List<CellLocation> possibleStairsPerimeterLocations = new List<CellLocation> ();

        foreach (CellLocation location in PotentialStairsPerimeterLocations(stairs)) {

            CellType testType = dungeonGenerator.cellTypeGrid[location.x, location.y, location.z];

            if (StairsPerimeterCanReplace(testType)) {

                possibleStairsPerimeterLocations.Add (location);
            }
        }

        return possibleStairsPerimeterLocations;
    }
Exemplo n.º 42
0
 private static Direction GetDirection(Stairs stair)
 {
     ICollection<ElementId> runIds = stair.GetStairsRuns();
     StairsRun sr = (StairsRun)_doc.GetElement(runIds.First());
     BoundingBoxXYZ bbXYZ = sr.get_BoundingBox(_doc.ActiveView);
     double lx = bbXYZ.Max.X - bbXYZ.Min.X;
     double ly = bbXYZ.Max.Y - bbXYZ.Min.Y;
     if (lx < ly) return Direction.Y;
     else return Direction.X;
 }
Exemplo n.º 43
0
 public void Test2()
 {
     Assert.AreEqual(-1, Stairs.NumberOfSteps(3, 5));
 }
Exemplo n.º 44
0
 public static bool Recognization(Stairs stair)
 {
     Level level = (Level)_doc.GetElement(stair.get_Parameter(BuiltInParameter.STAIRS_BASE_LEVEL_PARAM).AsElementId());
     double offset = stair.get_Parameter(BuiltInParameter.STAIRS_BASE_OFFSET).AsDouble();
     bool isFound;
     _floor = _myLevel.GetFloor(out isFound, level, offset);
     if (!isFound)
     {
         _abandonWriter.WriteAbandonment(stair, AbandonmentTable.LevelNotFound);
         return false;
     }
     _direction = GetDirection(stair);
     return true;
 }
Exemplo n.º 45
0
    public override void updateAI()
    {
        stateMachine.Enemy.BroadcastMessage("playAnimation", "move");

        if (stateMachine.Enemy.getCharacterPath().Length == 0)
        {
            if (movingComoponent.finishedAction)
            {
                if (stateMachine.Enemy.cType == CharacterType.NORMAL)
                {
                    stateMachine.changeState(StateType.IDLE_STATE);
                }
                else
                {
                    stateMachine.changeState(StateType.SEARCHING_ENEMY_STATE);
                }
                return;
            }
        }
        else
        {
            // Wenn grade keine Bewegung mehr stattfindet ...
            if (movingComoponent.finishedAction)
            {
                // ... frage nach, ob Objekt sich zu nächstem Objekt bewegen muss, ...
                if (!movingToTransition)
                {
                    // ... erhalte das nächste Ziel, ...
                    nextTarget = stateMachine.Enemy.popNextTarget();
                    // ... frage nach ob nächstes Ziel eine Tür oder Treppe ist und setze dementsprechend Transitions Bool Wert.
                    if (nextTarget.GetComponent <Door>() != null || nextTarget.GetComponent <Stairs>() != null)
                    {
                        movingToTransition = true;
                    }

                    // Gehe dann zum nächsten Ziel
                    movingComoponent.goToObject(nextTarget);
                }
                // Wenn nächtes Ziel Tür oder Treppe
                else
                {
                    // Wenn Tür ...
                    if (nextTarget.GetComponent <Door>() != null)
                    {
                        // ... setze temp. Variable Tür und benutze Tür
                        Door door = nextTarget.GetComponent <Door>();
                        door.use(movingComoponent);

                        // Keine Transition mehr
                        movingToTransition = false;
                    }
                    // Wenn Treppe ...
                    else
                    {
                        // ... setze temp. Variable für die Treppe
                        Stairs stairs = nextTarget.GetComponent <Stairs>();
                        // Wenn Treppe zum zweiten Stockwerk ...
                        if (stairs.level == 1)
                        {
                            // ... benutze Treppe nach oben ...
                            stairs.goUpstairs(stateMachine.Enemy.gameObject);
                        }
                        // Wenn Treppe zum ersten Stock ...
                        else
                        {
                            // ... benutze Treppe nach unten ...
                            stairs.goDownstairs(stateMachine.Enemy.gameObject);
                        }
                        // Keine Transition mehr
                        movingToTransition = false;
                    }
                }
            }
        }
    }
Exemplo n.º 46
0
 public void Test1()
 {
     Assert.AreEqual(6, Stairs.NumberOfSteps(10, 2));
 }
Exemplo n.º 47
0
 public virtual void ActivateContent(Stairs t){}
Exemplo n.º 48
0
        public void Initialize()
        {
            gameOverPosition.X = 320;
            gameOverPosition.Y = 130;

            device = graphics.GraphicsDevice;

            gameState = new GameState();
            gameStart = new GameStart(device.PresentationParameters.BackBufferWidth, device.PresentationParameters.BackBufferHeight);
            gameState.setState(GameState.state.Level);

            board = new GameBoard(new Vector2(33, 25), new Vector2(device.PresentationParameters.BackBufferWidth, device.PresentationParameters.BackBufferHeight));
            darwin = new Darwin(board);

            String zombieString = "This a zombie,\n don't near him \nas a human!!";
            zombieMessage = new MessageBox(board.getPosition(12, 8).X, board.getPosition(10, 10).Y, zombieString);

            String darwinString = "This is darwin,\n move with arrows, \n z to transform, \n a for actions";
            darwinMessage = new MessageBox(board.getPosition(12, 8).X, board.getPosition(10, 10).Y, darwinString);

            stairs = new Stairs(board);
            if (board.isGridPositionOpen(5, 18))
            {
                stairs.setGridPosition(5, 18);
            }

            // Initial starting position
            darwin.setGridPosition(6, 18);
            if (board.isGridPositionOpen(darwin))
            {
                board.setGridPositionOccupied(darwin.X, darwin.Y);
                darwin.setPosition(board.getPosition(darwin).X, board.getPosition(darwin).Y);
            }

            // Darwin's lag movement
            counterReady = counter = 5;

            zTime = new ZombieTime(board);
            zTimeReset = new ZombieTime(board);

            setPotionPosition(27, 5);

            setBoxes();
            setBoxPattern();
            pattern = new BoxPattern(board, spotsForPattern);

            setVortexes();

            setWalls();

            snake = new Snake(10, 9, 27, 5, 18, 5, board);
            snake2 = new Snake(8, 15, 27, 5, 18, 5, board);
            snake3 = new Snake(21, 9, 27, 5, 18, 5, board);
            snake4 = new Snake(21, 15, 27, 5, 18, 5, board);

            northZombie = new PyroZombie(15, 3, 25, 4, 3, 3, board);
            northZombie.setGridPosition(15, 3);
            northZombie.setCurrentPatrolPoint(new Vector2(27, 3));
            northZombie.setNextPatrolPoint(new Vector2(5, 3));
            
            southZombie = new PyroZombie(15, 20, 25, 4, 20, 20, board);
            southZombie.setGridPosition(15, 20);
            southZombie.setCurrentPatrolPoint(new Vector2(5, 20));
            southZombie.setNextPatrolPoint(new Vector2(27, 20));
           
            eastZombie = new PyroZombie(29, 11, 29, 29, 19, 4, board);
            eastZombie.setGridPosition(29, 11);
            eastZombie.setCurrentPatrolPoint(new Vector2(29, 17));
            eastZombie.setNextPatrolPoint(new Vector2(29, 6));

            westZombie = new PyroZombie(3, 11, 3, 3, 19, 4, board);
            westZombie.setGridPosition(3, 11);
            westZombie.setCurrentPatrolPoint(new Vector2(3, 5));
            westZombie.setNextPatrolPoint(new Vector2(3, 18));

            flames = new LinkedList<Flame>();

        }
Exemplo n.º 49
0
 public void SetStairs(IntVector3 p, Stairs stairs)
 {
     this.Grid[p.Z, p.Y, p.X].Stairs = stairs;
 }
Exemplo n.º 50
0
    /// <summary>
    /// 当碰撞发生时,执行相应事件
    /// </summary>
    /// <param name="hit">碰撞返回的一个碰撞体</param>
    private void ExecuteCollisions(RaycastHit2D hit)
    {
        // 当碰撞检测检测到物体时,每次调用开门事件
        if (moveObject.hit.transform != null)
        {
            // 根据碰撞物体的标签,执行不同的事件
            switch (moveObject.hit.collider.tag)
            {
            case "Door":
                // 正在进行碰撞时执行的事件
                if (moveObject.collider != null)
                {
                    // 获取门的脚本组件
                    Door door = moveObject.hit.collider.gameObject.GetComponent <Door>();
                    // 调用开门的方法
                    Open(door);
                }
                break;

            case "Monster":
                // 正在进行碰撞时执行的事件
                if (moveObject.collider != null)
                {
                    // 获取敌人脚本组件
                    Monster monster = moveObject.hit.collider.gameObject.GetComponent <Monster>();
                    //  获取当前敌人将对我方造成的总伤害值
                    int damagevalue = monster.GetDemageValue(ATK, DEF);
                    // 如果我方生命值高于敌方对我方造成的总伤害,则开启战斗
                    if (IsEnough("HP", damagevalue) && damagevalue >= 0)
                    {
                        Debug.Log("开始战斗");
                        // 打开战斗界面
                        UIManager.instance.battle.StartBattle(gameObject, moveObject.hit.collider.gameObject);
                        // 设置当前的状态为战斗状态
                        CurrentState = UIState.Battle;
                        // 开始一段攻击协程
                        StartCoroutine(Attack(monster));
                    }
                }
                break;

            case "NPC":
                if (moveObject.collider != null)
                {
                    // 设置当前状态为对话状态
                    CurrentState = UIState.Dialogue;
                    // 获取NPC脚本组件
                    NPC npc = moveObject.hit.collider.gameObject.GetComponent <NPC>();
                    // 打开对话界面

                    UIManager.instance.dialogue.StartDialogue(npc.NPCName);
                }
                // 在对话没有结束的情况下如果按下空格键,键执行下一段对话
                if (CurrentState == UIState.Dialogue && Input.GetKeyDown("space"))
                {
                    // 执行下一段对话
                    UIManager.instance.dialogue.CheckNextSentence();
                }
                break;

            case "Props":
                if (moveObject.collider != null)
                {
                    // 设置当前状态为获取道具的状态
                    CurrentState = UIState.GetProps;
                    // 获取道具的脚本组件
                    Props props = moveObject.hit.collider.gameObject.GetComponent <Props>() as Props;
                    // 执行获取道具的方法
                    GetProps(props);
                    // 显示UI
                    UIManager.instance.remainder.GetProps(props.Reminder());
                }
                break;

            case "Stairs":
                // 获取楼梯脚本组件
                Stairs stairs = moveObject.hit.collider.gameObject.GetComponent <Stairs>() as Stairs;
                // 当游戏角色完成移动到楼梯上时,则调用上下楼的方法
                if (moveObject.isMoved)
                {
                    // 进行上去或下来一层楼层
                    LayerManager.instance.DownOrUp(this, stairs.stairState);
                }
                break;
            }
        }
    }
Exemplo n.º 51
0
    /// <summary>
    /// Generates the entrance to stairs.
    /// </summary>
    /// <param name='stairs'>Stairs.</param>
    public void GenerateEntranceToStairs(Stairs stairs)
    {
        // The entrance location
        CellLocation entranceLocation;

        if (stairs.stairsUp) {

            if (stairs.direction == Dir.North)

                // Set the entrance location north of the upward stairs
                entranceLocation = new CellLocation (stairs.location.x, stairs.location.y, stairs.location.z + 1);

            else if (stairs.direction == Dir.South)

                // Set the entrance location south of the upward stairs
                entranceLocation = new CellLocation (stairs.location.x, stairs.location.y, stairs.location.z - 1);

            else if (stairs.direction == Dir.East)

                // Set the entrance location east of the upward stairs
                entranceLocation = new CellLocation (stairs.location.x + 1, stairs.location.y, stairs.location.z);

            else

                // Set the entrance location west of the upward stairs
                entranceLocation = new CellLocation (stairs.location.x - 1, stairs.location.y, stairs.location.z);
        }
        else {

            if (stairs.direction == Dir.North)

                // Set the entrance location north of the downward stairs
                entranceLocation = new CellLocation (stairs.location.x, stairs.location.y, stairs.location.z - 1);

            else if (stairs.direction == Dir.South)

                // Set the entrance location south of the downward stairs
                entranceLocation = new CellLocation (stairs.location.x, stairs.location.y, stairs.location.z + 1);

            else if (stairs.direction == Dir.East)

                // Set the entrance location east of the downward stairs
                entranceLocation = new CellLocation (stairs.location.x - 1, stairs.location.y, stairs.location.z);

            else

                // Set the entrance location west of the downward stairs
                entranceLocation = new CellLocation (stairs.location.x + 1, stairs.location.y, stairs.location.z);
        }

        // The entrance
        Entrance entrance = new Entrance (entranceLocation);

        // State that it is an entrance to stairs
        entrance.entranceToStairs = true;

        // Add the entrance
        AddEntrance (entrance);
    }
Exemplo n.º 52
0
        public void Initialize()
        {
            gameOverPosition.X = 320;
            gameOverPosition.Y = 130;

            device = graphics.GraphicsDevice;

            gameState = new GameState();

            gameStart = new GameStart(device.PresentationParameters.BackBufferWidth, device.PresentationParameters.BackBufferHeight);

            board = new GameBoard(new Vector2(33, 25), new Vector2(device.PresentationParameters.BackBufferWidth, device.PresentationParameters.BackBufferHeight));
            darwin = new Darwin(board);

            zTime = new ZombieTime(board);

            nurseryOne = new Nursery(board, darwin);
            nurseryTwo = new Nursery(board, darwin);

            fatBossZombie = new FatBossZombie(15, 4, 19, 14, 4, 3, darwin, board);
            fatBossZombie.resetGapeMode();
            stairs = new Stairs(board);

            walls = setWallsInLevelSix();

            setLevelState();
            gameState.setState(GameState.state.Start);
        }