Ejemplo n.º 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);
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
 public void RemoveRock(A_Rock rock)
 {
     if (rock is Graviton)
     {
         gravitons.Remove((Graviton)rock);
     }
     if (rock is Magneton)
     {
         magnetons.Remove((Magneton)rock);
     }
     if (rock is Generator)
     {
         generators.Remove((Generator)rock);
     }
     if (rock is BlackHole)
     {
         blackHoles.Remove((BlackHole)rock);
     }
 }
Ejemplo n.º 4
0
 public void InsertRock(A_Rock rock)
 {
     if (rock is Graviton)
     {
         gravitons.Add((Graviton)rock);
     }
     if (rock is Magneton)
     {
         magnetons.Add((Magneton)rock);
     }
     if (rock is Generator)
     {
         generators.Add((Generator)rock);
     }
     if (rock is BlackHole)
     {
         blackHoles.Add((BlackHole)rock);
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Load data from a stone entity
        /// </summary>
        /// <param name="rock"></param>
        public void InitData(A_Rock rock)
        {
            this.rock = rock;

            if (rock is BlackHole)
            {
                blackHoleGroup.Visibility = Visibility.Visible;
            }
            if (rock is Graviton)
            {
                gravitonGroup.Visibility = Visibility.Visible;
            }
            if (rock is Generator)
            {
                generatorGroup.Visibility = Visibility.Visible;
            }
            if (rock is Magneton)
            {
                magnetonGroup.Visibility = Visibility.Visible;
            }

            LoadValues();     // if we are loading an existing data, we need to load info about the first contour
        }
Ejemplo n.º 6
0
 public ContourRock(A_Rock rock, String contour_name)
 {
     this.rock         = rock;
     this.contour_name = contour_name;
 }
Ejemplo n.º 7
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;
            }
        }