public LoadingPage()
        {
            InitializeComponent();
            WindowConfig.GetCurrentAudioImg(AudioImg);
            Label         label;
            Button        button;
            int           i    = 1;
            List <string> list = FileSystem.SavedGameList();

            if (list != null)
            {
                foreach (string str in list)
                {
                    string[] tmp  = str.Split('\\', '.');
                    string   str1 = "";

                    str1 += tmp[1];

                    str1           = str1.TrimEnd('.');
                    label          = new Label();
                    label.Content  = str1;
                    button         = new Button();
                    button.Content = str1;
                    button.Click  += Button_Click;
                    LoadGrid.Children.Add(label);
                    LoadGrid.Children.Add(button);
                    Grid.SetRow(label, i);
                    Grid.SetRow(button, i);
                    Grid.SetColumn(label, 0);
                    Grid.SetColumn(button, 0);
                    i++;
                }
            }
        }
Beispiel #2
0
 public MainPage()
 {
     InitializeComponent();
     WindowConfig.GetCurrentAudioImg(AudioImg);
     WindowConfig.MainPage = this;
     //  WindowConfig.Player.Open(new Uri(Environment.CurrentDirectory+@"\pirat.wav"));
     //  WindowConfig.Player.Volume = 50;
     ////  WindowConfig.Player.Play();
     WindowConfig.game       = null;
     WindowConfig.OnlineGame = null;
 }
Beispiel #3
0
        public PlayPage(OnlineGame onlineGame)
        {
            WindowConfig.PlayPageCon = this;
            WindowConfig.OnlineGame  = onlineGame;
            WindowConfig.IsLoaded    = onlineGame.GameConfig.GameStatus == GameStatus.Loaded;
            OnlineGame             = onlineGame;
            WindowConfig.GameState = WindowConfig.State.Online;
            InitializeComponent();
            WindowConfig.GetCurrentAudioImg(AudioImg);
            MyField.PlaceHitted();
            EnemyField.PlaceHitted();
            PauseItem.IsEnabled    = OnlineGame.PlayerRole == PlayerRole.Server;
            SaveGameItem.IsEnabled = OnlineGame.PlayerRole == PlayerRole.Server;
            WindowConfig.SetStartColor();
            IsPaused = false;

            //ImageBehavior.SetAnimatedSource(TimerImage, new BitmapImage(new Uri("/Resources/timer.gif", UriKind.Relative)) { CreateOptions = BitmapCreateOptions.IgnoreImageCache });
            //ImageBehavior.SetAnimateInDesignMode(TimerImage, true);
            GameSpeed gs = WindowConfig.GameState == WindowConfig.State.Online ? OnlineGame.GameConfig.GameSpeed : Game.GameConfig.GameSpeed;

            switch (gs)
            {
            case GameSpeed.Fast:
                timer.Interval = new TimeSpan(0, 0, 0, 1, 250);
                break;

            case GameSpeed.Medium:
                timer.Interval = new TimeSpan(0, 0, 0, 2, 500);
                break;

            case GameSpeed.Slow:
                timer.Interval = new TimeSpan(0, 0, 0, 5);
                break;

            case GameSpeed.Turtle:
                timer.Interval = new TimeSpan(0, 0, 0, 12, 500);
                break;
            }

            //  timer.Interval = new TimeSpan(0, 0, 1);
            timer.Tick += Tick;
            // timer.Start();

            InitTimer();
            Timer.Start();
            timer.Start();
        }
Beispiel #4
0
        private void Tick(object sender, object e)
        {
            if (tickCount == 24)
            {
                if (IsPaused)
                {
                    Pause();
                }
                tickCount = 0;
                if (WindowConfig.GameState == WindowConfig.State.Offline)
                {
                    WindowConfig.SetSwitchColorOff(false);
                }
            }
            var controller = ImageBehavior.GetAnimationController(TimerImage);

            if (controller != null)
            {
                controller.GotoFrame(tickCount);
                controller.Pause();
                tickCount++;
            }
        }
Beispiel #5
0
        public PlayPage(Game game)
        {
            WindowConfig.PlayPageCon = this;
            WindowConfig.game        = game;
            WindowConfig.GameState   = WindowConfig.State.Offline;
            InitializeComponent();
            WindowConfig.GetCurrentAudioImg(AudioImg);
            Game = game;
            PauseItem.IsEnabled    = false;
            MyTurnLabel.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF93FF3A"));
            InitTimer();
            Timer.Start();

            GameSpeed gs = WindowConfig.GameState == WindowConfig.State.Online ? OnlineGame.GameConfig.GameSpeed : Game.GameConfig.GameSpeed;

            switch (gs)
            {
            case GameSpeed.Fast:
                timer.Interval = new TimeSpan(0, 0, 0, 1, 250);
                break;

            case GameSpeed.Medium:
                timer.Interval = new TimeSpan(0, 0, 0, 2, 500);
                break;

            case GameSpeed.Slow:
                timer.Interval = new TimeSpan(0, 0, 0, 5);
                break;

            case GameSpeed.Turtle:
                timer.Interval = new TimeSpan(0, 0, 0, 12, 500);
                break;
            }
            timer.Tick += Tick;
            timer.Start();
        }
Beispiel #6
0
 private void audioChanged(object sender, RoutedEventArgs e)
 {
     WindowConfig.AudioChanged((Image)sender);
 }