Ejemplo n.º 1
0
        public WeaponSwing(Vector2 position, WeaponSwingType gettype, SpriteEffects spreffect)
            : base()
        {
            // Link properties to instance
            this.world = GameWorld.GetInstance;

            // general properties
            this.swingtype = gettype;
            this.position = position;
            this.sprite_effect = spreffect;
            this.angle = -3;

            switch (swingtype)
            {
                case WeaponSwingType.Stab01:
                    this.sprite = world.Content.Load<Texture2D>(@"gfx\effects\weapon\0.stabO2.1_0");
                    if (sprite_effect == SpriteEffects.FlipHorizontally)
                        this.position.X += 80;
                    keepAliveTimer = (float)ResourceManager.GetInstance.
                                gameTime.TotalGameTime.Seconds + 0.12f;
                    break;
                case WeaponSwingType.Swing01:
                    this.sprite = world.Content.Load<Texture2D>(@"gfx\effects\weapon\0.swingT2.2_0");
                    if (sprite_effect == SpriteEffects.FlipHorizontally)
                        this.angle = -11.5f;
                    else
                        this.angle = -13.6f;
                    keepAliveTimer = (float)ResourceManager.GetInstance.
                                gameTime.TotalGameTime.Seconds + 0.06f;
                    break;
                case WeaponSwingType.Swing02:
                    this.sprite = world.Content.Load<Texture2D>(@"gfx\effects\weapon\0.swingT3.2_0");
                    break;
                case WeaponSwingType.Swing03:
                    this.sprite = world.Content.Load<Texture2D>(@"gfx\effects\weapon\0.swingTF.3_0");
                    break;
            }

            this.spriteFrame = new Rectangle(0, 0, (int)sprite.Width, (int)sprite.Height);
            this.origin = new Vector2(SpriteFrame.Width * 0.5f, SpriteFrame.Height * 0.5f);
        }
Ejemplo n.º 2
0
        public ActionScreen(Game game, SpriteFont gameFont)
            : base(game)
        {
            this.gameFont = gameFont;

            Content = (ContentManager)Game.Services.GetService(typeof(ContentManager));
            spriteBatch = (SpriteBatch)Game.Services.GetService(typeof(SpriteBatch));
            gfxdevice = (GraphicsDevice)Game.Services.GetService(typeof(GraphicsDevice));

            cam = Camera2d.Instance;

            GameWorld createworld = GameWorld.CreateInstance(game, cam);
            world = createworld;
            world.Active = true;

            hud = new HUDScreen(game);
            Components.Add(hud);
            hud.Active = true;

            //topmessage = new TopMessageScreen(game);
            //Components.Add(topmessage);
            //topmessage.Active = false;
        }
