Ejemplo n.º 1
0
        public SettingsArena(Golf game, BaseArena previousArena) : base(game, previousArena)
        {
            var effectVolume = new ScaleMenuItem(game,
                                                 Fonts.GameFont.MeasureString(new Vector2(10, 100), Strings.EffectVolume + MaxPercent), () => Game.Sounds.EffectVolume,
                                                 p => { Game.Sounds.SetEffectVolume(p); }, Strings.EffectVolume);
            var musicVolume = new ScaleMenuItem(game,
                                                Fonts.GameFont.MeasureString(new Vector2(10, effectVolume.Bounds.Y + effectVolume.Bounds.Height), Strings.MusicVolume + MaxPercent), () => Game.Sounds.MusicVolume,
                                                p => { Game.Sounds.SetMusicVolume(p); }, Strings.MusicVolume);

            var tileSets = new TileSetMenuItem(game,
                                               Fonts.GameFont.MeasureString(new Vector2(10, musicVolume.Bounds.Y + musicVolume.Bounds.Height), Strings.RoadBlock), () => Array.IndexOf(Game.TileSets, Game.TileSet),
                                               p => { Game.TileSet = Game.TileSets[p]; }, Strings.TileSet, new List <int> {
                0, 1, 2, 3
            });

            var backItem = new MenuItem(game,
                                        Fonts.GameFont.MeasureString(new Vector2(10, tileSets.Bounds.Y + tileSets.Bounds.Height), Strings.Back),
                                        Strings.Back);

            _menu = new Menu(Game, HandleMenuSelect,
                             effectVolume,
                             musicVolume,
                             tileSets,
                             backItem
                             );
        }
Ejemplo n.º 2
0
        //the game
        void Play(int maxGuesses)
        {
            Golf   golf     = new Golf();
            double distance = GetRangeDistance();

            for (int guess = 1; guess <= maxGuesses; guess++)     //use a for loop instead of while as we want to iterate a given number of times
            {
                double userVelocity = GetVelocity();
                double userAngle    = GetAngle();
                //since we're using different variables for targetDistance and distance I assume
                //that each shot's being taken from the tee; i.e. the player doesn't move to
                //where the ball lands.
                //Also I assume all shots go in a straight line between the tee and the hole
                //and that angle is just up/down; not left/right, as otherwise the calc for
                //target distance is off.
                double shotDistance   = golf.Fire(userAngle, userVelocity);   //store this in a variable so we can reuse the result without recalculating
                double targetDistance = distance - shotDistance;
                if (CheckWinCondition(targetDistance))
                {
                    ReportHit();
                    break;     //exits the for loop early
                }
                else
                {
                    ReportMiss(targetDistance, shotDistance);
                }
            }
        }
Ejemplo n.º 3
0
 public BaseArena(Golf game, BaseArena previousArena)
 {
     Game          = game;
     Fade          = new Fader(true, true);
     PreviousArena = previousArena;
     Game.KeyboardInput.IsOskVisable = false;
 }
Ejemplo n.º 4
0
 public static void LoadContent(Golf game, ContentManager content)
 {
     Game     = game;
     Title    = new Sprite(Game, 1, new TimeSpan(0, 0, 0, 0, 100), AnimationState.Pause, Textures.Title);
     TitleAni = new Sprite(Game, 4, new TimeSpan(0, 0, 0, 0, 500), AnimationState.LoopRewind, Textures.TitleAni, 0, 2);
     Splash   = new Sprite(Game, 10, new TimeSpan(0, 0, 0, 0, 100), AnimationState.Pause, Textures.Splash, 0, 2);
 }
Ejemplo n.º 5
0
        public PlayArena(Golf game, BaseArena previousArena, SaveState lastState) : base(game, previousArena)
        {
            Game.KeyboardInput.IsOskVisable = false;
            Maps    = new List <IMap>(lastState.Maps);
            Players = new List <Player>();

            foreach (var p in lastState.Players)
            {
                Players.Add(new Player(game, p));
            }
            Initialise();
            Game.UnifiedInput.TapListeners.Add(OnTap);

            //    foreach (var p in Players)
            //    {
            //        p.State = Graphics.PlayerState.Finished;
            //    }
            //Players[lastState.CurrentPlayer].State = Graphics.PlayerState.Ready;
            CurrentMap.CurrentPlayer = lastState.CurrentPlayer;
            for (int index = 0; index < CurrentMap.Players.Count; index++)
            {
                var p = CurrentMap.Players[index];
                p.Par                = lastState.Players[index].Par;
                p.Total              = lastState.Players[index].Total;
                p.Layer              = lastState.Players[index].Layer;
                p.CurrentTile        = lastState.Players[index].CurrentTile;
                p.State              = lastState.Players[index].State;
                p.LastTile           = lastState.Players[index].LastTile;
                p.Node.WorldPosition = lastState.Players[index].Position;
            }
            Players[lastState.CurrentPlayer].State = Graphics.PlayerState.Ready;
        }
