Exemplo n.º 1
0
        public override IObject2D CreateObject2D(LandWorld2D landWorld2D, IObject obj)
        {
            MountainLandObject mountainLandObject = obj as MountainLandObject;

            if (mountainLandObject != null)
            {
                return(new MountainObject2D(this, mountainLandObject));
            }
            return(null);
        }
Exemplo n.º 2
0
        public MountainObject2D(IObject2DFactory factory, MountainLandObject landObject) :
            base()
        {
            Texture texture = factory.GetTextureByIndex((int)landObject.LandMountainType);

            if (landObject.LandTransition == LandTransition.NONE)
            {
                Random random = new Random(landObject.Position.X - landObject.Position.Y * landObject.Position.Y);

                switch (random.Next(0, 4))
                {
                case 0:
                    this.ObjectSprite = new Sprite(texture, new IntRect(2 * MainWindow.MODEL_TO_VIEW, 4 * MainWindow.MODEL_TO_VIEW, 2 * MainWindow.MODEL_TO_VIEW, 2 * MainWindow.MODEL_TO_VIEW));
                    break;

                case 1:
                    this.ObjectSprite = new Sprite(texture, new IntRect(0 * MainWindow.MODEL_TO_VIEW, 0 * MainWindow.MODEL_TO_VIEW, 2 * MainWindow.MODEL_TO_VIEW, 2 * MainWindow.MODEL_TO_VIEW));
                    break;

                case 2:
                    this.ObjectSprite = new Sprite(texture, new IntRect(2 * MainWindow.MODEL_TO_VIEW, 0 * MainWindow.MODEL_TO_VIEW, 2 * MainWindow.MODEL_TO_VIEW, 2 * MainWindow.MODEL_TO_VIEW));
                    break;

                case 3:
                    this.ObjectSprite = new Sprite(texture, new IntRect(4 * MainWindow.MODEL_TO_VIEW, 0 * MainWindow.MODEL_TO_VIEW, 2 * MainWindow.MODEL_TO_VIEW, 2 * MainWindow.MODEL_TO_VIEW));
                    break;
                }
            }
            else
            {
                this.ObjectSprite = new Sprite(texture, this.GetTransitionTextureCoord(landObject.LandTransition));
            }

            this.ObjectSprite.Scale = new Vector2f(0.5f, 0.5f);

            this.Position = new Vector2f(landObject.Position.X, landObject.Position.Y);
        }