示例#1
0
        public void changeWeapon(string type,string callerType)
        {
            if (type == callerType)
                return;

            if (type == "bow")
                player = new Player(playerTexture);
            else if (type == "sword")
                playerWithSword = new PlayerWithSword(playerWithSwordTexture);
        }
示例#2
0
        protected override void LoadContent()
        {
            monsterTexture = Content.Load<Texture2D>("Skelly");
            playerTexture =  Content.Load<Texture2D>("playerBow");

            monster = new Monster(monsterTexture);
            player  = new Player(playerTexture);
            projektiler = new List<Projektil>();

            foreach (Projektil item in projektiler)
            {
                arrowTexture = Content.Load<Texture2D>("Arrow");
            }

            spriteBatch = new SpriteBatch(GraphicsDevice);
        }
示例#3
0
        }  // Gå animeringen hos spelaren

    public Vector2 update(KeyboardState pressedKeys)
    {
            velocity.Y = 2;
            velocity.X = 2;
            
            #region movement
        // om w och eller a,d är nertryck kan man gå snett. Kan springa max agility velocity. agilityAccel är hur snabbt man kan springa till max hastigheten agility
        if (pressedKeys.IsKeyDown(Keys.W))
        {
                position.Y = position.Y -= velocity.Y;
        }

        if (pressedKeys.IsKeyDown(Keys.S))
        {
                position.Y = position.Y += velocity.Y;

        }

        if (pressedKeys.IsKeyDown(Keys.A))
        {
                position.X = position.X -= velocity.X;

        }

        if (pressedKeys.IsKeyDown(Keys.D))
        {
                position.X = position.X += velocity.X;

        }
        velocity.X = 0;
        velocity.Y = 0;
            #endregion

            #region ChangeWeaponAndKillThisInstance
            if (pressedKeys.Equals(Keys.D1)|| pressedKeys.Equals(Keys.D2)|| pressedKeys.Equals(Keys.D3))
            {
                if (pressedKeys.Equals(Keys.D1))
                {
                    type = "bow";
                }
               else if (pressedKeys.Equals(Keys.D2))
                {
                    type = "sword";
                }
               else if (pressedKeys.Equals(Keys.D3))
                {
                    type = "staff";
                }
                game1.changeWeapon(type, thisType);
         
                player = null;
       
            }
            #endregion
            
            return position;
    }