Beispiel #1
0
 public virtual void Draw(DrawParams dp)
 {
     foreach (Line l in this.Outline)
     {
         dp.Graphics.DrawLine(dp.Pen, dp.Trans.TransPoint(new Point(l.Point1.X, l.Point1.Y)), dp.Trans.TransPoint(new Point(l.Point2.X, l.Point2.Y)));
     }
 }
Beispiel #2
0
        public Form1()
        {
            InitializeComponent();
            this.DoubleBuffered = true;

            DrawParams dp = new DrawParams();
            dp.Graphics = this.CreateGraphics();
            dp.Graphics.Clear(Color.White);
            dp.Trans = new Trans { XScale = 1, YScale = 1, Origin = new Point(510, 315) };
            dp.Pen = new Pen(Color.Blue);
            dp.FillBrush = new SolidBrush(Color.GreenYellow);

            gameArea = new GameController();
            gameArea.DrawParam = dp;

            GameServer.GameController = gameArea;
            new Thread(GameServer.Server).Start();

            time = new System.Windows.Forms.Timer();
            time.Enabled = true;
            time.Interval = 30;
            time.Tick += UpdateGameArea;

            PlayerVehicle veh1 = new PlayerVehicle(gameArea);
            veh1.Centre = new MatrixPoint(350, -200);

            FuelCell fuelCell1 = new FuelCell(gameArea);
            fuelCell1.Centre = new MatrixPoint(-20, 40);

            FuelCell fuelCell2 = new FuelCell(gameArea);
            fuelCell2.Centre = new MatrixPoint(20, 40);

            FuelCell fuelCell3 = new FuelCell(gameArea);
            fuelCell3.Centre = new MatrixPoint(20, -40);

            FuelCell fuelCell4 = new FuelCell(gameArea);
            fuelCell4.Centre = new MatrixPoint(-20, -40);

            FuelCell fuelCell5 = new FuelCell(gameArea);
            fuelCell5.Centre = new MatrixPoint(-40, 20);

            FuelCell fuelCell6 = new FuelCell(gameArea);
            fuelCell6.Centre = new MatrixPoint(40, 20);

            FuelCell fuelCell7 = new FuelCell(gameArea);
            fuelCell7.Centre = new MatrixPoint(40, -20);

            FuelCell fuelCell8 = new FuelCell(gameArea);
            fuelCell8.Centre = new MatrixPoint(-40, -20);

            WayPoint p1 = new WayPoint(gameArea);
            p1.Centre = new MatrixPoint(-150, 150);

            WayPoint p2 = new WayPoint(gameArea);
            p2.Centre = new MatrixPoint(250, -150);

            WayPoint p3 = new WayPoint(gameArea);
            p3.Centre = new MatrixPoint(-250, -250);

            WayPoint p4 = new WayPoint(gameArea);
            p4.Centre = new MatrixPoint(35, 85);

            WayPoint p5 = new WayPoint(gameArea);
            p5.Centre = new MatrixPoint(100, 150);

            WayPoint p6 = new WayPoint(gameArea);
            p6.Centre = new MatrixPoint(10, 150);

            IMission miss1 = new Mission();
            miss1.Targets.Add(new MissionTarget(p1, MissionObjective.Visit));
            miss1.Targets.Add(new MissionTarget(veh1, MissionObjective.Attack));
            miss1.Targets.Add(new MissionTarget(fuelCell1, MissionObjective.Collect));
            miss1.Targets.Add(new MissionTarget(p2, MissionObjective.Visit));
            miss1.Targets.Add(new MissionTarget(p4, MissionObjective.Visit));

            IMission miss2 = new Mission();
            miss2.Targets.Add(new MissionTarget(p2, MissionObjective.Visit));
            miss2.Targets.Add(new MissionTarget(fuelCell2, MissionObjective.Collect));
            miss2.Targets.Add(new MissionTarget(p3, MissionObjective.Visit));
            miss2.Targets.Add(new MissionTarget(p4, MissionObjective.Visit));

            IMission miss3 = new Mission();
            miss3.Targets.Add(new MissionTarget(p3, MissionObjective.Visit));
            miss3.Targets.Add(new MissionTarget(veh1, MissionObjective.Attack));
            miss3.Targets.Add(new MissionTarget(fuelCell3, MissionObjective.Collect));
            miss3.Targets.Add(new MissionTarget(p4, MissionObjective.Visit));
            miss3.Targets.Add(new MissionTarget(p5, MissionObjective.Visit));

            IMission miss4 = new Mission();
            miss4.Targets.Add(new MissionTarget(p4, MissionObjective.Visit));
            miss4.Targets.Add(new MissionTarget(veh1, MissionObjective.Attack));
            miss4.Targets.Add(new MissionTarget(fuelCell4, MissionObjective.Collect));
            miss4.Targets.Add(new MissionTarget(p5, MissionObjective.Visit));
            miss4.Targets.Add(new MissionTarget(p6, MissionObjective.Visit));

            IMission miss5 = new Mission();
            miss5.Targets.Add(new MissionTarget(p4, MissionObjective.Visit));
            miss5.Targets.Add(new MissionTarget(veh1, MissionObjective.Attack));
            miss5.Targets.Add(new MissionTarget(fuelCell5, MissionObjective.Collect));
            miss5.Targets.Add(new MissionTarget(p3, MissionObjective.Visit));
            miss5.Targets.Add(new MissionTarget(p2, MissionObjective.Visit));

            IMission miss6 = new Mission();
            miss6.Targets.Add(new MissionTarget(p6, MissionObjective.Visit));
            miss6.Targets.Add(new MissionTarget(veh1, MissionObjective.Attack));
            miss6.Targets.Add(new MissionTarget(fuelCell6, MissionObjective.Collect));
            miss6.Targets.Add(new MissionTarget(p2, MissionObjective.Visit));
            miss6.Targets.Add(new MissionTarget(p1, MissionObjective.Visit));

            IMission miss7 = new Mission();
            miss7.Targets.Add(new MissionTarget(p5, MissionObjective.Visit));
            miss7.Targets.Add(new MissionTarget(fuelCell7, MissionObjective.Collect));
            miss7.Targets.Add(new MissionTarget(p3, MissionObjective.Visit));
            miss7.Targets.Add(new MissionTarget(p4, MissionObjective.Visit));

            IMission miss8 = new Mission();
            miss8.Targets.Add(new MissionTarget(p3, MissionObjective.Visit));
            miss8.Targets.Add(new MissionTarget(veh1, MissionObjective.Attack));
            miss8.Targets.Add(new MissionTarget(fuelCell8, MissionObjective.Collect));
            miss8.Targets.Add(new MissionTarget(p6, MissionObjective.Visit));
            miss8.Targets.Add(new MissionTarget(p1, MissionObjective.Visit));

            gameArea.CollectMission(miss1);
            gameArea.CollectMission(miss2);
            gameArea.CollectMission(miss3);
            gameArea.CollectMission(miss4);
            gameArea.CollectMission(miss5);
            gameArea.CollectMission(miss6);
            gameArea.CollectMission(miss7);
            gameArea.CollectMission(miss8);

            new EnemyTank(gameArea).Centre = new MatrixPoint(-300, 900);
            new EnemyTank(gameArea).Centre = new MatrixPoint(400, 400);
            new EnemyTank(gameArea).Centre = new MatrixPoint(700, 80);
            new EnemyTank(gameArea).Centre = new MatrixPoint(-900, 900);
            new EnemyTank(gameArea).Centre = new MatrixPoint(1500, 1700);
            new EnemyTank(gameArea).Centre = new MatrixPoint(-2500, 3000);
            new EnemyTank(gameArea).Centre = new MatrixPoint(300, 600);
            new EnemyTank(gameArea).Centre = new MatrixPoint(2000, 200);
        }