Exemple #1
0
    /// <summary>
    /// Set the actual mode
    /// </summary>
    /// <param name="modus"></param>
    private void SetMode(Modus modus)
    {
        actualModus = modus;
        Debug.Log(actualModus);

        switch (actualModus)
        {
        case Modus.Orient:
            Cursor.Instance.SetMode(Cursor.Mode.Orient);
            Orientation.Instance.Reset();
            break;

        default:
        case Modus.Reset:
            Cursor.Instance.SetMode(Cursor.Mode.None);
            Orientation.Instance.Reset();
            break;

        case Modus.Next:
            Cursor.Instance.SetMode(Cursor.Mode.Next);
            Orientation.Instance.Reset();
            break;

        case Modus.Previous:
            Cursor.Instance.SetMode(Cursor.Mode.Previous);
            Orientation.Instance.Reset();
            break;
        }
    }
        public ScrollRenderer(Modus modus, TimeSpan speed, TimeSpan? pause = null)
        {
            Speed = speed;
            Pause = pause ?? new TimeSpan(0);
            Mode = modus;

            Reset();
        }
Exemple #3
0
        private void OnModusChanged(Modus modus)
        {
            EventHandler <ModusChangedEventArgs> modusChanged = ModusChanged;

            if (modusChanged != null)
            {
                modusChanged(this, new ModusChangedEventArgs(modus));
            }
        }
Exemple #4
0
        public void AverageCalculateTest()
        {
            string inputText = GetInputText("CorrectFile.txt");
            List <StudentsList> stByGroups = Parser.TransformRecevedInformation(inputText);
            Response            response   = Analyzer.AnalyzeReceievedInforamtion(stByGroups);
            Modus modus = response.GroupsInfo.FirstOrDefault(g => g.Group == "Group1").Modus;

            Assert.AreEqual(51, response.GroupsInfo.FirstOrDefault(g => string.Compare(g.Group, "Group1", StringComparison.OrdinalIgnoreCase) == 0).Average);
        }
Exemple #5
0
        public void TestModus123()
        {
            Modus m = new Modus();

            Assert.AreEqual(0, m.Value());

            m.Add(1);
            Assert.AreEqual(1, m.Value());

            m.Add(2);
            Assert.AreEqual(1, m.Value());

            m.Add(2);
            Assert.AreEqual(2, m.Value());

            m.Add(3);
            Assert.AreEqual(2, m.Value());

            m.Add(0);
            m.Add(0);
            Assert.AreEqual(0, m.Value());
        }
Exemple #6
0
        // überprüfen ob eine Schwierigkeit ausgewählt wurde
        private bool CheckDifficultySelection()
        {
            log.Trace("CheckDifficultySelection");

            // Schwierigkeitsgrad wählen
            if (difficulty == Difficulty.NotSelected)
            {
                log.Trace("CheckDifficultySelection 1");
                if (modus != Modus.Menu) // MenuUi zeigen, falls zuvor in einem anderen Modus gewesen
                {
                    log.Trace("CheckDifficultySelection 2");
                    modus = Modus.Menu;
                    log.Trace("CheckDifficultySelection 3");
                    Body.Instance.Scale(1f); // warum ist das nötig?
                    log.Trace("CheckDifficultySelection 4");
                    HideAllGuis();
                    log.Trace("CheckDifficultySelection 5");
                    MenuUi.Instance.Show();
                    log.Trace("CheckDifficultySelection 6");
                    backgroundSound.Play();
                    log.Trace("CheckDifficultySelection 7");
                }
                log.Trace("CheckDifficultySelection 8");

                return false;
            }
            log.Trace("CheckDifficultySelection 9");

            return true;
        }
Exemple #7
0
        // Überprüft ob das Button Tutorial abgeschlossen wurde
        private bool CheckButtonTutorial()
        {
            log.Trace("CheckButtonTutorial");

            if (ButtonTutorialCompleted == false)
            {
                if (modus != Modus.ButtonTutorial)
                {
                    modus = Modus.ButtonTutorial;
                    Body.Instance.Scale(1f); // warum ist das nötig?
                    HideAllGuis();
                    ButtonTutorialUi.Instance.Show();
                    backgroundSound.Play();
                }

                return false;
            }

            return true;
        }
