コード例 #1
0
    public Hex(Vector2Int coords, LandscapeData landscapeType)
    {
        X = coords[0]; // "column"
        Z = coords[1]; // "row"

        LandscapeType = landscapeType;
    }
コード例 #2
0
 /// <summary>
 /// Goes over the board and reselects each landscape type using the influence of neighbouring hexes' landscape types.
 /// </summary>
 public void SmoothTerrainUsingInfluence()
 {
     foreach (Vector2Int coords in boardCoords)
     {
         IEnumerable <LandscapeData> neighbourScapes = Neighbors(coordsToHex[coords]).Select(x => x.LandscapeType);
         LandscapeData landscape = PickLandscapeUsingNeighbours(neighbourScapes);
         coordsToHex[coords].SetLandscapeData(landscape);
     }
 }
コード例 #3
0
ファイル: Art.cs プロジェクト: byterj/phoenix
        private Art(string mulFile, IndexFile indexFile, Stream dataStream)
        {
            this.mulFile    = mulFile;
            this.indexFile  = indexFile;
            this.dataStream = dataStream;

            tileObject       = new LandscapeData(this);
            itemsObject      = new ItemsData(this);
            animationsObject = new AnimationsData(this);
        }
コード例 #4
0
ファイル: Art.cs プロジェクト: byterj/phoenix
        /// <summary>
        /// Initializes the new empty Art object.
        /// </summary>
        public Art()
        {
            mulFile    = null;
            dataStream = Stream.Null;

            indexFile = new IndexFile();
            indexFile.Resize(65536);

            tileObject       = new LandscapeData(this);
            itemsObject      = new ItemsData(this);
            animationsObject = new AnimationsData(this);
        }
コード例 #5
0
    /// <summary>
    /// Sets the "seed" for the terrain by setting the hex tiles to have random landscape types.
    /// </summary>
    public void InitialiseTerrain()
    {
        coordsToHex = new Dictionary <Vector2Int, Hex>();
        foreach (Vector2Int coords in boardCoords)
        {
            LandscapeData landscape = LandscapeData.ChooseRandomLandscape();

            Hex newHex = new Hex(coords, landscape);
            coordsToHex[coords] = newHex;
        }

        SmoothTerrainUsingInfluence();
    }
コード例 #6
0
    /// <summary>
    /// Calculate the "support" for a landscape type based on its neighbours.
    /// </summary>
    private static float CalculateSupportFromNeighbours(LandscapeData landscape, IEnumerable <LandscapeData> neighbourLandscapes)
    {
        IEnumerable <float> influencesOnChoice = neighbourLandscapes
                                                 .Select(x => LandscapeData.SupportValue(x.typeLabel, landscape.typeLabel));
        float totalInfluence = 0;

        foreach (var influence in influencesOnChoice)
        {
            totalInfluence += influence;
        }

        return(totalInfluence);
    }
コード例 #7
0
    /// <summary>
    /// Chooses a landscape given neighbouring landscapes.
    /// </summary>
    /// <param name="neighbourLandscapes"></param>
    /// <param name="maxAttempts"></param>
    /// <returns></returns>
    private static LandscapeData PickLandscapeUsingNeighbours(IEnumerable <LandscapeData> neighbourLandscapes, int maxAttempts = 100)
    {
        LandscapeData choice         = null;
        float         support        = 0;
        bool          choiceAccepted = false;

        for (int i = 0; i < maxAttempts; i++)
        {
            choice         = LandscapeData.ChooseRandomLandscape();
            support        = CalculateSupportFromNeighbours(choice, neighbourLandscapes);
            choiceAccepted = support > UnityEngine.Random.Range(0, 61);
            if (choiceAccepted)
            {
                break;
            }
        }

        return(choice);
    }
コード例 #8
0
ファイル: Art.cs プロジェクト: greeduomacro/phoenix
        private Art(string mulFile, IndexFile indexFile, Stream dataStream)
        {
            this.mulFile = mulFile;
            this.indexFile = indexFile;
            this.dataStream = dataStream;

            tileObject = new LandscapeData(this);
            itemsObject = new ItemsData(this);
            animationsObject = new AnimationsData(this);
        }
コード例 #9
0
ファイル: Art.cs プロジェクト: greeduomacro/phoenix
        /// <summary>
        /// Initializes the new empty Art object.
        /// </summary>
        public Art()
        {
            mulFile = null;
            dataStream = Stream.Null;

            indexFile = new IndexFile();
            indexFile.Resize(65536);

            tileObject = new LandscapeData(this);
            itemsObject = new ItemsData(this);
            animationsObject = new AnimationsData(this);
        }
コード例 #10
0
 public Landscape()
 {
     initialized   = false;
     landscapeData = new LandscapeData();
 }
コード例 #11
0
 public void SetLandscapeData(LandscapeData landscapeType)
 {
     LandscapeType = landscapeType;
 }