コード例 #1
0
ファイル: SheildShip.cs プロジェクト: jsw7524/JswShooter
        public override void Move(int x, int y)
        {
            MyShip myship = GameMgr.GameObjects.FirstOrDefault() as MyShip;

            this.X = myship.X + (int)(25 * Math.Cos(phase));
            this.Y = myship.Y + (int)(25 * Math.Sin(phase));
            phase += 0.1;
            SetGraph();
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: jsw7524/JswShooter
        public Form1(Timer t)
        {
            sb = new StringBuilder();

            blueBrush = new SolidBrush(Color.Blue);
            //gameMgr = g;
            FormTimer           = t;
            FormTimer.Tick     += new EventHandler(UpdateScreen);
            myShip              = GameMgr.GameObjects.Where(a => a.ID == 0).FirstOrDefault() as MyShip;
            this.DoubleBuffered = true;
            InitializeComponent();
        }
コード例 #3
0
ファイル: EnemyShip.cs プロジェクト: jsw7524/JswShooter
        public override void Shoot()
        {
            MyShip myship = GameMgr.GameObjects.FirstOrDefault() as MyShip;

            if (CheckCoolDown(ShipWeapon))
            {
                switch (ShipWeapon)
                {
                case "Bullet":
                    new EnemyBullet(this.X, this.Y + 20, (myship.X - this.X) > 0?1:-1, (myship.Y - this.Y > 0)?1:-1);
                    break;
                }
            }
        }
コード例 #4
0
        public override void Shoot()
        {
            MyShip myship = GameMgr.GameObjects.FirstOrDefault() as MyShip;

            if (CheckCoolDown(ShipWeapon))
            {
                switch (ShipWeapon)
                {
                case "Bullet":
                    new FriendBullet(this.X, this.Y + 20, 0, -1);
                    break;
                }
            }
        }
コード例 #5
0
ファイル: EnemyShipAce.cs プロジェクト: jsw7524/JswShooter
        public override void Shoot()
        {
            MyShip myship = GameMgr.GameObjects.FirstOrDefault() as MyShip;

            if (CheckCoolDown(ShipWeapon))
            {
                switch (ShipWeapon)
                {
                case "Bullet":
                    new EnemyBullet(this.X, this.Y + 20, Convert.ToInt32(-1 * 2 * Math.Cos(lastRad)), Convert.ToInt32(2 * Math.Sin(lastRad)));
                    break;
                }
            }
        }
コード例 #6
0
ファイル: GameMgr.cs プロジェクト: jsw7524/JswShooter
        public static void InitGame()
        {
            GamePlot         = JsonConvert.DeserializeObject <Plot>(File.ReadAllText("PLOT.txt"));
            GamePlot.Enemies = GamePlot.Enemies.OrderBy(t => t.time).ToList();

            MyShip myShip = new MyShip(300, 300);

            new SheildShip(myShip.X, myShip.Y, 0);
            new SheildShip(myShip.X, myShip.Y, 1 * 2 * Math.PI / 12);
            new SheildShip(myShip.X, myShip.Y, 2 * 2 * Math.PI / 12);
            new SheildShip(myShip.X, myShip.Y, 3 * 2 * Math.PI / 12);
            new SheildShip(myShip.X, myShip.Y, 4 * 2 * Math.PI / 12);
            new SheildShip(myShip.X, myShip.Y, 5 * 2 * Math.PI / 12);

            new SheildShip(myShip.X, myShip.Y, 6 * 2 * Math.PI / 12);
            new SheildShip(myShip.X, myShip.Y, 7 * 2 * Math.PI / 12);
            new SheildShip(myShip.X, myShip.Y, 8 * 2 * Math.PI / 12);
            new SheildShip(myShip.X, myShip.Y, 9 * 2 * Math.PI / 12);
            new SheildShip(myShip.X, myShip.Y, 10 * 2 * Math.PI / 12);
            new SheildShip(myShip.X, myShip.Y, 11 * 2 * Math.PI / 12);

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 1; j++)
                {
                    FriendShip friendShip = new FriendShip(i * 30, j * 30 + 600);
                }
            }
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 1; j++)
                {
                    FriendShip friendShip = new FriendShip(i * 30 + 600, j * 30 + 600);
                }
            }
            for (int i = 0; i < 30; i++)
            {
                for (int j = 0; j < 1; j++)
                {
                    Brick brick = new Brick(i * 5 + 200, j * 5 + 200);
                }
            }
        }
コード例 #7
0
ファイル: Form1.cs プロジェクト: jsw7524/JswShooter
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            MyShip myShip = GameMgr.GameObjects.FirstOrDefault() as MyShip;

            //label1.Hide();
            this.label1.Text = "HP:" + myShip.HP + " Frame:" + GameMgr.OffSetY;
            foreach (var gobj in GameMgr.GameObjects)
            {
                if (gobj is VisibleGameObject)
                {
                    Brush brush = Brushes.White;
                    var   g     = gobj as VisibleGameObject;

                    if (gobj is EnemyShip)
                    {
                        brush = Brushes.Red;
                        if (gobj is EnemyShipAce)
                        {
                            var ace = gobj as EnemyShipAce;

                            e.Graphics.DrawString("ACE", drawFont, brush, g.X - 5, g.BottomRightY);
                            //e.Graphics.DrawString("Left:   "+ ace.distanceLeft, drawFont, brush, g.X - 5, g.BottomRightY+20);
                            //e.Graphics.DrawString("Right: " + ace.distanceRight, drawFont, brush, g.X - 5, g.BottomRightY + 50);
                            //e.Graphics.DrawString("Up:   " + ace.distanceUp, drawFont, brush, g.X - 5, g.BottomRightY + 80);
                            //e.Graphics.DrawString("Down: " + ace.distanceDown, drawFont, brush, g.X - 5, g.BottomRightY + 110);
                            //e.Graphics.DrawString("Rad: " + ace.rad, drawFont, brush, g.X - 5, g.BottomRightY + 140);
                            //e.Graphics.DrawString("Dis: " + ace.measureDistance, drawFont, brush, g.X - 5, g.BottomRightY + 170);
                        }
                    }
                    else if (gobj is MyShip)
                    {
                        brush = Brushes.Blue;
                    }
                    else if (gobj is EnemyBullet)
                    {
                        brush = Brushes.Gold;
                    }
                    else if (gobj is Brick)
                    {
                        brush = Brushes.Black;
                    }
                    else if (gobj is FirstAidKit)
                    {
                        brush = Brushes.LimeGreen;
                    }
                    else if (gobj is PowerUpBullet)
                    {
                        brush = Brushes.Goldenrod;
                    }
                    else if (gobj is SheildShip)
                    {
                        brush = Brushes.DeepSkyBlue;
                    }
                    else if (gobj is FriendShip)
                    {
                        brush = Brushes.CornflowerBlue;
                    }
                    else if (gobj is FriendBullet)
                    {
                        brush = Brushes.CornflowerBlue;
                    }
                    else if (gobj is Laser)
                    {
                        //brush = Brushes.Aqua;

                        e.Graphics.DrawLine(penAqua, g.X, g.Y, g.X, g.BottomRightY);
                        continue;
                    }
                    e.Graphics.FillRectangle(brush, g.TopLeftX, g.TopLeftY, g.BottomRightX - g.TopLeftX, g.BottomRightY - g.TopLeftY);
                }
            }
        }