Exemplo n.º 1
0
    public static float DistanceNote(float distance, Hill hill)
    {
        float distanceNote;

        switch (hill.HillType)  //Punkty za odległość - uzależnione od typu skoczni
        {
        case hillType.small:
            distanceNote = 60 + (distance - hill.KPoint) * 2.2f;
            break;

        case hillType.medium:
            distanceNote = 60 + (distance - hill.KPoint) * 2f;
            break;

        case hillType.large:
            distanceNote = 120 + (distance - hill.KPoint) * 1.8f;
            break;

        case hillType.mamut:
            distanceNote = 120 + (distance - hill.KPoint) * 1.2f;
            break;

        default:
            distanceNote = 0;
            break;
        }
        return(distanceNote);
    }
        public override void Solve()
        {
            var NandM = ReadArrString().Select(int.Parse).ToArray();

            V = NandM[0] + 1;

            matrix = new Hill[NandM[0] + 1, NandM[0] + 1];
            graph  = new int[NandM[0] + 1, NandM[0] + 1];
            hill   = new bool[NandM[0] + 1];

            for (int i = 1; i < V; i++)
            {
                for (int j = 1; j < V; j++)
                {
                    matrix[i, j] = new Hill();
                }
            }

            for (int i = 0; i < NandM[1]; i++)
            {
                var hillInfo = ReadArrString().Select(int.Parse).ToArray();
                matrix[hillInfo[0], hillInfo[0]].Cost = int.MaxValue;

                if (hillInfo[2] < hillInfo[3])
                {
                    matrix[hillInfo[0], hillInfo[1]].TSpeed = hillInfo[2];
                    matrix[hillInfo[0], hillInfo[1]].HSpeed = hillInfo[3];
                    hill[hillInfo[0]] = true;
                    graph[hillInfo[0], hillInfo[1]] = hillInfo[2];
                }
            }
            path();
        }
Exemplo n.º 3
0
    private void OnSceneGUI()
    {
        hill = target as Hill;
        if (!hill.isActiveAndEnabled)
        {
            return;
        }
        handleTransform = hill.transform;
        handleRotation  = Tools.pivotRotation == PivotRotation.Local ?
                          handleTransform.rotation : Quaternion.identity;
        Vector2 top     = ShowPoint(0);
        Vector2 start   = ShowPoint(1);
        Vector2 control = ShowPoint(2);
        Vector2 end     = ShowPoint(3);

        Handles.color = Color.gray;
        Handles.DrawLine(start, control);
        Handles.DrawLine(control, end);

        Handles.color = Color.red;
        Vector2[] points    = hill.ComputePoints();
        Vector2   lineStart = top,
                  lineEnd;

        for (int i = 1; i <= hill.steps; i++)
        {
            lineEnd = handleTransform.TransformPoint(points[i]);
            Handles.DrawLine(lineStart, lineEnd);
            lineStart = lineEnd;
        }
    }
Exemplo n.º 4
0
        public static string FormatHillSummaryAsLine(Hill oHill)
        {
            string strLine = "";

            if ((oHill == null))
            {
                return(strLine);
            }

            strLine = oHill.Hillname + (", "
                                        + (oHill.Metres + ("m, "
                                                           + (oHill.Feet + "ft, "))));

            if (!string.IsNullOrEmpty(oHill.Gridref10) && (oHill.Gridref10.Length > 0))
            {
                if ((!string.IsNullOrEmpty(oHill.Gridref)) && (oHill.Gridref.Length > 0))
                {
                    strLine = (strLine + oHill.Gridref);
                }
            }
            else
            {
                strLine = (strLine + oHill.Gridref10);
            }
            if (!(oHill.Classification == null))
            {
                strLine = (strLine + (", " + oHill.Classification.Replace(",", " ")));
            }
            return(strLine);
        }
