PictureBox pic;
Label label1, label2; // 初始化怪物的控件
foreach (string key in gm.Game.CurrentLevel.Monsters.Keys)
{
UIContainer monsterContainer = new UIContainer(); pic = new PictureBox();
//背景色为透明
pic.BackColor = Color.Transparent;
pic.SizeMode = PictureBoxSizeMode.AutoSize;
//初始位置是怪物对象的初始位置
pic.Location = gm.Game.CurrentLevel.Monsters[key].OriginalLocation;
//怪物图片
pic.Image = gm.Game.CurrentLevel.Monsters[key].Image;
//右键指定
pic.ContextMenuStrip = this.cmsAttack;
//保存怪物key
pic.Tag = key;
//描绘到窗体
this.Controls.Add(pic);
//保存一个容器对象
monsterContainer.Pic = pic;
label1 = new Label();
//显示原始生命值长度
label1.Size = new Size(gm.Game.CurrentLevel.Monsters[key].OriginalBlood, 20);
label1.AutoSize = false;
label1.BackColor = Color.Red;
label1.BorderStyle = BorderStyle.FixedSingle;
//位置在PictureBox上方
label1.Location = new Point(
gm.Game.CurrentLevel.Monsters[key].OriginalLocation.X,
gm.Game.CurrentLevel.Monsters[key].OriginalLocation.Y - 25
);
this.Controls.Add(label1);
monsterContainer.LabelBlood = label1;
label2 = new Label();
//显示当前生命值
label2.Size = new Size(gm.Game.CurrentLevel.Monsters[key].CurrentBlood, 20);
label2.AutoSize = false;
label2.BackColor = Color.Yellow;
label2.BorderStyle = BorderStyle.FixedSingle;
label2.Location = new Point(
gm.Game.CurrentLevel.Monsters[key].OriginalLocation.X,
gm.Game.CurrentLevel.Monsters[key].OriginalLocation.Y - 25);
this.Controls.Add(label2);
monsterContainer.LabelHurt = label2;
//放在最顶层
label2.BringToFront(); UIMappings.Add(key, monsterContainer);
}
Label label1, label2; // 初始化怪物的控件
foreach (string key in gm.Game.CurrentLevel.Monsters.Keys)
{
UIContainer monsterContainer = new UIContainer(); pic = new PictureBox();
//背景色为透明
pic.BackColor = Color.Transparent;
pic.SizeMode = PictureBoxSizeMode.AutoSize;
//初始位置是怪物对象的初始位置
pic.Location = gm.Game.CurrentLevel.Monsters[key].OriginalLocation;
//怪物图片
pic.Image = gm.Game.CurrentLevel.Monsters[key].Image;
//右键指定
pic.ContextMenuStrip = this.cmsAttack;
//保存怪物key
pic.Tag = key;
//描绘到窗体
this.Controls.Add(pic);
//保存一个容器对象
monsterContainer.Pic = pic;
label1 = new Label();
//显示原始生命值长度
label1.Size = new Size(gm.Game.CurrentLevel.Monsters[key].OriginalBlood, 20);
label1.AutoSize = false;
label1.BackColor = Color.Red;
label1.BorderStyle = BorderStyle.FixedSingle;
//位置在PictureBox上方
label1.Location = new Point(
gm.Game.CurrentLevel.Monsters[key].OriginalLocation.X,
gm.Game.CurrentLevel.Monsters[key].OriginalLocation.Y - 25
);
this.Controls.Add(label1);
monsterContainer.LabelBlood = label1;
label2 = new Label();
//显示当前生命值
label2.Size = new Size(gm.Game.CurrentLevel.Monsters[key].CurrentBlood, 20);
label2.AutoSize = false;
label2.BackColor = Color.Yellow;
label2.BorderStyle = BorderStyle.FixedSingle;
label2.Location = new Point(
gm.Game.CurrentLevel.Monsters[key].OriginalLocation.X,
gm.Game.CurrentLevel.Monsters[key].OriginalLocation.Y - 25);
this.Controls.Add(label2);
monsterContainer.LabelHurt = label2;
//放在最顶层
label2.BringToFront(); UIMappings.Add(key, monsterContainer);
}
兄弟帮你顶了?
没劲啊