예제 #1
0
        public AltitudeObject2D(IObject2DFactory factory, AltitudeLandObject landObject)
        {
            Texture texture = factory.GetTextureByIndex(0);

            this.ObjectSprite = new Sprite(texture, this.GetTransitionTextureCoord(landObject.LandTransition));

            this.ObjectSprite.Position = this.ObjectSprite.Position;

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

            this.Position = new Vector2f(landObject.Position.X, landObject.Position.Y);
        }
예제 #2
0
        public WaterObject2D(IObject2DFactory factory, WaterLandObject landObject)
        {
            Texture texture = factory.GetTextureByIndex(0);

            this.textureRect  = this.GetTransitionTextureCoord(landObject.LandTransition);
            this.ObjectSprite = new Sprite(texture, this.textureRect);

            this.ObjectSprite.Position = this.ObjectSprite.Position;
            this.ObjectSprite.Color    = new Color(255, 255, 255, 127);
            this.ObjectSprite.Scale    = new Vector2f(0.5f, 0.5f);

            this.Position = new Vector2f(landObject.Position.X, landObject.Position.Y);
        }
예제 #3
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);
        }
예제 #4
0
        public MountainElementObject2D(IObject2DFactory factory, MountainElementLandObject landObject) :
            base()
        {
            Texture texture = factory.GetTextureByIndex(0);

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

            int elementIndex = landObject.ElementIndex;

            //if (landObject.LandMountainType == MountainType.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);
        }
예제 #5
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);
        }
예제 #6
0
        public PlayerEntity2D(IObject2DFactory factory, PlayerEntity playerEntity) :
            base(factory, playerEntity)
        {
            Texture texture = factory.GetTextureByIndex(0);

            IntRect[] walkTop = new IntRect[]
            {
                new IntRect(2 * 32, 0 * 32, 32, 32),
                new IntRect(11 * 32, 5 * 32, 32, 32)
            };

            Animation animationWalkTop = new Animation(walkTop, Time.FromMilliseconds(250), AnimationType.LOOP);

            IntRect[] walkBot = new IntRect[]
            {
                new IntRect(2 * 32, 2 * 32, 32, 32),
                new IntRect(2 * 32, 3 * 32, 32, 32)
            };

            Animation animationWalkBot = new Animation(walkBot, Time.FromMilliseconds(250), AnimationType.LOOP);

            IntRect[] walkRight = new IntRect[]
            {
                new IntRect(1 * 32, 2 * 32, 32, 32),
                new IntRect(1 * 32, 3 * 32, 32, 32)
            };

            Animation animationWalkRight = new Animation(walkRight, Time.FromMilliseconds(250), AnimationType.LOOP);

            IntRect[] walkLeft = new IntRect[]
            {
                new IntRect(0 * 32, 3 * 32, 32, 32),
                new IntRect(1 * 32, 0 * 32, 32, 32)
            };

            Animation animationWalkLeft = new Animation(walkLeft, Time.FromMilliseconds(250), AnimationType.LOOP);


            IntRect[] idleTop = new IntRect[]
            {
                new IntRect(9 * 32, 4 * 32, 32, 32)
            };

            Animation animationIdleTop = new Animation(idleTop, Time.FromMilliseconds(250), AnimationType.LOOP);

            IntRect[] idleBot = new IntRect[]
            {
                new IntRect(2 * 32, 1 * 32, 32, 32)
            };

            Animation animationIdleBot = new Animation(idleBot, Time.FromMilliseconds(250), AnimationType.LOOP);

            IntRect[] idleRight = new IntRect[]
            {
                new IntRect(10 * 32, 4 * 32, 32, 32)
            };

            Animation animationIdleRight = new Animation(idleRight, Time.FromMilliseconds(250), AnimationType.LOOP);

            IntRect[] idleLeft = new IntRect[]
            {
                new IntRect(9 * 32, 6 * 32, 32, 32)
            };

            Animation animationIdleLeft = new Animation(idleLeft, Time.FromMilliseconds(250), AnimationType.LOOP);

            this.animationsList.Add(animationIdleTop);
            this.animationsList.Add(animationIdleBot);
            this.animationsList.Add(animationIdleRight);
            this.animationsList.Add(animationIdleLeft);

            this.animationsList.Add(animationWalkTop);
            this.animationsList.Add(animationWalkBot);
            this.animationsList.Add(animationWalkRight);
            this.animationsList.Add(animationWalkLeft);

            this.ObjectSprite = new Sprite(texture, new IntRect(2 * 32, 1 * 32, 32, 32));

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

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

            WalkKinematicAbility walkKinematicAbility = this.characterEntity.GetAbilityById("kinematic.walk") as WalkKinematicAbility;

            walkKinematicAbility.MovingStateUpdated += OnMovingStateUpdated;
        }