예제 #1
0
        /// <summary>
        /// Resets values of the current contour settings
        /// </summary>
        private void RestartValues()
        {
            // if we change a type of a stone, everything will be reseted
            ContourRock contourRck = contourRocks.Where(ctr => ctr.contour_name.Equals(((ComboBoxItem)contourNameCombo.SelectedItem).Content)).First();

            contourRocks.Remove(contourRck);
            A_Rock contextRock = null;

            if (blackHoleCmbIt.IsSelected && !(contourRck.rock is BlackHole))
            {
                contextRock = new BlackHole();
            }
            if (generatorCmbIt.IsSelected && !(contourRck.rock is Generator))
            {
                contextRock = new Generator();
            }
            if (gravitonCmbIt.IsSelected && !(contourRck.rock is Graviton))
            {
                contextRock = new Graviton();
            }
            if (magnetonCmbIt.IsSelected && !(contourRck.rock is Magneton))
            {
                contextRock = new Magneton();
            }

            if (contextRock != null)
            {
                contourRck.rock = contextRock;
            }
            contourRocks.Add(contourRck);
        }
예제 #2
0
        /// <summary>
        /// Adds a stone to a gameboard
        /// </summary>
        private void InsertRockImage(System.Windows.Input.MouseButtonEventArgs e)
        {
            if (MouseInTableArea(e, dragImage_new))
            {
                int left = (int)e.GetPosition(tablePanel).X - dragImage_mousePos_X;
                int top  = (int)e.GetPosition(tablePanel).Y - dragImage_mousePos_Y;

                // sets handler so that we can manipulate with the object
                dragImage_new.MouseDown += new System.Windows.Input.MouseButtonEventHandler(RockImageOld_MouseDown);
                dragImage_new.MouseUp   += new System.Windows.Input.MouseButtonEventHandler(rockImage_MouseUp);

                // check the type of the object to insert
                A_TableObject object_to_put = null;
                if ((A_TableObject)dragImage_new.DataContext is Graviton)
                {
                    object_to_put = new Graviton();
                    ((Graviton)object_to_put).Name         = "Graviton";
                    ((Graviton)object_to_put).BaseSettings = tableManager.TableDepositor.table.Settings.gravitonSettings;
                }
                if ((A_TableObject)dragImage_new.DataContext is Generator)
                {
                    object_to_put = new Generator();
                    ((Generator)object_to_put).Name         = "Generator";
                    ((Generator)object_to_put).BaseSettings = tableManager.TableDepositor.table.Settings.generatorSettings;
                }
                if ((A_TableObject)dragImage_new.DataContext is Magneton)
                {
                    object_to_put = new Magneton();
                    ((Magneton)object_to_put).Name         = "Magneton";
                    ((Magneton)object_to_put).BaseSettings = tableManager.TableDepositor.table.Settings.magnetonSettings;
                }
                if ((A_TableObject)dragImage_new.DataContext is BlackHole)
                {
                    object_to_put = new BlackHole();
                    ((BlackHole)object_to_put).Name         = "BlackHole";
                    ((BlackHole)object_to_put).BaseSettings = tableManager.TableDepositor.table.Settings.blackHoleSettings;
                }

                // sets position
                object_to_put.Position = PointHelper.TransformPointToEuc(new FPoint(left * CommonAttribService.ACTUAL_TABLE_SIZE_MULTIPLIER + dragImage_new.Width / 2,
                                                                                    top * CommonAttribService.ACTUAL_TABLE_SIZE_MULTIPLIER + dragImage_new.Height / 2), CommonAttribService.ACTUAL_TABLE_WIDTH,
                                                                         CommonAttribService.ACTUAL_TABLE_HEIGHT);

                dragImage_new.DataContext = object_to_put;
                // add it into a system
                tableManager.InsertObject(object_to_put);
                rockImages.Add(dragImage_new);
            }
            else
            {
                // icon is beyond the border of the game table -> delete it
                if (tablePanel.mainGrid.Children.Contains(dragImage_new))
                {
                    tablePanel.mainGrid.Children.Remove(dragImage_new);
                }
            }
            dragImage_new = null;
        }
예제 #3
0
        /// <summary>
        /// Sets prototypes of all stones for the bottom bar
        /// </summary>
        private void SetToolContext()
        {
            Graviton  rck = new Graviton();
            Generator gn  = new Generator();
            Magneton  mg  = new Magneton();
            BlackHole blh = new BlackHole();

            tablePanel.tableToolPanel.generatorRockImage.DataContext = gn;
            tablePanel.tableToolPanel.gravityRockImage.DataContext   = rck;
            tablePanel.tableToolPanel.magnetonRockImage.DataContext  = mg;
            tablePanel.tableToolPanel.blackHoleRockImage.DataContext = blh;
        }
