代码拉取完成,页面将自动刷新
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Media;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TankGameV._10版本;
using TankGameV._10版本.Properties;
namespace mytankgame
{
class PlayerTank : TankFather
{
private static Image[] imgs = {
Resources.p1tankU,
Resources.p1tankD,
Resources.p1tankL,
Resources.p1tankR
};
public PlayerTank(int x, int y, int speed, int life, Direction dir)
: base(x, y, imgs, speed, life, dir)
{
Born();
}
public int ZDLevel
{
get;
set;
}
public override void Born()
{
SingleObject.GetSingle().AddGameObject(new TankBorn(this.X, this.Y));
}
public void KeyDown(KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.W:
this.Dir = Direction.Up;
base.Move();
break;
case Keys.S:
this.Dir = Direction.Down;
base.Move();
break;
case Keys.A:
this.Dir = Direction.Left;
base.Move();
break;
case Keys.D:
this.Dir = Direction.Right;
base.Move();
break;
case Keys.K:
Fire();
break;
}
}
public override void Fire()
{
switch (ZDLevel)
{
case 0: SingleObject.GetSingle().AddGameObject(new PlayerZD(this, 10, 10, 1));
break;
case 1: SingleObject.GetSingle().AddGameObject(new PlayerZD(this, 20, 10, 1));
break;
case 2: SingleObject.GetSingle().AddGameObject(new PlayerZD(this, 30, 10, 1));
break;
}
}
public override void IsOver()
{
SoundPlayer sp = new SoundPlayer(Resources.hit);
sp.Play();
SingleObject.GetSingle().RemoveGameObject(this);
SingleObject.GetSingle().AddGameObject(new Boom(this.X - 25, this.Y - 25));
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。