コード例 #1
0
    private void PlaceExitWall(RoomDirection location)
    {
        //Swing the directions back should become forward and so on
        if (exitPlaced)
        {
            return;
        }
        switch (location)
        {
        case RoomDirection.BACK:
            //Create the exit wall
            exitWall           = (KinematicBody)exitWallScene.Instance();
            exitWall.Transform = new Transform(exitWall.Transform.basis, backWall.Transform.origin);
            exitWall.RotateY(Mathf.Deg2Rad(90));
            AddChild(exitWall);
            backWall.QueueFree();
            //Instance the exit wall her and position it to align
            break;

        case RoomDirection.FRONT:
            //Create the exit wall
            exitWall           = (KinematicBody)exitWallScene.Instance();
            exitWall.Transform = new Transform(exitWall.Transform.basis, frontWall.Transform.origin);
            exitWall.RotateY(Mathf.Deg2Rad(-90));
            AddChild(exitWall);
            frontWall.QueueFree();
            break;

        case RoomDirection.LEFT:
            //Create the exit wall
            exitWall           = (KinematicBody)exitWallScene.Instance();
            exitWall.Transform = new Transform(exitWall.Transform.basis, leftWall.Transform.origin);
            AddChild(exitWall);
            leftWall.QueueFree();
            break;

        case RoomDirection.RIGHT:
            //Create the exit wall
            exitWall           = (KinematicBody)exitWallScene.Instance();
            exitWall.Transform = new Transform(exitWall.Transform.basis, rightWall.Transform.origin);
            AddChild(exitWall);
            rightWall.QueueFree();
            break;

        case RoomDirection.TOP:
            //Create the exit wall
            exitWall           = (KinematicBody)exitWallScene.Instance();
            exitWall.Transform = new Transform(exitWall.Transform.basis, roofWall.Transform.origin);
            exitWall.RotateX(Mathf.Deg2Rad(90));
            AddChild(exitWall);
            roofWall.QueueFree();
            break;

        case RoomDirection.BOTTOM:
            //Create the exit wall
            exitWall           = (KinematicBody)exitWallScene.Instance();
            exitWall.Transform = new Transform(exitWall.Transform.basis, floorWall.Transform.origin);
            exitWall.RotateX(Mathf.Deg2Rad(-90));
            AddChild(exitWall);
            floorWall.QueueFree();
            break;
        }
    }