コード例 #1
0
ファイル: Entity.cs プロジェクト: pauladrianfrench/RipOff
 public Entity(GameController ga)
 {
     this.parent = ga;
     this.Outline = new List<Line>();
     this.centre = new MatrixPoint(0, 0);
     this.Expired = false;
     this.parent.AddGameObject(this);
 }
コード例 #2
0
 public GameAreaBorder(GameController ga)
     : base(ga)
 {
     Outline.Add(new Line(new MatrixPoint(-500, -280), new MatrixPoint(-500, 300)));
     Outline.Add(new Line(new MatrixPoint(-500, 300), new MatrixPoint(500, 300)));
     Outline.Add(new Line(new MatrixPoint(500, 300), new MatrixPoint(500, -280)));
     Outline.Add(new Line(new MatrixPoint(500, -280), new MatrixPoint(-500, -280)));
 }
コード例 #3
0
ファイル: Box.cs プロジェクト: pauladrianfrench/RipOff
 public Box(GameController ga)
     : base(ga)
 {
     //box
     this.Outline.Add(new Line(new MatrixPoint(-10, 0), new MatrixPoint(0, 10)));
     this.Outline.Add(new Line(new MatrixPoint(0, 10), new MatrixPoint(10, 0)));
     this.Outline.Add(new Line(new MatrixPoint(10, 0), new MatrixPoint(0, -10)));
     this.Outline.Add(new Line(new MatrixPoint(0, -10), new MatrixPoint(-10, 0)));
 }
コード例 #4
0
ファイル: Missile.cs プロジェクト: pauladrianfrench/RipOff
        public Missile(GameController ga, Angle orientation, MatrixPoint centre, double range)
            : base(ga)
        {
            //body
            this.Outline.Add(new Line(new MatrixPoint(0, -2), new MatrixPoint(0, 2)));

            Rotate(orientation.Radians);
            this.Centre = centre;
            this.Move(5); // we make an initial move so we don't destroy whatever ever fired us

            this.Range = range;
            this.trace = this.Centre;

            distanceTravelled = 0;
        }
コード例 #5
0
ファイル: Explosion.cs プロジェクト: pauladrianfrench/RipOff
        public Explosion(GameController ga, int lifeSpanTicks)
            : base(ga)
        {
            // bang
            this.Outline.Add(new Line(new MatrixPoint(-5, -5), new MatrixPoint(-6, 2)));
            this.Outline.Add(new Line(new MatrixPoint(-6, 2), new MatrixPoint(-3, 7)));
            this.Outline.Add(new Line(new MatrixPoint(-3, 7), new MatrixPoint(-2, 8)));
            this.Outline.Add(new Line(new MatrixPoint(-2, 8), new MatrixPoint(4, 7)));
            this.Outline.Add(new Line(new MatrixPoint(4, 7), new MatrixPoint(6, 2)));
            this.Outline.Add(new Line(new MatrixPoint(6, 2), new MatrixPoint(7, -4)));
            this.Outline.Add(new Line(new MatrixPoint(7, -4), new MatrixPoint(4, -5)));
            this.Outline.Add(new Line(new MatrixPoint(4, -5), new MatrixPoint(-1, -6)));
            this.Outline.Add(new Line(new MatrixPoint(-1, -6), new MatrixPoint(-5, -5)));

            this.lifeSpan = lifeSpanTicks;
            this.ageTicks = 0;
            spawn = true;
        }
コード例 #6
0
ファイル: EnemyTank.cs プロジェクト: pauladrianfrench/RipOff
        public EnemyTank(GameController ga)
            : base(ga)
        {
            //body
            this.Outline.Add(new Line(new MatrixPoint(-7, -7), new MatrixPoint(0, 7)));
            this.Outline.Add(new Line(new MatrixPoint(0, 7), new MatrixPoint(7, -7)));
            this.Outline.Add(new Line(new MatrixPoint(7, -7), new MatrixPoint(0, -2)));
            this.Outline.Add(new Line(new MatrixPoint(0, -2), new MatrixPoint(-7, -7)));

            //gun tip, we'll use a zero length line to track the position of the gun tip
            this.gunTip = new Line(new MatrixPoint(0, 10), new MatrixPoint(0, 10));
            this.Outline.Add(gunTip);

            this.nextMove = 0.0;
            this.nextRotate = 0.0;

            this.Mission = ga.GetNextMission();
            tickCount = 0;

            abortTarget = false;
        }
