Пример #1
0
    // Start is called before the first frame update
    void Start()
    {
        GE = FindObjectOfType <GameEngine>();
        EG = FindObjectOfType <EngineGame>();
        winR.SetActive(false);
        //Reto Random
        nombre.text = name;


        int canvas = Random.Range(0, 4);

        if (canvas == 1)
        {
            current = retoStates.Semaforo; GE.startSemaforo = true;
        }
        else if (canvas == 2)
        {
            current = retoStates.Saltos; EG.startSalto = true;
        }
        else if (canvas == 3)
        {
            current = retoStates.Sentadillas; EG.startSalto = true;
        }
        else
        {
            current = retoStates.Saltos; EG.startSalto = true;
        }
    }
Пример #2
0
 /// <summary>
 /// Constructs a new screen manager component.
 /// </summary>
 public ScreenManager(EngineGame game)
     : base(game)
 {
     // we must set EnabledGestures before we can query for them, but
     // we don't assume the game wants to read them.
     TouchPanel.EnabledGestures = GestureType.None;
     this.gameWorld = game;
 }
Пример #3
0
        public void GetStartBarriersTest()
        {
            EngineGame game = new EngineGame();

            EngineRectangle[] barriers = game.GetStartBarriers();

            Assert.IsTrue(barriers.Length == 4);
        }
Пример #4
0
        public void ConstructorTest()
        {
            EngineGame game = new EngineGame(15000.0);

            Assert.AreEqual(15000.0, game.Width);
            Assert.AreEqual(game.Width / 20 * 6, game.Height);
            Assert.AreEqual(game.Width / 20, game.RectWidth);
            Assert.AreEqual(game.Height / 6, game.RectHeight);
        }
Пример #5
0
        public void MoveBarrierCantRight()
        {
            EngineGame      game   = new EngineGame();
            EngineRectangle square = new EngineRectangle(game.RectWidth * 14 + game.RectWidth * 0.5, game.RectHeight, game.RectHeight * 0.5, game.RectWidth * 0.5, Directions.Right, true);

            bool moved = game.MoveRectangle(ref square, 100.0);

            Assert.IsTrue(moved);
        }
Пример #6
0
        public void MoveRectangleCantRightTest()
        {
            EngineGame      game   = new EngineGame();
            EngineRectangle square = game.GetStartSquare();

            square.Direction = Directions.Right;

            bool moved = game.MoveRectangle(ref square, game.Width);

            Assert.IsFalse(moved);
        }
Пример #7
0
        public void MoveRectangleCantLeftTest()
        {
            EngineGame      game   = new EngineGame();
            EngineRectangle square = game.GetStartSquare();

            square.Direction = Directions.Left;

            bool moved = game.MoveRectangle(ref square, game.RectWidth * 1.5 + 100);

            Assert.IsFalse(moved);
        }
Пример #8
0
        public void MoveRectangleCantDownTest()
        {
            EngineGame      game   = new EngineGame();
            EngineRectangle square = game.GetStartSquare();

            square.Direction = Directions.Down;

            bool moved = game.MoveRectangle(ref square, 15000);

            Assert.IsFalse(moved);
        }
Пример #9
0
        static void Main()
        {
            EngineGame TankWars = new EngineGame(new LoadingScreen(new ProfileScreen()));

            TankWars.IsMouseVisible = true;
            EngineGame.graphics.PreferredBackBufferHeight = 640;
            EngineGame.graphics.PreferredBackBufferWidth  = 800;

            GameState.LoadContent();
            TankWars.Run();
        }
Пример #10
0
        public void MoveRectangleOverlapTest()
        {
            EngineGame      game   = new EngineGame();
            EngineRectangle square = new EngineRectangle(game.RectWidth * 4, 100, 100, 100);

            square.Direction = Directions.Right;


            bool moved = game.MoveRectangle(ref square, 100);

            Assert.IsFalse(moved);
        }
Пример #11
0
        public void GetStartSquareTest()
        {
            EngineGame      game   = new EngineGame();
            EngineRectangle square = game.GetStartSquare();

            Assert.IsFalse(square == null);
            Assert.IsTrue(square.X >= 0);
            Assert.IsTrue(square.Y >= 0);
            Assert.IsTrue(square.Height > 0);
            Assert.IsTrue(square.Width > 0);
            Assert.IsTrue(square.Direction == Directions.Wrong);
            Assert.IsTrue(square.IsBarrier == false);
            Assert.IsTrue(square.Height == game.RectHeight * 0.8);
            Assert.IsTrue(square.Width == game.RectHeight * 0.8);
        }
Пример #12
0
        public ConsoleUiGame()
        {
            Console.CursorVisible = false;

            this._timer          = new System.Timers.Timer();
            this._timer.Interval = 50.0;
            this._timer.Elapsed += new ElapsedEventHandler(this.TimerElapsed);

            this._game = new EngineGame();
            this.RegisterEvents();

            this._square   = this._game.GetStartSquare();
            this._barriers = this._game.GetStartBarriers();

            this._cd = new ConsoleDrawing();
        }
