public override IObject2D CreateObject2D(LandWorld2D landWorld2D, IObject obj)
        {
            GrassElementLandObject grassElementLandObject = obj as GrassElementLandObject;

            if (grassElementLandObject != null)
            {
                return(new GrassElementObject2D(this, grassElementLandObject));
            }
            return(null);
        }
Beispiel #2
0
        public GrassElementObject2D(IObject2DFactory factory, GrassElementLandObject landObject) :
            base()
        {
            Texture texture = factory.GetTextureByIndex((int)landObject.LandGrassType);

            // Random random = new Random(landObject.Position.X - landObject.Position.Y * landObject.Position.Y);

            int elementIndex = landObject.ElementIndex;

            if (landObject.LandGrassType == GrassType.DRY)
            {
                elementIndex = 0;
            }

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

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

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