public override void Update(GameTime gameTime)
        {
            center = new Vector2(pos.X + tex.Width / 2, pos.Y + tex.Height / 2);
            missileTimer++;
            particleEngineSteam.EmitterLocation = new Vector2(center.X, center.Y);
            particleEngineSteam.total           = 1;
            particleEngineSteam.Update();

            if (missileTimer >= 200)
            {
                missileRemove = true;
            }

            pos   -= direction * speed * (float)gameTime.ElapsedGameTime.TotalSeconds;
            hitBox = new Rectangle((int)pos.X, (int)pos.Y, tex.Width, tex.Height);

            if (target != null)
            {
                FaceTarget();

                //target är död måste läggas in!
                if (!IsInRange(target.Center))
                {
                    target = null;
                }
            }
        }
Beispiel #2
0
        public override void Update(GameTime gameTime)
        {
            color = Color.White;
            statusWindow.SetPos = pos;
            statusWindow.Update(gameTime);
            particleEnginePowerShoot.Update();
            particleEngineDash.Update();
            PowerShoot();
            Transparency(gameTime);
            HandleReload(gameTime);
            RemoveRainArrows();
            RainAttack(gameTime);
            SpeedMove(gameTime);
            AddTrap();

            foreach (Projectile p in powerShootList)
            {
                p.Update(gameTime);
            }
            foreach (Trap t in trapList)
            {
                t.Update(gameTime);
            }
            foreach (RainAttack r in rainAttackList)
            {
                r.Update(gameTime);
            }

            base.Update(gameTime);
            ShootRightThumbStick(newState, gameTime);
        }
        public override void Update(GameTime gameTime)
        {
            this.center     = new Vector2(pos.X + tex.Width / 2, pos.Y + tex.Height / 2);
            dispenserPower += 1;

            hitBox = new Rectangle((int)pos.X, (int)pos.Y, spriteWidth, spriteHeight);

            if (dispenserPower >= 500)
            {
                dispenserRemove = true;
            }

            particleEngineSteam.EmitterLocation = new Vector2(center.X, center.Y);
            particleEngineSteam.total           = 1;
            particleEngineSteam.Update();
        }
        public override void Update(GameTime gameTime)
        {
            particleEngineCharge.Update();

            statusWindow.SetPos = pos;
            statusWindow.Update(gameTime);

            if (statusWindow.hp < statusWindow.maxHp)
            {
                if (ghostMode == false)
                {
                    statusWindow.hp += 5 * ((1 + (statusWindow.vitality / 20)) * time / 2);
                }
            }

            //Dina knapptryckningar in här
            if (paused == false)
            {
                if (RTpress == true)
                {
                    isAttacking = true;
                }

                if (LTpress == true)
                {
                    isShielding = true;
                }

                if (availableAPress == true)
                {
                    if (Apress == true)
                    {
                        isCharging = true;
                    }
                }
            }

            if (isAttacking)
            {
                //tex = TextureManager.warriorAttack;
                timerAttack += (int)gameTime.ElapsedGameTime.TotalMilliseconds;

                if (timerAttack > 50)
                {
                    timerAttack -= 50;
                    ++currentFrameAttack.X;
                    if (currentFrameAttack.X >= sheetSizeAttack.X)
                    {
                        currentFrameAttack.X = 0;
                        ++currentFrameAttack.Y;
                        if (currentFrameAttack.Y >= sheetSizeAttack.Y)
                        {
                            currentFrameAttack.Y = 0;
                            //tex = TextureManager.warriorAnimation;
                            isAttacking = false;
                        }
                    }
                }
            }

            if (isShielding)
            {
                //tex = TextureManager.warriorAttack;
                timerShield += (int)gameTime.ElapsedGameTime.TotalMilliseconds;

                if (timerShield > 50)
                {
                    timerShield -= 50;
                    ++currentFrameShield.X;
                    if (currentFrameShield.X >= sheetSizeShield.X)
                    {
                        currentFrameShield.X = 0;
                        ++currentFrameShield.Y;
                        if (currentFrameShield.Y >= sheetSizeShield.Y)
                        {
                            currentFrameShield.Y = 0;
                            //tex = TextureManager.warriorAnimation;
                            isShielding = false;
                        }
                    }
                }
            }

            if (isCharging && (newState.ThumbSticks.Left.X != 0 || newState.ThumbSticks.Left.Y != 0))
            {
                isAPress           = true;
                getThumbStickValue = true;
                isCharging         = false;
            }
            if (isAPress)
            {
                timerCharge += (float)gameTime.ElapsedGameTime.TotalMilliseconds;

                if (getThumbStickValue)
                {
                    //ma.X = GamePad.GetState(playerIndex, GamePadDeadZone.None).ThumbSticks.Left.X;//har jag igång none så funkar det, konstigt
                    //ma.Y = -GamePad.GetState(playerIndex, GamePadDeadZone.None).ThumbSticks.Left.Y;
                    leftStickValue.X = newState.ThumbSticks.Left.X;//annars funkar dessa
                    leftStickValue.Y = -newState.ThumbSticks.Left.Y;
                    //angle = (float)Math.Atan2(GamePad.GetState(playerIndex, GamePadDeadZone.None).ThumbSticks.Left.X, GamePad.GetState(playerIndex, GamePadDeadZone.None).ThumbSticks.Left.Y);
                    angle = (float)Math.Atan2(newState.ThumbSticks.Left.X, newState.ThumbSticks.Left.Y);
                    getThumbStickValue = false;
                }

                //if (ma.X == 0 && ma.Y == 0)
                //{
                //    x = prevThumbStickLeftValue.X;
                //    y = prevThumbStickLeftValue.Y;
                //}

                Vector2 specialMove = new Vector2(leftStickValue.X, leftStickValue.Y);
                specialMove.Normalize();

                if (timerCharge < 400)
                {
                    isArcherMoving = false;

                    specialMove.Normalize();
                    pos += specialMove * (float)gameTime.ElapsedGameTime.TotalMilliseconds;

                    particleEngineCharge.EmitterLocation = new Vector2(pos.X, pos.Y);
                    particleEngineCharge.total           = 15;
                    //speed += 5;
                    //pos += direction * speed * (float)gameTime.ElapsedGameTime.TotalMilliseconds;
                    availableAPress = false;
                }
                else
                {
                    availableAPress            = true;
                    particleEngineCharge.total = 0;
                    isAPress       = false;
                    timerCharge    = 0;
                    isArcherMoving = true;
                }
            }

            base.Update(gameTime);
        }
        public override void Update(GameTime gameTime)
        {
            if (paused == false)
            {
                particleEngineSteam.Update();
                particleEngineWater.Update();
                particleEngineFire.Update();
                particleEngineRocks.Update();
                statusWindow.SetPos = pos;
                statusWindow.Update(gameTime);

                if (shieldActivated == true)
                {
                    time = (float)gameTime.ElapsedGameTime.TotalSeconds;
                }


                if (buying == false && statusWindow.active == false && ghostMode == false)
                {
                    //klar
                    #region Attack A
                    if (Apress == true)
                    {
                        if (statusWindow.mana >= 35)
                        {
                            Vector2    FireAngle = new Vector2(prevThumbStickRightValue.X, prevThumbStickRightValue.Y);
                            Projectile f         = new Projectile(pos, TextureManager.fireBall, FireAngle, angle, new Vector2(0, 0), 0.35f, 80, new Point(40, 40), new Point(4, 1), 60, true);
                            FireBallList.Add(f);
                            particleEngineFire.EmitterLocation = new Vector2(pos.X, pos.Y);
                            particleEngineFire.total           = 15;
                            rumble.Vibrate(0.1f, 1f);
                            statusWindow.mana -= 35;
                        }
                    }
                    else
                    {
                        particleEngineFire.total = 0;
                    }
                    #endregion
                    //klar
                    #region Attack X
                    if (Xpress == true)
                    {
                        if (statusWindow.mana >= 35)
                        {
                            Vector2    FireAngle = new Vector2(prevThumbStickRightValue.X, prevThumbStickRightValue.Y);
                            Projectile w         = new Projectile(pos, TextureManager.waterBall, FireAngle, angle, new Vector2(0, 0), 0.35f, 80, new Point(40, 40), new Point(4, 1), 60, true);
                            WaterBallList.Add(w);
                            particleEngineWater.EmitterLocation = new Vector2(pos.X, pos.Y);
                            particleEngineWater.total           = 15;
                            rumble.Vibrate(0.1f, 1f);
                            statusWindow.mana -= 35;
                        }
                    }
                    else
                    {
                        particleEngineWater.total = 0;
                    }
                    #endregion
                    //klar
                    #region Attack B
                    if (Bpress == true)
                    {
                        if (statusWindow.mana >= 20)
                        {
                            windruchOn         = true;
                            statusWindow.mana -= 20;
                        }
                    }
                    #endregion
                    //Klar
                    #region Attack Y
                    if (Ypress == true && boulderOn == false)
                    {
                        if (statusWindow.mana >= 100)
                        {
                            Vector2    FireAngle = new Vector2(prevThumbStickRightValue.X, prevThumbStickRightValue.Y);
                            Projectile b         = new Projectile(pos, TextureManager.BoulderSheetTexture, FireAngle, angle, new Vector2(0, 0), 0.25f, 120, new Point(72, 72), new Point(5, 4), 45, true);
                            BoulderList.Add(b);
                            boulderOn          = true;
                            statusWindow.mana -= 100;
                        }
                    }
                    #endregion

                    #region Mana Shield
                    if (LTpress == true)
                    {
                        if (statusWindow.mana > 0)
                        {
                            shieldActivated    = true;
                            statusWindow.mana -= 5 * time;
                        }
                        else
                        {
                            shieldActivated = false;
                        }
                    }
                    else
                    {
                        shieldActivated = false;
                    }
                    #endregion
                }


                if (statusWindow.hp < statusWindow.maxHp)
                {
                    if (ghostMode == false)
                    {
                        statusWindow.hp += 2 * ((1 + (statusWindow.vitality / 20)) * time / 2);
                    }
                }


                #region Update Fireball
                foreach (Projectile f in FireBallList)
                {
                    if (f != null)
                    {
                        f.Update(gameTime);
                    }

                    if (f.BulletRemove == true)
                    {
                        FireBallList.Remove(f);
                        break;
                    }
                }
                #endregion

                #region Update waterball
                foreach (Projectile w in WaterBallList)
                {
                    if (w != null)
                    {
                        w.Update(gameTime);
                    }

                    if (w.BulletRemove == true)
                    {
                        WaterBallList.Remove(w);
                        break;
                    }
                }
                #endregion

                #region Update Windruch

                if (windruchOn == true)
                {
                    particleEngineSteam.EmitterLocation = new Vector2(pos.X, pos.Y);
                    particleEngineSteam.total           = 20;
                    if (speed <= oldSpeed + 3)
                    {
                        speed += 0.5f;
                    }

                    timerWindRuch += gameTime.ElapsedGameTime.TotalMilliseconds;
                    if (timerWindRuch >= timeWindRuch)
                    {
                        windruchOn    = false;
                        timerWindRuch = 0;
                    }
                }
                if (windruchOn == false)
                {
                    if (speed > oldSpeed)
                    {
                        speed -= 0.2f;
                    }
                    particleEngineSteam.total = 0;
                }

                #endregion

                #region Update Boulder
                if (boulderOn == true)
                {
                    rumble.Vibrate(0.15f, 0.20f);
                    foreach (Projectile b in BoulderList)
                    {
                        particleEngineRocks.EmitterLocation = new Vector2(b.pos.X, b.pos.Y);
                        particleEngineRocks.total           = 15;
                        if (b != null || BoulderList.Count == 0)
                        {
                            b.Update(gameTime);
                            b.direction.X += (float)(newState.ThumbSticks.Right.X * boulderspeed);
                            b.direction.Y -= (float)(newState.ThumbSticks.Right.Y * boulderspeed);
                            b.direction.Normalize();
                        }
                        if (b.BulletRemove == true)
                        {
                            particleEngineRocks.total = 0;
                            BoulderList.Remove(b);
                            boulderOn = false;
                            break;
                        }
                    }
                }
                #endregion

                ShootRightThumbStick(newState, gameTime);
            }
            base.Update(gameTime);
        }