public void CachePoints(TerrainType type)
 {
     if (type == TerrainType.RMVX_Ground)
         CachePoints_RMVX_Ground();
     if (type == TerrainType.RMVX_Cliff)
         CachePoints_RMVX_Cliff();
 }
Beispiel #2
0
 public TileStruct(int x, int y, TileType type, TerrainType terrainType)
 {
     SetBoth(terrainType);
     this.X = x;
     this.Y = y;
     this.Type = type;
 }
Beispiel #3
0
 public bool isTerrainType(TerrainType terrainType)
 {
     if (Network.peerType == NetworkPeerType.Server) {
         TerrainType = (int)TerrainProvider.getTerrainType(GUID);
     }
     return TerrainType == (int)terrainType;
 }
Beispiel #4
0
 public static UnitStats GetTerrainBonus(TerrainType terrain)
 {
     UnitStats output;
     if (!TerrainBonuses.TryGetValue(terrain, out output))
         throw new Exception("Unknown terrain");
     return output;
 }
 //Constructors:
 public TerrainTile(Vector3 vec, TerrainType type, Topper top)
 {
     terrainType = type;
     topper = top;
     var battlespud = f*g;
     Coordinates coords = new Coordinates (vec);
 }
 public TerrainPaintBrushCatalogResource(int APIversion,
     uint version,
     uint brushVersion,
     Common common,
     BrushOperation normalOperation, BrushOperation oppositeOperation, TGIBlock profileTexture, BrushOrientation orientation,
     float width, float strength, byte baseTextureValue, float wiggleAmount,
     TGIBlock brushTexture,
     TerrainType terrain, CategoryType category
     )
     : base(APIversion,
         version,
         brushVersion,
         common,
         normalOperation,
         oppositeOperation,
         profileTexture,
         orientation,
         width,
         strength,
         baseTextureValue,
         wiggleAmount
     )
 {
     this.brushTexture = (TGIBlock)brushTexture.Clone(OnResourceChanged);
     this.terrain = terrain;
     this.category = category;
 }
Beispiel #7
0
 public float GetSpeed(TerrainType terrain)
 {
     switch (terrain)
     {
         case TerrainType.None:
         case TerrainType.Water:
         case TerrainType.Rock:
             return 0.0f;
         case TerrainType.Sand:
         case TerrainType.Snow:
             return 1.0f;
         case TerrainType.Dirt:
             return 1.5f;
         case TerrainType.Rough:
         case TerrainType.Grass:
         case TerrainType.Lava:
             return 2.0f;
         case TerrainType.Swamp:
             return 0.4f;
         case TerrainType.Subterrnian:
             return 3.0f;
         default:
             return 0.0f;
     }
 }
Beispiel #8
0
 public void AddTile(int x, int y, TerrainType type)
 {
     if(InXRange(x) && InYRange(y)) {
         if(!map.ContainsKey(new Point(x, y))) {
             switch(type) {
                 case TerrainType.PLATFORM:
                     map.Add(new Point(x, y), new Platform(x, y, this));
                     break;
                 case TerrainType.PORTAL:
                     map.Add(new Point(x, y), new Portal(x, y, this));
                     break;
             }
         } else {
             if(map[new Point(x, y)] is Platform) {
                 if(type == TerrainType.PORTAL) {
                     map[new Point(x, y)] = new Portal(x, y, this);
                 }
             } else if(map[new Point(x, y)] is Portal) {
                 if(type == TerrainType.PLATFORM) {
                     map[new Point(x, y)] = new Platform(x, y, this);
                 }
             }
         }
     }
 }
 public TerrainPaintBrushCatalogResource(int APIversion, Stream unused, TerrainPaintBrushCatalogResource basis)
     : base(APIversion, null, basis)
 {
     this.brushTexture = (TGIBlock)basis.brushTexture.Clone(OnResourceChanged);
     this.terrain = basis.terrain;
     this.category = basis.category;
 }
        /// <summary>
        /// Initialzes a new instance of the <see cref="DialogTerrain"/> form.
        /// Effectively puts the dialog in 'edit mode'.
        /// Populates the field with the corresponding data.
        /// </summary>
        /// <param name="name">Terrain name.</param>
        /// <param name="type">Type of the terrain.</param>
        /// <param name="tileset">ID of the tileset.</param>
        /// <param name="x">X co-ordinate of the terrain.</param>
        /// <param name="y">Y co-ordinate of the terrain.</param>
        /// <param name="width">Width of the terrain.</param>
        /// <param name="height">Height of the terrain.</param>
        public DialogTerrain(string name, TerrainType type, int tileset, int x, int y, int width, int height)
        {
            InitializeComponent();

            cmbTileset.Items.Clear();
            cmbType.Items.Clear();

            var tilesetList = TilesetManager.Instance.TilesetNames;
            tilesetList.Sort();
            foreach (var str in tilesetList)
            {
                cmbTileset.Items.Add(str);
            }

            var typeList = Enum.GetValues(typeof(TerrainType));
            foreach (var str in typeList)
            {
                cmbType.Items.Add(str);
            }

            if (cmbTileset.Items.Count > 0)
                SetTileset();
            if (cmbType.Items.Count > 0)
                SetTerrainSize();

            btnOK.Click += btnOK_Click;

            cmbTileset.SelectedIndexChanged += cmbTileset_SelectedIndexChanged;
            cmbType.SelectedIndexChanged += cmbType_SelectedIndexChanged;

            txtName.Text = name;
            for (int i = 0; i < cmbType.Items.Count; i++)
            {
                if (cmbType.Items[i].ToString() == type.ToString())
                {
                    cmbType.SelectedIndex = i;
                    SetTerrainSize();
                }
            }

            var tilesetName = TilesetManager.Instance.GetTileset(tileset).Name;
            for (int i = 0; i < cmbTileset.Items.Count; i++)
            {
                if (cmbTileset.Items[i].ToString() == tilesetName)
                {
                    cmbTileset.SelectedIndex = i;
                    SetTileset();
                }
            }

            viewTileset.SelectionX = x;
            viewTileset.SelectionY = y;
            viewTileset.SelectionWidth = width;
            viewTileset.SelectionHeight = height;

            Load += delegate { viewTileset.EnsureVisible(); };

            Text = @"Edit Terrain";
        }
