コード例 #1
0
ファイル: RealTableManager.cs プロジェクト: dodocloud/InTab
        /// <summary>
        /// Calculates a distance between two stones
        /// </summary>
        /// <returns></returns>
        private int DistanceBetweenRocks(ContourRock rck, FoundRock fnd)
        {
            double deltaX = rck.rock.Position.X - fnd.position.X;
            double deltaY = rck.rock.Position.Y - fnd.position.Y;

            if (deltaX == 0 && deltaY == 0)
            {
                return(0);
            }
            return((int)Math.Sqrt(deltaX * deltaX + deltaY * deltaY));
        }
コード例 #2
0
ファイル: RealTableManager.cs プロジェクト: dodocloud/InTab
        /// <summary>
        /// Sets a minimal distance between a newly detected stone and al others
        /// </summary>
        private void SetMinimumLengthForFoundRock(FoundRock found, HashSet <ContourRock> rocks)
        {
            found.minLength  = 100000;
            found.placedRock = null;

            foreach (ContourRock rock in rocks)
            {
                int distance = DistanceBetweenRocks(rock, found);
                if (distance < found.minLength)
                {
                    found.minLength  = distance;
                    found.placedRock = rock;
                }
            }
        }
コード例 #3
0
ファイル: RealTableManager.cs プロジェクト: dodocloud/InTab
        /// <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));
        }