Esempio n. 1
0
        //move
        private void Grid_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            //BGgrid.Background = Brushes.Blue;
            DoomsdayClock.Content = Time;
            Grid     g        = (Grid)this.Parent;
            Grid     roomgrid = (Grid)g.Parent;
            GameGrid game     = (GameGrid)roomgrid.Parent;

            ThicknessAnimation animation = new ThicknessAnimation();


            Thickness oldCenter = game.currentRoom.Margin;
            Thickness newCenter = this.Margin;
            Thickness oldMargin = roomgrid.Margin;



            //roomgrid.Margin =
            Thickness newMargin = new Thickness(oldMargin.Left + (oldCenter.Left - newCenter.Left),
                                                oldMargin.Top + (oldCenter.Top - newCenter.Top),
                                                oldMargin.Right + (oldCenter.Right - newCenter.Right),
                                                oldMargin.Bottom + (oldCenter.Bottom - newCenter.Bottom));


            animation.From = oldMargin;
            animation.To   = newMargin;

            PowerEase pe = new PowerEase();

            pe.EasingMode = EasingMode.EaseInOut; pe.Power = 3;

            animation.EasingFunction = pe;
            animation.Duration       = new Duration(TimeSpan.FromSeconds(.5));

            roomgrid.BeginAnimation(Grid.MarginProperty, animation);

            List <Room> desc = game.currentRoom.getalldescendents();

            game.currentRoom.BGgrid.Background = new SolidColorBrush(Color.FromArgb(190, 255, 152, 152));

            // game.StartRoom.BGgrid.Background = new SolidColorBrush(Color.FromArgb(255, 255, 152, 152));

            foreach (Room r in desc)
            {
                r.BGgrid.Background = new SolidColorBrush(Color.FromArgb(190, 255, 152, 152));
            }

            game.currentRoom = this;

            desc = game.currentRoom.getalldescendents();

            foreach (Room r in desc)
            {
                r.BGgrid.Background = new SolidColorBrush(Color.FromArgb(255, 255, 152, 152));
            }


            game.window.DoomsdayClock.Content = Time;

            game.adjustBG(Time);


            BGgrid.Background = Brushes.Blue;
            //CHANGE CHARA LOC

            if (oldCenter.Left == newCenter.Left)
            {
                game.window.avatar.standstill();
            }
            else if (oldCenter.Left < newCenter.Left)//traveling forward
            {
                game.window.avatar.fwd();
            }
            else
            {
                game.window.avatar.bwd();
            }
        }
Esempio n. 2
0
        private void optionsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            String s = (string)((ListBox)sender).SelectedItem;

            if (s == null)
            {
                return;
            }
            Room selectedroom = (Room)actions[s];

            (selectedroom).Visibility      = Visibility.Visible;
            ((ListBox)sender).SelectedItem = null;

            //v sloppy, revist later

            DoomsdayClock.Content = Time;
            Grid     g        = (Grid)this.Parent;
            Grid     roomgrid = (Grid)g.Parent;
            GameGrid game     = (GameGrid)roomgrid.Parent;

            ThicknessAnimation animation = new ThicknessAnimation();


            Thickness oldCenter = game.currentRoom.Margin;
            Thickness newCenter = selectedroom.Margin;
            Thickness oldMargin = roomgrid.Margin;



            //roomgrid.Margin =
            Thickness newMargin = new Thickness(oldMargin.Left + (oldCenter.Left - newCenter.Left),
                                                oldMargin.Top + (oldCenter.Top - newCenter.Top),
                                                oldMargin.Right + (oldCenter.Right - newCenter.Right),
                                                oldMargin.Bottom + (oldCenter.Bottom - newCenter.Bottom));


            animation.From = oldMargin;
            animation.To   = newMargin;

            PowerEase pe = new PowerEase();

            pe.EasingMode = EasingMode.EaseInOut; pe.Power = 3;

            animation.EasingFunction = pe;
            animation.Duration       = new Duration(TimeSpan.FromSeconds(.5));

            roomgrid.BeginAnimation(Grid.MarginProperty, animation);

            List <Room> desc = game.currentRoom.getalldescendents();

            game.currentRoom.BGgrid.Background = new SolidColorBrush(Color.FromArgb(190, 255, 152, 152));

            // game.StartRoom.BGgrid.Background = new SolidColorBrush(Color.FromArgb(255, 255, 152, 152));

            foreach (Room r in desc)
            {
                r.BGgrid.Background = new SolidColorBrush(Color.FromArgb(190, 255, 152, 152));
            }

            game.currentRoom = selectedroom;

            desc = game.currentRoom.getalldescendents();

            foreach (Room r in desc)
            {
                r.BGgrid.Background = new SolidColorBrush(Color.FromArgb(255, 255, 152, 152));
            }


            game.window.DoomsdayClock.Content = Time;

            game.adjustBG(Time);


            selectedroom.BGgrid.Background = Brushes.Blue;
            //CHANGE CHARA LOC

            if (oldCenter.Left == newCenter.Left)
            {
                game.window.avatar.standstill();
            }
            else if (oldCenter.Left < newCenter.Left)//traveling forward
            {
                game.window.avatar.fwd();
            }
            else
            {
                game.window.avatar.bwd();
            }
        }