Exemple #8
0
        internal void MoveShape(PointerRoutedEventArgs e, Point position)
        {
            Model.Shape shape = null;
            Name = ((FrameworkElement)e.OriginalSource).Name;
            OnPropertyChanged("Name");
            OriginalSource = ((FrameworkElement)e.OriginalSource);
            OnPropertyChanged("OriginalSource");
            if (Modus == Modus.TurnHandle && e.Pointer.IsInContact)
            {
                _model.TurnShape(position);
            }
            else if ((Modus >= (Modus)0 && Modus <= (Modus)7) && e.Pointer.IsInContact)
            {
                _model.ResizeShape(position, Modus);
            }
            else
            {
                try
                {
                    shape = _shapes.First(x => (x.Value == OriginalSource)).Key;
                    Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.SizeAll, 1);
                }
                catch (InvalidOperationException ex)
                {
                    if (adorner.Key != null)
                    {
                    }
                    switch (Name)
                    {
                    case "TopLeft":
                        ModusType  = (int)(2 * Math.Floor((adorner.Key.Rotation + 45) / 90));
                        CursorType = (int)(Math.Floor((adorner.Key.Rotation - 22.5) / 45));
                        Modus      = (Modus)ModusType;
                        Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor((Windows.UI.Core.CoreCursorType)CursorType, 1);
                        break;

                    case "TopCenter":
                        ModusType  = (int)(2 * Math.Floor((adorner.Key.Rotation + 45) / 90)) + 1;
                        CursorType = (int)(Math.Floor((adorner.Key.Rotation + 22.5) / 45));
                        Modus      = (Modus)ModusType;
                        Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor((Windows.UI.Core.CoreCursorType)CursorType, 1);
                        break;

                    case "TopRight":
                        ModusType  = (int)(2 * Math.Floor((adorner.Key.Rotation + 135) / 90));
                        CursorType = (int)(Math.Floor((adorner.Key.Rotation + 67.5) / 45));
                        Modus      = (Modus)ModusType;
                        Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor((Windows.UI.Core.CoreCursorType)CursorType, 1);
                        break;

                    case "CenterRight":
                        ModusType  = (int)(2 * Math.Floor((adorner.Key.Rotation + 135) / 90)) + 1;
                        CursorType = (int)(Math.Floor((adorner.Key.Rotation + 112.5) / 45));
                        Modus      = (Modus)ModusType;
                        Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor((Windows.UI.Core.CoreCursorType)CursorType, 1);
                        break;

                    case "BottomRight":
                        ModusType  = (int)(2 * Math.Floor((adorner.Key.Rotation + 225) / 90));
                        CursorType = (int)(Math.Floor((adorner.Key.Rotation + 157.5) / 45));
                        Modus      = (Modus)ModusType;
                        Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor((Windows.UI.Core.CoreCursorType)CursorType, 1);
                        break;

                    case "BottomCenter":
                        ModusType  = (int)(2 * Math.Floor((adorner.Key.Rotation + 225) / 90)) + 1;
                        CursorType = (int)(Math.Floor((adorner.Key.Rotation + 202.5) / 45));
                        Modus      = (Modus)ModusType;
                        Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor((Windows.UI.Core.CoreCursorType)CursorType, 1);
                        break;

                    case "BottomLeft":
                        ModusType  = (int)(2 * Math.Floor((adorner.Key.Rotation + 315) / 90));
                        CursorType = (int)(Math.Floor((adorner.Key.Rotation + 247.5) / 45));
                        Modus      = (Modus)ModusType;
                        Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor((Windows.UI.Core.CoreCursorType)CursorType, 1);
                        break;

                    case "CenterLeft":
                        ModusType  = (int)(2 * Math.Floor((adorner.Key.Rotation + 315) / 90)) + 1;
                        CursorType = (int)(Math.Floor((adorner.Key.Rotation + 292.5) / 45));
                        Modus      = (Modus)ModusType;
                        Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor((Windows.UI.Core.CoreCursorType)CursorType, 1);
                        break;

                    case "TurnHandle":
                        Modus = Modus.TurnHandle;
                        Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Custom, 101);
                        break;

                    default:
                        Modus = Modus.Move;
                        Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Arrow, 1);
                        break;
                    }
                    OnPropertyChanged("ModusType");
                }
            }
            _model.MoveShape(position);
        }
Exemple #9
0
 // Alles auf den Anfangszustand zurücksetzen
 private void ResetEverything()
 {
     modus = Modus.NotTracked;
     difficulty = Difficulty.NotSelected;
     ButtonLoadingClicked = false;
     Game.Instance.ResetGame();
 }
Exemple #10
0
        // prüfen ob eine Person von der Kinect erkannt wird
        private bool CheckPersonTracking()
        {
            log.Trace("CheckPersonTracking");

            // Überprüfen ob eine Person erkannt wird
            if (!Body.Instance.IsTracked)
            {
                if (modus != Modus.NotTracked) // NoTrackingUi zeigen, falls zuvor in einem anderen Modus gewesen
                {
                    modus = Modus.NotTracked;
                    HideAllGuis();
                    NoTrackingUi.Instance.Show();
                    backgroundSound.Play();
                }

                // Alles zurücksetzen, da keine Person mehr erkannt wird
                ResetEverything();

                // Tutorial wieder anzeigen, da es möglicherweise eine neue Person ist
                ButtonTutorialCompleted = false;

                return false;
            }

            // Kinect ist angeschlossen und Person erkannt: Cursors updaten
            JumpAndRun.Gui.Elements.Cursor.Instance.UpdateCursor();

            return true;
        }
Exemple #11
0
        // Überprüfen ob das Spiel am laufen ist
        private bool CheckGaming()
        {
            log.Trace("CheckGaming");

            // Darstellung des Spiels updaten
            Game.Instance.Update();

            // Level ist geladen
            if (Game.Instance.GameStatus == GameStatus.LoadingComplete)
            {
                if (modus != Modus.Play)
                {
                    modus = Modus.Play;
                    HideAllGuis();
                    backgroundSound.Stop();
                    Game.Instance.Start();
                }

                return false;
            }
            // am spielen
            else if (Game.Instance.GameStatus == GameStatus.Playing /*|| Game.Instance.GameStatus == GameStatus.Start*/)
            {
                if (modus != Modus.Play)
                {
                    log.Debug("Seltsamer Zustand: Run > CheckGaming()");
                    modus = Modus.Play;
                    HideAllGuis();
                    backgroundSound.Stop();
                    Game.Instance.Start();
                }

                return false;
            }
            // Spiel erfolgreich beendet
            else if (Game.Instance.GameStatus == GameStatus.Successful)
            {
                return true;
            }
            else if (Game.Instance.GameStatus == GameStatus.GameOver)
            {
                return true;
            }

            return false;
        }