コード例 #7
0
        public PlayerVehicle(GameController ga)
            : base(ga)
        {
            //body
            this.Outline.Add(new Line(new MatrixPoint(-5, -5), new MatrixPoint(-5, 5)));
            this.Outline.Add(new Line(new MatrixPoint(-5, 5), new MatrixPoint(5, 5)));
            this.Outline.Add(new Line(new MatrixPoint(5, 5), new MatrixPoint(5, -5)));
            this.Outline.Add(new Line(new MatrixPoint(5, -5), new MatrixPoint(-5, -5)));

            this.Outline.Add(new Line(new MatrixPoint(-5, 0), new MatrixPoint(-7, -7)));
            this.Outline.Add(new Line(new MatrixPoint(-7, -7), new MatrixPoint(-5, -5)));
            this.Outline.Add(new Line(new MatrixPoint(5, 0), new MatrixPoint(7, -7)));
            this.Outline.Add(new Line(new MatrixPoint(7, -7), new MatrixPoint(5, -5)));

            perimeter = new List<Line>();

            for (int i = 0; i < Outline.Count; i++)
            {
                perimeter.Add(Outline[i]);
            }

            //gun tip, we'll use a zero length line to track the position of the gun tip
            this.gunTip = new Line(new MatrixPoint(0, 15), new MatrixPoint(0, 15));
            this.Outline.Add(gunTip);

            //gun
            this.Outline.Add(new Line(new MatrixPoint(-1, 5), new MatrixPoint(-1, 8)));
            this.Outline.Add(new Line(new MatrixPoint(-1, 8), new MatrixPoint(1, 8)));
            this.Outline.Add(new Line(new MatrixPoint(1, 8), new MatrixPoint(1, 5)));

            this.Centre = new MatrixPoint(0, 0);

            left = false;
            right = false;
            driveForward = false;
            driveBackward = false;
            shoot = false;
        }
コード例 #8
0
ファイル: FuelCell.cs プロジェクト: pauladrianfrench/RipOff
        public FuelCell(GameController ga)
            : base(ga)
        {
            this.Outline.Add(new Line(new MatrixPoint(-3, -1), new MatrixPoint(-3, 2)));
            this.Outline.Add(new Line(new MatrixPoint(-3, 1), new MatrixPoint(0, 4)));
            this.Outline.Add(new Line(new MatrixPoint(0, 4), new MatrixPoint(3, 1)));
            this.Outline.Add(new Line(new MatrixPoint(3, 1), new MatrixPoint(3, -1)));
            this.Outline.Add(new Line(new MatrixPoint(3, -1), new MatrixPoint(0, -4)));
            this.Outline.Add(new Line(new MatrixPoint(0, -4), new MatrixPoint(-3, -1)));

            perimeter = new List<Line>();

            for (int i = 0; i < Outline.Count; i++)
            {
                perimeter.Add(Outline[i]);
            }

            this.Outline.Add(new Line(new MatrixPoint(-5, -2), new MatrixPoint(-5, 2)));
            this.Outline.Add(new Line(new MatrixPoint(-5, 2), new MatrixPoint(0, 6)));
            this.Outline.Add(new Line(new MatrixPoint(0, 6), new MatrixPoint(5, 2)));
            this.Outline.Add(new Line(new MatrixPoint(5, 2), new MatrixPoint(5, -2)));
            this.Outline.Add(new Line(new MatrixPoint(5, -2), new MatrixPoint(0, -6)));
            this.Outline.Add(new Line(new MatrixPoint(0, -6), new MatrixPoint(-5, -2)));
        }
コード例 #9
0
ファイル: Form1.cs プロジェクト: pauladrianfrench/RipOff
        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);
        }
コード例 #10
0
 public MovingEntity(GameController ga)
     : base(ga)
 {
     this.Orientation = new Angle(0.0);
     this.CentreLine = new Line(new MatrixPoint(0, 0), new MatrixPoint(0, 1));
 }
