Пример #1
0
        public override void Draw(SpriteBatch spriteBatch, Rectangle screenBounds)
        {
            if (countToBeginning < 120 && !gameOver)
            {
                string text = "esc to exit";

                Vector2 measure = MeasureText(text);

                ComputerUI.DrawFontText(spriteBatch, new Vector2(screenBounds.Width / 2, (screenBounds.Height / 2) - (measure.Y / 2) - 1) - (measure / 2), text);

                text = "arrow keys or wasd to move";

                measure = MeasureText(text);

                ComputerUI.DrawFontText(spriteBatch, new Vector2(screenBounds.Width / 2, (screenBounds.Height / 2) + (measure.Y / 2) + 1) - (measure / 2), text);
            }
            else if (!gameOver)
            {
                for (int i = 24; i < screenBounds.Height - 16; i += 8)
                {
                    spriteBatch.Draw(whiteSquare, screenBounds.GetPos() + new Vector2(screenBounds.Width / 2, i) - new Vector2(3, 3), Color.White * 0.6f);
                }

                spriteBatch.Draw(paddleTexture, screenBounds.GetPos() + yourPaddle.position, Color.White);

                spriteBatch.Draw(paddleTexture, screenBounds.GetPos() + aiPaddle.position, Color.White);

                spriteBatch.Draw(ballTexture, screenBounds.GetPos() + ball.position, Color.White);

                ComputerUI.DrawFontText(spriteBatch, new Vector2((screenBounds.Width / 2) - 16, 32), yourScore.ToString());

                ComputerUI.DrawFontText(spriteBatch, new Vector2((screenBounds.Width / 2) + 6, 32), aiScore.ToString());
            }

            if (gameOver)
            {
                string text = yourScore == 10 ? "you win" : "you lose";

                Vector2 measure = MeasureText(text);

                ComputerUI.DrawFontText(spriteBatch, new Vector2(screenBounds.Width / 2, screenBounds.Height / 2) - (measure / 2), text);
            }
        }
Пример #2
0
        public override void Update(ComputerUI parent, Rectangle screenBounds)
        {
            Main.blockInput = true;

            if (snake.segments.Count >= 390)
            {
                gameOver = true;

                endText = "You win!";
            }

            if (PressedExit || (gameOver && countToBeginning > 120))
            {
                parent.StopVideoGame();
            }

            if (countToBeginning < 120 && !gameOver)
            {
                countToBeginning++;
            }
            else if (countToBeginning >= 120 && !gameOver)
            {
                gameTimer++;

                Vector2 move = GetMoveDir();

                if (lastMove == Vector2.Zero && move == Vector2.UnitY)
                {
                    move = lastMove;
                }

                if (move != lastMove)
                {
                    lastMove = move;
                }

                if (gameTimer % 12 == 0)
                {
                    if (move != Vector2.Zero)
                    {
                        snakeSegmentsCache.Insert(0, snake.segments[0]);

                        if (snakeSegmentsCache.Count > snake.segments.Count)
                        {
                            snakeSegmentsCache.RemoveAt(snakeSegmentsCache.Count - 1);
                        }

                        snake.segments[0] += move * 10;

                        for (int i = 1; i < snakeSegmentsCache.Count - 1; i++)
                        {
                            snake.segments[i] = snakeSegmentsCache[i];
                        }

                        snakeSegmentsCache.RemoveAt(snakeSegmentsCache.Count - 1);
                    }
                }

                if (snakeFood == null && move != Vector2.Zero)
                {
                    Vector2 possiblePos = Main.rand.Next(possibleFoodSpawns);

                    while (new Rectangle((int)possiblePos.X, (int)possiblePos.Y, 10, 10).Intersects(new Rectangle((int)snake.segments[0].X, (int)snake.segments[0].Y, 10, 10)))
                    {
                        possiblePos = Main.rand.Next(possibleFoodSpawns);
                    }

                    snakeFood = new SnakeFood(possiblePos + screenBounds.GetPos() + offset);
                }

                if (snakeFood != null && new Rectangle((int)snakeFood.position.X, (int)snakeFood.position.Y, 10, 10).Intersects(new Rectangle((int)snake.segments[0].X, (int)snake.segments[0].Y, 10, 10)))
                {
                    score++;

                    snakeFood = null;

                    snake.segments.Add(snakeSegmentsCache[snakeSegmentsCache.Count - 1]);
                }

                if (!GetBounds(screenBounds).Contains(snake.segments[0].ToPoint()) || AnySegmentsAtSeg0())
                {
                    gameOver = true;

                    countToBeginning = 0;
                }
            }

            if (gameOver)
            {
                countToBeginning++;
            }

            oldKeyState = Key;
        }
