예제 #1
0
 //public void SetUnit(double pxPerUm)
 //{
 //    if(DrawForm != null)
 //        DrawForm.SetUnit(pxPerUm);
 //}
 public void SetScale(MeasureScale scale)
 {
     if (DrawForm != null)
     {
         DrawForm.SetScale(scale);
     }
 }
예제 #2
0
 static public void GameOver(int player)
 {
     f.pForm.timer.Stop();
     isGameOver = true;
     if (player == 0)//tie
     {
         DrawForm dForm = new DrawForm();
         dForm.ShowDialog();
         //Set Score
         Cons.Player1_score++;
         Cons.Player2_score++;
     }
     else  //player win
     {
         WinForm wForm = new WinForm(player);
         wForm.ShowDialog();
         if (player == 1)
         {
             Cons.Player_icon_check_IMG = Cons.Player1_icon_IMG;
             Cons.Player_icon_won_IMG   = Cons.Player1_icon_won_IMG;
             HighlightVictory();
             Cons.Player1_score++;
         }
         else
         {
             Cons.Player_icon_check_IMG = Cons.Player2_icon_IMG;
             Cons.Player_icon_won_IMG   = Cons.Player2_icon_won_IMG;
             HighlightVictory();
             Cons.Player2_score++;
         }
     }
     f.pForm.Score.Text = Cons.Player1_score.ToString() + ":" + Cons.Player2_score.ToString();
 }
예제 #3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            DrawForm DForm       = new DrawForm();
            Game     CurrentGame = new Game(DForm);

            Application.Run(DForm);
        }
예제 #4
0
 public void MouseEvent_Move(object sender, MouseEventArgs e)
 {
     if (_CurrentPlayer != null)
     {
         Point p1 = new Point(DForm.Width / 2, DForm.Height / 2);
         Point p2 = new Point(e.X, e.Y);
         CurrentPlayer.Facing = -DrawForm.GetAngleDegree(p2, p1) + 180;
     }
 }
예제 #5
0
 public Game(DrawForm DForm)
 {
     this.DForm        = DForm;
     DForm.MouseMoved += new MouseEventHandler(this.MouseEvent_Move);
     DForm.MouseUpP   += new MouseEventHandler(this.MouseEvent_Up);
     DForm.MouseDownP += new MouseEventHandler(this.MouseEvent_Down);
     DForm.KeyPressed += new DrawForm.KeyPressedDelegate(this.KeyPressed);
     DForm.LeftRotate += new DrawForm.AxisRotate(this.LeftRotate);
     this._DataPool    = new BaseDataPool();
     DForm.LevelStart += new DrawForm.LevelChosen(LevelChosen);
 }
예제 #6
0
        public System.Drawing.Graphics Drawing(bool modal = false)
        {
            System.Drawing.Graphics g = null;
            var f = new DrawForm();

            f.MaximumSize = new System.Drawing.Size(1024, 1024);

            InSTA(delegate
            {
                ConsoleHelper.AttachToConsole(f);
                System.Windows.Forms.Application.Run(f);
            });

            while ((g = f.Graphics) == null)
            {
                System.Threading.Thread.Sleep(100);
            }
            return(g);
        }
예제 #7
0
        /// <summary>
        /// Register Drawing Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DrawRegist_btn_Click(object sender, EventArgs e)
        {
            DrawForm drawform = new DrawForm();

            drawform.Show();
        }
