Ejemplo n.º 1
0
        public GameSceneController()
        {
            Tag(TAG);

            switch (Network.ActiveSession[0].Value)
            {
                case 0:
                    MotionMultiplier = 0.75f;
                    break;
                case 1:
                    MotionMultiplier = 1.0f;
                    break;
                case 2:
                    MotionMultiplier = 1.4f;
                    break;
            }

            SideWallsEnabled = Network.ActiveSession[1] == 1;
            BombsAllowed = true;

            updateBombAlarm = new Alarm(AlarmMode.Loop, OnUpdateBombAlarm, 2, false);
            updateShipAlarm = new Alarm(AlarmMode.Loop, OnUpdateShipAlarm, 3, false);
            gameStartAlarm = new Alarm(AlarmMode.Single, OnGameStartAlarm, 30, true);
            gameEndAlarm = new Alarm(AlarmMode.Single, OnGameEndAlarm, 30, false);
            Add(updateBombAlarm, updateShipAlarm, gameStartAlarm, gameEndAlarm);

            Network.FirstLocalGamer.Actions = new Actions(this);

            bombSwitchBinding = new InputBinding();
            bombSwitchBinding.DefineGamePadIndex(0).DefineInputType(InputType.Pressed)
                .Add(Keys.B).Add(Buttons.LeftStick);

            quitBinding = new InputBinding();
            quitBinding.DefineGamePadIndex(0).DefineInputType(InputType.Pressed)
                .Add(Keys.Escape).Add(Buttons.Back);

            HookEvents();
        }
Ejemplo n.º 2
0
        public override void SceneBegin()
        {
            base.SceneBegin();

            quitBinding = new InputBinding();
            quitBinding.DefineGamePadIndex(0).DefineInputType(InputType.Pressed)
                .Add(Keys.Escape, Keys.Q).Add(Buttons.Back);

            foreach (Gamer player in Network.ActiveSession.Gamers)
            {
                float percent = (float)(player.PlayerIndex + 1) / (Network.ActiveSession.NumGamers + 1);

                Ships.CreateObject(player,
                    (PlayerShip ship) =>
                    {
                        ship.Position = new Vector2(Calc.Lerp(128, Engine.Instance.Screen.Width - 128, percent), Calc.Lerp(80, Engine.Instance.Screen.Height - 80, percent));
                    });
            }
        }