コード例 #1
0
ファイル: 1v1.cs プロジェクト: geomastar/Projects
        public _1v1(Framework framework, bool demoMode, Framework.MapData mapData)
        {
            game_Framework = framework;

            BaseConstructor(game_Framework, demoMode, mapData);

            _1v1_Player1 = new Tank(this, "Player1", 100, 100, 245, 100);
            _1v1_Player2 = new Tank(this, "Player2", 100, 100, 945, 100);

            game_TankArray = new Tank[2] {
                _1v1_Player1, _1v1_Player2
            };

            foreach (Tank tank in game_TankArray)
            {
                tank.SetTank_IconPos(game_AimingIcon.GetAimingIcon_Centre());
            }

            _1v1_Player1HealthBar = new ProgressBar(this, 1000, 50, 20,
                                                    "Player1", true, _1v1_Player1.GetTank_Health());
            _1v1_Player2HealthBar = new ProgressBar(this, 1000, 100, 20,
                                                    "Player2", true, _1v1_Player2.GetTank_Health());

            _1v1_FuelBar = new ProgressBar(this, 730, 175, 15,
                                           "Fuel", false, game_TankArray[0].GetTank_Fuel());

            _1v1_CentreBoundary = 640;

            CompositionTarget.Rendering += UpdateEvent;

            AddToCanvas();
            //Adds the Grid to the Canvas of the Framework.
        }
コード例 #2
0
ファイル: ResultsMenu.cs プロジェクト: geomastar/Projects
        private void MainMenuButtonClickEvent(object sender, RoutedEventArgs e)
        {
            PlayClickBackwardSound();

            Framework.MapData selectedMapData = menu_Framework.GetFramework_Game().GetGame_MapData();

            if (menu_Framework.GetFramework_Game().GetType().Equals(typeof(Training)))
            {
                menu_Framework.ChangeGameMode(Framework.GameModes.Training, true, selectedMapData);
            }
            if (menu_Framework.GetFramework_Game().GetType().Equals(typeof(_1v1)))
            {
                menu_Framework.ChangeGameMode(Framework.GameModes._1v1, true, selectedMapData);
            }

            menu_Framework.ChangeMenu(Framework.Menus.MainMenu);
        }
コード例 #3
0
        public Training(Framework framework, bool demoMode, Framework.MapData mapData)
        {
            BaseConstructor(framework, demoMode, mapData);

            training_Player1 = new Tank(this, "Player1", 0, -1, 245, 100);
            training_Target  = new Tank(this, "Target", 0, -1, 945, 100);

            game_TankArray = new Tank[2] {
                training_Player1, training_Target
            };

            game_CurrentPlayer = training_Player1;
            game_Winner        = training_Player1;

            CompositionTarget.Rendering += UpdateEvent;

            AddToCanvas();
            //Adds the Grid to the Canvas of the Framework.
        }
コード例 #4
0
ファイル: 4PlayerFFA.cs プロジェクト: geomastar/Projects
        public _4PlayerFFA(Framework framework, bool demoMode, Framework.MapData mapData)
        {
            game_Framework = framework;

            BaseConstructor(game_Framework, demoMode, mapData);

            _4PlayerFFA_Player1 = new Tank(this, "Player1", 100, 100, 200, 100);
            _4PlayerFFA_Player2 = new Tank(this, "Player2", 100, 100, 450, 100);
            _4PlayerFFA_Player3 = new Tank(this, "Player3", 100, 100, 750, 100);
            _4PlayerFFA_Player4 = new Tank(this, "Player4", 100, 100, 1000, 100);

            game_TankArray = new Tank[4]
            {
                _4PlayerFFA_Player1,
                _4PlayerFFA_Player2,
                _4PlayerFFA_Player3,
                _4PlayerFFA_Player4
            };

            foreach (Tank tank in game_TankArray)
            {
                tank.SetTank_IconPos(game_AimingIcon.GetAimingIcon_Centre());
            }

            _4PlayerFFA_Player1HealthBar = new ProgressBar(this, 1000, 30, 20,
                                                           "Player1", true, _4PlayerFFA_Player1.GetTank_Health());
            _4PlayerFFA_Player2HealthBar = new ProgressBar(this, 1000, 80, 20,
                                                           "Player2", true, _4PlayerFFA_Player2.GetTank_Health());
            _4PlayerFFA_Player3HealthBar = new ProgressBar(this, 1000, 130, 20,
                                                           "Player3", true, _4PlayerFFA_Player3.GetTank_Health());
            _4PlayerFFA_Player4HealthBar = new ProgressBar(this, 1000, 180, 20,
                                                           "Player4", true, _4PlayerFFA_Player4.GetTank_Health());

            _4PlayerFFA_FuelBar = new ProgressBar(this, 730, 175, 15,
                                                  "Fuel", false, game_TankArray[0].GetTank_Fuel());

            CompositionTarget.Rendering += UpdateEvent;

            AddToCanvas();
            //Adds the Grid to the Canvas of the Framework.
        }