Пример #13
0
        public Move[] GetBestMoves()
        {
            Move[] bestMoveSequence = null;
            var    bestScore        = double.MinValue;
            var    allSequences     = GenerateMovesSequence(EngineGame);

            var       oponent    = EngineGame.OtherPlayer();
            var       myColor    = EngineGame.CurrentPlayer;
            const int inParallel = 2;

            var opt = new ParallelOptions {
                MaxDegreeOfParallelism = inParallel
            };

            Parallel.ForEach(allSequences, opt, (sequence) =>
            {
                var g    = allSequences.IndexOf(sequence) % inParallel;
                var game = EngineGame.Clone();

                var localSequence = ToLocalSequence(sequence, game);

                var hits  = DoSequence(localSequence, game);
                var score = 0d;
                if (Configuration.ProbablityScore)
                {
                    score = -ProbabilityScore(oponent, game);
                }
                else
                {
                    score = EvaluatePoints(myColor, game) + EvaluateCheckers(myColor, game);
                }

                UndoSequence(localSequence, hits, game);
                //Console.WriteLine($"Engine search {s} of {allSequences.Count}\t{score.ToString("0.##")}\t{sequence.BuildString()}");
                if (score > bestScore)
                {
                    bestScore        = score;
                    bestMoveSequence = sequence;
                }
            });

            if (bestMoveSequence == null)
            {
                return(new Move[0]);
            }
            return(bestMoveSequence.ToArray());
        }
Пример #14
0
        public void CheckDeathNotDieTest()
        {
            EngineGame game = new EngineGame();

            EngineRectangle[] barriers = game.GetStartBarriers();
            EngineRectangle   square   = game.GetStartSquare();

            bool die = true;

            game.EventDie += ((sender, e) =>
            {
                die = e.Die;
            });

            game.CheckDeath(square, barriers);

            Assert.IsFalse(die);
        }
Пример #15
0
        public void CheckDeathDieY2Test()
        {
            EngineGame game = new EngineGame();

            EngineRectangle[] barriers = game.GetStartBarriers();
            EngineRectangle   square   = new EngineRectangle(new EnginePoint(barriers[1].X + 1, barriers[1].Y - 10), new EngineSize(game.GetStartSquare().Height, game.GetStartSquare().Width));

            bool die = false;

            game.EventDie += ((sender, e) =>
            {
                die = e.Die;
            });

            game.CheckDeath(square, barriers);

            Assert.IsTrue(die);
        }
Пример #16
0
        public void CheckDeathDieXTest()
        {
            EngineGame game = new EngineGame();

            EngineRectangle[] barriers = game.GetStartBarriers();
            EngineRectangle   square   = new EngineRectangle(barriers[0].Location, game.GetStartSquare().Size);

            bool die = false;

            game.EventDie += ((sender, e) =>
            {
                die = e.Die;
            });

            game.CheckDeath(square, barriers);

            Assert.IsTrue(die);
        }
Пример #17
0
        public void MoveRectangleLeftTest()
        {
            EngineGame      game   = new EngineGame();
            EngineRectangle square = game.GetStartSquare();

            square.Direction = Directions.Left;

            bool finished = false;

            game.EventFinish += ((sender, e) =>
            {
                finished = e.Finish;
            });


            bool moved = game.MoveRectangle(ref square, 15.0);

            Assert.IsTrue(moved);
            Assert.IsFalse(finished);
        }
Пример #18
0
 /// <summary>
 /// Updates the background screen. Unlike most screens, this should not
 /// transition off even if it has been covered by another screen: it is
 /// supposed to be covered, after all! This overload forces the
 /// coveredByOtherScreen parameter to false in order to stop the base
 /// Update method wanting to transition off.
 /// </summary>
 public override void Update(GameTime gameTime, bool otherScreenHasFocus,
     bool coveredByOtherScreen, EngineGame world)
 {
     base.Update(gameTime, otherScreenHasFocus, false, world);
 }
Пример #19
0
 public override void doClickedProcess()
 {
     EngineGame.ExitGame();
     base.doClickedProcess();
 }
Пример #20
0
        /// <summary>
        /// Updates the menu.
        /// </summary>
        public override void Update(GameTime gameTime, bool otherScreenHasFocus,
            bool coveredByOtherScreen, EngineGame world)
        {
            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen, world);

            // Update each nested MenuEntry object.
            for (int i = 0; i < menuEntries.Count; i++)
            {
                bool isSelected = IsActive && (i == selectedEntry);

                menuEntries[i].Update(this, isSelected, gameTime);
            }
             /*   for (int i = 0; i < hudElements.Count; i++)
            {
                hudElements[i].Update(this, gameTime);
            }*/
        }