Beispiel #11
0
    public void Initialize(TerrainType type, TerrainMapPoint initPoint, Terrain t)
    {
        terrain = t;
        terrainType = type;
        terrain.SetPoint(initPoint, type);

        mapPoints.Add(initPoint);
    }
Beispiel #12
0
 public List<Terrain> getTerrainsByType(TerrainType type)
 {
   List<Terrain> terrains = new List<Terrain>();
   foreach (Terrain t in Terrains)
     if (t.Type == type)
       terrains.Add(t);
   return terrains;
 }
Beispiel #13
0
 public TileStruct(int x, int y, TileType type, TerrainType terrainType, DecorType decor)
 {
     this.DecorType = decor;
     SetBoth(terrainType);
     this.X = x;
     this.Y = y;
     this.Type = type;
 }
 /// <summary>
 /// Removes a terrain type to the list
 /// </summary>
 private void OnRemoveTerrainType( TerrainType terrainType )
 {
     Arguments.CheckNotNull( terrainType, "terrainType" );
     if ( Model != null )
     {
         Model.Remove( terrainType );
     }
 }
 /// <summary>
 /// Adds a new terrain type to the list
 /// </summary>
 private void OnAddTerrainType( TerrainType terrainType )
 {
     Arguments.CheckNotNull( terrainType, "terrainType" );
     if ( Model != null )
     {
         Model.Add( terrainType );
     }
 }
Beispiel #16
0
 public static string ToString(TerrainType type)
 {
   switch (type)
   {
     default:
       return "Unknown";
   }
 }
Beispiel #17
0
    public void Reset()
    {
        terrainType = TerrainType.None;
        mapPoints.Clear();

        floodFillIndex = 0;
        FloodComplete = false;
    }
Beispiel #18
0
    public void LoadTerrainTypes()
    {
        TerrainType terra = new TerrainType( new TerrainStaticData( "Plain", 1, Altitude.land, Capturable.False ) );
        TerrainType water = new TerrainType( new TerrainStaticData( "Water", 1, Altitude.sea, Capturable.False ) );

        //After I've been populated, alert the terrainEditor that the UI needs to be updated.
        PopulateTerrainUIGrid( TypeContainer<TerrainType>.getAll() );
    }
        public TerrainTypeEditorControl( )
        {
            InitializeComponent( );

            TerrainType = new TerrainType( );

            elevationControl.DistributionChanged += delegate { OnTerrainTypeChanged( ); };
            slopeControl.DistributionChanged += delegate { OnTerrainTypeChanged( ); };
        }
Beispiel #20
0
 public void Set(int col, int row, TerrainType ter)
 {
     x = col;
     y = row - (col - (col%2)) / 2;
     z = -x - y;
     terrain = ter;
     available = true;
     highlighter = transform.FindChild("HighlightingProjector").gameObject.GetComponent<Projector>();
 }