예제 #4
0
        /// <summary>
        /// Creates a new stone and adds it to the collection of stones
        /// </summary>
        /// <param name="rock"></param>
        private void CreateNewRock(FoundRock rock)
        {
            A_Rock newRock = null;

            if (rock.type == FoundRockType.BLACKHOLE)
            {
                newRock = new BlackHole();
                ((BlackHole)newRock).BaseSettings     = system.table.Settings.blackHoleSettings;
                ((BlackHole)newRock).Settings_Allowed = ((BlackHole)CommonAttribService.DEFAULT_TEMPLATES.rockSettings.Where(mrck => mrck.contour_name.Equals(rock.contour_name)).First().rock).Settings_Allowed;
                ((BlackHole)newRock).Settings         = ((BlackHole)CommonAttribService.DEFAULT_TEMPLATES.rockSettings.Where(mrck => mrck.contour_name.Equals(rock.contour_name)).First().rock).Settings;
                ((BlackHole)newRock).Position.X       = rock.position.X;
                ((BlackHole)newRock).Position.Y       = rock.position.Y;
            }
            if (rock.type == FoundRockType.GENERATOR)
            {
                newRock = new Generator();
                ((Generator)newRock).BaseSettings     = system.table.Settings.generatorSettings;
                ((Generator)newRock).Settings_Allowed = ((Generator)CommonAttribService.DEFAULT_TEMPLATES.rockSettings.Where(mrck => mrck.contour_name.Equals(rock.contour_name)).First().rock).Settings_Allowed;
                ((Generator)newRock).Settings         = ((Generator)CommonAttribService.DEFAULT_TEMPLATES.rockSettings.Where(mrck => mrck.contour_name.Equals(rock.contour_name)).First().rock).Settings;
                ((Generator)newRock).Position.X       = rock.position.X;
                ((Generator)newRock).Position.Y       = rock.position.Y;
            }
            if (rock.type == FoundRockType.GRAVITON)
            {
                newRock = new Graviton();
                ((Graviton)newRock).BaseSettings     = system.table.Settings.gravitonSettings;
                ((Graviton)newRock).Settings_Allowed = ((Graviton)CommonAttribService.DEFAULT_TEMPLATES.rockSettings.Where(mrck => mrck.contour_name.Equals(rock.contour_name)).First().rock).Settings_Allowed;
                ((Graviton)newRock).Settings         = ((Graviton)CommonAttribService.DEFAULT_TEMPLATES.rockSettings.Where(mrck => mrck.contour_name.Equals(rock.contour_name)).First().rock).Settings;
                ((Graviton)newRock).Position.X       = rock.position.X;
                ((Graviton)newRock).Position.Y       = rock.position.Y;
            }
            if (rock.type == FoundRockType.MAGNETON)
            {
                newRock = new Magneton();
                ((Magneton)newRock).BaseSettings     = system.table.Settings.magnetonSettings;
                ((Magneton)newRock).Settings_Allowed = ((Magneton)CommonAttribService.DEFAULT_TEMPLATES.rockSettings.Where(mrck => mrck.contour_name.Equals(rock.contour_name)).First().rock).Settings_Allowed;
                ((Magneton)newRock).Settings         = ((Magneton)CommonAttribService.DEFAULT_TEMPLATES.rockSettings.Where(mrck => mrck.contour_name.Equals(rock.contour_name)).First().rock).Settings;
                ((Magneton)newRock).Position.X       = rock.position.X;
                ((Magneton)newRock).Position.Y       = rock.position.Y;
            }

            // initial intensity is 5 in order to have a smooth fade-in
            newRock.Intensity = 5;
            newRock.Name      = rock.contour_name;
            system.InsertRock(newRock);
            rocks[rock.contour_name].Add(new ContourRock(newRock, rock.contour_name));
        }
예제 #5
0
        /// <summary>
        /// Initializes all data
        /// </summary>
        public void InitData()
        {
            contourRocks = templates.rockSettings;

            if (contourRocks == null)
            {
                contourRocks = new HashSet <ContourRock>();
            }

            if (templates != null)
            {
                // put the name of each contour into a combobox and create a ContourRock, bound with its id
                foreach (Template tmp in templates)
                {
                    if (contourRocks.Count(cnt => cnt.contour_name.Equals(tmp.name)) == 0)
                    {
                        // create a referential stone
                        A_Rock contextRock = null;
                        if (blackHoleCmbIt.IsSelected)
                        {
                            contextRock = new BlackHole();
                        }
                        if (generatorCmbIt.IsSelected)
                        {
                            contextRock = new Generator();
                        }
                        if (gravitonCmbIt.IsSelected)
                        {
                            contextRock = new Graviton();
                        }
                        if (magnetonCmbIt.IsSelected)
                        {
                            contextRock = new Magneton();
                        }

                        contourRocks.Add(new ContourRock(contextRock, tmp.name));
                    }

                    ComboBoxItem item = new ComboBoxItem();
                    item.Content    = tmp.name;
                    item.IsSelected = true;
                    contourNameCombo.Items.Add(item);
                }

                actual_contour = contourRocks.Where(cnt => cnt.contour_name.Equals(((ComboBoxItem)(contourNameCombo.SelectedItem)).Content)).First();
                if (actual_contour.rock is Graviton)
                {
                    gravitonCmbIt.IsSelected = true;
                }
                else if (actual_contour.rock is Generator)
                {
                    generatorCmbIt.IsSelected = true;
                }
                else if (actual_contour.rock is Magneton)
                {
                    magnetonCmbIt.IsSelected = true;
                }
                else if (actual_contour.rock is BlackHole)
                {
                    blackHoleCmbIt.IsSelected = true;
                }

                if (blackHoleCmbIt.IsSelected)
                {
                    blackHoleGroup.Visibility = Visibility.Visible;
                }
                if (gravitonCmbIt.IsSelected)
                {
                    gravitonGroup.Visibility = Visibility.Visible;
                }
                if (generatorCmbIt.IsSelected)
                {
                    generatorGroup.Visibility = Visibility.Visible;
                }
                if (magnetonCmbIt.IsSelected)
                {
                    magnetonGroup.Visibility = Visibility.Visible;
                }

                LoadValues();
                initialized = true;
            }
        }