Ejemplo n.º 6
0
        public void NextPlayer_CreatePlayers_FurthestAwayNotDoneWillPlay()
        {
            //Arrange
            Indexer.ResetPlayersId();
            string sorePlayer;
            string expectedPlayerName = "Harry";
            Golf   myGolf             = new Golf();
            Player myPlayer           = new Player(Indexer.NextPlayerId(), "Harry");

            myPlayer.LengthToGo = 100;
            myGolf.AddPlayer(myPlayer);
            myPlayer            = new Player(Indexer.NextPlayerId(), "Barry");
            myPlayer.Done       = true;
            myPlayer.LengthToGo = 200;
            myGolf.AddPlayer(myPlayer);
            myPlayer            = new Player(Indexer.NextPlayerId(), "Jerry");
            myPlayer.LengthToGo = 50;
            myGolf.AddPlayer(myPlayer);

            //Act
            sorePlayer = myGolf.NextPlayer().Name;

            //Assert
            Assert.Equal(expectedPlayerName, sorePlayer);
        }
Ejemplo n.º 7
0
        public EventGolfModel(EventGolf golf)
        {
            EventGolf           = golf;
            EventBookedProducts = new ObservableCollection <EventBookedProductModel>();

            _golfHole = EventGolf.GolfHole;
            _golf     = EventGolf.Golf;
        }
Ejemplo n.º 8
0
 public NameMenuItem(Golf game, Rectangle bounds, Getter <string> get, Setter <string> set, Getter <int> getColor, string name)
     : base(game, bounds, name)
 {
     _getColor   = getColor;
     _get        = get;
     _set        = set;
     SpriteBatch = new SpriteBatch(game.GraphicsDevice);
     game.KeyboardInput.AddKeyboardListener(KeyboardEvent);
 }
Ejemplo n.º 9
0
        public PlayerState(Golf game, PlayerSelectArena startState, List <Player> players, List <int> colors)
            : base(game, startState)
        {
            //game.KeyboardInput.IsOSKVisable = true;
            PlayerSelectArena = startState;
            _players          = players;
            _colors           = colors;
            if (_players.Count == 0)
            {
                AddNewPlayer();
            }

            _startNextItem = new MenuItem(game,
                                          Fonts.GameFont.MeasureString(new Vector2(10, 100),
                                                                       ((players.Count == Game.GameSettings.Players)
                                     ? Strings.Start : Strings.Next)),
                                          ((players.Count == Game.GameSettings.Players)
                                     ? Strings.Start : Strings.Next));
            _nameItem = new NameMenuItem(game, Fonts.GameFont.MeasureString(
                                             new Vector2(10, 10 + _startNextItem.Bounds.Y + _startNextItem.Bounds.Height),
                                             _player.Name),
                                         () => _player.Name,
                                         p => { _player.Name = p; }, () => _player.ColorIndex, Strings.Name);
            int       max    = 0;
            int       mindex = 0;
            Rectangle m      = new Rectangle();

            for (var index = 0; index < colors.Count; index++)
            {
                var color = colors[index];
                m = Fonts.GameFont.MeasureString(
                    new Vector2(10, _nameItem.Bounds.Y + _nameItem.Bounds.Height),
                    GameColors.Colors[color].Name.ToUpperInvariant());
                if (m.Width > max)
                {
                    max    = m.Width;
                    mindex = index;
                }
            }
            _colorItem = new ColorMenuItem(game,
                                           new Rectangle(10, _nameItem.Bounds.Y + _nameItem.Bounds.Height + 10,
                                                         m.Width, m.Height), () => _player.ColorIndex,
                                           delegate(int p) { _player.ColorIndex = p; }, Strings.Color, colors);
            _backItem = new MenuItem(game,
                                     Fonts.GameFont.MeasureString(
                                         new Vector2(10, 10 + _colorItem.Bounds.Y + _colorItem.Bounds.Height),
                                         Strings.Back), Strings.Back);
            _menu = new Menu(game, HandleMenuSelect,
                             _startNextItem,
                             _nameItem,
                             _colorItem,
                             _backItem
                             );
            _invalidName = new Tween(new TimeSpan(0, 0, 0, 1), 1, 0);
            _invalidName.Finish();
        }