예제 #8
0
        public void RefreshDrawing()
        {
            DForm.Data.ResetBuffers();
            DForm.Data.UpdateItem(GameDataType.Player, 0, CurrentPlayer.CurrentWeapons, CurrentPlayer.ImageIndex, (int)CurrentPlayer.GunRotation, CurrentPlayer.Facing, 3, CurrentPlayer.Location.ToPoint(), CurrentPlayer.Paint);
            List <int>    Indices      = new List <int>();
            List <int>    ArtIndices   = new List <int>();
            List <int>    ImageIndices = new List <int>();
            List <int>    Other        = new List <int>();
            List <double> Angles       = new List <double>();
            List <double> Sizes        = new List <double>();
            List <Color>  Colors       = new List <Color>();
            List <Point>  Locations    = new List <Point>();

            for (int i = 0; i < Enemies.Count; i++)
            {
                if (Enemies[i].Location != null)
                {
                    Indices.Add(i);
                    ArtIndices.Add(Enemies[i].ArtIndex);
                    ImageIndices.Add(Enemies[i].ImageIndex);
                    Other.Add(0);
                    Colors.Add(Enemies[i].Paint);
                    Sizes.Add(Enemies[i].Scale);
                    Locations.Add(Enemies[i].Location.ToPoint());
                    if (this._CurrentBoss != null && this._CurrentBoss.Auxes.Contains(Enemies[i]))
                    {
                        Angles.Add(DrawForm.GetAngleDegree((CurrentPlayer.Location).ToPoint(), this._CurrentBoss.Location.ToPoint()));
                    }
                    else
                    {
                        Angles.Add(DrawForm.GetAngleDegree((CurrentPlayer.Location).ToPoint(), Enemies[i].Location.ToPoint()));
                    }
                }
            }
            for (int i = Enemies.Count - 1; i >= 0; i--)
            {
                if (!(Enemies[i].Location != null))
                {
                    Enemies.RemoveAt(i);
                }
            }
            while (DForm.Data.Working)
            {
                ;
            }
            DForm.Data.UpdateItems(GameDataType.Enemy, Indices.ToArray(), ArtIndices.ToArray(), ImageIndices.ToArray(), Other.ToArray(), Angles.ToArray(), Sizes.ToArray(), Locations.ToArray(), Colors.ToArray());
            Indices      = new List <int>();
            ArtIndices   = new List <int>();
            ImageIndices = new List <int>();
            Angles       = new List <double>();
            Sizes        = new List <double>();
            Locations    = new List <Point>();
            Colors       = new List <Color>();
            Other        = new List <int>();
            for (int i = 0; i < Projectiles.Count; i++)
            {
                if (Projectiles[i].Location != null)
                {
                    Indices.Add(i);
                    ArtIndices.Add(Projectiles[i].ArtIndex);
                    ImageIndices.Add(Projectiles[i].ImageIndex);
                    Angles.Add(Projectiles[i].Facing);
                    Sizes.Add(Projectiles[i].Scale);
                    Other.Add(Projectiles[i].Spin);
                    Colors.Add(Projectiles[i].Paint);
                    Locations.Add(Projectiles[i].Location.ToPoint());
                }
            }
            for (int i = Projectiles.Count - 1; i >= 0; i--)
            {
                if (!(Projectiles[i].Location != null))
                {
                    Projectiles.RemoveAt(i);
                }
            }
            while (DForm.Data.Working)
            {
                ;
            }
            DForm.Data.UpdateItems(GameDataType.Projectile, Indices.ToArray(), ArtIndices.ToArray(), ImageIndices.ToArray(), Other.ToArray(), Angles.ToArray(), Sizes.ToArray(), Locations.ToArray(), Colors.ToArray());
            Indices      = new List <int>();
            ArtIndices   = new List <int>();
            ImageIndices = new List <int>();
            Angles       = new List <double>();
            Sizes        = new List <double>();
            Locations    = new List <Point>();
            Colors       = new List <Color>();
            Other        = new List <int>();
            for (int i = 0; i < Effects.Count; i++)
            {
                if (Effects[i].Location != null)
                {
                    Indices.Add(i);
                    ArtIndices.Add(Effects[i].ArtIndex);
                    ImageIndices.Add(Effects[i].ImageIndex);
                    Angles.Add(0);
                    Sizes.Add(1);
                    Other.Add(0);
                    Colors.Add(Color.White);
                    Locations.Add(Effects[i].Location.ToPoint());
                }
            }
            for (int i = Effects.Count - 1; i >= 0; i--)
            {
                if (!(Effects[i].Location != null))
                {
                    Effects.RemoveAt(i);
                }
            }
            while (DForm.Data.Working)
            {
                ;
            }
            DForm.Data.UpdateItems(GameDataType.Effect, Indices.ToArray(), ArtIndices.ToArray(), ImageIndices.ToArray(), Other.ToArray(), Angles.ToArray(), Sizes.ToArray(), Locations.ToArray(), Colors.ToArray());
            Indices      = new List <int>();
            ArtIndices   = new List <int>();
            ImageIndices = new List <int>();
            Angles       = new List <double>();
            Sizes        = new List <double>();
            Locations    = new List <Point>();
            Colors       = new List <Color>();
            Other        = new List <int>();
            for (int i = 0; i < PowerUps.Count; i++)
            {
                if (PowerUps[i].Location != null)
                {
                    Indices.Add(i);
                    ArtIndices.Add((int)(PowerUps[i].Type));
                    ImageIndices.Add(0);
                    Angles.Add(0);
                    Sizes.Add(1);
                    Other.Add(0);
                    Colors.Add(Color.White);
                    Locations.Add(PowerUps[i].Location.ToPoint());
                }
            }
            for (int i = PowerUps.Count - 1; i >= 0; i--)
            {
                if (!(PowerUps[i].Location != null))
                {
                    PowerUps.RemoveAt(i);
                }
            }
            while (DForm.Data.Working)
            {
                ;
            }
            DForm.Data.UpdateItems(GameDataType.PowerUp, Indices.ToArray(), ArtIndices.ToArray(), ImageIndices.ToArray(), Other.ToArray(), Angles.ToArray(), Sizes.ToArray(), Locations.ToArray(), Colors.ToArray());
            DForm.Data.SwapBuffers();
            DForm.DrawDataReady = true;
        }