Exemplo n.º 5
0
        public void Unigraph_HillTest()
        {
            Hill hill = new Hill(Utility.EnglishAlphabet());// Utility.KeyedEnglishAlphabet("KRYPTOS"));

            hill.Key = new Matrix(new double[, ] {
                { 6, 24, 1 }, { 13, 16, 10 }, { 20, 17, 15 }
            });
            //hill.Key = new double[,] { { 2, 4, 5 }, { 9, 2, 1 }, { 3, 17, 7 } };
            //hill.Key = new double[,] { { 5, 17 }, { 4, 15 } };

            cipher    = "";
            clear     = "";
            generated = "";
            for (int i = 0; i < 25; i++)
            {
                generated = hill.GenerateRandomString(552);

                while (generated.Length % hill.Key.Rows != 0)
                {
                    generated += 'Z';
                }

                //generated = "ABCDEFGHI";

                cipher = hill.Encrypt(generated);
                clear  = hill.Decrypt(cipher);

                int x = generated.Length;
                int y = cipher.Length;
                int z = clear.Length;

                Assert.AreEqual(generated, clear);
            }
        }
Exemplo n.º 6
0
        public void BasicEncryptTest()
        {
            var  key       = new int[][] { new int[] { 2, 4, 5 }, new int[] { 9, 2, 1 }, new int[] { 3, 17, 7 } };
            Hill h         = new Hill(key);
            var  encrypted = h.Encrypt("ATT");

            Assert.AreEqual("PFO", encrypted);
        }