Exemple #12
0
 private void ModelModusChanged(object sender, ModusChangedEventArgs e)
 {
     Modus = e.Modus;
 }
    /// <summary>
    /// berechnet den nächsten Schritt
    /// </summary>
    /// <param name="limit">Anzahl der zu berechnenden (kleinen) Arbeitsschritte, negativer Wert = optionale Vorbereitungsschritte)</param>
    /// <returns>gibt an, ob noch weitere Berechnungen anstehen</returns>
    public bool Next(int limit)
    {
      if (limit == 0) return false;
      switch (modus)
      {
        #region # case Modus.unbekannt:
        case Modus.Unbekannt:
        {
          if (limit > 0)
          {
            modus = Modus.SucheInit; // Initialisierung für die Suche direkt starten
          }
          else
          {
            modus = Modus.SteinerInit; // Initialisierung der Vorbereitung starten
          }
          return true;
        }
        #endregion
        #region # case Modus.steinerInit:
        case Modus.SteinerInit:
        {
          if (limit > 0)
          {
            modus = Modus.SucheInit; // Vorbereitung abbrechen und Suche direkt starten
            return true;
          }

          int maxKisten = feldData.Where(c => c == '$' || c == '*').Count();

          kistenAnzahl++;

          if (kistenAnzahl >= maxKisten)
          {
            return false; // Maximale Kistenanzahl erreicht, weitere Berechnungen sind nicht mehr möglich
          }

          modus = Modus.SteinerVarianten; // neue Aufgabe: alle Varianten ermitteln

          KistenSteinerInit();
          steinerPrüfStellungen = new List<Variante>();
          steinerPrüfstellungenPos = 0;

          return true;
        }
        #endregion
        #region # case Modus.steinerVarianten:
        case Modus.SteinerVarianten:
        {
          if (limit > 0)
          {
            modus = Modus.SucheInit; // Vorbereitung abbrechen und Suche direkt starten
            return true;
          }

          limit = -limit;

          while (limit > 0)
          {
            if (steinerPrüfstellungenPos == steinerPrüfStellungen.Count)
            {
              limit--;
              if (!KistenSteinerNext())
              {
                modus = Modus.SteinerLösen;
                steinerBöseStellungen = steinerPrüfStellungen.Where(x => bekannteStellungen.ContainsKey(x.stellungCrc) && bekannteStellungen[x.stellungCrc] == 1).ToArray();
                steinerPrüfStellungen = steinerPrüfStellungen.Where(x => bekannteStellungen.ContainsKey(x.stellungCrc) && bekannteStellungen[x.stellungCrc] == 2).ToList();
                bekannteStellungen = bekannteStellungen.Where(x => x.Value == 1).ToDictionary(x => x.Key, x => x.Value);
                steinerPrüfstellungenPos = 0;
                return true;
              }
            }
            else
            {
              var prüf = steinerPrüfStellungen[steinerPrüfstellungenPos++];
              LadeStellung(prüf.stellung); limit--;
              if (kistenMitZiel == kistenAnzahl) bekannteStellungen[prüf.stellungCrc] = 2;
              foreach (var neuPrüf in SucheVariantenSteiner())
              {
                steinerPrüfStellungen.Add(neuPrüf);
                bekannteStellungen.Add(neuPrüf.stellungCrc, 1);
              }
            }
          }

          return true;
        }
        #endregion
        #region # case Modus.steinerLösen:
        case Modus.SteinerLösen:
        {
          if (limit > 0)
          {
            modus = Modus.SucheInit; // Vorbereitung abbrechen und Suche direkt starten
            return true;
          }

          limit = -limit;

          while (limit > 0)
          {
            if (steinerPrüfstellungenPos == steinerPrüfStellungen.Count)
            {
              // var dummy = steinerBöseStellungen.Where(x => bekannteStellungen.ContainsKey(x.stellungCrc)).ToArray();

              foreach (var satz in steinerBöseStellungen.Where(x => bekannteStellungen.ContainsKey(x.stellungCrc)))
              {
                SteinerBlockerDazu(satz.stellung);
              }

              modus = Modus.SteinerInit;

              return true;
            }

            var prüf = steinerPrüfStellungen[steinerPrüfstellungenPos++];
            LadeStellung(prüf.stellung); limit--;
            suchTiefe = 99999;

            var vorgänger = SucheVariantenVorgänger().ToArray();

            if (vorgänger.Length > 0)
            {
              foreach (var check in vorgänger)
              {
                if (bekannteStellungen.ContainsKey(check.stellungCrc))
                {
                  steinerPrüfStellungen.Add(new Variante { stellung = check.stellung, stellungCrc = check.stellungCrc, tiefe = 1 });
                  bekannteStellungen.Remove(check.stellungCrc);
                }
              }
            }
            else // gute Stellung, da keine Vorgänger möglich sind
            {
              if (bekannteStellungen.ContainsKey(prüf.stellungCrc)) bekannteStellungen.Remove(prüf.stellungCrc);
            }

          }

          return true;
        }
        #endregion
        #region # case Modus.sucheInit:
        case Modus.SucheInit:
        {
          raumSpielerPos = feldZuRaum[startSpielerPos];

          KistenStandardInit();

          suchListenAnzahl = new int[2048]; // maximal Spielzüge in die Tiefe berechenbar (kann jedoch problemlos vergrößert werden)
          suchListenSatz = kistenAnzahl + 1 + 1;

          suchListenDaten = new ushort[suchListenSatz];
          for (int i = 0; i < suchListenDaten.Length; i += suchListenSatz) suchListenDaten[i] = 32000; // alle Felder als frei kennzeichnen
          suchListenSuchFrei = 0;
          suchListenSuchNext = 0;

          suchTiefe = 0;
          SuchListeInsert(GetStellung(), suchTiefe);
          bekannteStellungen = new Dictionary<ulong, ushort>();
          bekannteStellungen[StellungCrc(GetStellung())] = 0; // Startstellung als bekannte Stellung hinzufügen

          modus = Modus.SucheRechne;
          return true;
        }
        #endregion
        #region # case Modus.sucheRechne:
        case Modus.SucheRechne:
        {
          limit = Math.Min(limit, suchListenAnzahl[suchTiefe]);
          for (int listenPos = 0; listenPos < limit; listenPos++)
          {
            LadeStellung(SuchListeNext(suchTiefe));
            if (kistenMitZiel == kistenAnzahl)
            {
              modus = Modus.SucheGefunden;
              return false;
            }

            if (StellungBekannt(StellungCrc(GetStellung())) < suchTiefe) continue; // zu prüfende Stellung wurde schon früher (mit weniger Tiefe) berechnet

            foreach (var variante in SucheVariantenHashcheck())
            {
              var tmpTiefe = StellungBekannt(variante.stellungCrc);
              if (tmpTiefe >= 0)
              {
                if (tmpTiefe <= variante.tiefe) continue; // Vorschlag ignorieren
                bekannteStellungen[variante.stellungCrc] = (ushort)variante.tiefe; // neue Tiefe setzen
                SuchListeInsert(variante.stellung, variante.tiefe);
              }
              else
              {
                bekannteStellungen.Add(variante.stellungCrc, (ushort)variante.tiefe);
                SuchListeInsert(variante.stellung, variante.tiefe);
              }
            }
          }
          if (suchListenAnzahl[suchTiefe] == 0) suchTiefe++; // keine weiteren Stellungen bei dieser Zugtiefe vorhanden, dann zur nächsten Zugtiefe springen
          return true;
        }
        #endregion
        case Modus.SucheGefunden: return false; // Ergebnis gefunden, keine weiteren Berechnungen notwendig
        default: throw new Exception("? " + modus);
      }

    }
 public ModusChangedEventArgs(Modus modus)
 {
     Modus = modus;
 }