コード例 #5
0
ファイル: GameMenu.cs プロジェクト: geomastar/Projects
        private void PlayButtonClickEvent(object sender, RoutedEventArgs e)
        {
            if (gameMenu_MapSelector.SelectedItem != null && gameMenu_ModeSelector.SelectedItem != null)
            {
                PlayClickForwardSound();

                Framework.MapData selectedMapData = menu_Framework.GetFramework_MapDataList()[gameMenu_MapSelector.SelectedIndex];

                if (gameMenu_ModeSelector.SelectedItem == gameMenu_TrainingComboBoxItem)
                {
                    menu_Framework.ChangeGameMode(Framework.GameModes.Training, false, selectedMapData);
                }
                else if (gameMenu_ModeSelector.SelectedItem == gameMenu_1v1ComboBoxItem)
                {
                    menu_Framework.ChangeGameMode(Framework.GameModes._1v1, false, selectedMapData);
                    menu_Framework.GetFramework_Game().AssignUsernames(
                        gameMenu_Player1UsernamePrompt.inputBox.Text,
                        gameMenu_Player2UsernamePrompt.inputBox.Text,
                        "", "");
                }
                else if (gameMenu_ModeSelector.SelectedItem == gameMenu_4PlayerFFAComboBoxItem)
                {
                    menu_Framework.ChangeGameMode(Framework.GameModes._4PlayerFFA, false, selectedMapData);
                    menu_Framework.GetFramework_Game().AssignUsernames(
                        gameMenu_Player1UsernamePrompt.inputBox.Text,
                        gameMenu_Player2UsernamePrompt.inputBox.Text,
                        gameMenu_Player3UsernamePrompt.inputBox.Text,
                        gameMenu_Player4UsernamePrompt.inputBox.Text);
                }

                menu_Framework.GetFramework_Canvas().Children.Remove(menu_Canvas);
            }
            else
            {
                PlayClickBackwardSound();
            }
        }