Ejemplo n.º 3
0
 public static GameWorld CreateInstance(Game game, Camera2d camref)
 {
     lock (_mutex) // now I can claim some form of thread safety...
     {
         if (mInstance == null)
         {
             mInstance = new GameWorld(game, camref);
         }
     }
     return mInstance;
 }
        public override void Initialize()
        {
            world = GameWorld.GetInstance;
            base.Initialize();
Ejemplo n.º 5
0
        public override void Update(GameTime gameTime)
        {
            // Connect Global instances
            if (screenmanager == null)
                screenmanager = ScreenManager.Instance;

            if (world == null)
                world = GameWorld.GetInstance;

            // Apply Gravity
            Position += new Vector2(0, 1) * 250 * (float)gameTime.ElapsedGameTime.TotalSeconds;

            // create NPC rectangle
            Rectangle NPC = new Rectangle((int)this.Position.X, (int)this.Position.Y,
                                               this.SpriteFrame.Width, this.SpriteFrame.Height);

            // Animate NPC
            Animate(gameTime);

            // check intersection with player
            if (NPC.Intersects
                (new Rectangle((int)world.playerSprite.Position.X + (int)(world.playerSprite.SpriteFrame.Width * 0.25f),
                    (int)world.playerSprite.Position.Y,
                    (int)world.playerSprite.SpriteFrame.Width - (int)(world.playerSprite.SpriteFrame.Width * 0.25f),
                    (int)world.playerSprite.SpriteFrame.Height)
                ))
            {
                // set player state
                world.playerSprite.CollideNPC = true;

                previousTime = (float)gameTime.ElapsedGameTime.TotalSeconds + 0.8f;
                transperancy = 0.8f;

                // Update keyboard states
                newState = Keyboard.GetState();

                // Check for Keyboard input
                if (CheckKey(Keys.Space) || CheckKey(Keys.Enter))
                {
                    screenmanager.messageScreen(true, new Rectangle((int)Position.X, (int)Position.Y, SpriteFrame.Width, SpriteFrame.Height), this.entityName, this.entityScript);
                }

                // Save keyboard states
                oldState = newState;
            }
            else
            {
                // no collision, remove NPC nametag
                if (previousTime > 0)
                {
                    previousTime -= (float)gameTime.ElapsedGameTime.TotalSeconds;
                    transperancy = previousTime;
                }
            }
        }
Ejemplo n.º 6
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime); // Player Update Routines

            keyboardStateCurrent = Keyboard.GetState();
            previousState = this.state;
            previousSpriteEffect = this.spriteEffect;
            previousDirection = this.Direction;

            // reset effect state
            if (!collideWarp)
            {
                this.color = Color.White;
                this.effectCounter = 0;
            }

            if (Active)
            {
                switch (state)
                {
                    #region state skillactive
                    case EntityState.Skill:

                            // Move the Character
                            OldPosition = Position;

                            // lock player at position
                            this.Direction.X = 0;

                            // Walk speed
                            Position += Direction * Speed * (float)gameTime.ElapsedGameTime.TotalSeconds;

                        break;

                    #endregion
                    #region state cooldown
                    case EntityState.Cooldown:

                        // reduce timer
                        previousGameTimeMsec -= (float)gameTime.ElapsedGameTime.TotalSeconds;

                        if (previousGameTimeMsec < 0)
                        {
                            previousGameTimeMsec = 0;

                            spriteFrame.X = 0;
                            state = EntityState.Stand;
                        }

                        // Apply Gravity
                        Position += new Vector2(0, 1) * 250 * (float)gameTime.ElapsedGameTime.TotalSeconds;

                        break;

                    #endregion
                    #region state swinging
                    case EntityState.Swing:

                        Speed = 0;
                        Direction = Vector2.Zero;
                        Velocity = Vector2.Zero;

                        // Move the Character
                        OldPosition = Position;

                        // reduce timer
                        previousGameTimeMsec -= (float)gameTime.ElapsedGameTime.TotalSeconds;

                        // Player animation
                        if (prevspriteframe != spriteframe)
                        {
                            prevspriteframe = spriteframe;
                            for (int i = 0; i < spritepath.Length; i++)
                            {
                                spritename = attackSprite + spriteframe.ToString();
                                playerStore.activePlayer.spriteOfset[i] = getoffset(i);
                            }
                        }

                        if (previousGameTimeMsec < 0)
                        {
                            previousGameTimeMsec = (float)gameTime.ElapsedGameTime.TotalSeconds + 0.10f;

                            // set sprite frames
                            spriteframe++;

                            if (spriteframe > maxspriteframe)
                            {
                                spriteframe = maxspriteframe;
                                previousGameTimeMsec = (float)gameTime.ElapsedGameTime.TotalSeconds + 0.10f;

                                // make sure the world is connected
                                if (world == null)
                                    world = GameWorld.GetInstance;

                                // create swing effect
                                if (spriteEffect == SpriteEffects.FlipHorizontally)
                                {
                                    Vector2 pos = new Vector2(this.Position.X + this.SpriteFrame.Width * 1.6f, this.Position.Y + this.SpriteFrame.Height * 0.7f);

                                    world.newEffect.Add(new DamageArea(new Vector2(pos.X - 50, pos.Y), new Rectangle(0, 0, 80, 10), false, 1,
                                        (float)gameTime.ElapsedGameTime.TotalSeconds + 0.2f, 100));
                                    NetworkGameData.Instance.sendDmgArea(getPlayer().Name, new Vector2(pos.X - 50, pos.Y), new Vector2(80, 10), false.ToString(), 1, 0.20f, 100);

                                    world.newEffect.Add(new WeaponSwing(pos, WeaponSwingType.Swing01, spriteEffect));
                                }
                                else
                                {
                                    Vector2 pos = new Vector2(this.Position.X - this.SpriteFrame.Width * 0.6f, this.Position.Y + this.SpriteFrame.Height * 0.7f);

                                    world.newEffect.Add(new DamageArea(new Vector2(pos.X - 18, pos.Y), new Rectangle(0, 0, 80, 10), false, 1,
                                        (float)gameTime.ElapsedGameTime.TotalSeconds + 0.2f, 100));
                                    NetworkGameData.Instance.sendDmgArea(getPlayer().Name, new Vector2(pos.X - 18, pos.Y), new Vector2(80, 10), false.ToString(), 1, 0.20f, 100);

                                    world.newEffect.Add(new WeaponSwing(pos, WeaponSwingType.Swing01, spriteEffect));
                                }

                                // start cooldown
                                state = EntityState.Cooldown;
                            }
                        }

                        // Apply Gravity
                        Position += new Vector2(0, 1) * 250 * (float)gameTime.ElapsedGameTime.TotalSeconds;

                        break;
                    #endregion
                    #region state stabbing
                    case EntityState.Stab:

                        Speed = 0;
                        Direction = Vector2.Zero;
                        Velocity = Vector2.Zero;
                        Vector2 extend_position = Vector2.Zero;

                        // Move the Character
                        OldPosition = Position;

                        // reduce timer
                        previousGameTimeMsec -= (float)gameTime.ElapsedGameTime.TotalSeconds;

                        // long stab, extend weaponswing and DMG-area position
                        if (attackSprite.EndsWith("F_"))
                            extend_position = new Vector2(22, 0);

                        // Player animation
                        if (prevspriteframe != spriteframe)
                        {
                            prevspriteframe = spriteframe;
                            for (int i = 0; i < spritepath.Length; i++)
                            {
                                spritename = attackSprite + spriteframe.ToString();
                                playerStore.activePlayer.spriteOfset[i] = getoffset(i);
                            }
                        }

                        if (previousGameTimeMsec < 0)
                        {
                            previousGameTimeMsec = (float)gameTime.ElapsedGameTime.TotalSeconds + 0.10f;

                            // set sprite frames
                            spriteframe++;

                            if (spriteframe > maxspriteframe)
                            {
                                spriteframe = maxspriteframe;
                                previousGameTimeMsec = (float)gameTime.ElapsedGameTime.TotalSeconds + 0.10f;

                                // make sure the world is connected
                                if (world == null)
                                    world = GameWorld.GetInstance;

                                // create stab effect and DMG-area
                                if (spriteEffect == SpriteEffects.FlipHorizontally)
                                {
                                    Vector2 pos = new Vector2(this.Position.X + this.SpriteFrame.Width * 0.3f, this.Position.Y + this.SpriteFrame.Height * 0.7f) + extend_position;

                                    world.newEffect.Add(new DamageArea(new Vector2(pos.X + 15, pos.Y), new Rectangle(0, 0, 80, 10), false, 1,
                                        (float)gameTime.ElapsedGameTime.TotalSeconds + 0.1f, 100));

                                    NetworkGameData.Instance.sendDmgArea(getPlayer().Name, new Vector2(pos.X + 15, pos.Y), new Vector2(80, 10), false.ToString(), 1, 0.10f, 100);

                                    world.newEffect.Add(new WeaponSwing(pos, WeaponSwingType.Stab01, spriteEffect));

                                }
                                else
                                {
                                    Vector2 pos = new Vector2(this.Position.X - this.SpriteFrame.Width * 0.7f, this.Position.Y + this.SpriteFrame.Height * 0.7f) - extend_position;

                                    world.newEffect.Add(new DamageArea(new Vector2(pos.X - 18, pos.Y), new Rectangle(0, 0, 80, 10), false, 1,
                                        (float)gameTime.ElapsedGameTime.TotalSeconds + 0.1f, 100));

                                    NetworkGameData.Instance.sendDmgArea(getPlayer().Name, new Vector2(pos.X - 18, pos.Y), new Vector2(80, 10), false.ToString(), 1, 0.10f, 100);

                                    world.newEffect.Add(new WeaponSwing(pos, WeaponSwingType.Stab01, spriteEffect));
                                }

                                // reset sprite frame and change state
                                state = EntityState.Cooldown;
                            }
                        }

                        // Apply Gravity
                        Position += new Vector2(0, 1) * 250 * (float)gameTime.ElapsedGameTime.TotalSeconds;

                        break;
                    #endregion
                    #region state shooting
                    case EntityState.Shoot:

                        Speed = 0;
                        Direction = Vector2.Zero;
                        Velocity = Vector2.Zero;

                        // Move the Character
                        OldPosition = Position;

                        // reduce timer
                        previousGameTimeMsec -= (float)gameTime.ElapsedGameTime.TotalSeconds;

                        // Player animation
                        if (prevspriteframe != spriteframe)
                        {
                            prevspriteframe = spriteframe;
                            for (int i = 0; i < spritepath.Length; i++)
                            {
                                spritename = "shoot1_" + spriteframe.ToString();
                                playerStore.activePlayer.spriteOfset[i] = getoffset(i);
                            }
                        }

                        if (previousGameTimeMsec < 0)
                        {
                            spriteframe++;

                            if (keyboardStateCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftAlt)
                                || keyboardStateCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.D1))
                            {
                                // Later = charge arrow skill
                                if (spriteframe > 1)
                                    spriteframe = 1;
                            }
                            else
                            {
                                if (spriteframe > 2)
                                {
                                    // Update server to release arrow
                                    NetworkGameData.Instance.sendPlayerData("Release", getPlayer());
                                    spriteframe = 0;
                                    spriteFrame.X = 0;
                                }
                            }
                        }

                        // Apply Gravity
                        Position += new Vector2(0, 1) * 250 * (float)gameTime.ElapsedGameTime.TotalSeconds;

                        break;
                    #endregion
                    #region state sit
                    case EntityState.Sit:

                        Speed = 0;
                        Direction = Vector2.Zero;
                        Velocity = Vector2.Zero;

                        if (keyboardStateCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Space))
                        {
                            //state = EntityState.Stand;

                            NetworkGameData.Instance.sendPlayerData("Stand", getPlayer());
                        }
                        else if (keyboardStateCurrent.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.Up) &&
                                 keyboardStatePrevious.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Up))
                        {
                            //state = EntityState.Stand;

                            NetworkGameData.Instance.sendPlayerData("Stand", getPlayer());
                        }
                        //else if (keyboardStateCurrent.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.Insert) &&
                        //         keyboardStatePrevious.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Insert))
                        //{
                        //    state = EntityState.Stand;
                        //}

                        // Move the Character
                        OldPosition = Position;

                        // Player animation
                        if (prevspriteframe != spriteframe)
                        {
                            prevspriteframe = spriteframe;
                            for (int i = 0; i < spritepath.Length; i++)
                            {
                                spritename = "sit_0";
                                playerStore.activePlayer.spriteOfset[i] = getoffset(i);
                            }
                        }

                        // Apply Gravity
                        Position += new Vector2(0, 1) * 250 * (float)gameTime.ElapsedGameTime.TotalSeconds;

                        break;
                    #endregion
                    #region state Rope
                    case EntityState.Rope:

                        Speed = 0;
                        Direction = Vector2.Zero;
                        Velocity = Vector2.Zero;
                        spriteEffect = SpriteEffects.None;

                        if (keyboardStateCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Down) && !HoldPosition)
                        {
                            // move player location (make ActiveMap tile check here in the future)
                            this.Direction.Y = MOVE_DOWN;
                            this.Speed = PLAYER_SPEED * 0.75f;

                            if (!keyboardStatePrevious.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Down))
                                NetworkGameData.Instance.sendPlayerData("Down", getPlayer());

                            // reduce timer
                            previousGameTimeMsec -= (float)gameTime.ElapsedGameTime.TotalSeconds;

                            if (previousGameTimeMsec < 0)
                            {
                                previousGameTimeMsec = (float)gameTime.ElapsedGameTime.TotalSeconds + 0.10f;
                                spriteframe++;
                            }

                            // double check frame if previous state has higher X
                            if (spriteframe > 1)
                                spriteframe = 0;
                        }
                        else if (keyboardStateCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Up) && !HoldPosition)
                        {
                            // move player location (make ActiveMap tile check here in the future)
                            this.Direction.Y = MOVE_UP;
                            this.Speed = PLAYER_SPEED * 0.75f;

                            if(!keyboardStatePrevious.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Up))
                                NetworkGameData.Instance.sendPlayerData("Up", getPlayer());

                            // reduce timer
                            previousGameTimeMsec -= (float)gameTime.ElapsedGameTime.TotalSeconds;

                            if (previousGameTimeMsec < 0)
                            {
                                previousGameTimeMsec = (float)gameTime.ElapsedGameTime.TotalSeconds + 0.10f;
                                spriteframe++;
                            }

                            // double check frame if previous state has higher X
                            if (spriteframe > 1)
                                spriteframe = 0;
                        }
                        else
                        {
                            this.Direction = Vector2.Zero;
                            this.Speed = 0;

                            if(keyboardStatePrevious.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Up) ||
                               keyboardStatePrevious.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Down))
                                NetworkGameData.Instance.sendPlayerData("Stop", getPlayer());
                        }

                        //Player animation
                        if (prevspriteframe != spriteframe)
                        {
                            prevspriteframe = spriteframe;
                            for (int i = 0; i < spritepath.Length; i++)
                            {
                                spritename = "rope_" + spriteframe.ToString();
                                playerStore.activePlayer.spriteOfset[i] = getoffset(i);
                            }
                        }

                        // Move the Character
                        OldPosition = Position;

                        // avoid climbing air
                        if (!collideRope)
                            Direction = Vector2.Zero;

                        // Climb speed
                        Position += Direction * Speed * (float)gameTime.ElapsedGameTime.TotalSeconds;

                        break;
                    #endregion
                    #region state Ladder
                    case EntityState.Ladder:

                        Speed = 0;
                        Direction = Vector2.Zero;
                        Velocity = Vector2.Zero;
                        spriteEffect = SpriteEffects.None;

                        if (keyboardStateCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Down) && !HoldPosition)
                        {
                            // move player location (make ActiveMap tile check here in the future)
                            this.Direction.Y = MOVE_DOWN;
                            this.Speed = PLAYER_SPEED * 0.75f;

                            if (!keyboardStatePrevious.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Down))
                                NetworkGameData.Instance.sendPlayerData("Down", getPlayer());

                            // reduce timer
                            previousGameTimeMsec -= (float)gameTime.ElapsedGameTime.TotalSeconds;

                            if (previousGameTimeMsec < 0)
                            {
                                previousGameTimeMsec = (float)gameTime.ElapsedGameTime.TotalSeconds + 0.10f;
                                spriteframe++;
                            }

                            // double check frame if previous state has higher X
                            if (spriteframe > 1)
                                spriteframe = 0;
                        }
                        else if (keyboardStateCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Up) && !HoldPosition)
                        {
                            // move player location (make ActiveMap tile check here in the future)
                            this.Direction.Y = MOVE_UP;
                            this.Speed = PLAYER_SPEED * 0.75f;

                            if(!keyboardStatePrevious.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Up))
                                NetworkGameData.Instance.sendPlayerData("Up", getPlayer());

                            // reduce timer
                            previousGameTimeMsec -= (float)gameTime.ElapsedGameTime.TotalSeconds;

                            if (previousGameTimeMsec < 0)
                            {
                                previousGameTimeMsec = (float)gameTime.ElapsedGameTime.TotalSeconds + 0.10f;
                                spriteframe++;
                            }

                            // double check frame if previous state has higher X
                            if (spriteframe > 1)
                                spriteframe = 0;
                        }
                        else
                        {
                            this.Direction = Vector2.Zero;
                            this.Speed = 0;

                            if(keyboardStatePrevious.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Up) ||
                               keyboardStatePrevious.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Down))
                                NetworkGameData.Instance.sendPlayerData("Stop", getPlayer());
                        }

                        //Player animation
                        if (prevspriteframe != spriteframe)
                        {
                            prevspriteframe = spriteframe;
                            for (int i = 0; i < spritepath.Length; i++)
                            {
                                spritename = "ladder_" + spriteframe.ToString();
                                playerStore.activePlayer.spriteOfset[i] = getoffset(i);
                            }
                        }

                        // Move the Character
                        OldPosition = Position;

                        // avoid climbing air
                        if (!collideLadder)
                            Direction = Vector2.Zero;

                        // Climb speed
                        Position += Direction * Speed * (float)gameTime.ElapsedGameTime.TotalSeconds;

                        break;
                    #endregion
                    #region state stand
                    case EntityState.Stand:

                        Speed = 0;
                        Direction = Vector2.Zero;
                        Velocity = Vector2.Zero;

                        if (keyboardStateCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right) && !HoldPosition)
                        {
                            spriteframe = 0;
                            spriteEffect = SpriteEffects.FlipHorizontally;
                            NetworkGameData.Instance.sendPlayerData("Right", getPlayer());
                        }
                        else if (keyboardStateCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left) && !HoldPosition)
                        {
                            spriteframe = 0;
                            spriteEffect = SpriteEffects.None;
                            NetworkGameData.Instance.sendPlayerData("Left", getPlayer());
                        }
                        else if (keyboardStateCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Space) && !HoldPosition)
                        {
                            if (!collideNPC)
                            {
                                spriteframe = 0;
                                Velocity += new Vector2(0, -1.6f); // Add an upward impulse
                                NetworkGameData.Instance.sendPlayerData("Jump", getPlayer());
                            }
                        }
                        else if (keyboardStateCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Insert) && !HoldPosition)
                        {
                            spriteframe = 0;
                            NetworkGameData.Instance.sendPlayerData("Sit", getPlayer());
                        }
                        else if (keyboardStateCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Up) && !HoldPosition)
                        {
                            spriteframe = 0;
                            NetworkGameData.Instance.sendPlayerData("Up", getPlayer());
                        }
                        else if (keyboardStateCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftAlt) && !HoldPosition)
                        {
                            NetworkGameData.Instance.sendPlayerData("Action", getPlayer());

                            // check if weapon is equiped
                            if (getPlayer().equipment.item_list.FindAll(delegate(Item item) { return item.Type == ItemType.Weapon; }).Count > 0)
                            {
                                WeaponType weapontype = getPlayer().equipment.item_list.Find(delegate(Item item) { return item.Type == ItemType.Weapon; }).WeaponType;

                                // check the weapon type
                                if (weapontype == WeaponType.Bow)
                                {
                                    //previousGameTimeMsec = (float)gameTime.ElapsedGameTime.TotalSeconds + (float)((350 - playerStore.activePlayer.ASPD * 12) * 0.0006f) + 0.05f;
                                    spriteframe = 0;
                                    //state = EntityState.Shoot;
                                }
                                else
                                {
                                    previousGameTimeMsec = (float)gameTime.ElapsedGameTime.TotalSeconds + (float)((350 - playerStore.activePlayer.ASPD * 12) * 0.0006f) + 0.05f;

                                    spriteframe = 0;
                                    GetattackSprite(weapontype);
                                }
                            }
                        }

                        // Move the Character
                        OldPosition = Position;

                        // reduce timer
                        previousGameTimeMsec -= (float)gameTime.ElapsedGameTime.TotalSeconds;

                        if (previousGameTimeMsec < 0)
                        {
                            previousGameTimeMsec = (float)gameTime.ElapsedGameTime.TotalSeconds + 0.10f;
                            spriteframe++;
                            if (spriteframe > 4)
                                spriteframe = 0;
                        }

                        // Player animation
                        if (prevspriteframe != spriteframe)
                        {
                            prevspriteframe = spriteframe;
                            for (int i = 0; i < spritepath.Length; i++)
                            {
                                if (getPlayer().equipment.item_list.FindAll(x => x.Slot == ItemSlot.Weapon).Count > 0)
                                {
                                    Item weapon = getPlayer().equipment.item_list.Find(x => x.Slot == ItemSlot.Weapon);

                                    if (weapon.WeaponType == WeaponType.Two_handed_Axe ||
                                       weapon.WeaponType == WeaponType.Two_handed_Spear ||
                                       weapon.WeaponType == WeaponType.Two_handed_Sword)
                                        spritename = "stand2_" + spriteframe.ToString();
                                    else
                                        spritename = "stand1_" + spriteframe.ToString();
                                }
                                else
                                    spritename = "stand1_" + spriteframe.ToString();

                                    playerStore.activePlayer.spriteOfset[i] = getoffset(i);
                            }
                        }

                        // Apply Gravity
                        Position += new Vector2(0, 1) * 250 * (float)gameTime.ElapsedGameTime.TotalSeconds;

                        break;
                    #endregion
                    #region state walk
                    case EntityState.Walk:

                        Speed = 0;
                        Direction = Vector2.Zero;
                        Velocity = Vector2.Zero;

                        if (!keyboardStatePrevious.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left) &&
                            keyboardStateCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right) &&
                            !HoldPosition)
                        {
                            // move player location (make ActiveMap tile check here in the future)
                            this.Direction.X = MOVE_RIGHT;
                            this.Speed = PLAYER_SPEED;
                            spriteEffect = SpriteEffects.FlipHorizontally;
                        }
                        else if (!keyboardStatePrevious.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right) &&
                                 keyboardStateCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left) &&
                                 !HoldPosition)
                        {
                            // move player location (make ActiveMap tile check here in the future)
                            this.Direction.X = MOVE_LEFT;
                            this.Speed = PLAYER_SPEED;
                            spriteEffect = SpriteEffects.None;
                        }
                        else
                        {
                            //state = EntityState.Stand;
                            NetworkGameData.Instance.sendPlayerData("Stop", getPlayer());
                        }
                        if (keyboardStateCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Space) && !HoldPosition)
                        {
                            if (!collideNPC)
                            {
                                Velocity += new Vector2(0, -1.6f); // Add an upward impulse
                                //state = EntityState.Jump;

                                NetworkGameData.Instance.sendPlayerData("Jump", getPlayer());
                            }
                        }

                        // reduce timer
                        previousGameTimeMsec -= (float)gameTime.ElapsedGameTime.TotalSeconds;

                        // set sprite frames
                        if (previousGameTimeMsec < 0)
                        {
                            previousGameTimeMsec = (float)gameTime.ElapsedGameTime.TotalSeconds + 0.10f;
                            spriteframe ++;
                        }
                        if (spriteframe > 3)
                            spriteframe = 0;

                        // Player animation
                        if (prevspriteframe != spriteframe)
                        {
                            prevspriteframe = spriteframe;
                            for (int i = 0; i < spritepath.Length; i++)
                            {
                                spritename = "walk1_" + spriteframe.ToString();
                                playerStore.activePlayer.spriteOfset[i] = getoffset(i);
                            }
                        }

                        // Check if player is steady standing
                        //if (Position.Y > OldPosition.Y && collideSlope == false)
                        //    state = EntityState.Falling;

                        // Move the Character
                        OldPosition = Position;

                        // Walk speed
                        Position += Direction * Speed * (float)gameTime.ElapsedGameTime.TotalSeconds;

                        // Apply Gravity
                        Position += new Vector2(0,1) * 250 * (float)gameTime.ElapsedGameTime.TotalSeconds;

                        break;
                    #endregion
                    #region state jump
                    case EntityState.Jump:

                        Velocity.Y += (float)gameTime.ElapsedGameTime.TotalSeconds;

                        if (keyboardStateCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left))
                        {
                            // move player location (make ActiveMap tile check here in the future)
                            this.Direction.X += MOVE_LEFT * 0.1f * ((float)gameTime.ElapsedGameTime.TotalSeconds * 10f);
                            this.Speed = PLAYER_SPEED;

                            if (this.Direction.X < -1)
                                this.Direction.X = -1;
                            else if (this.Direction.X < 0)
                                this.Direction.X = 0;

                            NetworkGameData.Instance.sendPlayerData("Left", getPlayer());

                        }
                        else if (keyboardStateCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right))
                        {
                            // move player location (make ActiveMap tile check here in the future)
                            this.Direction.X += MOVE_RIGHT * 0.1f * ((float)gameTime.ElapsedGameTime.TotalSeconds * 10f);
                            this.Speed = PLAYER_SPEED;

                            if (this.Direction.X > 1)
                                this.Direction.X = 1;
                            else if (this.Direction.X > 0)
                                this.Direction.X = 0;

                            NetworkGameData.Instance.sendPlayerData("Right", getPlayer());
                        }
                        else if (keyboardStateCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Down))
                        {
                            //if (this.collideLadder)
                            //    state = EntityState.Ladder;
                            //else if (this.collideRope)
                            //    state = EntityState.Rope;
                            //else
                            //    state = EntityState.Sit;

                            NetworkGameData.Instance.sendPlayerData("Down", getPlayer());
                        }
                        else if (keyboardStateCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Up))
                        {
                            //if (this.collideLadder)
                            //    state = EntityState.Ladder;
                            //else if (this.collideRope)
                            //    state = EntityState.Rope;

                            NetworkGameData.Instance.sendPlayerData("Up", getPlayer());
                        }

                        // Move the Character
                        OldPosition = Position;

                        // Player animation
                        for (int i = 0; i < spritepath.Length; i++)
                        {
                            spritename = "jump_0";
                            playerStore.activePlayer.spriteOfset[i] = getoffset(i);
                        }

                        // Apply Gravity + jumping
                        if (Velocity.Y < -1.2f)
                        {
                            // Apply jumping
                            Position += Velocity * 350 * (float)gameTime.ElapsedGameTime.TotalSeconds;

                            // Apply Gravity
                            Position += new Vector2(0, 1) * 250 * (float)gameTime.ElapsedGameTime.TotalSeconds;

                            // Walk / Jump speed
                            Position += Direction * (Speed / 2) * (float)gameTime.ElapsedGameTime.TotalSeconds;
                        }
                        else
                        {
                            // landed = false;
                            // state = EntityState.Falling;
                        }

                        break;
                    #endregion
                    #region state falling
                    case EntityState.Falling:

                        if (keyboardStateCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left))
                        {
                            // move player location (make ActiveMap tile check here in the future)
                            this.Direction.X += MOVE_LEFT * 0.1f * ((float)gameTime.ElapsedGameTime.TotalSeconds * 10f);
                            this.Speed = PLAYER_SPEED;

                            if (this.Direction.X < -1)
                                this.Direction.X = -1;
                            else if (this.Direction.X < 0)
                                this.Direction.X = 0;

                            NetworkGameData.Instance.sendPlayerData("Left", getPlayer());
                        }
                        else if (keyboardStateCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right))
                        {
                            // move player location (make ActiveMap tile check here in the future)
                            this.Direction.X += MOVE_RIGHT * 0.1f * ((float)gameTime.ElapsedGameTime.TotalSeconds * 10f);
                            this.Speed = PLAYER_SPEED;

                            if (this.Direction.X > 1)
                                this.Direction.X = 1;
                            else if (this.Direction.X > 0)
                                this.Direction.X = 0;

                            NetworkGameData.Instance.sendPlayerData("Right", getPlayer());
                        }

                        if (OldPosition.Y < position.Y)
                        {
                            // Move the Character
                            OldPosition = Position;

                            Velocity.Y += (float)gameTime.ElapsedGameTime.TotalSeconds;

                            // Apply Gravity
                            Position += new Vector2(0, 1) * 250 * (float)gameTime.ElapsedGameTime.TotalSeconds;

                            // Walk / Jump speed
                            Position += Direction * (Speed / 2) * (float)gameTime.ElapsedGameTime.TotalSeconds;
                        }
                        else
                        {
                            // reduce timer
                            previousGameTimeMsec -= (float)gameTime.ElapsedGameTime.TotalSeconds;

                            // Move the Character
                            OldPosition = Position;

                            // Apply Gravity
                            Position += new Vector2(0, 1) * 250 * (float)gameTime.ElapsedGameTime.TotalSeconds;

                            // Walk / Jump speed
                            Position += Direction * (Speed / 2) * (float)gameTime.ElapsedGameTime.TotalSeconds;
                        }

                        // Player animation
                        for (int i = 0; i < spritepath.Length; i++)
                        {
                            spritename = "fly_0";
                            playerStore.activePlayer.spriteOfset[i] = getoffset(i);
                        }

                        break;
                    #endregion
                    #region state hit
                    case EntityState.Hit:

                        // Add an upward impulse
                        Velocity = new Vector2(0, -1.5f);

                        // Add an sideward pulse
                        if (spriteEffect == SpriteEffects.None)
                            Direction = new Vector2(1.6f, 0);
                        else
                            Direction = new Vector2(-1.6f, 0);

                        // Damage controll and balloon is triggered in monster-sprite Class

                        // Move the Character
                        OldPosition = Position;

                        // Player animation
                        for (int i = 0; i < spritepath.Length; i++)
                        {
                            spritename = "fly_0";
                            playerStore.activePlayer.spriteOfset[i] = getoffset(i);
                        }

                        // Set new state
                        // state = EntityState.Frozen;

                        break;
                    #endregion
                    #region state frozen
                    case EntityState.Frozen:

                        // Upward Position
                        Velocity.Y += (float)gameTime.ElapsedGameTime.TotalSeconds * 2;

                        // Make player transperant
                        if (transperancy >= 0 )
                            this.transperancy -= (float)gameTime.ElapsedGameTime.TotalSeconds * 10;

                        // turn red
                        this.color = Color.Red;

                        // Move the Character
                        OldPosition = Position;

                        // Player animation
                        for (int i = 0; i < spritepath.Length; i++)
                        {
                            spritename = "fly_0";
                            playerStore.activePlayer.spriteOfset[i] = getoffset(i);
                        }

                        // Apply Gravity + jumping
                        if (Velocity.Y < -1.2f && OldPosition.Y != Position.Y)
                        {
                            // Apply jumping
                            Position += Velocity * 350 * (float)gameTime.ElapsedGameTime.TotalSeconds;

                            // Apply Gravity
                            Position += new Vector2(0, 1) * 250 * (float)gameTime.ElapsedGameTime.TotalSeconds;

                            // Walk / Jump speed
                            Position += Direction * 100 * (float)gameTime.ElapsedGameTime.TotalSeconds;
                        }
                        else
                        {
                            // landed = false;
                            // state = EntityState.Falling;
                            Direction = Vector2.Zero;
                            Velocity = Vector2.Zero;
                            //this.color = Color.White;
                            this.transperancy = 1;
                        }

                        break;
                    #endregion
                }
            }

            #region temporary quickbuttons
            // temporary global function buttons
            // should be handles by singleton class keyboard manager
            if (CheckKey(Keys.Q) && !HoldPosition)
                NetworkGameData.Instance.sendItemData(new Random().Next(1100, 1114), "AddItem");
                //getPlayer().inventory.addItem(itemStore.getItem(new Random().Next(1100, 1114)));
            else if (CheckKey(Keys.W) && !HoldPosition)
                NetworkGameData.Instance.sendItemData(new Random().Next(1300, 1303), "AddItem");
                //getPlayer().inventory.addItem(itemStore.getItem(XNA_ScreenManager.ScreenClasses.MainClasses.ResourceManager.randomizer.Instance.generateRandom(1300, 1303)));
            else if (CheckKey(Keys.E) && !HoldPosition)
                NetworkGameData.Instance.sendItemData(new Random().Next(2300, 2308), "AddItem");
                //getPlayer().inventory.addItem(itemStore.getItem(XNA_ScreenManager.ScreenClasses.MainClasses.ResourceManager.randomizer.Instance.generateRandom(2300, 2308)));
            // temporary
            #endregion

            // if the client is connected to a server
            // these functions will trigger a player update
            if (spriteEffect != previousSpriteEffect)
                NetworkGameData.Instance.sendPlayerData();

            keyboardStatePrevious = keyboardStateCurrent;
        }