Ejemplo n.º 10
0
        public MenuItem(Golf game, Rectangle bounds, string name, Func <Vector2> offset = null)
        {
            Game    = game;
            _bounds = bounds;
            Name    = name;
            _offset = offset ?? (() => Vector2.Zero);

            SpriteBatch = new SpriteBatch(Game.GraphicsDevice);
            UnifiedInput.TapListeners.Add(Tap);
        }
Ejemplo n.º 11
0
 public Player(Golf game, PlayerSave saved) : this(game, saved.ColorIndex, saved.Name)
 {
     Par          = saved.Par;
     Total        = saved.Total;
     PreviousTile = saved.LastTile;
     CurrentTile  = saved.CurrentTile;
     //Layer = saved.Layer;
     // State = saved.State;
     //  Node.WorldPosition = saved.Position;
 }
Ejemplo n.º 12
0
        public void NextPlayer_Cond_Expect()
        {
            //Arrange
            Golf   myGOlfPlay = new Golf();
            Player myPlayer   = new Player(0, "Harry");


            //Act

            //Assert
        }
Ejemplo n.º 13
0
        public GameTypeItem(Golf game, Rectangle bounds, string name)
            : base(game, bounds, name)
        {
            var mx = Textures.Back.Width;
            var my = Textures.Back.Height;
            var xs = (float)Math.Min(my, Bounds.Height) / Math.Max(my, Bounds.Height);

            _bounds     = new Rectangle(bounds.X, bounds.Y, (int)(bounds.Width + ((mx * xs) * 2)), bounds.Height);
            RightRegion = new Rectangle((int)(bounds.X + bounds.Width + (mx * xs)), bounds.Y, (int)(mx * xs), bounds.Height);
            LeftRegion  = new Rectangle(bounds.X, bounds.Y, (int)(mx * xs), bounds.Height);
        }
Ejemplo n.º 14
0
 public Player(Golf game, int color, string name)
 {
     ColorIndex = color;
     Game       = game;
     Name       = name;
     GolfBall   = new Sprite(Game, 3, new TimeSpan(0, 0, 0, 0, 200), AnimationState.LoopPlay, Textures.GolfBall, 0,
                             2);
     State = PlayerState.Finished;
     Power = new Tween(new TimeSpan(0, 0, 0, 1), 0f, 4f, true);
     Game.UnifiedInput.TapListeners.Add(OnTap);
 }
Ejemplo n.º 15
0
 public Sprite(Golf game, int frames, TimeSpan rate, AnimationState anim, Texture2D map, int margin = 0, int spacing = 0)
 {
     Game      = game;
     Map       = map;
     Animation = anim;
     Rate      = rate;
     Margin    = margin;
     Spacing   = spacing;
     Frames    = frames;
     OnFinish += () => { };
 }
Ejemplo n.º 16
0
 public PlayArena(Golf game, BaseArena previousArena, List <IMap> maps, List <Player> players) : base(game, previousArena)
 {
     Game.KeyboardInput.IsOskVisable = false;
     Maps = maps ?? new List <IMap> {
         new Map01(), new Map02(), new Map03(), new Map04(), new Map05(), new Map06(), new Map07(), new Map08(), new Map09(), new Map10()
     };
     Players = players ?? new List <Player> {
         new Player(Game, 0, Strings.Player1)
     };                                                                            //, new Player(Game, Color.Red, "Jansen"), new Player(Game, Color.DarkGreen, "Aurora"), new Player(Game, Color.Purple, "Chloe") };
     Game.UnifiedInput.TapListeners.Add(OnTap);
     Initialise();
 }
Ejemplo n.º 17
0
        public void GolfInDifferentFactory_Test()
        {
            //Arrange
            var golf = new Golf(new WolfsburgFactory());

            //Act
            golf.Assemble();

            //Assert
            Assert.AreEqual(golf.Axe.GetPrice(), 6340);
            Assert.AreEqual(golf.Hood.GetPrice(), 9650);
            Assert.AreEqual(golf.Interior.GetPrice(), 14300);
        }
Ejemplo n.º 18
0
        public void GolfPartsAreValidPrice_Test()
        {
            //Arrange
            var golf = new Golf(new HannoverFactory());

            //Act
            golf.Assemble();

            //Assert
            Assert.AreEqual(golf.Axe.GetPrice(), 2420);
            Assert.AreEqual(golf.Hood.GetPrice(), 600);
            Assert.AreEqual(golf.Interior.GetPrice(), 7500);
        }
