public EngineStateZoneTransition(
            Engine engine,
            DoorController departingDoor,
            DoorController arrivingDoor,
            Zone arrivingZone,
            Vector2 newSamusPosition
            )
            : base(engine)
        {
            m_departingDoorController = departingDoor;
            m_arrivingDoorController = arrivingDoor;
            m_arrivingZone = arrivingZone;
            m_newSamusPosition = newSamusPosition;

            if (m_departingDoorController.Side.IsHorizontal)
            {
                m_cameraDistanceToTravel = Zone.SCREEN_WIDTH_IN_PIXELS;
            }
            else
            {
                m_cameraDistanceToTravel = Zone.SCREEN_HEIGHT_IN_PIXELS;
            }
            m_cameraSpeed = m_cameraDistanceToTravel / (Engine.FRAMERATE * 1.0f);

            startTransition();
        }
        public static void initialize(EngineStateGameplay esg, PlayerController pc, Zone startZone)
        {
            GameplayState = esg;
            playerController = pc;
            ActiveZone = startZone;

            ActiveZone.add(pc);
        }
        public static void RegisterZone(Zone zone)
        {
            foreach (Point pt in zone.PositionsOwned)
            {
                if (ZoneMap.ContainsKey(pt))
                    throw new Exception(String.Format("Zone at {0},{1} already registered", pt.X, pt.Y));

                ZoneMap[pt] = zone;
                Zones.Add(zone);
            }
        }
示例#4
0
        /// <summary>
        /// Creates an empty zone using a specified tileset using provided screen construction infos
        /// </summary>
        /// <param name="tileSetpath"></param>
        /// <param name="location"></param>
        /// <returns></returns>
        public static Zone makeEmptyZone(string tileSetpath, List<ScreenConstructionInfo> screens)
        {
            Zone z = new Zone(tileSetpath, screens);

            // default area
            foreach (Point p in z.PositionsOwned)
            {
                for (int i = 0; i < SCREEN_WIDTH_IN_TILES; ++i)
                    for (int j = 0; j < SCREEN_HEIGHT_IN_TILES; ++j)
                    {
                        z.Tiles[p][i, j] = z.m_efi.EMPTY;
                    }
            }

            return z;
        }
        public DoorController(Direction side, Zone zone, Point zoneScreenCoord)
        {
            AnimationController =
                new AnimationController(@"Animation/Data/Doors", @"Sprites/Doors");
            AnimationController.DrawBottomCenter = false;
            AnimationController.Scale = Scale;

            Color = "Metal";
            State = DoorState.Closed;
            Side = side;

            bool zoneWidthOdd = (Zone.SCREEN_WIDTH_IN_TILES % 2) == 1;
            bool zoneHeightOdd = (Zone.SCREEN_HEIGHT_IN_TILES % 2) == 1;

            // Initialize bounding box

            Point pos = Point.Zero;
            Rectangle bounds = Rectangle.Empty;
            if (side == Direction.Up)
            {
                pos =
                    zone.getPixelPositionFromScreenPosition(zoneScreenCoord,
                    new Point(Zone.SCREEN_WIDTH_IN_PIXELS / 2 + (zoneWidthOdd ? -Zone.TILE_WIDTH / 2 : 0),
                                  0));
                bounds = new Rectangle(
                    pos.X - LongEdge / 2,
                    pos.Y - ShortEdge / 2,
                    LongEdge,
                    ShortEdge);
            }
            if (side == Direction.Down)
            {
                pos =
                    zone.getPixelPositionFromScreenPosition(zoneScreenCoord,
                    new Point(Zone.SCREEN_WIDTH_IN_PIXELS / 2 + (zoneWidthOdd ? - Zone.TILE_WIDTH / 2 : 0),
                                    Zone.SCREEN_HEIGHT_IN_PIXELS));
                bounds = new Rectangle(
                    pos.X - LongEdge / 2,
                    pos.Y - ShortEdge / 2,
                    LongEdge,
                    ShortEdge);
            }
            if (side == Direction.Left)
            {
                pos =
                    zone.getPixelPositionFromScreenPosition(zoneScreenCoord,
                        new Point(0,
                                    Zone.SCREEN_HEIGHT_IN_PIXELS / 2 + (zoneHeightOdd ? -Zone.TILE_HEIGHT / 2 : 0)));
                bounds = new Rectangle(
                    pos.X - ShortEdge / 2,
                    pos.Y - LongEdge / 2,
                    ShortEdge,
                    LongEdge);
            }
            if (side == Direction.Right)
            {
                pos =
                    zone.getPixelPositionFromScreenPosition(zoneScreenCoord,
                        new Point(Zone.SCREEN_WIDTH_IN_PIXELS,
                                    Zone.SCREEN_HEIGHT_IN_PIXELS / 2 + (zoneHeightOdd ? -Zone.TILE_HEIGHT / 2 : 0)));
                bounds = new Rectangle(
                    pos.X - ShortEdge / 2,
                    pos.Y - LongEdge / 2,
                    ShortEdge,
                    LongEdge);
            }

            this.m_position = new Vector2(pos.X, pos.Y);
            this.m_collider = new Collider(this, bounds, ColliderType.Scenery);

            this.m_owningZone = zone;
            this.m_zoneScreenCoord = zoneScreenCoord;
        }