Blink.Classes.SpearClass.Update C# (CSharp) Method

Update() public method

public Update ( KeyboardState input, GamePadState padState ) : void
input Microsoft.Xna.Framework.Input.KeyboardState
padState Microsoft.Xna.Framework.Input.GamePadState
return void
        public void Update(KeyboardState input, GamePadState padState)
        {
            //Reset variables to defualt state
            KeyboardState newState = input;
            //spear.Width = Width;  //updates the rectangle of the spear
            //spear.Height = Height;
			if (isInUse)  //delay after spear being thrown
			{
				if(inUseTimer > 0)
				{
					inUseTimer -= 1;
				}
				else
				{
					isInUse = false;
					inUseTimer = 10;
                    coolDown = 20;
				}
			}
            if (!isInUse && coolDown > 0)
            {
                coolDown -= 1;
            }
            //Spear throw
            /*if ((input.IsKeyDown(THROW_KEY) || padState.IsButtonDown(THROW_BUTTON)) && attachedToPlayer && !spearOwner.dead && !isInUse && coolDown <= 0 && !throwDown)
            {
                throwDown = true;
                isInUse = true;
                if (spearOwner.getDirectionFacing() == 0)
                {
                    spearOrientation = 0;
                }
                else if (spearOwner.getDirectionFacing() == 1)
                {
                    spearOrientation = 4;
                }
                if (input.IsKeyDown(Keys.Up) || padState.IsButtonDown(Buttons.LeftThumbstickUp))
                {
                    spearOrientation = 2;
                }
                else if (input.IsKeyDown(Keys.Down) || padState.IsButtonDown(Buttons.LeftThumbstickDown))
                {
                    spearOrientation = 6;
                }
                thrownBy = spearOwner;
                throwSpear();
            }

            else if ((input.IsKeyUp(THROW_KEY) && padState.IsButtonUp(THROW_BUTTON)))
                throwDown = false;
                */


            //Updating aim from player
            if(spearOwner != null) { 
                Vector2 stickDir = spearOwner.spearVector;
                if (stickDir.Length() >= .85f)
            {
                    orientation = VectorMath.rotationFromVector(stickDir) + (float)(Math.PI * 0.5f); //90 degree adjustment is to account for spear's initial rotation
                    spearVector = stickDir;
                }
                }
            //Holding spear attacks
            if ((input.IsKeyDown(ATTACK_KEY) || padState.IsButtonDown(ATTACK_BUTTON) || padState.IsButtonDown(THROW_BUTTON)) && attachedToPlayer && !spearOwner.dead && !isInUse && coolDown <= 0)
                {
                attackDown = true;
                
                }
            else if ((input.IsKeyUp(ATTACK_KEY) && padState.IsButtonUp(ATTACK_BUTTON)) && attackDown)
                {
                attackDown = false;
                }
            
            if(attachedToPlayer && !isInUse) { 
                spear.Location = spearOwner.getPlayerRect().Center;

                spear.X -= 16;
                spear.Y -= 8;
            }

            if (!attachedToPlayer)
            {
            playerCollision();
            }
            if (!atRest)
            {
                mapCollision();
                //if (thrownBy != null)
                    throwUpdate();
                /*if (Math.Abs(velocity.Y) + gravityEffect < TERMINAL_V)
                    if(thrownBy != null)
                        gravityEffect += GRAVITY / 10;
                    else
                        gravityEffect += GRAVITY;
                spear.Y += (int)(velocity.Y + gravityEffect);*/
            }

            oldState = newState;
        }