PlantWar/Models/PlaneHero.cs

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using PlantWar.Properties;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PlantWar.Models
{
    public class PlaneHero : PlaneFather
    {
        //导入玩家飞机的图片 存储到字段中
        private static Image imgPlane = Resources.hero1;
        public PlaneHero(int x,int y,int speed,int life,Direction dir)
            : base(x, y, imgPlane, speed, life, dir) { }



        //必须要重写GameObject中抽象函数Draw,将自己绘制到屏幕上
        public override void Draw(Graphics g)
        {
            g.DrawImage(imgPlane, this.X, this.Y, this.Width / 2, this.Height / 2);
        }

        //让玩家飞机跟着鼠标走
        public void MouseMove(MouseEventArgs e)
        {
            this.X = e.X;
            this.Y = e.Y;
            //移动完成后 判断一下游戏对象是否超出了窗体
            if (this.X <= -10)
            {
                this.X = -10;
            }
            if (this.X >= 430)
            {
                this.X = 430;
            }
            if (this.Y <= 0)
            {
                this.Y = 0;
            }
            if (this.Y >= 700)
            {
                this.Y = 700;
            }
        }

        //提供一个开炮的函数
        public void Fire()
        {
            SingleObject.GetSingle().AddGameObject(new HeroZiDan(this, 10, 1));
        }

        public override void IsOver()
        {
            SingleObject.GetSingle().AddGameObject(new HeroBoom(this.X, this.Y));
        }
    }
后面还有 1 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。