Exemplo n.º 1
0
        // preparing to perform Kruscal method
        private void PrepareForMethod()
        {
            foreach (var ed in cruscalEdgesList)
            {
                ed.condition = Condition.Waiting;
            }
            cruscalVertsList = new List <List <Verticle> >();
            for (var i = 0; i < Verticles.Count(); i++)
            {
                var newlist = new List <Verticle> {
                    Verticles[i]
                };
                cruscalVertsList.Add(newlist);
            }

            currentEdge       = 0;
            next_btn.Enabled  = curMode == DemoMode.Manual;
            start_btn.Enabled = curMode != DemoMode.Manual;
            curState          = DemoState.NotStarted;
            log_tb.Clear();
            firstPart      = true;
            start_btn.Text = "Начать";
            RefreshSets();
            drawing_panel.Refresh();
        }
Exemplo n.º 2
0
 private void FadeOut(float duration)
 {
     m_DemoState = DemoState.FadingOut;
     App.Instance.SetDesiredState(App.AppState.Reset);
     m_SecondsRemainingInState = duration;
     ViewpointScript.m_Instance.FadeToColor(Color.black, 1.0f / duration);
 }
Exemplo n.º 3
0
        //start + pause + continue button
        private void start_btn_Click(object sender, EventArgs e)
        {
            switch (curState)
            {
            case DemoState.NotStarted:     //start
                curState       = DemoState.Going;
                start_btn.Text = "Пауза";
                if (curMode != DemoMode.Manual)
                {
                    timer1.Start();
                }
                break;

            case DemoState.Going:     //pause
                timer1.Stop();
                curState       = DemoState.Paused;
                start_btn.Text = "Продолжить";
                break;

            case DemoState.Paused:     //continue
                start_btn.Text = "Пауза";
                curState       = DemoState.Going;
                if (curMode != DemoMode.Manual)
                {
                    timer1.Start();
                }
                break;

            case DemoState.End:     //ended already
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 4
0
        public ServerMode()
        {
            InitializeComponent();

            stateNoData   = new NoDataState(this);
            stateLinq2Sql = new Linq2SqlState(this);

            State = stateNoData;
        }
Exemplo n.º 5
0
 /// Called on start, and after any reset has completed.
 private void OnSessionStart()
 {
     m_DemoState = ShouldUseCountdownTimer ? DemoState.WaitingForFirstStroke
                                   : DemoState.Standard;
     if (ShouldUseCountdownTimer)
     {
         m_SecondsRemainingInState = App.UserConfig.Demo.Duration.Value;
     }
     ViewpointScript.m_Instance.FadeToScene(1.0f / m_FadeInDuration);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     base.Initialize();
     // TODO: Add your initialization logic here
     DemoState     = new DemoState();
     PausedState   = new PausedState();
     PlayingState  = new PlayingState();
     GameOverState = new GameOverState();
     GameStateManager.PushState(DemoState);
 }
Exemplo n.º 7
0
        public StateViewModel(string stateName, StateMachine <DemoState> machine, ILog logger)
            : base(logger)
        {
            _myState = (DemoState)Enum.Parse(typeof(DemoState), stateName);
            Model    = machine[_myState];
            (Model as IStateBehavior).EntryInitiated += HandleEnteringState;

            // Check for initial state.
            if (Model.IsCurrentState)
            {
                Select();
            }
        }
Exemplo n.º 8
0
        void Update()
        {
            if (!DemoModeEnabled)
            {
                return;
            }

            switch (m_DemoState)
            {
            case DemoState.WaitingForFirstStroke:
                if (PointerManager.m_Instance.IsMainPointerCreatingStroke())
                {
                    m_DemoState = DemoState.Standard;
                }
                break;

            case DemoState.Standard:
                if (ShouldUseCountdownTimer)
                {
                    m_SecondsRemainingInState -= Time.deltaTime;

                    // If the timer is up, immediately lock the sketch and start a slow fade out.
                    if (m_SecondsRemainingInState <= 0.0f)
                    {
                        FadeOut(m_TimesUpFadeOutDuration);
                    }
                }
                break;

            case DemoState.FadingOut:
                m_SecondsRemainingInState -= Time.deltaTime;
                if (m_SecondsRemainingInState <= 0.0f)
                {
                    m_SecondsRemainingInState = 0.0f;
                    App.Instance.SetDesiredState(App.AppState.Standard);
                    OnSessionStart();
                }
                break;
            }

            UpdateKeyboardCommands();

            // Update on-screen counter.
            m_DemoGui.m_CountdownTimerUI.SetActive(ShouldUseCountdownTimer);
            if (ShouldUseCountdownTimer)
            {
                m_DemoGui.m_TimeRemainingText.text = TimeRemaining;
            }
        }
Exemplo n.º 9
0
        void RunDBGenerator(DemoState nextState)
        {
            WindowDatabaseGenerator windowDBGenerator = new WindowDatabaseGenerator(this, State.DBGeneratorString);

            if (windowDBGenerator.ShowDialog() == true)
            {
                if (State == nextState)
                {
                    pivotGrid.ReloadDataAsync();
                }
                else
                {
                    State = nextState;
                }
            }
        }
Exemplo n.º 10
0
 private void PivotGridDemoModule_Loaded(object sender, RoutedEventArgs e)
 {
     IsLoad = true;
     State  = stateLinq2Sql;
     IsLoad = false;
 }
Exemplo n.º 11
0
        private void onButtonPress(object sender, ButtonPressEventArgs args)
        {
            switch (state) {
            case DemoState.AddingPoints:
                addedPoints [numPointsAdded] = new PointD (args.Event.X, args.Event.Y);
                numPointsAdded++;
                if (2 == numPointsAdded) {
                    lineSegments.Add (new LineSegment (addedPoints [0], addedPoints [1]));
                    numPointsAdded = 0;
                    state = DemoState.Walking;
                }

                break;
            case DemoState.Walking:
                Logger.Log ("Walk on walker!");
                player.setTarget (new PointD(args.Event.X,args.Event.Y));
                break;
            default:
                break;
            }
            Logger.Log("in the button press : " + args.Event.X);
        }
Exemplo n.º 12
0
 private void enterAddingPointsState()
 {
     numPointsAdded = 0;
     state = DemoState.AddingPoints;
 }
Exemplo n.º 13
0
 public void TransitorTo(DemoState state)
 {
     _state = state;
     _state.SetContext(this);
 }
Exemplo n.º 14
0
 public DemoContext(DemoState state)
 {
     _state = state;
 }
Exemplo n.º 15
0
 private void OnGUI()
 {
     GUI.skin.label.fontSize  = 40;
     GUI.skin.button.fontSize = 30;
     buttonWidth  = Screen.width / 2;
     buttonHeight = buttonWidth / 4;
     if (GUI.Button(new Rect(10f, 10f, 200f, 100f), "BACK"))
     {
         currentState = DemoState.Init;
     }
     GUI.Label(new Rect(250f, 35f, Screen.width - 260, 45f), "AATKit Unity " + version);
     if (currentState == DemoState.Init)
     {
         if (GUI.Button(new Rect(Screen.width / 2 - buttonWidth / 2, 140f, buttonWidth, buttonHeight), "Init AATKit") && !initialized)
         {
             AATKitConfiguration configuration = new AATKitConfiguration
             {
                 TestModeAccountId       = 74,
                 DetailedConsent         = AATKitConfiguration.DetailedConsentTypes.ManagedConsent,
                 ManagedConsentLanguages = new List <AATKitConfiguration.ManagedConsentLanguage>
                 {
                     AATKitConfiguration.ManagedConsentLanguage.ENGLISH,
                     AATKitConfiguration.ManagedConsentLanguage.GERMAN
                 }
             };
             AATKitBinding.Init(base.gameObject.name, configuration);
             AATKitBinding.SetDebugEnabled();
             Vector2 vector  = AATKitBinding.CreatePlacement("BannerPlacement", AATKitBinding.PlacementSize.BannerAuto);
             Vector2 vector2 = AATKitBinding.CreatePlacement("FullscreenPlacement", AATKitBinding.PlacementSize.Fullscreen);
             AATKitBinding.CreatePlacement("MultiSizePlacement", AATKitBinding.PlacementSize.MultiSizeBanner);
             UnityEngine.Debug.Log("Banner size: " + vector.x + " x " + vector.y);
             UnityEngine.Debug.Log("Fullscreen size: " + vector2.x + " x " + vector2.y);
             initialized = true;
         }
         if (GUI.Button(new Rect(Screen.width / 2 - buttonWidth / 2, buttonHeight + 150, buttonWidth, buttonHeight), "Enable Debug Log") && initialized)
         {
             AATKitBinding.SetDebugEnabled();
         }
         if (GUI.Button(new Rect(Screen.width / 2 - buttonWidth / 2, buttonHeight * 2 + 160, buttonWidth, buttonHeight), shakeText) && initialized)
         {
             if (shakeEnabled)
             {
                 AATKitBinding.SetDebugShakeEnabled(enabled: false);
                 shakeEnabled = false;
                 shakeText    = "Enable Debug Shake";
             }
             else
             {
                 AATKitBinding.SetDebugShakeEnabled(enabled: true);
                 shakeEnabled = true;
                 shakeText    = "Disable Debug Shake";
             }
         }
         if (GUI.Button(new Rect(Screen.width / 2 - buttonWidth / 2, buttonHeight * 3 + 200, buttonWidth, buttonHeight), "BANNER"))
         {
             currentState = DemoState.Banner;
         }
         if (GUI.Button(new Rect(Screen.width / 2 - buttonWidth / 2, buttonHeight * 4 + 220, buttonWidth, buttonHeight), "FULLSCREEN"))
         {
             currentState = DemoState.Fullscreen;
         }
         if (GUI.Button(new Rect(Screen.width / 2 - buttonWidth / 2, buttonHeight * 5 + 230, buttonWidth, buttonHeight), "MULTISIZE"))
         {
             currentState = DemoState.Multisize;
         }
     }
     if (currentState == DemoState.Banner)
     {
         if (GUI.Button(new Rect(Screen.width / 2 - buttonWidth / 2, 140f, buttonWidth, buttonHeight), "Reload Banner") && initialized)
         {
             AATKitBinding.ReloadPlacement("BannerPlacement");
         }
         if (GUI.Button(new Rect(Screen.width / 2 - buttonWidth / 2, buttonHeight + 150, buttonWidth, buttonHeight), autoreloadBannerText) && initialized)
         {
             if (bannerAutoreload)
             {
                 AATKitBinding.StopPlacementAutoReload("BannerPlacement");
                 bannerAutoreload     = false;
                 autoreloadBannerText = "Enable Banner Autoreload";
             }
             else
             {
                 AATKitBinding.StartPlacementAutoReload("BannerPlacement");
                 bannerAutoreload     = true;
                 autoreloadBannerText = "Disable Banner Autoreload";
             }
         }
         if (GUI.Button(new Rect(Screen.width / 2 - buttonWidth / 2, buttonHeight * 2 + 160, buttonWidth, buttonHeight), "Change Banner Alignment") && initialized)
         {
             bannerAlignment = GetNewAlignment(bannerAlignment);
             AATKitBinding.SetPlacementAlignment("BannerPlacement", bannerAlignment);
         }
     }
     if (currentState == DemoState.Fullscreen)
     {
         if (GUI.Button(new Rect(Screen.width / 2 - buttonWidth / 2, 140f, buttonWidth, buttonHeight), "Reload Interstitial") && initialized)
         {
             AATKitBinding.ReloadPlacement("FullscreenPlacement");
         }
         if (GUI.Button(new Rect(Screen.width / 2 - buttonWidth / 2, buttonHeight + 150, buttonWidth, buttonHeight), autoreloadInterstitialText) && initialized)
         {
             if (interstitialAutoreload)
             {
                 AATKitBinding.StopPlacementAutoReload("FullscreenPlacement");
                 interstitialAutoreload     = false;
                 autoreloadInterstitialText = "Enable Interstitial Autoreload";
             }
             else
             {
                 AATKitBinding.StartPlacementAutoReload("FullscreenPlacement");
                 interstitialAutoreload     = true;
                 autoreloadInterstitialText = "Disable Interstitial Autoreload";
             }
         }
         if (GUI.Button(new Rect(Screen.width / 2 - buttonWidth / 2, buttonHeight * 2 + 160, buttonWidth, buttonHeight), "Show Interstitial") && initialized)
         {
             AATKitBinding.ShowPlacement("FullscreenPlacement");
         }
     }
     if (currentState != DemoState.Multisize)
     {
         return;
     }
     if (GUI.Button(new Rect(Screen.width / 2 - buttonWidth / 2, 140f, buttonWidth, buttonHeight), "Reload MultiSize") && initialized)
     {
         AATKitBinding.ReloadPlacement("MultiSizePlacement");
     }
     if (GUI.Button(new Rect(Screen.width / 2 - buttonWidth / 2, buttonHeight + 150, buttonWidth, buttonHeight), autoreloadMultiSizeText) && initialized)
     {
         if (multiSizeAutoreload)
         {
             AATKitBinding.StopPlacementAutoReload("MultiSizePlacement");
             multiSizeAutoreload     = false;
             autoreloadMultiSizeText = "Enable Multi Size Banner Autoreload";
         }
         else
         {
             AATKitBinding.StartPlacementAutoReload("MultiSizePlacement");
             multiSizeAutoreload     = true;
             autoreloadMultiSizeText = "Disable Multi Size Banner Autoreload";
         }
     }
     if (GUI.Button(new Rect(Screen.width / 2 - buttonWidth / 2, buttonHeight * 2 + 160, buttonWidth, buttonHeight), "Change MultiSize Alignment") && initialized)
     {
         multiSizeBannerAlignment = GetNewAlignment(multiSizeBannerAlignment);
         AATKitBinding.SetMultiSizeAlignment("MultiSizePlacement", multiSizeBannerAlignment);
     }
 }
Exemplo n.º 16
0
        //Tick. Every tick performing its part of algorithm
        private void timer1_Tick(object sender, EventArgs e)
        {
            // Checking
            if (firstPart)
            {
                cruscalEdgesList[currentEdge].condition = Condition.Checking;
                log_tb.AppendText(cruscalEdgesList[currentEdge] + Environment.NewLine);
                if (curMode != DemoMode.NoAnime)
                {
                    drawing_panel.Refresh();
                }
                currentEdgeApproved = CruscalIterations(cruscalEdgesList[currentEdge]);

                firstPart = !firstPart;
            }
            else
            {
                // Checking result
                if (currentEdgeApproved)
                {
                    cruscalEdgesList[currentEdge].condition = Condition.Accept;
                    log_tb.Text          += "Подходит" + Environment.NewLine + Environment.NewLine;
                    log_tb.SelectionStart = log_tb.Text.Length;
                    log_tb.ScrollToCaret();
                }
                else
                {
                    log_tb.Text += "Не подходит" + Environment.NewLine + Environment.NewLine;
                    cruscalEdgesList[currentEdge].condition = Condition.Waiting;
                    log_tb.SelectionStart = log_tb.Text.Length;
                    log_tb.ScrollToCaret();
                }

                if (curMode != DemoMode.NoAnime)
                {
                    drawing_panel.Invalidate();
                }

                RefreshSets();

                if (cruscalVertsList.Count() == 1)
                {
                    timer1.Stop();
                    curState          = DemoState.End;
                    next_btn.Enabled  = false;
                    start_btn.Text    = "Начать";
                    start_btn.Enabled = false;
                    if (currentEdge < Edges.Count() - 1)
                    {
                        log_tb.Text += "Остальные ребра не подходят" + Environment.NewLine;
                    }
                    else
                    {
                        log_tb.Text += "Конец списка рёбер" + Environment.NewLine;
                    }
                    log_tb.SelectionStart = log_tb.Text.Length;
                    log_tb.ScrollToCaret();

                    if (curMode != DemoMode.NoAnime)
                    {
                        MessageBox.Show("Метод завершил свою работу, все вершины присоединены.", "Готово!",
                                        MessageBoxButtons.OK);
                    }
                    drawing_panel.Invalidate();
                }

                firstPart = !firstPart;
                ++currentEdge;
            }
        }