예제 #9
0
        public void RefreshGame()
        {
            if (TimeStamp % 3 == 0)
            {
                DForm.ImgSwitch_Tick();
            }
            if (TimeStamp % 100 == 0)
            {
                Spawn();
            }
            for (int i = 0; i < Projectiles.Count; i++)
            {
                Projectiles[i].Spin += 5;
            }
            CurrentPlayer.ApplyBuffs(TimeStamp);
            if (PlayerOnMove)
            {
                //Vertex UnitVector = Vertex.Norm(DrawForm.GetAngleDegree(CurrentPlayer.Location.ToPoint(), CurrentPlayer.NextLocation.ToPoint())) * CurrentPlayer.Speed;
                Vertex UnitVectorBase = new Vertex(1, 0);
                double Angle          = CurrentPlayer.Facing + 90;
                Vertex UnitVector     = UnitVectorBase.RotateZ(Angle);
                CurrentPlayer.Location += UnitVector * CurrentPlayer.ActiveSpeed;
            }
            for (int i = 0; i < Projectiles.Count; i++)
            {
                double Angle = 0;
                if (Projectiles[i].Behave.Linear)
                {
                    Angle = Projectiles[i].Facing + 90;
                }
                else
                {
                    Angle = -DrawForm.GetAngleDegree(Projectiles[i].Location.ToPoint(), CurrentPlayer.Location.ToPoint()) + 90;
                }
                Vertex UnitVectorBase = new Vertex(1, 0);
                Vertex UnitVector     = UnitVectorBase.RotateZ(Angle);
                Projectiles[i].Location += UnitVector * Projectiles[i].Speed;
                if (!Projectiles[i].Behave.Sustainable)
                {
                    Projectiles[i].Health -= 10;
                }
                if (Projectiles[i].Health == 0)
                {
                    for (int j = 0; j < Projectiles[i].Summons.Count; j++)
                    {
                        if (Projectiles[i].Summons[j].Event == SummonActivationType.OnExpire || Projectiles[i].Summons[j].Event == SummonActivationType.OnBoth)
                        {
                            if (Projectiles[i].Summons[j].Type == SummonType.Projectile)
                            {
                                Projectile P = new Projectile(Projectiles[i].Summons[j].Projectile);
                                P.Owner     = Projectiles[i].Owner;
                                P.Location += Projectiles[i].Location;
                                P.Facing   += Projectiles[i].Facing + Projectiles[i].Summons[j].Facing;
                                Projectiles.Add(P);
                            }
                            else if (Projectiles[i].Summons[j].Type == SummonType.Enemy)
                            {
                                Enemy E = new Enemy(_DataPool.Enemies[Projectiles[i].Summons[j].Enemy]);
                                E.Location += Projectiles[i].Location;
                                E.Facing    = Projectiles[i].Facing;
                                this._Enemies.Add(E);
                            }
                        }
                    }
                    Projectiles[i].Location = null;
                }
            }
            if (PlayerOnFire && TimeStamp % 5 == 0)
            {
                if (!CurrentPlayer.Disabled)
                {
                    for (int i = 0; i < CurrentPlayer.Guns.Count; i++)
                    {
                        if (!CurrentPlayer.Guns[i].Active)
                        {
                            continue;
                        }
                        this._Projectiles.AddRange(CurrentPlayer.Guns[i].Shoot(CurrentPlayer, TimeStamp));
                    }
                    CurrentPlayer.IsActiveEmpty();
                }
            }
            for (int i = 0; i < Effects.Count; i++)
            {
                Effects[i].Lifetime--;
                if (Effects[i].Lifetime == 0)
                {
                    Effects[i].Location = null;
                }
            }
            for (int i = 0; i < Enemies.Count; i++)
            {
                if (Sanctuary > 0)
                {
                    break;
                }
                if (Enemies[i].Location == null)
                {
                    continue;
                }
                Enemies[i].ApplyBuffs(TimeStamp);
                if (Vertex.Distance(Enemies[i].Location, CurrentPlayer.Location) < Enemies[i].Behave.Sight)
                {
                    if (Vertex.Distance(Enemies[i].Location, CurrentPlayer.Location) > Enemies[i].Behave.Radius)
                    {
                        Vertex UnitVectorBase = new Vertex(1, 0);
                        double Angle          = DrawForm.GetAngleDegree(Enemies[i].Location.ToPoint(), CurrentPlayer.Location.ToPoint());
                        Vertex UnitVector     = UnitVectorBase.RotateZ(Angle + 90);
                        UnitVector.Y        *= -1;
                        Enemies[i].Location -= UnitVector * Enemies[i].ActiveSpeed;
                    }
                    else if (TimeStamp % 5 == 0)
                    {
                        Enemies[i].Facing = -DrawForm.GetAngleDegree(Enemies[i].Location.ToPoint(), CurrentPlayer.Location.ToPoint());

                        for (int j = 0; j < Enemies[i].Guns.Count; j++)
                        {
                            if (!Enemies[i].Guns[j].Active)
                            {
                                continue;
                            }
                            this._Projectiles.AddRange(Enemies[i].Guns[j].Shoot(Enemies[i], TimeStamp));
                        }
                    }
                }
            }
            if (this._CurrentBoss != null)
            {
                for (int i = 0; i < this._CurrentBoss.Auxes.Count; i++)
                {
                    this._CurrentBoss.Auxes[i].Location = this._CurrentBoss.Location + this._CurrentBoss.Offsets[i].RotateZ(this._CurrentBoss.Facing);
                    this._CurrentBoss.Auxes[i].Facing   = this._CurrentBoss.Facing;
                }
            }
            isHit();
            isPlayerHit();
            if (PowerUps.Count > 0)
            {
                tookPowerUp();
            }
            if (CurrentPlayer.CurrentWeapons == 0)
            {
                DForm.RefreshData((int)(200 * CurrentPlayer.Health * 1.0 / CurrentPlayer.MaxHealth), "Basic");
            }
            else if (CurrentPlayer.CurrentWeapons == 1)
            {
                DForm.RefreshData((int)(200 * CurrentPlayer.Health * 1.0 / CurrentPlayer.MaxHealth), "Heavy - " + CurrentPlayer.CurrentAmmo());
            }
            else if (CurrentPlayer.CurrentWeapons == 2)
            {
                DForm.RefreshData((int)(200 * CurrentPlayer.Health * 1.0 / CurrentPlayer.MaxHealth), "Laser - " + CurrentPlayer.CurrentAmmo());
            }
            else if (CurrentPlayer.CurrentWeapons == 3)
            {
                DForm.RefreshData((int)(200 * CurrentPlayer.Health * 1.0 / CurrentPlayer.MaxHealth), "Plasma - " + CurrentPlayer.CurrentAmmo());
            }
            RefreshDrawing();
        }