Ejemplo n.º 19
0
        public ScaleMenuItem(Golf game, Rectangle bounds, Getter <float> get, Setter <float> set, string name)
            : base(game, bounds, name)
        {
            var mx = Textures.Back.Width;
            var my = Textures.Back.Height;
            var xs = (float)Math.Min(my, Bounds.Height) / Math.Max(my, Bounds.Height);

            _bounds      = new Rectangle(bounds.X, bounds.Y, (int)(bounds.Width + ((mx * xs) * 2)), bounds.Height);
            _rightRegion = new Rectangle((int)(bounds.X + bounds.Width + (mx * xs)), bounds.Y, (int)(mx * xs), bounds.Height);
            _leftRegion  = new Rectangle(bounds.X, bounds.Y, (int)(mx * xs), bounds.Height);
            _get         = get;
            _set         = set;
        }
Ejemplo n.º 20
0
        public TileSetMenuItem(Golf game, Rectangle bounds, Getter <int> get, Setter <int> set, string name, List <int> tileSets)
            : base(game, bounds, name)
        {
            _tileSets = tileSets;
            var mx = Textures.Back.Width;
            var my = Textures.Back.Height;
            var xs = (float)Math.Min(my, Bounds.Height) / Math.Max(my, Bounds.Height);

            _bounds     = new Rectangle(bounds.X, bounds.Y, (int)(bounds.Width + ((mx * xs) * 2)), bounds.Height);
            RightRegion = new Rectangle((int)(bounds.X + bounds.Width + (mx * xs)), bounds.Y, (int)(mx * xs), bounds.Height);
            LeftRegion  = new Rectangle(bounds.X, bounds.Y, (int)(mx * xs), bounds.Height);
            _get        = get;
            _set        = set;
        }
Ejemplo n.º 21
0
        public IActionResult Swing(string angle, string velocity)
        {
            double numAngle    = 0;
            double numVelocity = 0;

            angle    = angle.Replace(".", ",");
            velocity = velocity.Replace(".", ",");

            double.TryParse(angle, out numAngle);
            double.TryParse(velocity, out numVelocity);

            ViewBag.Distance = Golf.Distance(numAngle, numVelocity);//klass golf + method

            return(View());
        }
Ejemplo n.º 22
0
        private void GolfOuting()
        {
            Golf golf = new Golf();

            golf.TypeOfEvent = "Golf";
            Console.WriteLine("How many people attended this event?");
            golf.NumberOfPeople = int.Parse(Console.ReadLine());
            Console.WriteLine("What was the total event cost?");
            golf.EventCost     = decimal.Parse(Console.ReadLine());
            golf.CostPerPerson = golf.EventCost / golf.NumberOfPeople;
            Console.WriteLine($"This event cost ${golf.CostPerPerson}");
            Console.WriteLine("When was this event?");
            golf.DateOfEvent = DateTime.Parse(Console.ReadLine());
            _outing.AddToOutingList(golf);
        }
Ejemplo n.º 23
0
        public PlayersMenuItem(Golf game, Rectangle bounds, Getter <int> get, Setter <int> set, string name)
            : base(game, bounds, name)
        {
            var mx = Textures.Back.Width;
            var my = Textures.Back.Height;
            var xs = (float)Math.Min(my, Bounds.Height) / Math.Max(my, Bounds.Height);

            _bounds      = new Rectangle(bounds.X, bounds.Y, (int)(bounds.Width + ((mx * xs) * 2)), bounds.Height);
            _rightRegion = new Rectangle((int)(bounds.X + bounds.Width + (mx * xs)), bounds.Y, (int)(mx * xs),
                                         bounds.Height);
            _leftRegion = new Rectangle(bounds.X, bounds.Y, (int)(mx * xs), bounds.Height);
            _get        = get;
            _set        = set;
            // UnifiedInput.TapListeners.Add(Tap);
        }
Ejemplo n.º 24
0
        public ActionResult <IEnumerable <string> > Get(string model)
        {
            if (model == null)
            {
                return new string[] { "wrong parameter" }
            }
            ;

            if (model.Equals("Der Golf"))
            {
                return new string[] { Golf.generateBaseInfo() }
            }
            ;

            return(new string[] { "unknown model" });
        }
Ejemplo n.º 25
0
        public void AddCourse_CreateOneInput_OnlyOneThere()
        {
            //Arrange
            Course localCourse = new Course(0, 200);
            Golf   myGolf      = new Golf();

            myGolf.AddCourse(localCourse);
            int expectedNoCourses = 1;
            int actualNoCourses;

            //Act
            actualNoCourses = myGolf.GetCourses().Length;

            //Assert
            Assert.Equal(expectedNoCourses, actualNoCourses);
        }