コード例 #6
0
        protected void BaseConstructor(Framework framework, bool demoMode, Framework.MapData mapData)
        {
            game_Framework = framework;
            //Assigns the framework parameter to the variable.

            game_MediaPlayer = new MediaPlayer()
            {
                Volume = 0.1
            };
            game_TankMoveSoundUri      = new Uri(@"Resources/Tank Move sound effect.mp3", UriKind.Relative);
            game_TankFireSoundUri      = new Uri(@"Resources/Tank Fire sound effect.mp3", UriKind.Relative);
            game_ExplosionSoundUri     = new Uri(@"Resources/Explosion sound effect.mp3", UriKind.Relative);
            game_ClickForwardSoundUri  = new Uri(@"Resources/Click Forward sound effect.mp3", UriKind.Relative);
            game_ClickBackwardSoundUri = new Uri(@"Resources/Click Backward sound effect.mp3", UriKind.Relative);

            game_SkyTexture   = new BitmapImage(new Uri(@"Resources/Sky texture.png", UriKind.Relative));
            game_SteelTexture = new BitmapImage(new Uri(@"Resources/GUI texture.png", UriKind.Relative));
            //Selects the images for the two textures.

            game_MainCanvas = new Canvas()
            {
                Height     = 450,
                Width      = 1280,
                Background = new ImageBrush(game_SkyTexture)
            };
            game_GUICanvas = new Canvas()
            {
                Height     = 240,
                Width      = 1280,
                Background = new ImageBrush(game_SteelTexture)
                {
                    Viewport = new Rect(0, 0, 1d / 7.2, 1d / 1.35),
                    TileMode = TileMode.Tile
                }
            };
            //Instantiates the two Canvas objects, giving them heights
            //and widths, as well as applying their textures.

            game_Grid = new Grid()
            {
                Height = 690,
                Width  = 1280,
            };
            //Instantiates the Grid control that will encapsulate the two
            //Canvas objects.

            game_MainRow = new RowDefinition()
            {
                Height = new GridLength(450)
            };
            game_Grid.RowDefinitions.Add(game_MainRow);
            Grid.SetRow(game_MainCanvas, 0);
            game_Grid.Children.Add(game_MainCanvas);
            //Adds the game_MainCanvas to the Grid.

            game_GUIRow = new RowDefinition()
            {
                Height = new GridLength(240)
            };
            game_Grid.RowDefinitions.Add(game_GUIRow);
            Grid.SetRow(game_GUICanvas, 1);
            game_Grid.Children.Add(game_GUICanvas);
            //Adds the game_GUICanvas to the Grid.

            game_Map        = new Map(this, mapData);
            game_Projectile = new Shot(this);
            //Instantiates the game objects.

            game_MessageBox     = new MessageBox(this);
            game_AimingIcon     = new AimingIcon(this, 500, 115);
            game_FireButton     = new FireButton(this, 700, 85);
            game_WeaponSelector = new WeaponSelector(this, 700, 10);
            //Instantiates the GUI objects.

            game_LeftBoundary  = 0;
            game_RightBoundary = 1280;
            //Sets the boundaries for the Tank and Projectile objects.

            game_NewTurn             = true;
            game_Gravity             = 10;
            game_Turn                = 1;
            game_ProjectileDetonated = false;
            game_TurnDamage          = 0;
            //Sets the gravity, turn counter and NewTurn bool.

            game_Stats = new GameStats();
            game_Stats.player1Username = "******";
            game_Stats.player2Username = "******";

            game_MapData = mapData;

            game_NextMinX       = 100;
            game_NextMaxX       = 500;
            game_AngleDirection = true;
            GenerateRandomXLoc();
            if (demoMode)
            {
                ToggleDemoMode();
            }
            //Assigns the demo mode variables to their defaults and
            //activates the demo mode.

            game_Framework.GetFramework_Window().KeyDown += EscKeyPress;

            game_MessageBox.StartGameMessage(demoMode);
        }
コード例 #7
0
        protected override void UpdateEvent(object sender, EventArgs e)
        {
            int  i = game_Gravity;
            bool intersectionFound = false;

            while (i > 0 & !intersectionFound)
            {
                mapLoader_AngleMeasurer.MoveDown();

                IntersectionDetail angleMeasurerMapIntersection =
                    mapLoader_AngleMeasurer.GetGeometry().
                    FillContainsWithDetail(game_Map.GetGeometry());

                if (angleMeasurerMapIntersection == IntersectionDetail.Intersects)
                {
                    mapLoader_AngleMeasurer.MoveUp();
                    mapLoader_AngleMeasurer.MoveUp();
                    intersectionFound = true;
                    mapLoader_AngleMeasurer.angleMeasurer_Start = true;
                }

                i--;
            }

            if (game_NewTurn)
            {
                mapLoader_CurrentMapIndex++;
                if (mapLoader_CurrentMapIndex == mapLoader_MapDataList.Count)
                {
                    mapLoader_CalculatingAngles = false;
                }
                else
                {
                    game_MainCanvas.Children.Remove(game_Map.GetPath());
                    game_Map = new Map(this, mapLoader_MapDataList[mapLoader_CurrentMapIndex]);

                    mapLoader_AngleMeasurer.ResetPosition();
                    mapLoader_AngleMeasurer.angleMeasurer_AngleList = new List <double>();
                    mapLoader_AngleMeasurer.angleMeasurer_Start     = false;
                }
                game_NewTurn = false;
            }
            else
            {
                if (mapLoader_AngleMeasurer.angleMeasurer_TranslateTransform.X >= game_RightBoundary)
                {
                    string  mapName       = mapLoader_MapDataList[mapLoader_CurrentMapIndex].mapName;
                    Point[] mapPointArray = mapLoader_MapDataList[mapLoader_CurrentMapIndex].pointArray;

                    mapLoader_MapDataList[mapLoader_CurrentMapIndex] =
                        new Framework.MapData(mapName, mapPointArray, mapLoader_Step)
                    {
                        angleArray = mapLoader_AngleMeasurer.angleMeasurer_AngleList.ToArray()
                    };

                    game_NewTurn = true;
                }
                else if (mapLoader_AngleMeasurer.angleMeasurer_Start)
                {
                    mapLoader_AngleMeasurer.angleMeasurer_PrevY =
                        mapLoader_AngleMeasurer.angleMeasurer_TranslateTransform.Y;

                    for (int s = 0; s < mapLoader_Step; s++)
                    {
                        mapLoader_AngleMeasurer.MoveRight();

                        int j = game_Gravity;
                        intersectionFound = false;

                        while (j > 0 & !intersectionFound)
                        {
                            mapLoader_AngleMeasurer.MoveDown();

                            IntersectionDetail angleMeasurerMapIntersection =
                                mapLoader_AngleMeasurer.GetGeometry().
                                FillContainsWithDetail(game_Map.GetGeometry());

                            if (angleMeasurerMapIntersection == IntersectionDetail.Intersects)
                            {
                                mapLoader_AngleMeasurer.MoveUp();
                                mapLoader_AngleMeasurer.MoveUp();
                                intersectionFound = true;
                            }

                            j--;
                        }
                    }

                    mapLoader_AngleMeasurer.CalculateNextAngle();
                }
            }
        }
