Esempio n. 1
0
 public override void Run(LTimerContext time)
 {
     if (outerInstance._game != null)
     {
         try
         {
             //outerInstance.StartTransition();
             //screen.SetClose(false);
             //screen.ResetOrder();
             //screen.ResetSize();
             //screen.OnLoad();
             //screen.OnLoaded();
             //screen.SetOnLoadState(true);
             screen.Resume();
             //outerInstance.endTransition();
         }
         catch (System.Exception cause)
         {
             LSystem.Error("Screen onLoad dispatch failed: " + screen, cause);
         }
         finally
         {
             Kill();
         }
     }
 }
Esempio n. 2
0
 public virtual void Tick(LTimerContext time)
 {
     if (timer.Action(time))
     {
         Run(time);
     }
 }
Esempio n. 3
0
 public virtual void Tick(LTimerContext time)
 {
     if (processes.size > 0)
     {
         SortedList <GameProcess> toBeUpdated;
         lock (this.processes)
         {
             toBeUpdated = new SortedList <GameProcess>(this.processes);
         }
         SortedList <GameProcess> deadProcesses = new SortedList <GameProcess>();
         try
         {
             for (LIterator <GameProcess> it = toBeUpdated.ListIterator(); it.HasNext();)
             {
                 GameProcess realtimeProcess = it.Next();
                 if (realtimeProcess != null)
                 {
                     lock (realtimeProcess)
                     {
                         realtimeProcess.Tick(time);
                         if (realtimeProcess.IsDead())
                         {
                             deadProcesses.Add(realtimeProcess);
                         }
                     }
                 }
             }
             if (deadProcesses.size > 0)
             {
                 for (LIterator <GameProcess> it = deadProcesses.ListIterator(); it.HasNext();)
                 {
                     GameProcess realtimeProcess = it.Next();
                     if (realtimeProcess != null)
                     {
                         lock (realtimeProcess)
                         {
                             realtimeProcess.Finish();
                         }
                     }
                 }
                 lock (this.processes)
                 {
                     this.processes.RemoveAll(deadProcesses);
                 }
             }
         }
         catch (System.Exception cause)
         {
             //LSystem.Error("Process dispatch failure", cause);
         }
     }
 }
Esempio n. 4
0
 public bool Action(LTimerContext context)
 {
     if (this.active)
     {
         this.currentTick += context.GetTimeSinceLastUpdate();
         if (this.currentTick >= this.delay)
         {
             this.currentTick -= this.delay;
             return true;
         }
     }
     return false;
 }
Esempio n. 5
0
 public bool Action(LTimerContext context)
 {
     if (this.active)
     {
         this.currentTick += context.GetTimeSinceLastUpdate();
         if (this.currentTick >= this.delay)
         {
             this.currentTick -= this.delay;
             return(true);
         }
     }
     return(false);
 }
Esempio n. 6
0
        public override void Alter(LTimerContext timer)
        {
            int size = keyActions.Size();

            if (size > 0)
            {
                for (int i = 0; i < size; i++)
                {
                    ActionKey act = (ActionKey)keyActions.Get(i);
                    if (act.IsPressed())
                    {
                        act.Act(elapsedTime);
                        if (act.isReturn)
                        {
                            return;
                        }
                    }
                }
            }
            if (follow != null)
            {
                foreach (TileMap tile in tiles)
                {
                    float offsetX = GetHalfWidth() - follow.GetX();
                    offsetX = MathUtils.Min(offsetX, 0);
                    offsetX = MathUtils.Max(offsetX, GetWidth() - tile.GetWidth());

                    float offsetY = GetHalfHeight() - follow.GetY();
                    offsetY = MathUtils.Min(offsetY, 0);
                    offsetY = MathUtils
                              .Max(offsetY, GetHeight() - tile.GetHeight());

                    SetOffset(offsetX, offsetY);
                    tile.Update(elapsedTime);
                }
            }

            foreach (SpriteBatchObject o in objects)
            {
                o.Update(elapsedTime);
                if (updateListener != null)
                {
                    updateListener.Act(o, elapsedTime);
                }
            }
            Update(elapsedTime);
            Commits();
        }
Esempio n. 7
0
 public override void Alter(LTimerContext c)
 {
     // 初始化完毕
     if (IsOnLoadComplete())
     {
         // 标题未达到窗体边缘
         if (title.GetX() + title.GetWidth() + 25 <= GetWidth())
         {
             // 以三倍速移动(红色无角……)
             title.Move_right(3);
         }
         else
         {
             // 设定开始按钮可用
             start.SetEnabled(true);
             // 设定结束按钮可用
             end.SetEnabled(true);
         }
     }
 }