コード例 #11
0
ファイル: Tests.cs プロジェクト: pauladrianfrench/RipOff
        public void TestMovingEntities()
        {
            GameController ga = new GameController();

            MovingEntity mover = new MovingEntity(ga);

            mover.Rotate(-Math.PI / 4);
            mover.Move(10);
            Assert.AreEqual(Math.Round(Math.Sqrt(50), 7), Math.Round(mover.Centre.Xd, 7), "Test move x");
            Assert.AreEqual(Math.Round(Math.Sqrt(50), 7), Math.Round(mover.Centre.Yd, 7), "Test move y");

            Missile m = new Missile(ga, mover.Orientation, new MatrixPoint(0, 0), 1000);
            m.Move(5);

            Assert.AreEqual(Math.Round(Math.Sqrt(50), 7), Math.Round(m.Centre.Xd, 7), "Missile move x");
            Assert.AreEqual(Math.Round(Math.Sqrt(50), 7), Math.Round(m.Centre.Yd, 7), "Missile move y");

            Line trace = m.GetPerimeter()[0];
            Assert.AreEqual(Math.Round(0.0, 7), Math.Round(trace.Point1.Xd, 7), "Trace move x");
            Assert.AreEqual(Math.Round(0.0, 7), Math.Round(trace.Point1.Yd, 7), "Trace move y");
            Assert.AreEqual(Math.Round(Math.Sqrt(50), 7), Math.Round(trace.Point2.Xd, 7), "Trace move x");
            Assert.AreEqual(Math.Round(Math.Sqrt(50), 7), Math.Round(trace.Point2.Yd, 7), "Trace move y");

            m.Move(10);
            trace = m.GetPerimeter()[0];
            Assert.AreEqual(Math.Round(Math.Sqrt(50), 7), Math.Round(trace.Point1.Xd, 7), "Trace move x");
            Assert.AreEqual(Math.Round(Math.Sqrt(50), 7), Math.Round(trace.Point1.Yd, 7), "Trace move y");
            Assert.AreEqual(Math.Round(2 * Math.Sqrt(50), 7), Math.Round(trace.Point2.Xd, 7), "Trace move x");
            Assert.AreEqual(Math.Round(2 * Math.Sqrt(50), 7), Math.Round(trace.Point2.Yd, 7), "Trace move y");

            m.Move(10);
            trace = m.GetPerimeter()[0];
            Assert.AreEqual(Math.Round(2 * Math.Sqrt(50), 7), Math.Round(trace.Point1.Xd, 7), "Trace move x");
            Assert.AreEqual(Math.Round(2 * Math.Sqrt(50), 7), Math.Round(trace.Point1.Yd, 7), "Trace move y");
            Assert.AreEqual(Math.Round(3 * Math.Sqrt(50), 7), Math.Round(trace.Point2.Xd, 7), "Trace move x");
            Assert.AreEqual(Math.Round(3 * Math.Sqrt(50), 7), Math.Round(trace.Point2.Yd, 7), "Trace move y");

            PlayerVehicle veh1 = new PlayerVehicle(ga);
            Missile miss = new Missile(ga, new Angle(-3.0499999999999972), new MatrixPoint(-7.2369182872595275, 99.435069414788984), 1000);

            trace = miss.GetPerimeter()[0];
            Assert.AreEqual(Math.Round(-7.2369182872595275, 7), Math.Round(trace.Point1.Xd, 7), "Trace2 move x");
            Assert.AreEqual(Math.Round(99.435069414788984, 7), Math.Round(trace.Point1.Yd, 7), "Trace2 move y");
            Assert.AreEqual(Math.Round(-7.2369182872595275, 7), Math.Round(trace.Point2.Xd, 7), "Trace2 move x");
            Assert.AreEqual(Math.Round(99.435069414788984, 7), Math.Round(trace.Point2.Yd, 7), "Trace2 move y");
            Assert.False(miss.DetectProximity(veh1).Collision, "Collison check 1");

            miss.Move(10);
            trace = miss.GetPerimeter()[0];
            Assert.AreEqual(Math.Round(-7.2369182872595275, 7), Math.Round(trace.Point1.Xd, 7), "Trace2 move x");
            Assert.AreEqual(Math.Round(99.435069414788984, 7), Math.Round(trace.Point1.Yd, 7), "Trace2 move y");
            Assert.AreEqual(Math.Round(-6.3222718999999996, 7), Math.Round(trace.Point2.Xd, 7), "Trace2 move x");
            Assert.AreEqual(Math.Round(89.476986199999999, 7), Math.Round(trace.Point2.Yd, 7), "Trace2 move y");
            Assert.False(miss.DetectProximity(veh1).Collision, "Collison check 2");

            miss.Move(10);
            trace = miss.GetPerimeter()[0];
            Assert.AreEqual(Math.Round(-6.3222718999999996, 7), Math.Round(trace.Point1.Xd, 7), "Trace2 move x1");
            Assert.AreEqual(Math.Round(89.476986199999999, 7), Math.Round(trace.Point1.Yd, 7), "Trace2 move y1");
            Assert.AreEqual(Math.Round(-5.4076253999999997, 7), Math.Round(trace.Point2.Xd, 7), "Trace2 move x2");
            Assert.AreEqual(Math.Round(79.5189029, 7), Math.Round(trace.Point2.Yd, 7), "Trace2 move y2");
            Assert.False(miss.DetectProximity(veh1).Collision, "Collison check 3");

            miss.Move(10);
            trace = miss.GetPerimeter()[0];
            Assert.AreEqual(Math.Round(-5.4076253999999997, 7), Math.Round(trace.Point1.Xd, 7), "Trace2 move x1");
            Assert.AreEqual(Math.Round(79.5189029, 7), Math.Round(trace.Point1.Yd, 7), "Trace2 move y1");
            Assert.AreEqual(Math.Round(-4.4929790000000001, 7), Math.Round(trace.Point2.Xd, 7), "Trace2 move x2");
            Assert.AreEqual(Math.Round(69.560819699999996, 7), Math.Round(trace.Point2.Yd, 7), "Trace2 move y2");
            Assert.False(miss.DetectProximity(veh1).Collision, "Collison check 4");

            miss.Move(10);
            miss.Move(10);
            miss.Move(10);
            miss.Move(10);
            miss.Move(10);

            miss.Move(10);
            trace = miss.GetPerimeter()[0];
            Assert.AreEqual(Math.Round(0.080253099999999994, 7), Math.Round(trace.Point1.Xd, 7), "Trace2 move x1");
            Assert.AreEqual(Math.Round(19.7704035, 7), Math.Round(trace.Point1.Yd, 7), "Trace2 move y1");
            Assert.AreEqual(Math.Round(0.99489950000000005, 7), Math.Round(trace.Point2.Xd, 7), "Trace2 move x2");
            Assert.AreEqual(Math.Round(9.8123202000000003, 7), Math.Round(trace.Point2.Yd, 7), "Trace2 move y2");
            Assert.True(miss.DetectProximity(veh1).Collision, "Collison check 5");

            miss.Move(10);
            trace = miss.GetPerimeter()[0];
            Assert.AreEqual(Math.Round(0.99489950000000005, 7), Math.Round(trace.Point1.Xd, 7), "Trace2 move x1");
            Assert.AreEqual(Math.Round(9.8123202000000003, 7), Math.Round(trace.Point1.Yd, 7), "Trace2 move y1");
            Assert.AreEqual(Math.Round(1.9095458999999999, 7), Math.Round(trace.Point2.Xd, 7), "Trace2 move x2");
            Assert.AreEqual(Math.Round(-0.145763, 7), Math.Round(trace.Point2.Yd, 7), "Trace2 move y2");
            Assert.False(miss.DetectProximity(veh1).Collision, "Collison check 6");

            miss.Move(10);
            trace = miss.GetPerimeter()[0];
            Assert.AreEqual(Math.Round(1.9095458999999999, 7), Math.Round(trace.Point1.Xd, 7), "Trace2 move x1");
            Assert.AreEqual(Math.Round(-0.145763, 7), Math.Round(trace.Point1.Yd, 7), "Trace2 move y1");
            Assert.AreEqual(Math.Round(2.8241923999999998, 7), Math.Round(trace.Point2.Xd, 7), "Trace2 move x2");
            Assert.AreEqual(Math.Round(-10.103846300000001, 7), Math.Round(trace.Point2.Yd, 7), "Trace2 move y2");
            Assert.True(miss.DetectProximity(veh1).Collision, "Collison check 7");
        }