PlantWar/Models/ZiDan.cs

(完整代码) 1KB

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace PlantWar.Models
{
    public class ZiDan : GameObject
    {
        private Image imgZiDan;//存储子弹图片
        //记录一下子弹的威力
        public int Power { get; set; }

        public ZiDan(PlaneFather pf, Image img, int speed, int power)
            : base(pf.X + pf.Width / 2 - 30, pf.Y + pf.Height / 2 - 50, img.Width, img.Height, speed, 0, pf.Dir)
        {
            this.imgZiDan = img;
            this.Power = power;
        }

        public override void Draw(Graphics g)
        {
            this.Move();
            g.DrawImage(imgZiDan, this.X, this.Y, this.Width / 2, this.Height / 2);
        }

        public override void Move()
        {
            switch (this.Dir)
            {
                case Direction.Up:
                    this.Y -= this.Speed;
                    break;
                case Direction.Down:
                    this.Y += this.Speed;
                    break;
            }
            //子弹发出后 控制一下子弹的坐标
            if (this.Y <= 0)
            {
                this.Y = -100;
                //在游戏中移除子弹对象
            }
            if (this.Y >= 780)
            {
                this.Y = 1000;
                //在游戏中移除子弹对象
            }
        }

    }
}

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

AI 解读 AI

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

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