Mob Mob_1 = new Mob(); Mob Mob_2 = new Mob(); Mob Mob_3 = new Mob(); Mob Mob_4 = new Mob(); Mob Mob_5 = new Mob(); Mob Mob_6 = new Mob(); Mob Mob_7 = new Mob(); Mob Mob_8 = new Mob(); Mob Mob_9 = new Mob(); Mob Mob_10 = new Mob(); Battel Battel_1 = new Battel(); Battel Battel_2 = new Battel(); Battel Battel_3 = new Battel(); Battel Battel_4 = new Battel(); Battel Battel_5 = new Battel(); Battel Battel_6 = new Battel(); Battel Battel_7 = new Battel(); Battel Battel_8 = new Battel(); Battel Battel_9 = new Battel(); Battel Battel_10 = new Battel(); private void MobLoad() { Mob_1.HP = 25; Mob_1.MaxHP = 25; Mob_1.MP = 10; Mob_1.MaxMP = 10; Mob_1.Atk = 7; Mob_1.Def = 3; Mob_1.Agi = 5; } private void BattelLoad() { Battel_1.EnimyNum = 1; Battel_1.Enimy_1 = Mob_1; }
以上代码求简化
解决方案
80
Mob[] Mobs = new Mob[10];
Battel[] Battels = new Battel[10];
private void Mob_Load()
{
Mobs[0] = new Mob();
Mobs[0].HP = 25;
Mobs[0].MaxHP = 25;
Mobs[0].MP = 10;
Mobs[0].MaxMP = 10;
Mobs[0].Atk = 7;
Mobs[0].Def = 3;
Mobs[0].Agi = 5;
}
Battel[] Battels = new Battel[10];
private void Mob_Load()
{
Mobs[0] = new Mob();
Mobs[0].HP = 25;
Mobs[0].MaxHP = 25;
Mobs[0].MP = 10;
Mobs[0].MaxMP = 10;
Mobs[0].Atk = 7;
Mobs[0].Def = 3;
Mobs[0].Agi = 5;
}