コード例 #1
0
    new public bool Generate(int orbital)
    {
        if (!base.Generate(orbital))
        {
            return(false);
        }
        PlanetType[] validTypes = (orbital < 4) ? typesNoIce : types;
        var          r          = new System.Random(seed);
        double       val        = r.NextDouble();
        float        div        = 0f;

        foreach (PlanetType t in validTypes)
        {
            div += t.weight;
        }
        float total = 0f;

        type = validTypes[validTypes.Length - 1];
        foreach (PlanetType t in validTypes)
        {
            total += t.weight / div;
            if (total > val)
            {
                type = t;
                break;
            }
        }
        techlevel = r.Next(techlevels.Length);

        interactions = new List <OrbitalInteraction>();
        InfoInteraction info = new InfoInteraction(this, seed);

        info.Generate(techlevel, orbital, type);
        interactions.Add(info);
        if (techlevel > 0)
        {
            TradeInteraction trade = new TradeInteraction(this, seed);
            trade.Generate(techlevel);
            //interactions.Add(trade);
        }
        prefab   = Resources.Load("Prefabs/Planets/" + type.name) as GameObject;
        rotation = (int)(360 * r.NextDouble());
        return(true);
    }
コード例 #2
0
ファイル: InfoTab.cs プロジェクト: pterolatypus/GameDev3_2D
 public void Bind(InfoInteraction interaction)
 {
     source = interaction;
 }