Esempio n. 8
0
            internal void Update(LTimerContext c)
            {
                try
                {
                    switch (type)
                    {
                    case DRAW_USER:
                        /*DrawListener<Screen> drawing = screen._drawListener;
                         * if (drawing != null)
                         * {
                         *      drawing.update(c.timeSinceLastUpdate);
                         * }*/
                        screen.Alter(c);
                        break;

                    case DRAW_SPRITE:
                        /*screen.spriteRun = (screen.sprites != null && screen.sprites.size() > 0);
                         * if (screen.spriteRun)
                         * {
                         *      screen.sprites.update(c.timeSinceLastUpdate);
                         * }*/
                        break;

                    case DRAW_DESKTOP:
                        /*	screen.desktopRun = (screen.desktop != null && screen.desktop.size() > 0);
                         *      if (screen.desktopRun)
                         *      {
                         *              screen.desktop.update(c.timeSinceLastUpdate);
                         *      }*/
                        break;

                    case DRAW_EMPTY:
                    default:
                        break;
                    }
                }
                catch (System.Exception cause)
                {
                    LSystem.Error("Screen update() dispatch failure", cause);
                }
            }
Esempio n. 9
0
        public override void DoMain()
        {
            m_game.OnStateLog(m_log);

            LSystem.isResume  = false;
            LSystem.isPaused  = false;
            LSystem.isDestroy = false;

            timerContext = new LTimerContext();
            timer        = LSystem.GetSystemTimer();

            if (m_game != null)
            {
                GameType type = m_game.GetGameType();
                if (type != null)
                {
                    Register(type.setting, type.mainType, type.args);
                }
            }

            Printf("doMain");
        }
Esempio n. 10
0
        public void RunTimer(LTimerContext context)
        {
            if (isInstance)
            {
                if (waitTransition)
                {
                    if (transition != null)
                    {
                        switch (transition.code)
                        {
                        default:
                            if (!currentControl.IsOnLoadComplete())
                            {
                                transition.Update(context.timeSinceLastUpdate);
                            }
                            break;

                        case 1:
                            if (!transition.Completed())
                            {
                                transition.Update(context.timeSinceLastUpdate);
                            }
                            else
                            {
                                EndTransition();
                            }
                            break;
                        }
                    }
                }
                else
                {
                    currentControl.RunTimer(context);
                    return;
                }
            }
        }
Esempio n. 11
0
 public void Update(LTimerContext clock)
 {
     update.Emit(clock);
 }
Esempio n. 12
0
 public override void Alter(LTimerContext context)
 {
     throw new NotImplementedException();
 }
Esempio n. 13
0
        public override void Alter(LTimerContext timer)
        {
            if (!IsOnLoadComplete())
            {
                return;
            }

            gameTime.Update(timer);

            if (!isInit)
            {
                LoadContent();
            }

            gameCollection.Update(gameTime);
            if (drawablesToUpdate.Count > 0)
            {
                CollectionUtils.Clear(drawablesToUpdate);
            }

            foreach (Drawable drawable in drawables)
            {
                CollectionUtils.Add(drawablesToUpdate, drawable);
            }

            bool otherScreenHasFocus  = false;
            bool coveredByOtherScreen = false;

            Drawable _drawable;
            int      screenIndex;

            for (; drawablesToUpdate.Count > 0;)
            {
                screenIndex = drawablesToUpdate.Count - 1;
                _drawable   = drawablesToUpdate[screenIndex];

                CollectionUtils.RemoveAt(drawablesToUpdate, screenIndex);

                if (_drawable._enabled)
                {
                    _drawable.Update(gameTime, otherScreenHasFocus,
                                     coveredByOtherScreen);

                    if (_drawable.GetDrawableState() == Painting.DrawableState.TransitionOn ||
                        _drawable.GetDrawableState() == Painting.DrawableState.Active)
                    {
                        if (!otherScreenHasFocus)
                        {
                            _drawable.HandleInput(this);
                            otherScreenHasFocus = true;
                        }
                        if (!_drawable.IsPopup)
                        {
                            coveredByOtherScreen = true;
                        }
                    }
                }
            }

            Update(gameTime);
        }
Esempio n. 14
0
 public abstract void Alter(LTimerContext context);
Esempio n. 15
0
 public override void Alter(LTimerContext timer)
 {
 }
