だから私は一般的にプログラミングにかなり慣れていません。私は現在、地形生成プログラムに取り組んでいます。これを除いて、すべてが順調に進んでいます。
public static class Desert
{
public const int iChance = 15;
public static int chance = iChance;
public static int chancepoint = 0;
public const int octaves = 4;
public const int lengthMin = 60;
public const int lengthMax = 90;
public const float scaleMin = 250;
public const float scaleMax = 350;
public const float persistenceMin = 0.5f;
public const float persistenceMax = 0.9f;
public const pType ptype = pType.Lowland;
public const bTag[] tags = { bTag.desert };
}
public static class Meadow
{
public const int iChance = 45;
public static int chance = iChance;
public static int chancepoint = 0;
public const int octaves = 4;
public const int lengthMin = 45;
public const int lengthMax = 70;
public const float scaleMin = 200;
public const float scaleMax = 470;
public const float persistenceMin = 0.35f;
public const float persistenceMax = 0.70f;
public const pType ptype = pType.noAbs;
public const bTag[] tags = { bTag.lush };
}
これらは、「バイオーム」の異なるタイプごとのプロパティです。
私は現在これらのうち約7つを持っていますが、各フィールドの値を除いてすべてまったく同じです.
コードを短くする方法はありますか? 継承を調べましたが、エラーになってしまい、少し混乱しました。><
私が書かなければならなかったのは素晴らしいことです:
public static class Desert
{
iChance = 15;
chance = iChance;
chancepoint = 0;
octaves = 4;
lengthMin = 60;
lengthMax = 90;
scaleMin = 250;
scaleMax = 350;
persistenceMin = 0.5f;
persistenceMax = 0.9f;
ptype = pType.Lowland;
strongTags = { bTag.desert };
}
前もって感謝します。
ああ、質問が曖昧で申し訳ありません。プログラムの残りの部分を見たら、私のコードがいかにひどいものであるかと叫ぶことでしょう。XD
編集:「チャンス」の値を除いて、クラス内のものを二度と変更しないことを伝えるのはおそらく賢明です。