Exemple #15
0
        // Überprüfen ob der Spieler noch den Endbildschirm bestaunt
        private bool CheckFinishedGame()
        {
            log.Trace("CheckFinishedGame");

            // Spiel erfolgreich beendet
            if (Game.Instance.GameStatus == GameStatus.Successful)
            {
                if (modus != Modus.Score)
                {
                    modus = Modus.Score;
                    Body.Instance.Scale(1f);
                    ScoreUi.Instance.Gains = Game.Instance.Player.Gains;
                    ScoreUi.Instance.Penalties = Game.Instance.Player.Penalties;
                    HideAllGuis();
                    ScoreUi.Instance.Show();
                    backgroundSound.Play();
                }

                return false;
            }
            // Spiel nicht so erfolgreich beendet
            else if (Game.Instance.GameStatus == GameStatus.GameOver)
            {
                if (modus != Modus.GameOver)
                {
                    modus = Modus.GameOver;
                    Body.Instance.Scale(1f);
                    HideAllGuis();
                    GameOverUi.Instance.Show();
                    backgroundSound.Play();
                }

                return false;
            }

            return true;
        }
Exemple #16
0
        // Überprüfen ob das Spiel geladen ist
        private bool CheckGameLoading()
        {
            log.Trace("CheckGameLoading");

            // Button auf Lade Bildschirm noch nicht geklickt
            if (!ButtonLoadingClicked)
            {
                // Spiel muss geladen werden
                if (Game.Instance.GameStatus == GameStatus.Start) // GameStatus.Initial???
                {
                    if (modus != Modus.Loading)
                    {
                        modus = Modus.Loading;
                        HideAllGuis();
                        LoadingUi.Instance.Show();
                        backgroundSound.Play();

                        // Spiel laden
                        string path = "data/levels/jungle/level.xml";
                        Game.Instance.Load(path, difficulty);
                    }

                    return false;
                }
                // Level ist geladen
                else if (Game.Instance.GameStatus == GameStatus.LoadingComplete)
                {
                    if (modus != Modus.LoadingComplete)
                    {
                        modus = Modus.LoadingComplete;
                        // Button anzeigen
                        LoadingUi.Instance.LoadingComplete();
                    }

                    return false;
                }
            }

            return true;
        }