Esempio n. 16
0
        public override void Alter(LTimerContext t)
        {
            if (IsWait())
            {
                return;
            }
            if (timer1 == null)
            {
                timer1 = new LTimer(50);
            }
            if (title != null && timer1.Action(t.GetTimeSinceLastUpdate()))
            {
                if (title.GetY() > 50)
                {
                    title.Move_up(8);
                    title.ValidatePosition();
                }
                else if (title.GetAlpha() > 0.2f)
                {
                    title.SetAlpha(title.GetAlpha() - 0.1f);
                }
                else
                {
                    title.SetVisible(false);
                    Remove(title);
                    title = null;
                }
                return;
            }
            else if (over != null && timer1.Action(t.GetTimeSinceLastUpdate()) &&
                     !overFlag)
            {
                if (over.GetY() < (GetHeight() - over.GetHeight()) / 2)
                {
                    over.Move_down(8);
                    over.ValidatePosition();
                }
                else if (over.GetAlpha() < 1.0f)
                {
                    over.SetAlpha(over.GetAlpha() + 0.1f);
                }
                else
                {
                    CenterOn(over);
                    overFlag = true;
                }

                return;
            }
            if (!wingame)
            {
                if (timer == null)
                {
                    timer = new LTimer(100);
                }
                if (timer.Action(t.GetTimeSinceLastUpdate()))
                {
                    if (progress != null)
                    {
                        progress.SetUpdate(progress.GetValue() - (stageNo * 30));
                        if (progress.GetValue() <= 100 && !failgame)
                        {
                            failgame = true;
                            GetSprites().SetVisible(false);

                            over       = new LPaper(GetImage(16), 0, 0);
                            over.Click = new OverClick();
                            over.SetAlpha(0.1f);
                            CenterOn(over);
                            over.SetY(0);
                            Add(over);
                        }
                    }
                }
            }
            else
            {
                wingame = false;
                RemoveAll();
                Stage(stageNo + 1);
            }
        }
Esempio n. 17
0
 public void Update(LTimerContext context)
 {
     Update(context.GetMilliseconds());
 }
Esempio n. 18
0
 public abstract void Run(LTimerContext time);
Esempio n. 19
0
        public override void Alter(LTimerContext timer)
        {
            for (int i = 0; i < keySize; i++)
            {
                ActionKey act = (ActionKey)keyActions.Get(i);
                if (act.IsPressed())
                {
                    act.Act(elapsedTime);
                    if (act.isReturn)
                    {
                        return;
                    }
                }
            }
            if (content.IsVisible())
            {
                ProcessEvents();
                content.UpdateNode(timer.GetMilliseconds());
            }
            if (usePhysics)
            {
                if (_dt < 0)
                {
                    _manager.Step(timer.GetMilliseconds());
                }
                else
                {
                    _manager.Step(_dt);
                }
            }
            if (follow != null)
            {
                if (usePhysics)
                {
                    _manager.Offset(follow.GetX(), follow.GetY());
                }
                foreach (TileMap tile in tiles)
                {
                    float offsetX = GetHalfWidth() - follow.GetX();
                    offsetX = MathUtils.Min(offsetX, 0);
                    offsetX = MathUtils.Max(offsetX, GetWidth() - tile.GetWidth());

                    float offsetY = GetHalfHeight() - follow.GetY();
                    offsetY = MathUtils.Min(offsetY, 0);
                    offsetY = MathUtils
                              .Max(offsetY, GetHeight() - tile.GetHeight());

                    SetOffset(tile, offsetX, offsetY);
                    tile.Update(elapsedTime);
                }
            }
            foreach (SpriteBatchObject o in objects)
            {
                if (usePhysics)
                {
                    PBody body = (PBody)CollectionUtils.Get(_Bodys, o);
                    if (body != null)
                    {
                        PShape shape    = body.Inner_shapes()[0];
                        float  rotation = (shape.GetAngle() * MathUtils.RAD_TO_DEG) % 360;
                        AABB   aabb     = shape.GetAABB();
                        o.SetLocation(_manager.GetScreenX(aabb.minX),
                                      _manager.GetScreenY(aabb.minY));
                        o.SetRotation(rotation);
                    }
                }
                o.Update(elapsedTime);
                if (updateListener != null)
                {
                    updateListener.Act(o, elapsedTime);
                }
            }
            Update(elapsedTime);
            Commits();
        }
Esempio n. 20
0
 public void Paint(LTimerContext clock)
 {
     paint.Emit(clock);
 }
Esempio n. 21
0
 public void Update(LTimerContext context)
 {
     Update(context.GetMilliseconds());
 }
Esempio n. 22
0
 public override void Alter(LTimerContext context)
 {
 }
Esempio n. 23
0
 public void Update(LTimerContext context)
 {
     Update(context.timeSinceLastUpdate);
 }