PlantWar/Models/PlaneEnemy.cs
(开头部分) 6KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using PlantWar.Properties;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
namespace PlantWar.Models
{
public class PlaneEnemy: PlaneFather
{
private static Image img1 = Resources.enemy0;//最小的飞机
private static Image img2 = Resources.enemy1;//中间的飞机
private static Image img3 = Resources.enemy2;//最大的飞机
//因为每一架飞机的大小、生命值、速度都不一样,所以我们需要声明一个标示来标记当前到底属于哪架飞机
//0--最小的飞机 1--中间的飞机 2--最大的飞机
public int EnemyType
{
get;
set;
}
public PlaneEnemy(int x,int y,int type):
base(x, y, GetImage(type), GetSpeed(type), GetLife(type), Direction.Down)
{
this.EnemyType = type;
}
//我们需要重写父类中的Draw函数 将自己绘制到Form窗体上
public override void Draw(Graphics g)
{
//随着将敌人飞机绘制出来 就让我们的敌人飞机 开始移动
this.Move();
//也需要根据不同的飞机类型 来绘制不同的飞机
switch (this.EnemyType)
{
case 0:
g.DrawImage(img1, this.X, this.Y);
break;
case 1:
g.DrawImage(img2, this.X, this.Y);
break;
case 2:
g.DrawImage(img3, this.X, this.Y);
break;
}
}
public override void IsOver()
{
if (this.Life <= 0)
{
//敌人飞机坠毁 应该将敌人飞机从游戏中移除
SingleObject.GetSingle().RemoveGameObject(this);
//播放敌人爆炸的图片
SingleObject.GetSingle().AddGameObject(new EnemyBoom(this.X, this.Y, this.EnemyType));
//敌人发生了爆炸 给玩家加分
//需要根据不同的敌人类型 添加不同的分数
SingleObject.GetSingle().Score += (this.EnemyType + 1) * 100;
后面还有 149 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。