Exemple #17
0
        internal void MoveShape(MouseEventArgs e, Point position)
        {
            Model.Shape shape = null;
            Name           = ((FrameworkElement)e.OriginalSource).Name;
            OriginalSource = ((FrameworkElement)e.OriginalSource);
            if (Modus == Modus.TurnHandle && e.LeftButton == MouseButtonState.Pressed)
            {
                _model.TurnShape(position);
            }
            else if ((Modus >= (Modus)0 && Modus <= (Modus)7) && e.LeftButton == MouseButtonState.Pressed)
            {
                _model.ResizeShape(position, Modus);
            }
            else
            {
                try
                {
                    shape = _shapes.First(x => (x.Value == OriginalSource)).Key;
                    Mouse.OverrideCursor = Cursors.SizeAll;
                }
                catch (InvalidOperationException ex)
                {
                    resize = true;
                    switch (Name)
                    {
                    case "TopLeft":
                        ModusType  = (int)(2 * Math.Floor((adorner.Key.Rotation + 45) / 90));
                        CursorType = (int)(Math.Floor((adorner.Key.Rotation - 22.5) / 45));
                        Modus      = (Modus)ModusType;
                        break;

                    case "TopCenter":
                        ModusType  = (int)(2 * Math.Floor((adorner.Key.Rotation + 45) / 90)) + 1;
                        CursorType = (int)(Math.Floor((adorner.Key.Rotation + 22.5) / 45));
                        Modus      = (Modus)ModusType;
                        break;

                    case "TopRight":
                        ModusType  = (int)(2 * Math.Floor((adorner.Key.Rotation + 135) / 90));
                        CursorType = (int)(Math.Floor((adorner.Key.Rotation + 67.5) / 45));
                        Modus      = (Modus)ModusType;
                        break;

                    case "CenterRight":
                        ModusType  = (int)(2 * Math.Floor((adorner.Key.Rotation + 135) / 90)) + 1;
                        CursorType = (int)(Math.Floor((adorner.Key.Rotation + 112.5) / 45));
                        Modus      = (Modus)ModusType;
                        break;

                    case "BottomRight":
                        ModusType  = (int)(2 * Math.Floor((adorner.Key.Rotation + 225) / 90));
                        CursorType = (int)(Math.Floor((adorner.Key.Rotation + 157.5) / 45));
                        Modus      = (Modus)ModusType;
                        break;

                    case "BottomCenter":
                        ModusType  = (int)(2 * Math.Floor((adorner.Key.Rotation + 225) / 90)) + 1;
                        CursorType = (int)(Math.Floor((adorner.Key.Rotation + 202.5) / 45));
                        Modus      = (Modus)ModusType;
                        break;

                    case "BottomLeft":
                        ModusType  = (int)(2 * Math.Floor((adorner.Key.Rotation + 315) / 90));
                        CursorType = (int)(Math.Floor((adorner.Key.Rotation + 247.5) / 45));
                        Modus      = (Modus)ModusType;
                        break;

                    case "CenterLeft":
                        ModusType  = (int)(2 * Math.Floor((adorner.Key.Rotation + 315) / 90)) + 1;
                        CursorType = (int)(Math.Floor((adorner.Key.Rotation + 292.5) / 45));
                        Modus      = (Modus)ModusType;
                        break;

                    case "TurnHandle":
                        Modus = Modus.TurnHandle;
                        Mouse.OverrideCursor = Cursors.Cross;
                        resize = false;
                        break;

                    default:
                        Modus = Modus.Move;
                        Mouse.OverrideCursor = Cursors.SizeAll;
                        resize = false;
                        break;
                    }
                    if (resize)
                    {
                        switch (CursorType)
                        {
                        case 0:
                        case 4:
                            Mouse.OverrideCursor = Cursors.SizeNWSE;
                            break;

                        case 1:
                        case 5:
                            Mouse.OverrideCursor = Cursors.SizeNS;
                            break;

                        case 2:
                        case 6:
                            Mouse.OverrideCursor = Cursors.SizeNESW;
                            break;

                        case 3:
                        case 7:
                            Mouse.OverrideCursor = Cursors.SizeWE;
                            break;
                        }
                    }
                    OnPropertyChanged("ModusType");
                }
            }
            _model.MoveShape(position);
        }
Exemple #18
0
        // prüfen ob Kinect angeschlossen ist
        private bool CheckKinect()
        {
            log.Trace("CheckKinect");

            if (sensor == null)
            {
                modus = Modus.KinectMissing;

                // Personenerkennung starten
                try
                {
                    // Programm Starten
                    sensor = new SkeletonTracker();
                    sensor.Start();
                    KinectUi.Instance.Hide();

                    return true;
                }
                catch (Exception e)
                {
                    KinectUi.Instance.SetText("Die Kinect ist nicht angeschlossen");
                    KinectUi.Instance.Show();
                    modus = Modus.KinectMissing;
                    sensor = null;
                }
            }
            else
            {
                return true;
            }

            return false;
        }
