Ejemplo n.º 1
0
 public static void IngameScreenBackground_5(Image a, Image b, Image c, Image f, Image a1, Image b1, Image c1, Image f1, double speed, double x, double windowWidth, bool leftCollison, bool rightCollison)
 {
     GraphicalEffects.IngameScreenBackground_1(a, a1, speed / 16, x, windowWidth, leftCollison, rightCollison);
     GraphicalEffects.IngameScreenBackground_1(b, b1, speed / 8, x, windowWidth, leftCollison, rightCollison);
     GraphicalEffects.IngameScreenBackground_1(c, c1, speed / 4, x, windowWidth, leftCollison, rightCollison);
     GraphicalEffects.IngameScreenBackground_1(f, f1, speed, x / 1.3, windowWidth, leftCollison, rightCollison);
 }
Ejemplo n.º 2
0
 private void PhysicsTimerTick(object sender, EventArgs e)
 {
     PlayerMovement.PlayerMove(Background_Canvas, PlayerOne, true);
     Collision.CollisonDetectAll(Background_Canvas, PlayerTwo, true);
     Physics.Gravity(Background_Canvas, PlayerOne);
     CameraMovement.CameraFollow(PlayerOne, Scroller, 400);
     GraphicalEffects.IngameScreenBackground_5(background1, background2, background3, background5, background11, background21, background31, background51, 1, PlayerOne.X, GamePage.ActualWidth, Collision.CollisonDetectLeft(Background_Canvas, PlayerOne, false), Collision.CollisionDetectRight(Background_Canvas, PlayerOne, false));
 }
Ejemplo n.º 3
0
        public Game(string localPlayerName, string oponentPlayerName, string gameId)
        {
            _gameId           = gameId;
            PlayerOne.Name    = localPlayerName;
            PlayerTwo.Name    = oponentPlayerName;
            DataContext       = PlayerOne;
            debug.DataContext = PlayerOne;
            InitializeComponent();
            PlayerOne.GameOver += OnGameOver;
            Background_Canvas.Children.RemoveRange(3, Background_Canvas.Children.Count);
            player2.DataContext        = PlayerTwo;
            counterOponent.DataContext = PlayerTwo;
            //debug.Show();

            //get game hub connection and register methods
            _gameHubConnection = GameHubConnection.GetInstance();
            _gameHubConnection.RegisterMethod("UpdateOponent", new Action <Object>((Object playerRequest) =>
            {
                Dispatcher.Invoke((Action)(async() =>
                {
                    var player = JsonConvert.DeserializeObject <PlayerDto>(playerRequest.ToString());
                    await UpdateOponent(player);
                }));
            }
                                                                                   ));

            _gameHubConnection.RegisterMethod("DeleteItem", new Action <Object>((Object itemRequest) =>
            {
                Dispatcher.Invoke((Action)(async() =>
                {
                    var item = JsonConvert.DeserializeObject <ItemDto>(itemRequest.ToString());
                    await DeleteItem(item);
                }));
            }
                                                                                ));

            _gameHubConnection.RegisterMethod("EndGame", new Action <GameEndDto>((GameEndDto request) =>
            {
                Dispatcher.Invoke((Action)(async() =>
                {
                    await EndGame(request);
                }));
            }
                                                                                 ));

            //building map
            //var builder = new MapBuilder(new EasyGameObjectFactory());
            var builder  = new MapBuilder(new MediumGameObjectFactory(), Background_Canvas);
            var director = new MapDirector(builder);

            director.ConstructMap();
            _items = builder.GetMap();

            //setting up command and invoker
            Models.Commands.ICommand command = new SpeedCommand(PlayerOne);
            _invoker = new Invoker();
            _invoker.SetCommand(command);

            //sound adapter
            _soundAdapter = new NullObjectSoundAdapter();
            _soundAdapter.Play();

            //animation adapter
            _playerOneAnimationAdapter  = new PlayerAnimationAdapter(Player_Canvas);
            _playerTwoAnimationAdapter  = new PlayerAnimationAdapter(player2);
            _starAnimationAdapter       = new ObjectAnimationAdapter(new StarAnimationController(Background_Canvas));
            _starShieldAnimationAdapter = new ObjectAnimationAdapter(new StarShieldAnimationController(Background_Canvas));

            //prototype
            //TestingDeepAndShallowCopies();

            //Interpreter
            _expressionParser = new ExpressionParser();

            //Memento
            _careTaker = new CareTaker();

            GraphicalEffects.EndTransiton(Background_Canvas, GamePage);

            PhysicsTimer          = new DispatcherTimer();
            PhysicsTimer.Tick    += PhysicsTimerTick;
            PhysicsTimer.Interval = new TimeSpan(0, 0, 0, 0, 10);
            PhysicsTimer.Start();
            //task1 = new Task(PhysicsTimer.Start);

            AnimationTimer          = new DispatcherTimer();
            AnimationTimer.Tick    += AnimationTimerTick;
            AnimationTimer.Interval = new TimeSpan(0, 0, 0, 0, 50);
            AnimationTimer.Start();
            //task2 = new Task(AnimationTimer.Start);

            StarTimer          = new DispatcherTimer();
            StarTimer.Tick    += StarTimerTick;
            StarTimer.Interval = new TimeSpan(0, 0, 0, 0, 50);
            StarTimer.Start();
            //task3 = new Task(CoinTimer.Start);

            JumpingTimer          = new DispatcherTimer();
            JumpingTimer.Tick    += JumpingTimerTick;
            JumpingTimer.Interval = new TimeSpan(0, 0, 0, 0, 400);
            JumpingTimer.Start();
            //task4 = new Task(JumpingTimer.Start);

            NetworkTimer          = new DispatcherTimer();
            NetworkTimer.Tick    += NetworktTimerTick;
            NetworkTimer.Interval = new TimeSpan(0, 0, 0, 0, 20);
            NetworkTimer.Start();
            //task5 = new Task(NetworktTimer.Start);

            //task1.Start();
            //task2.Start();
            //task3.Start();
            //task4.Start();
            //task5.Start();
        }