コード例 #8
0
        public Map(Game map_Game, Framework.MapData mapData)
        {
            game = map_Game;
            //Sets the game variable of the base class to the parameter
            //map_Game.

            map_BezierPointCollection = new PointCollection();
            bool temp = false;

            foreach (Point point in mapData.pointArray)
            {
                if (temp)
                {
                    map_BezierPointCollection.Add(point);
                }
                temp = true;
            }

            map_PolyBezierSegment = new PolyBezierSegment()
            {
                Points = map_BezierPointCollection
                         //Instantiates the PolyBezierSegment.
                         //Adds the BezierPointCollection object to the PolyBezierSegment
                         //object.
            };

            map_LinePointCollection = new PointCollection()
            {
                mapData.pointArray[mapData.pointArray.Length - 1],
                new Point(1265, 450),
                new Point(0, 450),
                mapData.pointArray[0]
                //Instantiates the PointCollection object of the line segment.
                //Defines the points for the geometry for the bottom section of
                //the map.
            };

            map_PolyLineSegment = new PolyLineSegment()
            {
                Points = map_LinePointCollection
                         //Instantiates the PolyLineSegment.
                         //Adds the LinePointCollection object to the PolyLineSegment
                         //object.
            };

            map_PathSegmentCollection = new PathSegmentCollection();
            map_PathSegmentCollection.Add(map_PolyBezierSegment);
            map_PathSegmentCollection.Add(map_PolyLineSegment);
            //Instantiates the PathSegmentCollection object and adds the two
            //PathSegment objects to it.

            map_PathFigure = new PathFigure()
            {
                StartPoint = mapData.pointArray[0], //P0
                Segments   = map_PathSegmentCollection
                                                    //Instantiates the PathFigure.
                                                    //Defines the first control point of the Bezier curve and adds
                                                    //the PathSegmentCollection to the PathFigure object.
            };

            map_PathFigureCollection = new PathFigureCollection();
            map_PathFigureCollection.Add(map_PathFigure);
            //Instantiates the PathFigureCollection object and adds the
            //PathFigure object to it.

            geometry = new PathGeometry()
            {
                Figures = map_PathFigureCollection
                          //Instantiates the PathGeometry.
                          //Adds the PathFigureCollection to the PathGeometry.
            };

            map_DirtTexture = new BitmapImage(new Uri(@"Resources/Dirt texture.png", UriKind.Relative));
            //Selects the image for the Map's texture.

            path = new Path()
            {
                Stroke = Brushes.Brown,
                Fill   = new ImageBrush(map_DirtTexture)
                {
                    Viewport = new Rect(0, 0, 1d / 12.8, 1d / 1.5),
                    TileMode = TileMode.Tile
                },
                StrokeThickness = 2,
                Data            = geometry
                                  //Instantiates the Path object that will define the Map's
                                  //geometry, stroke thickness and stroke colour.
                                  //Assigns the stroke colour as brown and thickness as 2.
                                  //Assigns the PathGeometry object instantiated earlier
                                  //to the Path's data variable.
            };

            AddToCanvas();
            //Adds the Path to the Canvas of the Game that it belongs to.
        }