Exemple #19
0
        internal void ResizeShape(Point position, Modus modus)
        {
            switch (modus)
            {
            case Modus.TopLeft:
                if (position.X < currentShape.Key.End.X && position.Y < currentShape.Key.End.Y)
                {
                    ResizeTopLeft(position);
                }
                else if (position.X >= currentShape.Key.End.X && position.Y >= currentShape.Key.End.Y)
                {
                    modus = Modus.BottomRight;
                }
                else if (position.X >= currentShape.Key.End.X && position.Y < currentShape.Key.End.Y)
                {
                    modus = Modus.BottomLeft;
                }
                else if (position.X < currentShape.Key.End.X && position.Y >= currentShape.Key.End.Y)
                {
                    modus = Modus.TopRight;
                }
                OnModusChanged(modus);
                break;

            case Modus.BottomRight:
                if (position.X > currentShape.Key.Start.X && position.Y > currentShape.Key.Start.Y)
                {
                    ResizeBottomRight(position);
                }
                else if (position.X <= currentShape.Key.Start.X && position.Y <= currentShape.Key.Start.Y)
                {
                    modus = Modus.TopLeft;
                }
                else if (position.X <= currentShape.Key.Start.X && position.Y > currentShape.Key.Start.Y)
                {
                    modus = Modus.BottomLeft;
                }
                else if (position.X > currentShape.Key.Start.X && position.Y <= currentShape.Key.Start.Y)
                {
                    modus = Modus.TopRight;
                }
                OnModusChanged(modus);
                break;

            case Modus.TopRight:
                if (position.X > currentShape.Key.Start.X && position.Y < currentShape.Key.End.Y)
                {
                    ResizeTopRight(position);
                }
                else if (position.X <= currentShape.Key.Start.X && position.Y >= currentShape.Key.End.Y)
                {
                    modus = Modus.BottomLeft;
                }
                else if (position.X > currentShape.Key.Start.X && position.Y >= currentShape.Key.End.Y)
                {
                    modus = Modus.BottomRight;
                }
                else if (position.X <= currentShape.Key.Start.X && position.Y < currentShape.Key.End.Y)
                {
                    modus = Modus.TopLeft;
                }
                OnModusChanged(modus);
                break;

            case Modus.BottomLeft:
                if (position.X < currentShape.Key.End.X && position.Y > currentShape.Key.Start.Y)
                {
                    ResizeBottomLeft(position);
                }
                else if (position.X >= currentShape.Key.End.X && position.Y <= currentShape.Key.Start.Y)
                {
                    modus = Modus.TopRight;
                }
                else if (position.X < currentShape.Key.End.X && position.Y <= currentShape.Key.Start.Y)
                {
                    modus = Modus.TopLeft;
                }
                else if (position.X >= currentShape.Key.End.X && position.Y > currentShape.Key.Start.Y)
                {
                    modus = Modus.BottomRight;
                }
                OnModusChanged(modus);
                break;

            case Modus.TopCenter:
                if (position.Y < currentShape.Key.End.Y)
                {
                    ResizeTopCenter(position);
                }
                else if (position.Y >= currentShape.Key.End.Y)
                {
                    currentShapeStartX = currentShape.Key.Start.X - (currentShapeHeight / 2 - currentShape.Key.Area.Height / 2) * Math.Sin(Math.PI / 180 * currentShape.Key.Rotation);
                    modus = Modus.BottomCenter;
                }
                OnModusChanged(modus);
                break;

            case Modus.BottomCenter:
                if (position.Y > currentShape.Key.Start.Y)
                {
                    ResizeBottomCenter(position);
                }
                else if (position.Y <= currentShape.Key.Start.Y)
                {
                    currentShapeStartX = currentShape.Key.Start.X + (currentShapeHeight / 2 - currentShape.Key.Area.Height / 2) * Math.Sin(Math.PI / 180 * currentShape.Key.Rotation);
                    modus = Modus.TopCenter;
                }
                OnModusChanged(modus);
                break;

            case Modus.CenterLeft:
                if (position.X < currentShape.Key.End.X)
                {
                    ResizeCenterLeft(position);
                }
                else if (position.X >= currentShape.Key.End.X)
                {
                    currentShapeStartY = currentShape.Key.Start.Y + (currentShapeWidth / 2 - currentShape.Key.Area.Width / 2) * Math.Sin(Math.PI / 180 * currentShape.Key.Rotation);
                    modus = Modus.CenterRight;
                }
                OnModusChanged(modus);
                break;

            case Modus.CenterRight:
                if (position.X > currentShape.Key.Start.X)
                {
                    ResizeCenterRight(position);
                }
                else if (position.X <= currentShape.Key.Start.X)
                {
                    currentShapeStartY = currentShape.Key.Start.Y - (currentShapeWidth / 2 - currentShape.Key.Area.Width / 2) * Math.Sin(Math.PI / 180 * currentShape.Key.Rotation);
                    modus = Modus.CenterLeft;
                }
                OnModusChanged(modus);
                break;
            }
            MoveAdorner(position);
        }
Exemple #20
0
        private bool Initialize()
        {
            log.Debug("Run Initialize");

            // Fenster öffnen
            bool fullscreen = true;
            uint windowWidth = 0;
            uint windowHeight = 0;

            // fenstermodus im debugmodus
            if (Program.state == Program.State.Debug)
            {
                fullscreen = false;
                windowWidth = 1024;
                windowHeight = 768;
            }
            if (!Window.Init("Dschungel Trainer", fullscreen, windowWidth, windowHeight))
            {
                System.Windows.Forms.MessageBox.Show("Leider kann das Spiel auf deinem Computer nicht gestartet werden. Wahrscheinlich ist die Grafikkarte zu alt.");
                return false;
            }

            // sound
            backgroundSound = new Sound.Sound(GetRandomFileFromFolder("data/sound/menu/background", "*.mp3"));
            backgroundSound.Volume = 50;
            backgroundSound.SoundFinished += new Sound.Sound.SoundFinishedEventHandler(SoundFinished);

            // GUI für Initialisierung anzeigen
            modus = Modus.KinectMissing;
            KinectUi.Instance.SetText("Kinect wird gestartet");
            KinectUi.Instance.Show();

            // Spielerskalierung
            Player.Instance.Scale = 1;

            // click events
            ButtonTutorialUi.Instance.ButtonClickedEvent += new ButtonTutorialUi.ButtonClick(TutorialButtonClicked);
            MenuUi.Instance.DifficultySelectedEvent += new MenuUi.DifficultySelected(DifficultySelected);
            LoadingUi.Instance.ButtonClickedEvent += new LoadingUi.ButtonClick(LoadingButtonClicked);
            ScoreUi.Instance.ButtonClickedEvent += new ScoreUi.ButtonClick(ScoreButtonClicked);
            GameOverUi.Instance.ButtonClickedEvent += new GameOverUi.ButtonClick(GameOverButtonClicked);

            // Zufallszahlen initialisieren
            RandomNumberGenerator.SetSeedFromSystemTime();

            return true;
        }
Exemple #21
0
 internal void AdornerResize(Modus direction, Point position)
 {
 }