Beispiel #21
0
 public static Terrain forType(TerrainType type)
 {
     Terrain terrain;
     if (terrains.TryGetValue(type, out terrain)){
         return terrain;
     }
     terrain = createForType(type);
     terrains.Add(type, terrain);
     return terrain;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Tileset"/> class.
 /// </summary>
 /// <param name="id">ID of the terrain.</param>
 /// <param name="name">Name of the terrain.</param>
 /// <param name="type">Type of the terrain.</param>
 /// <param name="tileset">Tileset of the terrain.</param>
 /// <param name="x">X co-ordinate of the terrain.</param>
 /// <param name="y">Y co-ordinate of the terrain.</param>
 /// <param name="width">Width of the terrain.</param>
 /// <param name="height">Height of the terrain.</param>
 public TerrainTile(int id, string name, TerrainType type, int tileset, int x, int y, int width, int height)
 {
     ID = id;
     Name = name;
     Type = type;
     Tileset = tileset;
     X = x;
     Y = y;
     Width = width;
     Height = height;
 }
Beispiel #23
0
        public CityVertex(Vector3 position, Vector2 textureCoords, Color color, TerrainType terrain)
        {
            this.Position = position;
            this.Color = color;
            this.TextureCoordinate = textureCoords;
            this.TextureWeight1 = new Vector4(terrain == TerrainType.Grass ? 1 : 0,
                                              terrain == TerrainType.Snow ? 1 : 0,
                                              terrain == TerrainType.Sand ? 1 : 0,
                                              terrain == TerrainType.Rock ? 1 : 0);

            this.TextureWeight2 = new Vector4(terrain == TerrainType.Water ? 1 : 0, 0, 0, 0);
        }
Beispiel #24
0
 public Block(TerrainType tt, Bitmap utl, Bitmap utr, Bitmap ubl, Bitmap ubr, Bitmap ltl, Bitmap ltr, Bitmap lbl, Bitmap lbr)
 {
     attribute = tt;
     upperTopLeft = utl;
     upperTopRight = utr;
     upperBottomLeft = ubl;
     upperBottomRight = ubr;
     lowerTopLeft = ltl;
     lowerTopRight = ltr;
     lowerBottomLeft = lbl;
     lowerBottomRight = lbr;
 }
Beispiel #25
0
    public MapGen(int mapWidth, int mapHeight, int wallPercentage, TerrainType terrainType, int seed)
    {
        this.seed = seed;
        rand = new System.Random(seed);

        this.TerrainType = terrainType;
        MapWidth = mapWidth;
        MapHeight = mapHeight;
        PercentAreWalls = wallPercentage;

        RandomFillMap();
    }
 short CalculateTerrainWeight(GameEvent evnt, TerrainType terrain)
 {
     short weight = 0;
     byte terrainsCount = (byte)(System.Enum.GetNames(typeof(TerrainType)).Length - 1);
     for (byte i = 0; i < terrainsCount; ++i)
     {
         TerrainType t = (TerrainType)(1 << i);
         if ((t & terrain) != TerrainType.NONE)
             weight += evnt.TerrainWeights[t];
     }
     return weight;
 }
Beispiel #27
0
 public void MirrorTnGAttributesFrom(TnGAttribute src)
 {
     m_height = src.m_height;
     m_terrainType = src.m_terrainType;
     if(src.m_unit != null){
         m_unit = (GameObject)Instantiate(src.m_unit);
         m_unit.name = src.m_unit.name;
     }
     if(src.m_building != null){
         m_building = (GameObject)Instantiate(src.m_building);
         m_building.name = src.m_building.name;
     }
 }
Beispiel #28
0
    public bool SetPoint(TerrainMapPoint point, TerrainType type)
    {
        if (GetTerrainType(point) != TerrainType.None)
        {
            return false;
        }
        else
        {
            terrainMap[point.x, point.y].type = type;
        }

        return true;
    }
Beispiel #29
0
 public void SetWall(TerrainType WallTerrain)
 {
     switch (WallTerrain)
     {
         case TerrainType.YellowCave:
             WallTerrainType = "YellowCave";
             break;
         case TerrainType.BlackCaste:
             WallTerrainType = "BlackCastle";
             break;
         default:
             break;
     }
 }
Beispiel #30
0
        /// <summary>
        /// Creates a new tile
        /// </summary>
        /// <param name="x">The x position of the tile</param>
        /// <param name="y">The y position of the tile</param>
        /// <param name="w">The width of the tile</param>
        /// <param name="h">The height of the tile</param>
        /// <param name="tType">The type of the tile</param>
        /// <param name="tileNumber">The number of the tile</param>
        public Tile(int x, int y, int w, int h, TerrainType tType, int tileNumber)
            : base(x, y, w, h)
        {
            CardSlots = new List<CardSlot>();
            _cubes = new List<Cube>();

            // Add the appropriate amount of slots
            for (int i = 0; i < tileNumber; i++)
            {
                    CardSlots.Add(new CardSlot(this, 0, 0, CardSlot.Position.Above));
                    CardSlots.Add(new CardSlot(this, 0, 0, CardSlot.Position.Below));
            }
            this.Terrain = tType;
            this.Number = tileNumber;
        }
    private Texture2D BuildBiomeTexture(TerrainType[,] heightTerrainTypes, TerrainType[,] heatTerrainTypes, TerrainType[,] moistureTerrainTypes)
    {
        int tileDepth = heatTerrainTypes.GetLength(0);
        int tileWidth = heatTerrainTypes.GetLength(1);

        Color[] colorMap = new Color[tileDepth * tileWidth];
        for (int zIndex = 0; zIndex < tileDepth; zIndex++)
        {
            for (int xIndex = 0; xIndex < tileWidth; xIndex++)
            {
                int colorIndex = zIndex * tileWidth + xIndex;

                TerrainType heightTerrainType = heightTerrainTypes [zIndex, xIndex];
                // check if the current coordinate is a water region
                if (heightTerrainType.name != "water")
                {
                    // if a coordinate is not water, its biome will be defined by the heat and moisture values
                    TerrainType heatTerrainType     = heatTerrainTypes [zIndex, xIndex];
                    TerrainType moistureTerrainType = moistureTerrainTypes [zIndex, xIndex];

                    // terrain type index is used to access the biomes table
                    Biome biome = this.biomes [moistureTerrainType.index].biomes [heatTerrainType.index];
                    // assign the color according to the selected biome
                    colorMap [colorIndex] = biome.color;
                }
                else
                {
                    // water regions don't have biomes, they always have the same color
                    colorMap [colorIndex] = this.waterColor;
                }
            }
        }

        // create a new texture and set its pixel colors
        Texture2D tileTexture = new Texture2D(tileWidth, tileDepth);

        tileTexture.wrapMode = TextureWrapMode.Clamp;
        tileTexture.SetPixels(colorMap);
        tileTexture.Apply();

        return(tileTexture);
    }
Beispiel #32
0
        // Let sand fall down etc
        private void UpdateTerrain(int minY, int minX, int maxX)
        {
            minY = Math.Max(0, minY);

            // For every column check whether there is air below sand so that the latter moves downwards
            for (int x = minX; x < maxX; ++x)
            {
                int lowestAirPosition = height;
                for (int y = minY; y < height; ++y)
                {
                    TerrainType cur = PublicShape.TerrainBitmap[x, y];

                    //PublicShape.TerrainBitmap[x, y] = TerrainType.Air;

                    if (cur == TerrainType.Air)
                    {
                        if (lowestAirPosition == height)
                        {
                            lowestAirPosition = y;
                        }
                    }
                    else if (cur == TerrainType.Sand)
                    {
                        if (lowestAirPosition < height)
                        {
                            // Fill lowest air with sand
                            PublicShape.TerrainBitmap[x, lowestAirPosition] = TerrainType.Sand;

                            ++lowestAirPosition;

                            // This position is now air
                            PublicShape.TerrainBitmap[x, y] = TerrainType.Air;
                        }
                    }
                    else
                    {
                        // Reset
                        lowestAirPosition = height;
                    }
                }
            }
        }
Beispiel #33
0
    public static int movementCost(this TerrainType t)
    {
        switch (t)
        {
        case TerrainType.Space:
            return(2);

        case TerrainType.Ground:
            return(5);

        case TerrainType.Water:
            return(12);

        case TerrainType.Star:
            return(45);

        default:
            throw new System.ArgumentException($"Invalid TerrainType {t}");
        }
    }
Beispiel #34
0
        /// <summary>
        /// Calc minimum distance for the same terrain types items (by terrain type)
        /// </summary>
        /// <param name="TT"></param>
        /// <returns></returns>
        public double GetNearestSameTerrainTypeMinDistance(TerrainType TT)
        {
            List <FieldElement> ItemsList;

            ItemsList = GetItemsByTerrainType(TT);

            var minDist = 100.0;

            foreach (var item in ItemsList)
            {
                FieldElement Nearest = GetNearestSameTerrainType(item);
                var          dist    = CalcDistance(item, Nearest);
                if (dist < minDist)
                {
                    minDist = dist;
                }
            }

            return(minDist);
        }
Beispiel #35
0
        private static Color getColor(TerrainType terrainType)
        {
            switch (terrainType)
            {
            case TerrainType.OCEAN:
                return(Color.blue);

            case TerrainType.LAKE:
                return(Color.cyan);

            case TerrainType.LAND:
                return(Color.grey);

            case TerrainType.COAST:
                return(Color.yellow);

            default:
                return(Color.white);
            }
        }
    public TerrainAttributes()
    {
        //                     friction,bounce,lieRate,lieRange
        tee     = new TerrainType(0.45f, 0.25f, 0.99f, 0.01f);
        green   = new TerrainType(0.45f, 0.25f, 0.99f, 0.02f);
        fairway = new TerrainType(0.50f, 0.25f, 0.99f, 0.02f);
        rough   = new TerrainType(0.60f, 0.20f, 0.80f, 0.16f);
        bunker  = new TerrainType(0.75f, 0.10f, 0.70f, 0.20f);
        water   = new TerrainType(0.99f, 0.00f, 0.20f, 0.10f);

        ResetSwapMap();

        // Initialize terrain map
        terrainMap = new Dictionary <MaterialType, TerrainType>();
        terrainMap.Add(MaterialType.GREEN, green);
        terrainMap.Add(MaterialType.FAIRWAY, fairway);
        terrainMap.Add(MaterialType.ROUGH, rough);
        terrainMap.Add(MaterialType.BUNKER, bunker);
        terrainMap.Add(MaterialType.WATER, water);
    }
Beispiel #37
0
 /// <summary>
 /// Tries to clean the current node and all its child nodes.
 /// </summary>
 private void clean()
 {
     if (!isLeaf && children[0].isLeaf)
     {
         var firstType = children[0].type;
         for (int i = 1; i < 4; i++)
         {
             if (!children[i].isLeaf)
             {
                 return;
             }
             if (firstType != children[i].type)
             {
                 return;
             }
         }
         type     = children[0].type;
         children = null;
     }
 }
        private int CalcTerrainDefBonus(TerrainType terrain)
        {
            switch (terrain)
            {
            case TerrainType.forest:
            case TerrainType.mountain:
                return(1);

            case TerrainType.fort:
                return(2);

            case TerrainType.bridge:
            case TerrainType.plains:
            case TerrainType.impassible:
            case TerrainType.unknown:
            case TerrainType.river:
            default:
                return(0);
            }
        }
Beispiel #39
0
        public void AddRoads(List <PopulationCentre> popCentres, List <RoadType> roadTypes)
        {
            var links = getPopCenterConnections(popCentres);
            var types = roadTypes.OrderByDescending(x => x.weightRequirement);

            foreach (var link in links)
            {
                if (link.weight < 2)
                {
                    if ((link.node1.position - link.node2.position).Length > 200)
                    {
                        continue;
                    }
                }
                TerrainType roadType = types.First(x => x.weightRequirement < link.weight);
                var         path     = solvePath(link.node1, link.node2);
                roadNetwork.Add(path, roadType);
                //yield return new List<RoadSegment>(roadNetwork.roadSegments);
            }
        }
Beispiel #40
0
        public void AddCells_ShouldThrow_WhenAddingCellWithAnUnknownType()
        {
            var graph = GraphFactory.CreateRectangularGraph(3, 3, MovementTypesFixture.GetMovementTypes(),
                                                            MovementTypesFixture.Ground);
            var unexpectedTerrainType = new TerrainType(10, "Some Unexpected Terrain");

            Assert.That(() =>
            {
                graph.AddCells(new List <CellState>
                {
                    new CellState(
                        false,
                        new Coordinate2D(),
                        unexpectedTerrainType
                        )
                });
            },
                        Throws.ArgumentException.With.Message.EqualTo(
                            "One of the cells in graph has an unknown terrain type: 'Some Unexpected Terrain'"));
        }
Beispiel #41
0
        public bool IsActiveState(TerrainType type, ref IState successorState)
        {
            switch (type)
            {
            case TerrainType.Standard:
                throw new Exception("Illegal Terrain");

            case TerrainType.Convex:
                successorState = new PrimaryState();
                return(true);

            case TerrainType.Wall:
                return(true);

            case TerrainType.Concave:
                successorState = new SecondaryState();
                return(true);
            }
            return(false);
        }
Beispiel #42
0
    public static string name(this TerrainType t)
    {
        switch (t)
        {
        case TerrainType.Space:
            return("Space");

        case TerrainType.Ground:
            return("Ground");

        case TerrainType.Water:
            return("Water");

        case TerrainType.Star:
            return("Star");

        default:
            throw new System.ArgumentException($"Invalid TerrainType {t}");
        }
    }
    Vector2 CalculateMovementVector(float xInput, TerrainType currentTerrain, MediumType currentMedium)
    {
        UpdateMovementAugmentations(currentTerrain, currentMedium);

        float finalXMovement = 0;

        // Player is trying to move
        if (xInput != 0)
        {
            finalXMovement = AccelerateMovement(xInput);
        }
        // Player has released controls
        else
        {
            finalXMovement = DeccelerateMovement(xInput);
        }


        return(new Vector2(finalXMovement, 0));
    }
Beispiel #44
0
        public GameObject Get(TerrainType type)
        {
            GameObject prototype;

            if (type == TerrainType.Swamp)
            {
                prototype = swampPrototype;
            }
            else if (type == TerrainType.Wall)
            {
                prototype = wallPrototype;
            }
            else
            {
                throw new Exception("invalid terrain type: " + type);
            }
            var go = Instantiate(prototype);

            return(go);
        }
Beispiel #45
0
        public void UpdateTerrain(TerrainType light, TerrainType dark, short[] heights, byte[] grass)
        {
            //DECEMBER TEMP: snow replace
            //TODO: tie to tuning, or serverside weather system.
            LightType = light;
            DarkType  = dark;

            //special tuning from server
            var forceSnow = DynamicTuning.Global?.GetTuning("city", 0, 0);

            if (forceSnow != null)
            {
                ForceSnow(forceSnow.Value);
            }

            GrassState   = grass;
            GroundHeight = heights;
            UpdateLotType();
            TerrainDirty = true;
        }
Beispiel #46
0
        public void Reset(Wmap map = null, int x = 0, int y = 0)
        {
            TileId   = _originalDesc.TileId;
            TileDesc = _originalDesc.TileDesc;

            ObjType = _originalDesc.ObjType;
            ObjDesc = _originalDesc.ObjDesc;
            ObjCfg  = _originalDesc.ObjCfg;

            Terrain   = _originalDesc.Terrain;
            Region    = _originalDesc.Region;
            Elevation = _originalDesc.Elevation;

            if (map != null)
            {
                InitConnection(map, x, y);
            }

            UpdateCount++;
        }
Beispiel #47
0
        public void SetTerrain(int y, int x, int y1, int x1, TerrainType terrainType)
        {
            if (x < 0)
            {
                x = 0;
            }

            if (y < 0)
            {
                y = 0;
            }

            for (int i = x; i < x1 && i < _world.Width; i++)
            {
                for (int j = y; j < y1 && j < _world.Length; j++)
                {
                    _world.Terrain[i, j] = terrainType;
                }
            }
        }
Beispiel #48
0
        private TerrainType[] SenseAdjacent(IRover rover)
        {
            TerrainType[] terrain = new TerrainType[Direction.DirectionCount];

            for (Int32 i = 0; i < terrain.Length; i++)
            {
                Direction   direction = (Direction)i;
                TerrainType tile      = rover.SenseSquare(direction);

                // For simplicity, we'll just ensure dead ends are always considered to be impassable.
                if (IsDeadEnd(rover, direction))
                {
                    tile = TerrainType.Impassable;
                }

                terrain[i] = tile;
            }

            return(terrain);
        }
Beispiel #49
0
    public void Generate(int a_mapWidth, int a_mapHeight, int a_seed, float a_scale, int a_octaves, float a_persistance, float a_lacunarity, Vector2 a_offset, float a_meshHeightMultiplier, GameObject a_mesh)
    {
        float[,] noiseMap = Noise.GenerateNoiseMap(a_mapWidth, a_mapHeight, seed, noiseScale, octaves, persistance, lacunarity, offset);

        MapDisplay display = a_mesh.GetComponent <MapDisplay>();

        noiseMap = Noise.GenerateNoiseMap(a_mapWidth, a_mapHeight, seed, a_scale, a_octaves, a_persistance, a_lacunarity, a_offset);

        Color[] colourMap = new Color[a_mapWidth * a_mapHeight];

        regions    = new TerrainType[5];
        regions[0] = new TerrainType("Water", 0.2f, new Color(0.2f, 0.2f, 1.0f));
        regions[1] = new TerrainType("Sand", 0.3f, new Color(0.6f, 0.6f, 0.4f));
        regions[2] = new TerrainType("Grass", 0.5f, new Color(0.2f, 0.5f, 0.2f));
        regions[3] = new TerrainType("Rock", 0.85f, new Color(0.3f, 0.15f, 0.1f));
        regions[4] = new TerrainType("Snpw", 1.0f, new Color(1.0f, 1.0f, 1.0f));

        for (int y = 0; y < a_mapHeight; y++)
        {
            for (int x = 0; x < a_mapWidth; x++)
            {
                float currentHeight = noiseMap[x, y];
                for (int i = 0; i < regions.Length; i++)
                {
                    if (currentHeight <= regions [i].height)
                    {
                        colourMap[y * a_mapWidth + x] = regions[i].colour;
                        break;
                    }
                }
            }
        }

        Keyframe[]     keyframes = { new Keyframe(0.0f, 0.0f), new Keyframe(0.4f, 0.0f), new Keyframe(1.0f, 1.0f) };
        AnimationCurve ac        = new AnimationCurve(keyframes);

        Texture2D tex      = TextureGenerator.TextureFromColourMap(colourMap, a_mapWidth, a_mapHeight);
        MeshData  meshData = MeshGenerator.GenerateTerrainMesh(noiseMap, a_meshHeightMultiplier, ac, levelOfDetail);

        display.DrawMesh(meshData, tex);
    }
Beispiel #50
0
 public bool ContainTerrainType(Coordinates coordinates, TerrainType terrainType)
 {
     if ((uint)terrainType < 256)
     {
         // 1.地表地形的类型,只设置低8位
         if (mMapDatas[coordinates.x, coordinates.y] == ((uint)terrainType & TERRAINTYPE_MASK))
         {
             return(true);
         }
         ;
     }
     else
     {
         // 2.复合类型,只设置高24位
         if ((mMapDatas[coordinates.x, coordinates.y] & (uint)terrainType) != 0)
         {
             return(true);
         }
     }
     return(false);
 }
        public void UpdateTerrain(TerrainType light, TerrainType dark, short[] heights, byte[] grass)
        {
            if (DateTime.UtcNow.Month == 12 || DateTime.UtcNow.Month == 1)
            {
                if (light == TerrainType.GRASS || light == TerrainType.SAND)
                {
                    light = TerrainType.SNOW;
                }
                if (dark == TerrainType.SAND)
                {
                    dark = TerrainType.SNOW;
                }
            }

            LightType    = light;
            DarkType     = dark;
            GrassState   = grass;
            GroundHeight = heights;
            UpdateLotType();
            TerrainDirty = true;
        }
        protected override void Parse(Stream s)
        {
            base.Parse(s);
            this.brushTexture = new TGIBlock(requestedApiVersion, OnResourceChanged, s);

            if (version >= 4)
            {
                BinaryReader r = new BinaryReader(s);
                this.terrain  = (TerrainType)r.ReadUInt32();
                this.category = (CategoryType)r.ReadUInt32();
            }

            if (checking)
            {
                if (this.GetType().Equals(typeof(TerrainPaintBrushCatalogResource)) && s.Position != s.Length)
                {
                    throw new InvalidDataException(String.Format("Data stream length 0x{0:X8} is {1:X8} bytes longer than expected at {2:X8}",
                                                                 s.Length, s.Length - s.Position, s.Position));
                }
            }
        }
Beispiel #53
0
        public void ChangeTerrainType(TerrainType terrainType, Tools.Accessing.NoiseParameters noiseParameters)
        {
            BlockedByError       = false;
            this.terrainType     = terrainType;
            this.seed            = seed;
            this.noiseParameters = noiseParameters;

            fnoise = new FastNoise(seed);

            //Debugging
            if (terrainType == TerrainType.CustomCayonNoise)
            {
                BlockedByError = true;
                error          = new TerrainNoiseError("The TerrainNoise cannot return any value, the noise requires cayonParameters.", TerrainNoiseError.ErrorTypes.Error);
            }
            if (noiseParameters.octaves == 0)
            {
                BlockedByError = true;
                error          = new TerrainNoiseError("The TerrainNoise cannot return any value, the noiseParameters has no octaves.", TerrainNoiseError.ErrorTypes.Error);
            }
        }
Beispiel #54
0
        public HexField(TerrainType terrain, ContentManager content, int x, int y, int width, int height,
                        IList <NodeObject> nodeObject, IList <LineObject> lineObject)
        {
            this.Terrain         = terrain;
            this.Resource        = DataGenerator.GenerateHexResource(this.Terrain);
            this.ProduceAtNumber = (uint)DataGenerator.GenerateHexProducingNumber(this.Terrain);
            this.IsRobbed        = false;
            this.TradeInAct      = false;

            this.NodeObjects = nodeObject;
            this.LineObjects = lineObject;

            //Drawable
            this.Texture   = content.Load <Texture2D>(DataGenerator.GenerateHexTextureName(this.Terrain));
            this.font      = content.Load <SpriteFont>("Arial");
            this.Rectangle = new Rectangle(x, y, width, height);
            this.ScreenX   = x;
            this.ScreenY   = y;
            this.DX        = (uint)width;
            this.DY        = (uint)height;
        }
Beispiel #55
0
    //todo: generation
    private static void ComputeWater(Config_Map config, ref TerrainType[,] types)
    {
        for (int x = 0; x < types.GetLength(0); x++)
        {
            for (int y = 0; y < types.GetLength(1); y++)
            {
                float px   = x / (float)config.GridSize;
                float py   = y / (float)config.GridSize;
                float prob = Mathf.PerlinNoise(px, py) * config.AmountWater;

                float r = Random.Range(0f, 1f);

                if (r < prob)
                {
                    types[x, y] = new TerrainType(config.WaterTerrain);
                }
                //  else tileTypes[x, y] = TileType.blank;
                // Debug.Log( $"X: {x}, Y: {y} : Mountain Prob is {prob}" );
            }
        }
    }
Beispiel #56
0
        private static float GetPercent(TerrainType pType)
        {
            switch (pType)
            {
            case TerrainType.Water:
                return(.01f);

            case TerrainType.Shrubland:
                return(.02f);

            case TerrainType.Grassland:
            case TerrainType.TemperateDeciduous:
                return(.01f);

            case TerrainType.Desert:
                return(.001f);

            default:
                return(-1f);    //Will not create
            }
        }
Beispiel #57
0
    public TerrainTool()
    {
        currMode     = TerrainToolMode.Off;
        currTerrain  = TerrainType.SmlBox;
        currTerrInt  = (int)currTerrain;
        terrainArray = new string[] { "SmlBox", "MidBox", "BigBox", "RubbleSmall", "RubbleLarge", "Fence", "Pitchfork", "BarnTest", "BarnRoofless" };

        buttonGet   = GameObject.Find("Place Terr Button");
        placeButton = buttonGet.GetComponent <Button>();
        placeButton.onClick.AddListener(PlaceButtonTask);

        buttonGet = GameObject.Find("Rotate Terr Button");
        rotButton = buttonGet.GetComponent <Button>();
        rotButton.onClick.AddListener(RotateButtonTask);

        buttonGet = GameObject.Find("Remove Terr Button");
        remButton = buttonGet.GetComponent <Button>();
        remButton.onClick.AddListener(RemoveButtonTask);

        terrTypeMax = terrainArray.Length - 1;
    }
Beispiel #58
0
    public TerrainType[] SmoothRegions(TerrainType[] regions, int amount)
    {
        Array.Sort <TerrainType>(regions, (x, y) => x.height.CompareTo(y.height));
        TerrainType[] smoothedRegions = new TerrainType[regions.Length * amount - amount + 1];
        for (int i = 0; i < regions.Length - 1; i++)
        {
            TerrainType current = regions[i];
            TerrainType next    = regions[i + 1];

            for (int j = 0; j <= amount; j++)
            {
                float       percentage = j == 0 ? 0 : (float)j / (float)amount;
                TerrainType smoothed   = new TerrainType();
                smoothed.name   = i + "_Smoothed_" + j;
                smoothed.height = current.height + ((next.height - current.height) * percentage);
                smoothed.colour = Color.Lerp(current.colour, next.colour, percentage);
                smoothedRegions[i * amount + j] = smoothed;
            }
        }
        return(smoothedRegions);
    }
Beispiel #59
0
        /// <summary>
        /// Get the character to display on the console for a game map tile of
        /// a specific terrain type.
        /// </summary>
        /// <param name="terrainType">The terrain type.</param>
        /// <returns>An unicode character. Ensure proper console output.</returns>
        public static char GetChar(this TerrainType terrainType)
        {
            switch (terrainType)
            {
            case TerrainType.Grass:
                //return '"';
                return('\u201c');

            case TerrainType.Sand:
                //return 'o';
                return('\u25cb');

            case TerrainType.Water:
                //return '~';
                return('\u2248');

            default:
                //return '.';
                return('\u25cf');
            }
        }
Beispiel #60
0
    public static float CellMoveCost(Vector2Int p)
    {
        uint        t    = terrainIndexes[p.y * w + p.x];
        TerrainType type = (TerrainType)(t & 31);
        float       riv  = (t & 0x80) != 0 ? 4 : 0;

        //if (t == 0) return 10000;
        if (TerrainType.ForestLeaf <= type && type <= TerrainType.ForestSpire)
        {
            return(5 + riv);
        }
        if (TerrainType.MountainDesert <= type && type <= TerrainType.MountainVerySnow)
        {
            return(10 + riv);
        }
        if (TerrainType.Swamp == type)
        {
            return(12 + riv);
        }
        return(3 + riv);
    }