Пример #3
0
        public override void Draw(SpriteBatch spriteBatch, Rectangle screenBounds)
        {
            if (countToBeginning < 120 && !gameOver)
            {
                string text = "esc to exit";

                Vector2 measure = MeasureText(text);

                ComputerUI.DrawFontText(spriteBatch, new Vector2(screenBounds.Width / 2, (screenBounds.Height / 2) - (measure.Y / 2) - 1) - (measure / 2), text);

                text = "arrow keys or wasd to move";

                measure = MeasureText(text);

                ComputerUI.DrawFontText(spriteBatch, new Vector2(screenBounds.Width / 2, (screenBounds.Height / 2) + (measure.Y / 2) + 1) - (measure / 2), text);
            }
            else if (!gameOver)
            {
                foreach (Vector2 pos in snake.segments)
                {
                    spriteBatch.Draw(ComputerUI.snakeTexture, pos, Color.White);
                }

                if (snakeFood != null)
                {
                    spriteBatch.Draw(ComputerUI.snakeFoodTexture, snakeFood.position, Color.White);
                }
            }

            if (gameOver)
            {
                if (endText == null)
                {
                    string text = "game over";

                    Vector2 measure = MeasureText(text);

                    ComputerUI.DrawFontText(spriteBatch, new Vector2(screenBounds.Width / 2, (screenBounds.Height / 2) - (measure.Y * 1.5f) - 1) - (measure / 2), text);

                    ScorePlayer sPlayer = Main.LocalPlayer.GetModPlayer <ScorePlayer>();

                    if (score > sPlayer.highScore)
                    {
                        sPlayer.highScore = score;
                    }

                    text = $"your high score is {sPlayer.highScore}";

                    measure = MeasureText(text);

                    ComputerUI.DrawFontText(spriteBatch, new Vector2(screenBounds.Width / 2, (screenBounds.Height / 2) + (measure.Y * 1.5f) + 1) - (measure / 2), text);

                    text = $"you scored {score}";

                    measure = MeasureText(text);

                    ComputerUI.DrawFontText(spriteBatch, new Vector2(screenBounds.Width / 2, screenBounds.Height / 2) - (measure / 2), text);
                }
                else
                {
                    ComputerUI.DrawFontText(spriteBatch, new Vector2(screenBounds.Width / 2, screenBounds.Height / 2) - (MeasureText(endText) / 2), endText);
                }
            }
        }
Пример #4
0
 public virtual void Update(ComputerUI parent, Rectangle screenBounds)
 {
 }
Пример #5
0
        public override void Update(ComputerUI parent, Rectangle screenBounds)
        {
            Rectangle actualBounds = new Rectangle((int)offset.X, (int)offset.Y, 320, 150);

            Main.blockInput = true;

            if (PressedExit || (gameOver && countToBeginning > 120))
            {
                parent.StopVideoGame();
            }

            if (countToBeginning < 120 && !gameOver)
            {
                countToBeginning++;
            }
            else if (countToBeginning >= 120 && !gameOver)
            {
                if (delay > 0)
                {
                    delay--;
                }
                else
                {
                    if (MovedUp && yourPaddle.position.Y > actualBounds.Y)
                    {
                        yourPaddle.position.Y -= paddleSpeed;
                    }
                    else if (MovedDown && yourPaddle.position.Y + 40 < actualBounds.Y + actualBounds.Height)
                    {
                        yourPaddle.position.Y += paddleSpeed;
                    }

                    if (ball.position.X > actualBounds.X + (actualBounds.Width / 2))
                    {
                        AIPaddle(actualBounds);
                    }

                    Rectangle yourGoal = new Rectangle(actualBounds.X, actualBounds.Y, 8, 150);
                    Rectangle aiGoal   = new Rectangle(actualBounds.X + actualBounds.Width - 8, actualBounds.Y, 8, 150);

                    if (ball.Hitbox.Intersects(yourGoal))
                    {
                        aiScore++;

                        BoardReset(screenBounds);
                    }
                    else if (ball.Hitbox.Intersects(aiGoal))
                    {
                        yourScore++;

                        BoardReset(screenBounds);
                    }

                    if (ball.Hitbox.Intersects(yourPaddle.Hitbox))
                    {
                        MakePositive(ref ball.velocity.X);
                    }
                    else if (ball.Hitbox.Intersects(aiPaddle.Hitbox))
                    {
                        MakeNegative(ref ball.velocity.X);
                    }

                    if (ball.position.Y < actualBounds.Y || ball.position.Y + 10 > actualBounds.Y + actualBounds.Height)
                    {
                        ball.velocity.Y *= -1;
                    }

                    ball.position += ball.velocity;
                }
            }

            if (yourScore == 10 || aiScore == 10)
            {
                gameOver = true;

                countToBeginning = 0;
            }

            if (gameOver)
            {
                countToBeginning++;
            }

            oldKeyState = Key;
        }
