Esempio n. 1
0
        private void generateLakeHouse(int HouseID)
        {
            int Radius = 32;

            int PX = (int)CenterPosition.X;
            int PY = (int)CenterPosition.Y;

            for (int countX = -Radius; countX <= Radius; countX += 2)
            {
                for (int countY = -Radius; countY <= Radius; countY += 2)
                {
                    if (MapUtil.HasSurrounding(PX + countX, PY + countY, IslandMap.lk, 8) && !IslandMap.lk[PX + countX, PY + countY] && !MapUtil.HasSurrounding(PX + countX, PY + countY, IslandMap.m, 1))
                    {
                        Point LakePoint = MapUtil.getClosest(PX + countX, PY + countY, IslandMap.lk, Radius);
                        int   angle     = MapUtil.GetDirectionAngle(PX + countX, PY + countY, IslandMap.lk) + 90;

                        if (angle >= 0)
                        {
                            Point3D Dimensions = VoxelModels.VoxelModels.ModelDimensionLibrary["House_" + HouseID + "_Dimensions"];

                            //Debug.WriteLine(Dimensions);

                            Structure Structure         = new Structure(new Point3D(PX + countX, IslandMap.h[PX + countX, PY + countY], PY + countY), angle, (int)Dimensions.X, (int)Dimensions.Y, (int)Dimensions.Z);
                            Boolean   HasNearbyBuilding = MapUtil.HasStructureSurroundingStructure(Structure, this, 3);

                            if (!HasNearbyBuilding)
                            {
                                Boolean HasLake = MapUtil.HasStructureSurrounding(Structure, IslandMap.lk, 6);

                                if (!HasLake)
                                {
                                    //add system for random houses
                                    IslandMap.StructureNames.Add("House_" + HouseID + "_");

                                    //IslandMap.StructurePoints.Add(new Point3D(PX + countX, IslandMap.h[PX + countX, PY + countY], PX + countX));
                                    IslandMap.StructurePoints.Add(new Point3D(PX + countX, IslandMap.h[PX + countX, PY + countY], PY + countY));
                                    //IslandMap.StructurePoints.Add(new Point3D(512, 2, 512));
                                    //IslandMap.StructureRotations.Add(new Vector3D(dir.X, 1, dir.Y));
                                    IslandMap.StructureRotations.Add(angle);

                                    StructureList.Add(Structure);

                                    //Debug.WriteLine("House added");

                                    return;
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        public void createBridge()
        {
            Point DeltaPosition = IslandMap.GetDeltaPoint(CenterPosition);

            Vector dir = new Vector(DeltaPosition.X - CenterPosition.X, DeltaPosition.Y - CenterPosition.Y);

            dir.Normalize();

            int distance = (int)MathUtil.MathUtil.distance(CenterPosition, DeltaPosition);

            dir.Normalize();

            int allowedDistance = (int)(distance * 0.25f);

            for (int i = 1; i < distance; i++)
            {
                float wavePosX = (float)(dir.X * i + dir.X * Math.Sin(Math.PI * i / distance) * 10);
                float wavePosY = (float)(dir.Y * i + dir.Y * Math.Sin(Math.PI * i / distance) / 10);

                int px = (int)(CenterPosition.X + wavePosX);
                int py = (int)(CenterPosition.Y + wavePosY);

                if (!IslandMap.lk[px, py] && IslandMap.r[px, py])
                {
                    if (i > allowedDistance)
                    {
                        Point BridgePosition = new Point(px - 5, py - 5);

                        int angle = MapUtil.GetDirectionAngle(px, py, IslandMap.lk);

                        //Debug.WriteLine(BridgePositionB);

                        IslandMap.StructureNames.Add("Bridge_");
                        IslandMap.StructurePoints.Add(new Point3D(BridgePosition.X, IslandMap.h[px, py], BridgePosition.Y));

                        //IslandMap.StructureRotations.Add(new Vector3D(CrossDir.X, 1, CrossDir.Y));
                        //IslandMap.StructureRotations.Add(new Vector3D(dir.X, 1, dir.Y));
                        IslandMap.StructureRotations.Add(angle + 270);
                        return;
                    }
                }
            }
        }