Ejemplo n.º 26
0
        public IActionResult Swing(string angle, string velocity)
        //public IActionResult Swing(double angle, double velocity)
        {
            double numAngle    = 0;
            double numVelocity = 0;

            angle    = angle.Replace('.', ',');
            velocity = velocity.Replace('.', ',');

            double.TryParse(angle, out numAngle);
            double.TryParse(velocity, out numVelocity);

            ViewBag.Distance = Golf.Distance(numAngle, numVelocity);

            return(View());
        }
Ejemplo n.º 27
0
        public UnifiedInput(Golf game)
        {
            Game              = game;
            TapListeners      = new List <Procedure <Vector2> >();
            MoveListeners     = new List <Procedure <Vector2> >();
            DraggingListeners = new List <Operation <Vector2> >();
            DraggedListeners  = new List <Operation <Vector2> >();

            Game.MouseInput.LeftClickListeners.Add(Tap);
            Game.MouseInput.MoveListeners.Add(Move);
            Game.MouseInput.DraggedListeners.Add(Dragged);
            Game.MouseInput.DraggingListeners.Add(Dragging);
            Game.TouchInput.TapListeners.Add(Tap);
            Game.TouchInput.MoveListeners.Add(Move);
            Game.TouchInput.DraggedListeners.Add(Dragged);
            Game.TouchInput.DraggingListeners.Add(Dragging);
        }
Ejemplo n.º 28
0
        static void Main(string[] args)
        {
            //Some comments
            IBasicFactory euFactory  = new EUFactory();
            IBasicFactory rusFactory = new RusFactory();

            Car polo = new Polo(euFactory);
            Car golf = new Golf(rusFactory);

            polo.Configure();

            Console.WriteLine("----------------------");

            golf.Configure();

            Console.ReadKey();
        }
Ejemplo n.º 29
0
        public string Update(Golf golf)
        {
            Golf newGolf = db.Golves.FirstOrDefault(h => h.Id == golf.Id);

            newGolf.Address = golf.Address;
            newGolf.Name    = golf.Name;
            newGolf.City    = golf.City;

            db.Entry(newGolf).State = System.Data.Entity.EntityState.Modified;

            if (db.SaveChanges() > 0)
            {
                return("更新成功");
            }

            return("更新失败");
        }
Ejemplo n.º 30
0
        public void TestMethod2()
        {
            var dictionary = new Dictionary <Card, IPosition>
            {
                { Card.KingOfClubs, new Hand(0) },
                { Card.AceOfSpades, new Field(Lane.First, 0) },
                { Card.KingOfDiamonds, new Field(Lane.Second, 1) },
                { Card.FiveOfClubs, new Field(Lane.Second, 0) },
            };

            var golf = new Golf(dictionary, true);

            Assert.AreEqual(0, golf.DeckCount());
            Assert.IsFalse(golf.IsWin());
            Assert.IsFalse(golf.IsLose());

            Assert.IsFalse(golf.CanMoveToHand(Card.KingOfClubs));
            Assert.IsTrue(golf.CanMoveToHand(Card.AceOfSpades));
            Assert.IsFalse(golf.CanMoveToHand(Card.KingOfDiamonds));
            Assert.IsFalse(golf.CanMoveToHand(Card.FiveOfClubs));


            golf.MoveToHand(Card.AceOfSpades);

            Assert.AreEqual(0, golf.DeckCount());
            Assert.IsFalse(golf.IsWin());
            Assert.IsFalse(golf.IsLose());

            Assert.IsFalse(golf.CanMoveToHand(Card.KingOfClubs));
            Assert.IsFalse(golf.CanMoveToHand(Card.AceOfSpades));
            Assert.IsTrue(golf.CanMoveToHand(Card.KingOfDiamonds));
            Assert.IsFalse(golf.CanMoveToHand(Card.FiveOfClubs));


            golf.MoveToHand(Card.KingOfDiamonds);

            Assert.AreEqual(0, golf.DeckCount());
            Assert.IsFalse(golf.IsWin());
            Assert.IsTrue(golf.IsLose());

            Assert.IsFalse(golf.CanMoveToHand(Card.KingOfClubs));
            Assert.IsFalse(golf.CanMoveToHand(Card.AceOfSpades));
            Assert.IsFalse(golf.CanMoveToHand(Card.KingOfDiamonds));
            Assert.IsFalse(golf.CanMoveToHand(Card.FiveOfClubs));
        }