Пример #1
0
        public Key(LevelState parent, Vector2 position, LevelKeyModule.KeyColor color)
        {
            this.parentWorld = parent;
            this.position    = position;
            this.velocity    = Vector2.Zero;
            this.dimensions  = new Vector2(48f, 48f);

            this.color = color;

            isKnockedBack   = false;
            knockedBackTime = 0.0f;

            keyGraphic = AnimationLib.getFrameAnimationSet("keyPic");
        }
Пример #2
0
        public KeyDoor(LevelState parent, Vector2 position, LevelKeyModule.KeyColor color, DoorDirection directions)
        {
            this.parentWorld = parent;
            this.position    = position;
            this.velocity    = Vector2.Zero;
            dimensions       = GlobalGameConstants.TileSize;

            this.color      = color;
            this.directions = directions;

            keyGraphic = AnimationLib.getFrameAnimationSet("keyPic");

            // reposition and resize the door to fill the current wall
            {
                this.position.X -= this.position.X % GlobalGameConstants.TileSize.X;
                this.position.Y -= this.position.Y % GlobalGameConstants.TileSize.Y;

                if (directions == DoorDirection.EastWest)
                {
                    while (parentWorld.Map.hitTestWall(this.position - new Vector2(1.0f, 0.0f)) != true)
                    {
                        this.position.X -= GlobalGameConstants.TileSize.X;
                    }

                    while (parentWorld.Map.hitTestWall(this.position + new Vector2(this.dimensions.X, 0.0f)) != true)
                    {
                        this.dimensions.X += GlobalGameConstants.TileSize.X;
                    }
                }
                else if (directions == DoorDirection.NorthSouth)
                {
                    while (parentWorld.Map.hitTestWall(this.position - new Vector2(0.0f, 1.0f)) != true)
                    {
                        this.position.Y -= GlobalGameConstants.TileSize.Y;
                    }

                    while (parentWorld.Map.hitTestWall(this.position + new Vector2(0.0f, this.dimensions.Y)) != true)
                    {
                        this.dimensions.Y += GlobalGameConstants.TileSize.Y;
                    }
                }
            }
        }