示例#1
0
        // выбор варианта ответа (изменение активного элемента ListBox)
        private void lstbxResp_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // обновление брифинга и вариантов ответов
            foreach (Location location in locations)
            {
                // переход к новой локации
                try
                {
                    Path selectedPath = prevLocation.Paths[lstbxResp.SelectedIndex];

                    if (selectedPath.IdLocationToGo == location.Id)
                    {
                        // если в path есть desc, то обновить описание локации
                        if (selectedPath.Desc != null)
                            txtblkDesc.Text = selectedPath.Desc + "\n\n" + location.Desc;
                        else
                        {
                            txtblkDesc.Text = location.Desc; // вывод нового описания локации
                            this.sv.ScrollToVerticalOffset(0);
                        }

                        // очистка предыдущих вариантов ответов
                        lstbxResp.Items.Clear();

                        // загрузка новых вариантов ответов
                        switch (location.Type)
                        {
                            case LocType.Left1:
                                // иниц парам при первом попадании в локацию Left1
                                if (parametersIsInitialized == false)
                                {
                                    InitParameters();
                                    parametersIsInitialized = true;
                                }
                                else
                                {
                                    selectedPath.God.Pos = GodPos.Left;
                                    TimeLeft -= selectedPath.God.Hours;
                                    boat.Pos = BoatPos.Left;
                                    // проверить победу\провал
                                    if (parametersIsInitialized == true)
                                    {
                                        CheckIfWin();
                                        ChechIfFailed();
                                    }
                                }
                                // загрузка вариантов ответов
                                for (int i = 0; i < 4; i++)
                                {
                                    if (gods[i].Pos == GodPos.Left)
                                    {
                                        location.Paths[i].God = gods[i];
                                        lstbxResp.Items.Add(new TextBlock()
                                        {
                                            Text = "> " + location.Paths[i].Title,
                                            TextWrapping = TextWrapping.Wrap,
                                            Padding = new Thickness(0, 17, 0, 17),
                                        });
                                    }
                                    else
                                    {
                                        location.Paths[i].God = gods[i];
                                        lstbxResp.Items.Add(new TextBlock()
                                        {
                                            Text = "> " + location.Paths[i].Title,
                                            TextWrapping = TextWrapping.Wrap,
                                            Padding = new Thickness(0, 17, 0, 17),
                                            Visibility = System.Windows.Visibility.Collapsed
                                        });
                                    }
                                }
                                break;
                            case LocType.Left2:
                                god1 = selectedPath.God;
                                god1.Pos = GodPos.InBoat;
                                // проверить победу\провал
                                if (parametersIsInitialized == true)
                                {
                                    CheckIfWin();
                                    ChechIfFailed();
                                }
                                // загрузка вариантов ответов
                                for (int i = 0; i < 4; i++)
                                {
                                    if (gods[i].Pos == GodPos.Left)
                                    {
                                        location.Paths[i].God = gods[i];
                                        lstbxResp.Items.Add(new TextBlock()
                                        {
                                            Text = "> " + location.Paths[i].Title,
                                            TextWrapping = TextWrapping.Wrap,
                                            Padding = new Thickness(0, 17, 0, 17)
                                        });
                                    }
                                    else
                                    {
                                        location.Paths[i].God = gods[i];
                                        lstbxResp.Items.Add(new TextBlock()
                                        {
                                            Text = "> " + location.Paths[i].Title,
                                            TextWrapping = TextWrapping.Wrap,
                                            Padding = new Thickness(0, 17, 0, 17),
                                            Visibility = System.Windows.Visibility.Collapsed
                                        });
                                    }
                                }
                                break;
                            case LocType.Right:
                                god1.Pos = GodPos.Right;
                                god2 = selectedPath.God;
                                god2.Pos = GodPos.Right;
                                if (god1.Hours > god2.Hours)
                                    TimeLeft -= god1.Hours;
                                else
                                    TimeLeft -= god2.Hours;
                                boat.Pos = BoatPos.Right;
                                // проверить победу\провал
                                if (parametersIsInitialized == true)
                                {
                                    CheckIfWin();
                                    ChechIfFailed();
                                }
                                // загрузка вариантов ответов
                                for (int i = 0; i < 4; i++)
                                {
                                    if (gods[i].Pos == GodPos.Right)
                                    {
                                        location.Paths[i].God = gods[i];
                                        lstbxResp.Items.Add(new TextBlock()
                                        {
                                            Text = "> " + location.Paths[i].Title,
                                            TextWrapping = TextWrapping.Wrap,
                                            Padding = new Thickness(0, 17, 0, 17)
                                        });
                                    }
                                    else
                                    {
                                        location.Paths[i].God = gods[i];
                                        lstbxResp.Items.Add(new TextBlock()
                                        {
                                            Text = "> " + location.Paths[i].Title,
                                            TextWrapping = TextWrapping.Wrap,
                                            Padding = new Thickness(0, 17, 0, 17),
                                            Visibility = System.Windows.Visibility.Collapsed
                                        });
                                    }
                                }
                                break;
                            default:
                                // загрузка вариантов ответов
                                foreach (Path path in location.Paths)
                                {
                                    lstbxResp.Items.Add(new TextBlock()
                                    {
                                        Text = "> " + path.Title,
                                        TextWrapping = TextWrapping.Wrap,
                                        Padding = new Thickness(0, 17, 0, 17)
                                    });
                                }
                                break;
                        }

                        // новая текущая локация
                        prevLocation = location;

                        // переход к PivotItem Name="piDesc"
                        pivot.SelectedItem = piDesc;

                        break;
                    }
                }
                catch
                {
                    continue;
                }
            }
        }
示例#2
0
        void InitAll()
        {
            //gods = new God[4];
            InitLocations();

            foreach (Location location in locations)
            {
                if (location.Type == LocType.Start) // стартовая локация
                {
                    txtblkDesc.Text = location.Desc; // брифинг
                    this.sv.ScrollToVerticalOffset(0);
                    lstbxResp.Items.Clear();

                    foreach (Path path in location.Paths)
                    {
                        lstbxResp.Items.Add(new TextBlock()
                        {
                            Text = "> " + path.Title,
                            TextWrapping = TextWrapping.Wrap,
                            Padding = new Thickness(0, 17, 0, 17)
                        }); // варианты ответов
                    }
                    prevLocation = location; // текущая локация
                    break;
                }
            }
            pivot.SelectedItem = piDesc;
        }