コード例 #1
0
    private StageData GenerateRandomStage(int seed)
    {
        Random.InitState(seed);
        int           stripCount     = Random.Range((this.minStrips - 1) / 2, (this.maxStrips - 1) / 2) * 2 + 1; // Should be odd?
        int           min            = Mathf.Max(this.minLongestStripLength, stripCount / 2 + 1);
        int           maxStripLength = Random.Range(min, this.maxLongestStripLength + 1);
        HoneycombData honey          = HoneycombData.Generate(stripCount, maxStripLength);

        // For each hex, give it random contents.
        foreach (StripData stripData in honey.strips)
        {
            foreach (HexData data in stripData.hexes)
            {
                this.RandomizeHex(data);
            }
        }

        // Pick a random starting location.
        // Do this last so it replaces whatever was at the hex's location.
        int     strip   = Random.Range(0, stripCount);
        int     hex     = Random.Range(0, honey.GetStripLength(strip));
        HexData hexData = honey.strips[strip].hexes[hex];

        hexData.entityType = EntityType.Player;
        hexData.entityData = HexData.PLAYER_DATA_HEAD;

        StageData stageData = new StageData();

        stageData.name             = "Random stage from seed " + seed;
        stageData.growthPerSegment = this.possibleGrowthPerSegment[Random.Range(0, this.possibleGrowthPerSegment.Length)];
        stageData.honeycomb        = honey;
        return(stageData);
    }
コード例 #2
0
    public int GetStripLength(int stripNumber)
    {
        int middleStrip = this.strips.Length / 2;

        return(HoneycombData.GetStripLength(stripNumber, this.strips.Length, this.strips[middleStrip].hexes.Length));
    }