Пример #21
0
 void Start()
 {
     speed  = 15f;
     change = true;
     engine = FindObjectOfType <EngineGame>();
 }
Пример #22
0
        /// <summary>
        /// Allows the screen to run logic, such as updating the transition position.
        /// Unlike HandleInput, this method is called regardless of whether the screen
        /// is active, hidden, or in the middle of a transition.
        /// </summary>
        public virtual void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen, EngineGame world)
        {
            this.otherScreenHasFocus = otherScreenHasFocus;

            if (isExiting)
            {
                // If the screen is going away to die, it should transition off.
                screenState = ScreenState.TransitionOff;

                if (!UpdateTransition(gameTime, transitionOffTime, 1))
                {
                    // When the transition finishes, remove the screen.
                    ScreenManager.RemoveScreen(this);
                }
            }
            else if (coveredByOtherScreen)
            {
                // If the screen is covered by another, it should transition off.
                if (UpdateTransition(gameTime, transitionOffTime, 1))
                {
                    // Still busy transitioning.
                    screenState = ScreenState.TransitionOff;
                }
                else
                {
                    // Transition finished!
                    screenState = ScreenState.Hidden;
                }
            }
            else
            {
                // Otherwise the screen should transition on and become active.
                if (UpdateTransition(gameTime, transitionOnTime, -1))
                {
                    // Still busy transitioning.
                    screenState = ScreenState.TransitionOn;
                }
                else
                {
                    // Transition finished!
                    screenState = ScreenState.Active;
                }
            }
        }
Пример #23
0
        /// <summary>
        /// Allows each screen to run logic.
        /// </summary>
        public void Update(GameTime gameTime, EngineGame world)
        {
            // Read the keyboard and gamepad.
            input.Update();

            // Make a copy of the master screen list, to avoid confusion if
            // the process of updating one screen adds or removes others.
            tempScreensList.Clear();

            foreach (GameScreen screen in screens)
                tempScreensList.Add(screen);

            bool otherScreenHasFocus = !Game.IsActive;
            bool coveredByOtherScreen = false;

            // Loop as long as there are screens waiting to be updated.
            while (tempScreensList.Count > 0)
            {
                // Pop the topmost screen off the waiting list.
                GameScreen screen = tempScreensList[tempScreensList.Count - 1];

                tempScreensList.RemoveAt(tempScreensList.Count - 1);

                // Update the screen.
                screen.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen, world);

                if (screen.ScreenState == ScreenState.TransitionOn ||
                    screen.ScreenState == ScreenState.Active)
                {
                    // If this is the first active screen we came across,
                    // give it a chance to handle input.
                    if (!otherScreenHasFocus)
                    {
                        screen.HandleInput(gameTime, input);

                        otherScreenHasFocus = true;
                    }

                    // If this is an active non-popup, inform any subsequent
                    // screens that they are covered by it.
                    if (!screen.IsPopup)
                        coveredByOtherScreen = true;
                }
            }

            // Print debug trace?
            if (traceEnabled)
                TraceScreens();
        }
Пример #24
0
 public bool Update(GameTime time, EngineGame world)
 {
     LifeLeft -= time.ElapsedGameTime.Milliseconds;
     if (LifeLeft <= 0)
     {
         world.LevelManager.RenderManager.UnregisterRenderable(this);
         return false;
     }
     if (Position.X >= (StartingPos.X + MaxWidth) || Position.X <= (StartingPos.X - MaxWidth) ||
         Position.Y >= (StartingPos.Y + MaxHeight) || Position.Y <= (StartingPos.Y - MaxHeight))
     {
         world.LevelManager.RenderManager.UnregisterRenderable(this);
         return false;
     }
     lifePhase = LifeLeft / StartingLife;      // 1 means newly created 0 means dead.
     Position += MathLib.LinearInterpolate(EndDirection, StartDirection, lifePhase) * time.ElapsedGameTime.Milliseconds;
     return true;
 }
Пример #25
0
        /// <summary>
        /// Updates the loading screen.
        /// </summary>
        public override void Update(GameTime gameTime, bool otherScreenHasFocus,
            bool coveredByOtherScreen, EngineGame world)
        {
            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen, world);

            // If all the previous screens have finished transitioning
            // off, it is time to actually perform the load.
            if (otherScreensAreGone)
            {
                ScreenManager.RemoveScreen(this);

                foreach (GameScreen screen in screensToLoad)
                {
                    if (screen != null)
                    {
                        ScreenManager.AddScreen(screen, ControllingPlayer);
                    }
                }

                // Once the load has finished, we use ResetElapsedTime to tell
                // the  game timing mechanism that we have just finished a very
                // long frame, and that it should not try to catch up.
                ScreenManager.Game.ResetElapsedTime();
            }
        }