Пример #1
0
 public virtual void Update(double elapsedTime)
 {
     multiSprite.Update(elapsedTime);
     if (effect != null)
     {
         effect.Update(elapsedTime);
     }
 }
Пример #2
0
        public override void Update(double elapsedTime)
        {
            base.Update(elapsedTime);
            if (!isfast)
            {
                SlowMoveEffect.Update(elapsedTime);
            }

            #region Move
            //根据方向,改变其动画状态
            if (Direction.X < 0)        //向左移动
            {
                if (CurrentCharactor.multiSprite.State != 2 && CurrentCharactor.multiSprite.State != 1)
                {
                    CurrentCharactor.multiSprite.State = 1;
                }
            }
            else if (Direction.X > 0)  //向右移动
            {
                if (CurrentCharactor.multiSprite.State != 4 && CurrentCharactor.multiSprite.State != 3)
                {
                    CurrentCharactor.multiSprite.State = 3;
                }
            }
            else
            {
                if (CurrentCharactor.multiSprite.State != 0)
                {
                    CurrentCharactor.multiSprite.State = 0;
                }
            }
            if (!(Direction.X == 0 && Direction.Y == 0))
            {
                tt += elapsedTime;
                //System.Diagnostics.Debug.Print(tt.ToString());
                //System.Diagnostics.Debug.Print(" offset " + elapsedTime.ToString());
            }
            //    System.Diagnostics.Debug.Print("X: " + Position.X.ToString() + "Y: "+ Position.Y.ToString()
            //         + "  "+ DateTime.Now.ToString());
            float speed = 0;
            if (isfast)
            {
                speed = fast_speed;
            }
            else
            {
                speed = slow_speed;
            }
            double dx = (elapsedTime * Direction.X * speed);
            double dy = (elapsedTime * Direction.Y * speed);
            double tx = Position.X + dx;
            double ty = Position.Y + dy;
            if (tx > 180)
            {
                tx = 180;
            }
            if (tx < -180)
            {
                tx = -180;
            }
            if (ty < 25)
            {
                ty = 25;
            }
            if (ty > 425)
            {
                ty = 425;
            }
            if (canmove)
            {
                Position.X = tx;
                Position.Y = ty;
            }

            #endregion

            //       CurrentCharactor  Update
            CurrentCharactor.Update(elapsedTime);

            #region  AddBullets

            //  将人物序列中的载入子弹全部载入player子弹库中
            foreach (Bullet b in CurrentCharactor.bullets_toAdd)
            {
                bullet_toAdd.Add(b);
            }
            CurrentCharactor.bullets_toAdd.Clear();

            foreach (Bullet b in Bullets)
            {
                if (b.disabled)
                {
                    bullet_toRemove.Add(b);
                }
            }

            foreach (Bullet b in bullet_toRemove)
            {
                Bullets.Remove(b);
            }
            bullet_toRemove.Clear();


            #endregion

            #region UnBeatable
            //无敌
            if (unbeatable)
            {
                unbeatable_time -= elapsedTime;
                if (unbeatable_time < 0)
                {
                    unbeatable      = false;
                    unbeatable_time = 0;
                    //解除被击中状态
                    hitted = false;
                }
            }
            #endregion

            #region AttackRush
            UpdateAttack(elapsedTime);

            #endregion

            //Fire
            if (fireing)
            {
                Fire(elapsedTime);
            }
        }