Exemple #22
0
        internal void ResizeShape(Point position, Modus modus)
        {
            switch (modus)
            {
            case Modus.TopLeft:
                if (position.X < currentShape.Key.End.X && position.Y < currentShape.Key.End.Y)
                {
                    ResizeTopLeft(position);
                }
                else if (position.X >= currentShape.Key.End.X && position.Y >= currentShape.Key.End.Y)
                {
                    modus = Modus.BottomRight;
                }
                else if (position.X >= currentShape.Key.End.X && position.Y < currentShape.Key.End.Y)
                {
                    modus = Modus.BottomLeft;
                }
                else if (position.X < currentShape.Key.End.X && position.Y >= currentShape.Key.End.Y)
                {
                    modus = Modus.TopRight;
                }
                OnModusChanged(modus);
                break;

            case Modus.BottomRight:
                if (position.X > currentShape.Key.Start.X && position.Y > currentShape.Key.Start.Y)
                {
                    ResizeBottomRight(position);
                }
                else if (position.X <= currentShape.Key.Start.X && position.Y <= currentShape.Key.Start.Y)
                {
                    modus = Modus.TopLeft;
                }
                else if (position.X <= currentShape.Key.Start.X && position.Y > currentShape.Key.Start.Y)
                {
                    modus = Modus.BottomLeft;
                }
                else if (position.X > currentShape.Key.Start.X && position.Y <= currentShape.Key.Start.Y)
                {
                    modus = Modus.TopRight;
                }
                OnModusChanged(modus);
                break;

            case Modus.TopRight:
                if (position.X > currentShape.Key.Start.X && position.Y < currentShape.Key.End.Y)
                {
                    ResizeTopRight(position);
                }
                else if (position.X <= currentShape.Key.Start.X && position.Y >= currentShape.Key.End.Y)
                {
                    modus = Modus.BottomLeft;
                }
                else if (position.X > currentShape.Key.Start.X && position.Y >= currentShape.Key.End.Y)
                {
                    modus = Modus.BottomRight;
                }
                else if (position.X <= currentShape.Key.Start.X && position.Y < currentShape.Key.End.Y)
                {
                    modus = Modus.TopLeft;
                }
                OnModusChanged(modus);
                break;

            case Modus.BottomLeft:
                if (position.X < currentShape.Key.End.X && position.Y > currentShape.Key.Start.Y)
                {
                    ResizeBottomLeft(position);
                }
                else if (position.X >= currentShape.Key.End.X && position.Y <= currentShape.Key.Start.Y)
                {
                    modus = Modus.TopRight;
                }
                else if (position.X < currentShape.Key.End.X && position.Y <= currentShape.Key.Start.Y)
                {
                    modus = Modus.TopLeft;
                }
                else if (position.X >= currentShape.Key.End.X && position.Y > currentShape.Key.Start.Y)
                {
                    modus = Modus.BottomRight;
                }
                OnModusChanged(modus);
                break;

            case Modus.TopCenter:
                if (position.Y < currentShape.Key.End.Y)
                {
                    ResizeTopCenter(position);
                }
                else if (position.Y >= currentShape.Key.End.Y)
                {
                    modus = Modus.BottomCenter;
                }
                OnModusChanged(modus);
                break;

            case Modus.BottomCenter:
                if (position.Y > currentShape.Key.Start.Y)
                {
                    ResizeBottomCenter(position);
                }
                else if (position.Y <= currentShape.Key.Start.Y)
                {
                    modus = Modus.TopCenter;
                }
                OnModusChanged(modus);
                break;

            case Modus.CenterLeft:
                if (position.X < currentShape.Key.End.X)
                {
                    ResizeCenterLeft(position);
                }
                else if (position.X >= currentShape.Key.End.X)
                {
                    modus = Modus.CenterRight;
                }
                OnModusChanged(modus);
                break;

            case Modus.CenterRight:
                if (position.X > currentShape.Key.Start.X)
                {
                    ResizeCenterRight(position);
                }
                else if (position.X <= currentShape.Key.Start.X)
                {
                    modus = Modus.CenterLeft;
                }
                OnModusChanged(modus);
                break;
            }
            MoveAdorner(position);
        }
    /// <summary>
    /// berechnet den nächsten Schritt
    /// </summary>
    /// <param name="limit">Anzahl der zu berechnenden (kleinen) Arbeitsschritte, negativer Wert = optionale Vorbereitungsschritte)</param>
    /// <returns>gibt an, ob noch weitere Berechnungen anstehen</returns>
    public bool Next(int limit)
    {
      if (limit == 0) return false;
      switch (modus)
      {
        #region # case Modus.unbekannt:
        case Modus.Unbekannt:
        {
          if (limit > 0)
          {
            modus = Modus.SucheInit; // Initialisierung für die Suche direkt starten
          }
          else
          {
            modus = Modus.SteinerInit; // Initialisierung der Vorbereitung starten
          }
          return true;
        }
        #endregion
        #region # case Modus.steinerInit:
        case Modus.SteinerInit:
        {
          if (limit > 0)
          {
            modus = Modus.SucheInit; // Vorbereitung abbrechen und Suche direkt starten
            return true;
          }

          int maxKisten = feldData.Where(c => c == '$' || c == '*').Count();

          kistenAnzahl++;

          if (kistenAnzahl >= maxKisten)
          {
            return false; // Maximale Kistenanzahl erreicht, weitere Berechnungen sind nicht mehr möglich
          }

          modus = Modus.SteinerVarianten; // neue Aufgabe: alle Varianten ermitteln

          KistenSteinerInit();
          steinerPrüfStellungen = new List<Variante>();
          steinerPrüfstellungenPos = 0;

          return true;
        }
        #endregion
        #region # case Modus.steinerVarianten:
        case Modus.SteinerVarianten:
        {
          if (limit > 0)
          {
            modus = Modus.SucheInit; // Vorbereitung abbrechen und Suche direkt starten
            return true;
          }

          limit = -limit;

          while (limit > 0)
          {
            if (steinerPrüfstellungenPos == steinerPrüfStellungen.Count)
            {
              limit--;
              if (!KistenSteinerNext())
              {
                modus = Modus.SteinerLösen;
                steinerBöseStellungen = steinerPrüfStellungen.Where(x => hashStellungen.Get(x.stellungCrc) == 1).ToArray();
                steinerPrüfStellungen = steinerPrüfStellungen.Where(x => hashStellungen.Get(x.stellungCrc) == 2).ToList();
                var old = hashStellungen;
                hashStellungen = new SokowahnHash_Index24Multi();
                foreach (var satz in old.GetAll().Where(x => x.Value == 1))
                {
                  hashStellungen.Add(satz.Key, satz.Value);
                }
                steinerPrüfstellungenPos = 0;
                return true;
              }
            }
            else
            {
              var prüf = steinerPrüfStellungen[steinerPrüfstellungenPos++];
              LadeStellung(prüf.stellung); limit--;
              if (kistenMitZiel == kistenAnzahl)
              {
                if (hashStellungen.Get(prüf.stellungCrc) == 65535) hashStellungen.Add(prüf.stellungCrc, 2); else hashStellungen.Update(prüf.stellungCrc, 2);
              }
              foreach (var neuPrüf in SucheVariantenSteiner())
              {
                steinerPrüfStellungen.Add(neuPrüf);
                hashStellungen.Add(neuPrüf.stellungCrc, 1);
              }
            }
          }

          return true;
        }
        #endregion
        #region # case Modus.steinerLösen:
        case Modus.SteinerLösen:
        {
          if (limit > 0)
          {
            modus = Modus.SucheInit; // Vorbereitung abbrechen und Suche direkt starten
            return true;
          }

          limit = -limit;

          while (limit > 0)
          {
            if (steinerPrüfstellungenPos == steinerPrüfStellungen.Count)
            {
              // var dummy = steinerBöseStellungen.Where(x => bekannteStellungen.ContainsKey(x.stellungCrc)).ToArray();

              foreach (var satz in steinerBöseStellungen.Where(x => hashStellungen.Get(x.stellungCrc) < 65535))
              {
                SteinerBlockerDazu(satz.stellung);
              }

              modus = Modus.SteinerInit;

              return true;
            }

            var prüf = steinerPrüfStellungen[steinerPrüfstellungenPos++];
            LadeStellung(prüf.stellung); limit--;
            suchTiefe = 99999;

            var vorgänger = SucheVariantenVorgänger().ToArray();

            if (vorgänger.Length > 0)
            {
              foreach (var check in vorgänger)
              {
                if (hashStellungen.Get(check.stellungCrc) < 65535)
                {
                  steinerPrüfStellungen.Add(new Variante { stellung = check.stellung, stellungCrc = check.stellungCrc, tiefe = 1 });
                  hashStellungen.Remove(check.stellungCrc);
                }
              }
            }
            else // gute Stellung, da keine Vorgänger möglich sind
            {
              if (hashStellungen.Get(prüf.stellungCrc) < 65535)
              {
                hashStellungen.Remove(prüf.stellungCrc);
              }
            }

          }

          return true;
        }
        #endregion
        #region # case Modus.sucheInit:
        case Modus.SucheInit:
        {
          raumSpielerPos = feldZuRaum[startSpielerPos];

          KistenStandardInit();

          suchListenSatz = kistenAnzahl + 1;

          suchTiefe = 0;
          SuchListeInsert(GetStellung(), suchTiefe);

          hashStellungen = new SokowahnHash_Index24Multi();
          hashStellungen.Add(StellungCrc(GetStellung()), 0);

          modus = Modus.SucheRechne;
          return true;
        }
        #endregion
        #region # case Modus.sucheRechne:
        case Modus.SucheRechne:
        {
          var listeAuswahl = suchListe[suchTiefe];
          limit = (int)Math.Min(limit, listeAuswahl.SatzAnzahl);
          for (int listenPos = 0; listenPos < limit; listenPos++)
          {
            LadeStellung(listeAuswahl.Pop());
            if (kistenMitZiel == kistenAnzahl)
            {
              modus = Modus.SucheGefunden;
              return false;
            }

            if (StellungBekannt(StellungCrc(GetStellung())) < suchTiefe) continue; // zu prüfende Stellung wurde schon früher (mit weniger Tiefe) berechnet

            foreach (var variante in SucheVariantenHashcheck())
            {
              var tmpTiefe = StellungBekannt(variante.stellungCrc);
              if (tmpTiefe >= 0)
              {
                if (tmpTiefe <= variante.tiefe) continue; // Vorschlag ignorieren
                hashStellungen.Update(variante.stellungCrc, variante.tiefe);
                SuchListeInsert(variante.stellung, variante.tiefe);
              }
              else
              {
                hashStellungen.Add(variante.stellungCrc, variante.tiefe);
                SuchListeInsert(variante.stellung, variante.tiefe);
              }
            }
          }
          if (listeAuswahl.SatzAnzahl == 0) suchTiefe++; // keine weiteren Stellungen bei dieser Zugtiefe vorhanden, dann zur nächsten Zugtiefe springen
          return true;
        }
        #endregion
        case Modus.SucheGefunden: return false; // Ergebnis gefunden, keine weiteren Berechnungen notwendig
        default: throw new Exception("? " + modus);
      }

    }