Exemplo n.º 7
0
        private void btnMaHoa_Click(object sender, EventArgs e)
        {
            txtMHBanRo.Text = txtMHBanRo.Text.ToUpper();
            string tz = txtMHBanRo.Text;
            string kz = "";

            for (int iz = 0; iz < tz.Length; iz++)
            {
                if (tz[iz] < 'A' || tz[iz] > 'Z')
                {
                    continue;
                }
                kz = kz + tz[iz];
            }
            txtMHBanRo.Text = kz;

            if (txtMHBanRo.Text == "")
            {
                MessageBox.Show("Bản rõ đang trống", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            /// Kiểm tra khóa
            int k = (int)numRowCount.Value;

            Matrix mt = new Matrix(k, k);

            /// tính lại mt
            foreach (var item in panelGroupKhoa.Controls)
            {
                TextBox z = item as TextBox;

                Point pos = (Point)z.Tag;
                if (pos.X > k || pos.Y > k)
                {
                    continue;
                }

                int gt = 0;
                try
                {
                    gt = Int32.Parse(z.Text);
                }
                catch
                {
                    gt = 0;
                }
                mt[pos.X, pos.Y] = new Complex(gt);
            }

            if (!MaHoa.Crypto.Hill.ok(mt))
            {
                MessageBox.Show("Key chưa thỏa mãn. Không tồn tại ma trận nghịch đảo", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            txtMHBanMa.Text = Hill.encrypt(txtMHBanRo.Text, mt);
        }
Exemplo n.º 8
0
        private void btnThamMa_Click(object sender, EventArgs e)
        {
            txtMHBanMa.Text = txtMHBanMa.Text.Trim();
            if (txtMHBanMa.Text == "")
            {
                MessageBox.Show("Bản mã đang trống", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            txtBanGiaiMa.Text = Hill.decrypt(txtMHBanMa.Text, "VJHACFCAVMUQBEQNDBPSKCDBIBWJAENNDYYGBEKWXXYOZAPMEVCFRJEWOMAN", "THEFREQUENCYOFLETTERSATTHEBEGINNINGSOFWORDSISDIFFERENTAGAINA");
        }
Exemplo n.º 9
0
 void OnCollisionStay(Collision collision)
 {
     if (collision.gameObject.tag == "hill")
     {
         hill = collision.gameObject.GetComponent <Hill>();
         print(hill.playersOnHill);
         if (hill.playersOnHill == 1)
         {
             this.hillPoints++;
             print(hillPoints);
         }
     }
 }
        public IActionResult EncryptMessage([FromBody] VigenereModel message)
        {
            var plainText = message.Message;
            var alphabet  = message.Alphabet;
            var password  = message.Password;

            Hill cipher = new Hill(alphabet);

            //message.Message = cipher.Encrypt(plainText, password);
            var mess = new VigenereModel();

            mess.Message = Message.FeistelEncryptedMessage;
            return(Json(mess));
        }
Exemplo n.º 11
0
 private void OnTriggerEnter2D(Collider2D c)
 {
     if (c.tag == "Hill")
     {
         if (sliding)
         {
             rb2D.isKinematic = true;
             hill             = c.gameObject.GetComponent <Hill>();
             hillPoint        = -1;
             hill.speed       = rb2D.velocity.magnitude * Time.fixedDeltaTime * hill.speed;
             rb2D.velocity    = Vector2.zero;
         }
     }
 }
Exemplo n.º 12
0
 static void Main()
 {
     Languege.Libra("ru");
     #region
     FileStream   fs       = new FileStream("hillNewUpdateDatabase.txt", FileMode.OpenOrCreate);
     StreamWriter hillBase = new StreamWriter(fs, Encoding.Default);
     //Random rnd = new Random();
     #endregion
     #region
     var    lcm3  = new TheLinearCongruentialMethod();
     var    lcm11 = new TheLinearCongruentialMethod();
     var    china = new ChineseRemainderTheorem();
     Random rnd   = new Random();
     while (true)
     {
         var text = Console.ReadLine();
         if (text == "end")
         {
             break;
         }
         var staticKey = Generate.CreateKeysMatrix(text.Length);
         var libra     = new WordAndKey <List <Matrix <double> > >(text, staticKey);
         var tr        = new Hill();
         lcm11.CreatePeriod(11, rnd.Next(0, 11));
         lcm3.CreatePeriod(3, rnd.Next(0, 3));
         china.CreatePeriod(lcm3.Period, lcm11.Period);
         tr.Code(libra, china.Period);
         hillBase.WriteLine(string.Join(" ", lcm3.Period));
         hillBase.WriteLine(string.Join(" ", lcm11.Period));
         hillBase.WriteLine(libra.Word);
         hillBase.WriteLine(libra.Encoded);
         foreach (var l in libra.Key)
         {
             hillBase.WriteLine(l.ToMatrixString());
         }
     }
     hillBase.Close();
     #endregion //
     #region
     //key.Add(Matrix<double>.Build.DenseOfArray(new double[,] { { 7, 2 }, { 29, 29 } }));
     //key.Add(Matrix<double>.Build.DenseOfArray(new double[,] { { 15 }, { 6 } }));
     //var libra = new WordAndKey<List<Matrix<double>>>("БУБЛИКИ", key);
     //var tr = new Hill();
     //tr.Code(libra);
     //Console.WriteLine(libra.Encoded);
     #endregion
 }
Exemplo n.º 13
0
        private void btnGiaiMa_Click(object sender, EventArgs e)
        {
            txtMHBanMa.Text = txtMHBanMa.Text.Trim();
            if (txtMHBanMa.Text == "")
            {
                MessageBox.Show("Bản mã đang trống", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            /// Kiểm tra khóa
            int k = (int)numRowCount.Value;

            Matrix mt = new Matrix(k, k);

            /// tính lại mt
            foreach (var item in panelGroupKhoa.Controls)
            {
                TextBox z = item as TextBox;

                Point pos = (Point)z.Tag;
                if (pos.X > k || pos.Y > k)
                {
                    continue;
                }

                int gt = 0;
                try
                {
                    gt = Int32.Parse(z.Text);
                }
                catch
                {
                    gt = 0;
                }
                mt[pos.X, pos.Y] = new Complex(gt);
            }

            if (!MaHoa.Crypto.Hill.ok(mt))
            {
                MessageBox.Show("Key chưa thỏa mãn. Không tồn tại ma trận nghịch đảo", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            txtBanGiaiMa.Text = Hill.decrypt(txtMHBanMa.Text, mt);
        }
Exemplo n.º 14
0
    void Start()
    {
        // single mesh and poly collider better?  Probably.
        var bounds    = lineSegment.renderer.bounds;
        var rightEdge = new Vector2(bounds.max.x, 0);
        var leftEdge  = -rightEdge;

        GameObject lastSegment = null;
        var        hill        = new Hill(0);

        for (int h = 0; h < HILLS; ++h)
        {
            float range = hill.endAngle - hill.startAngle;
            for (int s = 0; s < Hill.SEGMENTS; ++s)
            {
                GameObject segment = (GameObject)Instantiate(lineSegment);

                var currentAngle = hill.startAngle + range * (s / Hill.SEGMENTS);
                var rotation     = currentAngle;
                segment.transform.Rotate(0, 0, rotation);

                if (lastSegment != null)
                {
                    var lastRightEdge = Util.RotatePoint(rightEdge, lastSegment.transform.rotation.eulerAngles.z);
                    var thisLeftEdge  = Util.RotatePoint(leftEdge, currentAngle);

                    Debug.Log(thisLeftEdge);
                    segment.transform.position =
                        (Vector2)lastSegment.transform.position + lastRightEdge -
                        thisLeftEdge;
                }

                segment.transform.parent = transform;

                lastSegment = segment;

                if (s == 0)
                {
                    var sprite = segment.GetComponent <SpriteRenderer>();
                    sprite.color = Color.red;
                }
            }
            hill = allowSharp ? new Hill() : new Hill(hill.endAngle);
        }
    }
Exemplo n.º 15
0
        private void generateGeography()
        {
            List <double> heightArr = new List <double>();

            foreach (double[] row in myHeightMap)
            {
                foreach (double d in row)
                {
                    heightArr.Add(d);
                }
            }

            heightArr.Sort();

            double waterline = heightArr[(int)(heightArr.Count * WATER_LEVEL)];
            double treeline  = heightArr[(int)(heightArr.Count * TREE_LINE)];
            double hillline  = heightArr[(int)(heightArr.Count * HILL_LINE)];

            for (int i = 0; i < myHeightMap[0].Length; i++)
            {
                for (int j = 0; j < myHeightMap.Length; j++)
                {
                    double temp = myHeightMap[i][j];

                    // create geography types
                    if (temp < waterline)
                    {
                        myTerrain[i][j] = new Water(temp);
                    }
                    else if (temp > hillline && temp < treeline)
                    {
                        myTerrain[i][j] = new Hill(temp);
                    }
                    else if (temp > treeline)
                    {
                        myTerrain[i][j] = new Mountain(temp);
                    }
                    else
                    {
                        myTerrain[i][j] = new Plains(temp);
                    }
                }
            }
        }
Exemplo n.º 16
0
    void HillUpdate()
    {
        hill.speed *= 1.01f;
        hillPoint  += hill.speed;

        if (hillPoint > 1)
        {
            rb2D.isKinematic = false;
            rb2D.velocity    = hill.endForce;
            hill             = null;
        }
        else
        {
            Vector2 P0 = hill.GetPoint(hillPoint),
                    P1 = hill.GetPoint(hillPoint + 0.01f),
                    P2 = P1 - P0;

            transform.rotation = Quaternion.Euler(0, 0, -Mathf.Atan2(P2.x, P2.y) * (180.0f / Mathf.PI));
            transform.position = P0;
        }
    }
Exemplo n.º 17
0
        private bool ConstructibleSpot(System.Drawing.Point p)
        {
            bool inside;

            if (Helpers.IsInPolygon(Hill, p))
            {
                return(false);                              // cannot build inside
            }
            for (int s = 1; s < Hill.Count(); s++)
            {
                if (Helpers.DistanceToLine(p, Hill[s - 1], Hill[s], out inside) < CONSTRUCTION_ZONE && inside)
                {
                    return(true);
                }
            }
            if (Helpers.DistanceToLine(p, Hill[Hill.Count() - 1], Hill[0], out inside) < CONSTRUCTION_ZONE && inside)
            {
                return(true);
            }
            Console.WriteLine($"Attempt to build non-constructible spot {p}");
            return(false);
        }
Exemplo n.º 18
0
        //----------------------------------------------------------------------------------------------
        // Function AddWalkSummitsVisited
        // Add visited summits to a walk
        //----------------------------------------------------
        public int AddWalkSummitsVisited(List <HillAscent> summits)
        {
            int iResult = 0;

            this.myWalkingDB.HillAscents.InsertAllOnSubmit(summits);

            foreach (HillAscent oHillAscent in summits)
            {
                int  iHillNumber = oHillAscent.Hillnumber;
                Hill oHill       = this.myWalkingDB.Hills.SingleOrDefault(h => h.Hillnumber == iHillNumber);

                if (oHill == null)
                {
                    throw new NullReferenceException("Could not find Hill ID " + iHillNumber + " in the Hills table in the database");
                }

                if (oHill.NumberOfAscents == 0)
                {
                    oHill.FirstClimbedDate = oHillAscent.AscentDate;
                }
                else
                {
                    //---Its not the first time an ascent has been logged for this hill, but the ascent may still be the first---
                    if (oHill.FirstClimbedDate > oHillAscent.AscentDate)
                    {
                        oHill.FirstClimbedDate = oHillAscent.AscentDate;
                    }
                }

                int iNumAscents = this.GetNumberOfHillAscentsByHillID(iHillNumber);
                //TODO Change this so that the number of ascents is calculated from the number of ascents in hillascents-----
                oHill.NumberOfAscents = (Int16)(iNumAscents + 1);
            }

            this.myWalkingDB.SubmitChanges();

            return(iResult);
        }
Exemplo n.º 19
0
        static LevelLoader()
        {
            // Mario loader
            loaders.Add("mario", (game, x, y) =>
            {
                game.Mario = new Entities.Mario.Mario(game, x, y);
            });

            LevelLoader_Block1();
            LevelLoader_Block2();

            // Enemy loaders
            loaders.Add("goomba", (game, x, y) =>
            {
                game.WorldLoader.Enemies.Add(new Goomba(game, x, y));
            });
            loaders.Add("koopa", (game, x, y) =>
            {
                game.WorldLoader.Enemies.Add(new Koopa(game, x, y));
            });
            loaders.Add("boss", (game, x, y) =>
            {
                game.WorldLoader.Enemies.Add(new Bowser(game, x - 1, y - 1));
            });

            loaders.Add("lakitu", (game, x, y) =>
            {
                game.WorldLoader.Enemies.Add(new Lakitu(game, x, y));
            });

            // Pipe loader
            loaders.Add("pipeTop", (game, x, y) =>
            {
                Pipe pipe = new Pipe("Top", game)
                {
                    Position = new Vector2(x, y)
                };
                game.WorldLoader.Pipes.Add(pipe);
                game.Map.SetBlock(x, y, pipe);
                game.Map.SetHiddenBlock(x, y + 1, pipe);
                game.Map.SetHiddenBlock(x + 1, y, pipe);
                game.Map.SetHiddenBlock(x + 1, y + 1, pipe);
            });

            loaders.Add("UGpipeTop", (game, x, y) =>
            {
                Pipe pipe     = new Pipe("UGTop", game);
                pipe.Position = new Vector2(x, y);
                game.WorldLoader.Pipes.Add(pipe);
                game.Map.SetBlock(x, y, pipe);
                game.Map.SetHiddenBlock(x, y + 1, pipe);
                game.Map.SetHiddenBlock(x + 1, y, pipe);
                game.Map.SetHiddenBlock(x + 1, y + 1, pipe);
            });

            loaders.Add("pipeBody", (game, x, y) =>
            {
                Pipe pipeBody     = new Pipe("Body", game);
                pipeBody.Position = new Vector2(x, y);
                game.WorldLoader.Pipes.Add(pipeBody);
                game.Map.SetBlock(x, y, pipeBody);
                game.Map.SetHiddenBlock(x + 1, y, pipeBody);
            });

            loaders.Add("SWPipeEntrance", (game, x, y) =>
            {
                Pipe pipeBody     = new Pipe("SWEntrance", game);
                pipeBody.Position = new Vector2(x, y);
                game.WorldLoader.Pipes.Add(pipeBody);
                game.Map.SetBlock(x, y, pipeBody);
                game.Map.SetHiddenBlock(x + 1, y, pipeBody);
                game.Map.SetHiddenBlock(x, y + 1, pipeBody);
                game.Map.SetHiddenBlock(x + 1, y + 1, pipeBody);
            });

            loaders.Add("SWPipeBody", (game, x, y) =>
            {
                Pipe pipeBody     = new Pipe("SWBody", game);
                pipeBody.Position = new Vector2(x, y);
                game.WorldLoader.Pipes.Add(pipeBody);
                game.Map.SetBlock(x, y, pipeBody);
                game.Map.SetBlock(x, y + 1, pipeBody);
            });

            //Item loaders
            loaders.Add("coin", (game, x, y) =>
            {
                IItem coin    = new Coin(game, new Vector2(x, y - 1));
                coin.Position = new Vector2(x, y);
                game.WorldLoader.Items.Add(coin);
            });

            loaders.Add("flagPole", (game, x, y) =>
            {
                IItem flagPole    = new FlagPole(game);
                flagPole.Position = new Vector2(x, y);
                flagPole.Bounds   = new Rectangle(x, y, 1, 12 - y);
                game.WorldLoader.Items.Add(flagPole);
            });

            // Background loaders
            loaders.Add("bush", (game, x, y) =>
            {
                IBackground bush = new Bush();
                bush.Position    = new Vector2(x, y);
                game.WorldLoader.Background.Add(bush);
            });

            loaders.Add("bushMid", (game, x, y) =>
            {
                IBackground bushmid = new BushMid();
                bushmid.Position    = new Vector2(x, y);
                game.WorldLoader.Background.Add(bushmid);
            });

            loaders.Add("bushLong", (game, x, y) =>
            {
                IBackground bushlong = new BushLong();
                bushlong.Position    = new Vector2(x, y);
                game.WorldLoader.Background.Add(bushlong);
            });

            loaders.Add("hill", (game, x, y) =>
            {
                IBackground hill = new Hill();
                hill.Position    = new Vector2(x, y);
                game.WorldLoader.Background.Add(hill);
            });

            loaders.Add("cloud", (game, x, y) =>
            {
                IBackground cloud = new Cloud();
                cloud.Position    = new Vector2(x, y);
                game.WorldLoader.Background.Add(cloud);
            });

            loaders.Add("cloudMid", (game, x, y) =>
            {
                IBackground cloudMid = new CloudMid();
                cloudMid.Position    = new Vector2(x, y);
                game.WorldLoader.Background.Add(cloudMid);
            });

            loaders.Add("cloudLong", (game, x, y) =>
            {
                IBackground cloudlong = new CloudLong();
                cloudlong.Position    = new Vector2(x, y);
                game.WorldLoader.Background.Add(cloudlong);
            });

            loaders.Add("castle", (game, x, y) =>
            {
                IBackground castle = new ToadCastle();
                castle.Position    = new Vector2(x, y);
                game.WorldLoader.Background.Add(castle);
            });

            loaders.Add("flag", (game, x, y) =>
            {
                Flag flag = new Flag(new Vector2(x, y));
                game.WorldLoader.Background.Add(flag);
            });

            loaders.Add("lavaTop", (game, x, y) =>
            {
                IBackground lavatop = new LavaTop {
                    Position = new Vector2(x, y)
                };
                game.WorldLoader.Background.Add(lavatop);
            });

            loaders.Add("LavaBot", (game, x, y) => {
                IBackground lavatop = new LavaBot {
                    Position = new Vector2(x, y)
                };
                game.WorldLoader.Background.Add(lavatop);
            });

            loaders.Add("BridgeChain", (game, x, y) => {
                IBackground bc = new BridgeChain {
                    Position = new Vector2(x, y)
                };
                game.WorldLoader.Background.Add(bc);
            });

            loaders.Add("Hammer", (game, x, y) => {
                game.WorldLoader.Items.Add(new Hammer(game, new Vector2(x, y)));
            });
        }
Exemplo n.º 20
0
 public void AddHill(int col, int row, int team)
 {
     var hill = new Hill { X = col, Y = row, Team = team };
     if (team != 0)
     {
         var index = EnemyHills.BinarySearch(hill);
         if (index < 0)
         {
             EnemyHills.Insert(~index, hill);
             hill.DistanceMap = new int[Width, Height];
             hill.NeedRecalcDistanceMap = true;
             hill.IsVisible = true;
         }
         else
             EnemyHills[index].IsVisible = true;
     }
     else
         if (!Hills.Contains(hill))
         {
             hill.DistanceMap = new int[Width, Height];
             hill.StochasticMap = new int[Width, Height];
             hill.NeedRecalcDistanceMap = true;
             hill.Live = true;
             Hills.Add(hill);
         }
         else
             Hills.Where(h => h.Equals(hill)).First().Live = true;
 }
Exemplo n.º 21
0
        public INoise CreateLandFormFct(Gradient ground_gradient, INoise terrainDelimiter, out INoise landScapeTypeFct)
        {
            //Create various landcreation Algo. ===================================================================
            //Montains forms
            INoise montainFct = new Montain(_worldParameters.Seed + 28051979, ground_gradient).GetLandFormFct();

            //MidLand forms
            INoise midlandFct = new Midland(_worldParameters.Seed + 08092007, ground_gradient).GetLandFormFct();

            //Plains forms ===========================================================
            INoise hillFct  = new Hill(_worldParameters.Seed + 1, ground_gradient).GetLandFormFct();
            INoise plainFct = new Plain(_worldParameters.Seed, ground_gradient).GetLandFormFct();
            INoise flatFct  = new Flat(_worldParameters.Seed + 96, ground_gradient).GetLandFormFct();
            //Controler to manage Plains form transitions
            INoise plainsCtrl = new PlainCtrl(_worldParameters.Seed + 96, _config.ProcessorParam.PlainCtrlOctave,
                                              _config.ProcessorParam.PlainCtrlFrequency).GetLandFormFct();                                     //Noise That will merge hillFct, plainFct and flatFct together

            //Oceans forms
            INoise oceanBaseFct = new Ocean(_worldParameters.Seed + 10051956, ground_gradient).GetLandFormFct();

            //Surface main controler
            INoise surfaceCtrl = new SurfaceCtrl(_worldParameters.Seed + 123, _config.ProcessorParam.GroundCtrlOctave,
                                                 _config.ProcessorParam.GroundCtrlFrequency).GetLandFormFct();

            var param = _config.ProcessorParam;

            //=====================================================================================================
            //Plains Noise selecting based on plainsCtrl controler
            //Merge flat with Plain *************************************************************
            LandscapeRange flatBasicParam  = param.BasicPlain[0];
            LandscapeRange plainBasicParam = param.BasicPlain[1];
            LandscapeRange hillBasicParam  = param.BasicPlain[2];

            //Select flat_Plain_select = new Select(flatFct, plainFct, plainsCtrl, 0.4, 0.1);
            Select flat_Plain_select = new Select(flatFct, plainFct, plainsCtrl, flatBasicParam.Size, flatBasicParam.MixedNextArea + plainBasicParam.MixedPreviousArea)
            {
                Name = "flat_Plain_select"
            };
            INoise flat_Plain_result = new Select(enuLandFormType.Flat, enuLandFormType.Plain, plainsCtrl, flat_Plain_select.Threshold)
            {
                Name = "flat_Plain_result"
            };                                                                                                                                                            //Biome composition

            //Merge Plain with hill *************************************************************
            //Select mergedPlainFct = new Select(flat_Plain_select, hillFct, plainsCtrl, 0.65, 0.1);
            Select mergedPlainFct = new Select(flat_Plain_select, hillFct, plainsCtrl, flat_Plain_select.Threshold.ScalarParam + plainBasicParam.Size, plainBasicParam.MixedNextArea + hillBasicParam.MixedPreviousArea)
            {
                Name = "mergedPlainFct"
            };
            INoise mergedPlainFct_result = new Select(flat_Plain_result, enuLandFormType.Hill, plainsCtrl, mergedPlainFct.Threshold)
            {
                Name = "mergedPlainFct_result"
            };                                                                                                                                                               //Biome composition

            //=====================================================================================================
            //Surface Noise selecting based on surfaceCtrl controler
            //Merge Plains with Midland *********************************************************
            LandscapeRange plainGroundParam   = param.Ground[0];
            LandscapeRange midLandGroundParam = param.Ground[1];
            LandscapeRange MontainGroundParam = param.Ground[2];

            //Select Plain_midland_select = new Select(mergedPlainFct, midlandFct, surfaceCtrl, 0.45, 0.10);
            Select Plain_midland_select = new Select(mergedPlainFct, midlandFct, surfaceCtrl, plainGroundParam.Size, plainGroundParam.MixedNextArea + midLandGroundParam.MixedPreviousArea)
            {
                Name = "Plain_midland_select"
            };
            INoise Plain_midland_result = new Select(mergedPlainFct_result, enuLandFormType.Midland, surfaceCtrl, Plain_midland_select.Threshold)
            {
                Name = "Plain_midland_result"
            };                                                                                                                                                                       //Biome composition

            //Merge MidLand with Montain ********************************************************
            //Select midland_montain_select = new Select(Plain_midland_select, montainFct, surfaceCtrl, 0.55, 0.05);
            Select midland_montain_select = new Select(Plain_midland_select, montainFct, surfaceCtrl, Plain_midland_select.Threshold.ScalarParam + midLandGroundParam.Size, midLandGroundParam.MixedNextArea + MontainGroundParam.MixedPreviousArea)
            {
                Name = "midland_montain_select"
            };
            INoise midland_montain_result = new Select(Plain_midland_result, enuLandFormType.Montain, surfaceCtrl, midland_montain_select.Threshold)
            {
                Name = "midland_montain_result"
            };                                                                                                                                                                            //Biome composition

            //=====================================================================================================
            //Surface Noise selecting based on terrainDelimiter controler
            //Merge the Water landForm with the surface landForm
            LandscapeRange waterWorldParam  = param.World[0];
            LandscapeRange groundWorldParam = param.World[1];

            //Select world_select = new Select(oceanBaseFct, midland_montain_select, terrainDelimiter, 0.009, 0.20);
            Select world_select = new Select(oceanBaseFct, midland_montain_select, terrainDelimiter, waterWorldParam.Size, waterWorldParam.MixedNextArea + groundWorldParam.MixedPreviousArea)
            {
                Name = "world_select"
            };
            INoise world_select_result = new Select(enuLandFormType.Ocean, midland_montain_result, terrainDelimiter, world_select.Threshold)
            {
                Name = "world_select_result"
            };                                                                                                                                                                         //Biome composition

            landScapeTypeFct = world_select_result;

            return(world_select);
        }
Exemplo n.º 22
0
        public override int Effect(Deity creator)
        {
            Hill hill = new Hill("PlaceHolder", SelectedProvince, creator);

            int chance = rnd.Next(100);

            switch (SelectedProvince.LocalClimate)
            {
            case Climate.Arctic:
                hill.BiomeType = BiomeType.Tundra;
                break;

            case Climate.SubArctic:
                if (chance < 33)
                {
                    hill.BiomeType = BiomeType.Tundra;
                }
                else if (chance < 66)
                {
                    hill.BiomeType = BiomeType.ColdDesert;
                }
                else
                {
                    hill.BiomeType = BiomeType.BorealForest;
                }
                break;

            case Climate.Temperate:
                if (chance < 25)
                {
                    hill.BiomeType = BiomeType.TemperateGrassland;
                }
                else if (chance < 50)
                {
                    hill.BiomeType = BiomeType.ColdDesert;
                }
                else if (chance < 75)
                {
                    hill.BiomeType = BiomeType.HotDesert;
                }
                else
                {
                    hill.BiomeType = BiomeType.TemperateDeciduousForest;
                }
                break;

            case Climate.SubTropical:
                if (chance < 33)
                {
                    hill.BiomeType = BiomeType.TropicalGrassland;
                }
                else if (chance < 66)
                {
                    hill.BiomeType = BiomeType.HotDesert;
                }
                else
                {
                    hill.BiomeType = BiomeType.TropicalRainforest;
                }
                break;

            case Climate.Tropical:
                if (chance < 33)
                {
                    hill.BiomeType = BiomeType.TropicalGrassland;
                }
                else if (chance < 66)
                {
                    hill.BiomeType = BiomeType.HotDesert;
                }
                else
                {
                    hill.BiomeType = BiomeType.TropicalRainforest;
                }
                break;
            }

            hill.Name = Program.GenerateNames.GetName("hill_names");

            // Add hill to hill range.
            ((HillRange)SelectedProvince.PrimaryTerrainFeature).Hills.Add(hill);
            hill.Range = (HillRange)SelectedProvince.PrimaryTerrainFeature;
            SelectedProvince.SecondaryTerrainFeatures.Add(hill);

            hill.Modifiers.NaturalDefenceValue += 2;
            switch (hill.BiomeType)
            {
            case BiomeType.BorealForest:
            case BiomeType.TemperateDeciduousForest:
            case BiomeType.TropicalDryForest:
            case BiomeType.TropicalRainforest:
                hill.Modifiers.NaturalDefenceValue += 1;
                break;

            default:
                break;
            }

            // Add mountain to deity lists
            creator.TerrainFeatures.Add(hill);
            creator.LastCreation = hill;

            Program.WorldHistory.AddRecord(hill, hill.printTerrainFeature);

            return(0);
        }