Пример #6
0
        public override void Load()
        {
            noxiumInstance = GetInstance <NoxiumMod>();

            vanillaScreenMatrix = typeof(SpriteViewMatrix).GetField("_transformationMatrix", BindingFlags.NonPublic | BindingFlags.Instance);
            vanillaUIMatrix     = typeof(Main).GetField("_uiScaleMatrix", BindingFlags.NonPublic | BindingFlags.Static);

            On.Terraria.Graphics.SpriteViewMatrix.ShouldRebuild += (On.Terraria.Graphics.SpriteViewMatrix.orig_ShouldRebuild orig, SpriteViewMatrix self) =>
            {
                if (doingBarrelRoll)
                {
                    return(false);
                }
                return(orig(self));
            };

            ComputerUI.PleaseForTheLoveOfGodDontOpenChatWhenIPressEnter();

            HitboxesGlobalItem.meleeHitbox = new Rectangle?[256];

            SeedHotkey = RegisterHotKey("Seed Fruit", "C");

            if (!Main.dedServ)
            {
                AhmUI          = new AhmBar();
                AHMUiInterface = new UserInterface();
                AHMUiInterface.SetState(AhmUI);

                dimensionalUI = new DimensionalUI();
                dimensionalUI.LoadUI();
                dimensionalUI.Activate();

                computerInterface = new UserInterface();
                computerUI        = new ComputerUIState();
                computerUI.Activate();

                JoiningUI.LoadLoadingSymbol();

                PlasmaDesert.LoadBubbleTextures();

                /* Examples:
                 *
                 *              dimensionalUI.RegisterDimension("The Cum Zone", ModContent.GetTexture("Terraria/Item_2"), () => Main.dayTime, () => Main.NewText("Welcome to the cum zone"));
                 *              // Appears as 'The Cum Zone', shows a dirt block texture, only appears in the day, when clicked will say 'Welcome to the cum zone'.
                 *
                 *              dimensionalUI.RegisterDimension("Hell", ModContent.GetTexture("Terraria/Item_1"), () => !Main.dayTime, () => Main.NewText("Welcome to hell"));
                 *              // Appears as 'Hell', shows an iron pickaxe texture, only appears at night, when clicked will say 'Welcome to hell'.
                 *
                 *              Call("AddDimension", "The Cum Zone", ModContent.GetTexture("Terraria/Item_2"), (Func<bool>)(() => Main.dayTime), (Action)(() => Main.NewText("Welcome to the cum zone")));
                 *              // Example of a mod.Call to add a dimension.
                 *
                 */
                // Gaming
                dimensionalUI.RegisterDimension("Plasma Desert", ModContent.GetTexture("NoxiumMod/PlasmaDesert"), () => true, () => Subworld.Enter <PlasmaDesert>());
                dimensionalUI.RegisterDimension("The Cum Zone", ModContent.GetTexture("Terraria/Item_2"), () => true, () => Main.NewText("Welcome to the cum zone"));

                dimensionalInterface = new UserInterface();
            }

            Mod yabhb = ModLoader.GetMod("FKBossHealthBar");

            if (yabhb != null)
            {
                yabhb.Call("hbStart");
                yabhb.Call("hbSetTexture", GetTexture("UI/AhmHealthStart"), GetTexture("UI/AhmHealthMid"), GetTexture("UI/AhmHealthEnd"), GetTexture("UI/AhmHealthFill"));
                yabhb.Call("hbFinishSingle", NPCType("AncientHealingMachine"));
            }
        }