Update() public method

public Update ( ) : void
return void
Beispiel #1
0
        public void Update(int dt)
        {
            if (GameOver)
            {
                return;
            }

            BonusPoints.Update(dt);

            Timer.Update(dt);

            if (Timer.State == DynamicState.END)
            {
                GameOver = true;
                return;
            }

            bool isBusy       = false;
            bool hasInvisible = false;

            foreach (var go in GameMatrix)
            {
                go.Update(dt);
                isBusy       |= go.IsBusy();
                hasInvisible |= !go.Visible;
            }

            if (!isBusy)
            {
                if (hasInvisible)
                {
                    GameMatrix.Next(MatrixState.KILL);
                }
                else
                {
                    GameMatrix.Next();

                    if (clientSwapModel != null && GameMatrix.State == MatrixState.NONE)
                    {
                        switch (clientSwapModel.Direction)
                        {
                        case SwapDirection.HORIZONTAL:
                            GameMatrix.SwapH(clientSwapModel.GameObject1, clientSwapModel.GameObject2);
                            break;

                        case SwapDirection.VERTICAL:
                            GameMatrix.SwapV(clientSwapModel.GameObject1, clientSwapModel.GameObject2);
                            break;
                        }
                    }

                    if (clientSwapModel != null)
                    {
                        clientSwapModel = null;
                    }
                }
            }

            CanClientInput = !isBusy && GameMatrix.State == MatrixState.NONE;
        }