Exemple #1
0
        protected override void Update(GameTime gameTime)
        {
            Scene.Update(gameTime.ElapsedGameTime);

            if (ownGoal != null)
            {
                TimeSpan since = DateTime.Now - from;

                if (since.TotalSeconds > timeToDisplayMoron)
                {
                    ownGoal = null;
                }
            }

            KeyboardState ks = Keyboard.GetState();

            if (ks.IsKeyUp(Keys.Z) && ksLast.IsKeyDown(Keys.Z))
            {
                // cycle player 1
                PlayerController controller = Scene.Coordinator.Select("Player")[0].Get <PlayerController>();

                controller.SelectedControlScheme += 1;

                string[] values = Enum.GetNames(typeof(ControlScheme));
                if (controller.SelectedControlScheme > (ControlScheme)Enum.Parse(typeof(ControlScheme), values[values.Length - 1]))
                {
                    controller.SelectedControlScheme = 0;
                }
            }
            if (ks.IsKeyUp(Keys.X) && ksLast.IsKeyDown(Keys.X))
            {
                // cycle player 2
                PlayerController controller = Scene.Coordinator.Select("Player")[1].Get <PlayerController>();

                controller.SelectedControlScheme += 1;

                string[] values = Enum.GetNames(typeof(ControlScheme));
                if (controller.SelectedControlScheme > (ControlScheme)Enum.Parse(typeof(ControlScheme), values[values.Length - 1]))
                {
                    controller.SelectedControlScheme = 0;
                }
            }

            ksLast = ks;

            base.Update(gameTime);
        }
Exemple #2
0
        void Collision_OwnGoal(object sender, OwnGoalEventArgs e)
        {
            // where 3 is the amount of fail messages currently.. yea yea, hardcoded..
            int n = r.Next(0, 5);

            string msg = "";

            switch (n)
            {
            case 0: msg = Fail1; break;

            case 1: msg = Fail2; break;

            case 2: msg = Fail3; break;

            case 3: msg = Fail4; break;

            case 4: msg = Fail5; break;
            }

            ownGoal = new OwnGoalData(e.PlayerIndex, msg, fontBold.MeasureString(msg));

            from = DateTime.Now;
        }
        void Collision_OwnGoal(object sender, OwnGoalEventArgs e)
        {
            // where 3 is the amount of fail messages currently.. yea yea, hardcoded..
            int n = r.Next(0, 5);

            string msg = "";

            switch (n) {
                case 0: msg = Fail1; break;
                case 1: msg = Fail2; break;
                case 2: msg = Fail3; break;
                case 3: msg = Fail4; break;
                case 4: msg = Fail5; break;
            }

            ownGoal = new OwnGoalData(e.PlayerIndex, msg, fontBold.MeasureString(msg));

            from = DateTime.Now;
        }
        protected override void Update(GameTime gameTime)
        {
            Scene.Update(gameTime.ElapsedGameTime);

            if (ownGoal != null) {
                TimeSpan since = DateTime.Now - from;

                if (since.TotalSeconds > timeToDisplayMoron) {
                    ownGoal = null;
                }
            }

            KeyboardState ks = Keyboard.GetState();

            if (ks.IsKeyUp(Keys.Z) && ksLast.IsKeyDown(Keys.Z)) {
                // cycle player 1
                PlayerController controller = Scene.Coordinator.Select("Player")[0].Get<PlayerController>();

                controller.SelectedControlScheme += 1;

                string[] values = Enum.GetNames(typeof(ControlScheme));
                if (controller.SelectedControlScheme > (ControlScheme)Enum.Parse(typeof(ControlScheme), values[values.Length - 1])) {
                    controller.SelectedControlScheme = 0;
                }
            } if (ks.IsKeyUp(Keys.X) && ksLast.IsKeyDown(Keys.X)) {
                // cycle player 2
                PlayerController controller = Scene.Coordinator.Select("Player")[1].Get<PlayerController>();

                controller.SelectedControlScheme += 1;

                string[] values = Enum.GetNames(typeof(ControlScheme));
                if (controller.SelectedControlScheme > (ControlScheme)Enum.Parse(typeof(ControlScheme), values[values.Length - 1])) {
                    controller.SelectedControlScheme = 0;
                }
            }

            ksLast = ks;

            base.Update(gameTime);
        }