Example #1
0
        public GetBallOverlay() : base()
        {
            giftBox = new AnimatedGameObject(Depth.GiftBox);
            giftBox.LoadAnimation("Sprites/Animations/spr_animation_getball@4x3", "box", false, 0.05f);
            giftBox.PlayAnimation("box", true);
            giftBox.SetOriginToCenter();
            giftBox.LocalPosition = new Vector2(320, 600);
            AddChild(giftBox);

            glowing = new AnimatedGameObject(Depth.OverlayButton2);
            glowing.LoadAnimation("Sprites/Animations/spr_animation_glowing@5x2", "glowing", true, 0.1f);
            glowing.PlayAnimation("glowing", true);
            glowing.SetOriginToCenter();
            glowing.LocalPosition = new Vector2(350, 500);
            AddChild(glowing);

            background = new SpriteGameObject("Sprites/Backgrounds/spr_getball", Depth.OverlayBackground2);
            AddChild(background);

            message = new TextGameObject("Fonts/GetBall", Depth.OverlayMessage, Color.White, TextGameObject.HorizontalAlignment.Center, TextGameObject.VerticalAlignment.Center);
            AddChild(message);
            message.Visible       = false;
            message.Text          = "Click to get ball";
            message.LocalPosition = new Vector2(350, 900);

            fireWorkMaker = new ListStar(Depth.RandomBall + 0.001f);
            AddChild(fireWorkMaker);
            Reset();
        }
Example #2
0
 void OnTriggerEnter(Collider col)
 {
     YesGameObject.SetActive(false);
     TextGameObject.SetActive(false);
     OriginalTextGameObject.SetActive(true);
     this.gameObject.SetActive(false);
 }
Example #3
0
        public override void ItemInfo(ItemSlot caller)
        {
            base.ItemInfo(caller);

            Player         player = caller.GameWorld.Find(Player.LocalPlayerName) as Player;
            TextGameObject dType  = new TextGameObject("Arial12", cameraSensitivity: 0, layer: 0, id: "DamageTypeInfo." + this);

            dType.Text   = GetDamageType + " Damage: " + baseValue + " + " + (Value(player) - baseValue);
            dType.Color  = Color.Red;
            dType.Parent = infoList;
            infoList.Children.Insert(1, dType);

            TextGameObject scalingText = new TextGameObject("Arial12", cameraSensitivity: 0, layer: 0, id: "scalingInfoText." + this);

            scalingText.Text = "DamageBonus:";
            switch (damageType)
            {
            case DamageType.Physical:
                scalingText.Text += " str " + (int)(strScalingFactor * baseValue) + " dex " + (int)(dexScalingFactor * baseValue);
                break;

            case DamageType.Magic:
                scalingText.Text += " int " + (int)(intScalingFactor * baseValue);
                break;

            default:
                throw new Exception("invalid damageType");
            }
            scalingText.Color  = Color.Red;
            scalingText.Parent = infoList;
            infoList.Children.Insert(2, scalingText);


            TextGameObject scalingStatText = new TextGameObject("Arial12", cameraSensitivity: 0, layer: 0, id: "scalingStatInfoText." + this);

            scalingStatText.Text = "Statbonus:";
            switch (damageType)
            {
            case DamageType.Physical:
                scalingStatText.Text += " str " + string.Format("{0:N2}", strScalingFactor) + " dex " + string.Format("{0:N2}", dexScalingFactor);
                break;

            case DamageType.Magic:
                scalingStatText.Text += " int " + string.Format("{0:N2}", intScalingFactor);
                break;

            default:
                throw new Exception("invalid damageType");
            }
            scalingStatText.Color  = Color.Red;
            scalingStatText.Parent = infoList;
            infoList.Children.Insert(3, scalingStatText);

            TextGameObject reachText = new TextGameObject("Arial12", cameraSensitivity: 0, layer: 0, id: "ReachInfoText." + this);

            reachText.Text   = "Reach: " + reach;
            reachText.Color  = Color.Red;
            reachText.Parent = infoList;
            infoList.Add(reachText);
        }
    /// <summary>Load the level.</summary>
    public void LoadTiles(string path)
    {
        this.path = path;
        List <string> textlines  = new List <string>();
        StreamReader  fileReader = new StreamReader(path);
        string        line       = fileReader.ReadLine(); // first row of the level

        width = line.Length;                              // calculated level width
        while (line != null)
        {
            // read all lines
            textlines.Add(line);
            line = fileReader.ReadLine();
        }
        height = textlines.Count - 2;

        // add the hint
        GameObjectList hintfield = new GameObjectList(100);

        Add(hintfield);
        SpriteGameObject hint_frame = new SpriteGameObject("Overlays/spr_frame_hint", 1); // hint background

        hintfield.Position = new Vector2((GameEnvironment.Screen.X - hint_frame.Width) / 2, 10);
        hintfield.Add(hint_frame);
        TextGameObject hintText = new TextGameObject("Fonts/HintFont", 2); // hint text

        hintText.Text     = textlines[textlines.Count - 2];                // last line in the level descriptor
        hintText.Position = new Vector2(120, 25);
        hintText.Color    = Color.Black;
        hintfield.Add(hintText);
        VisibilityTimer hintTimer = new VisibilityTimer(hintfield, 1, "hintTimer"); // timeout

        Add(hintTimer);

        TimerGameObject timer = new TimerGameObject(101, "timer");

        timer.Position = new Vector2(25, 30);
        timer.TimeLeft = TimeSpan.FromSeconds(double.Parse(textlines[textlines.Count - 1]));
        Add(timer);

        // construct the level
        TileField tiles = new TileField(height, width, 1, "tiles");

        Add(tiles);
        // tile dimentions
        tiles.CellWidth = 72;
        cellWidth       = 72;

        tiles.CellHeight = 55;
        cellHeight       = 55;

        for (int x = 0; x < width; ++x)
        {
            for (int y = 0; y < height; ++y)
            {
                Tile t = LoadTile(textlines[y][x], x, y);
                tiles.Add(t, x, y);
            }
        }
    }
        public PainterGameWorld()
        {
            background = new SpriteGameObject("spr_background");

            scoreBar = new SpriteGameObject("spr_scorebar");

            cannon = new Cannon();

            canSprites = new GameObjectList();
            canSprites.Add(new PaintCan(450f, Color.Red));
            canSprites.Add(new PaintCan(575f, Color.Green));
            canSprites.Add(new PaintCan(700f, Color.Blue));

            scoreText = new TextGameObject("GameFont");
            scoreText.Position = new Vector2(5, 7);

            livesSprites = new GameObjectList();
            for(int iLife = 0; iLife < MAX_LIVES; iLife++)
            {
                SpriteGameObject life = new SpriteGameObject("spr_lives", 0, iLife.ToString());
                life.Position = new Vector2(iLife * life.BoundingBox.Width, scoreBar.Position.Y + scoreBar.BoundingBox.Height + 15);
                livesSprites.Add(life);
            }

            //Add the background sprite to the gameworld
            Add(background);
            Add(scoreBar);
            Add(cannon);
            Add(canSprites);
            Add(scoreText);
            Add(livesSprites);

            Reset();
        }
Example #6
0
        public PlayingGUI()
        {
            Layer = 1;
            id    = "PlayingGui";

            Point      screen      = GameEnvironment.Screen;
            SpriteFont defaultFont = GameEnvironment.AssetManager.GetFont("Arial12");

            SpriteGameObject topBar = new SpriteGameObject("HUD/topbar", 0, "TopBar", 0, 0);

            Add(topBar);

            playingMenu = new PlayingMenu();
            Rectangle pmBB = playingMenu.BoundingBox;

            playingMenu.Position = new Vector2((screen.X - pmBB.Width) / 2, (screen.Y - pmBB.Height) / 2);
            playingMenu.Visible  = false;
            playingMenu.Layer    = 100;
            Add(playingMenu);

            SpriteGameObject floor = new SpriteGameObject("empty:75:75:75:Transparent", 1, "FloorBG", 0, 0);

            floor.Position = new Vector2((screen.X - floor.Width) / 2, 7.5f);
            Add(floor);

            TextGameObject floorNumber = new TextGameObject("Arial36", cameraSensitivity: 0, layer: 2, id: "FloorNumber");

            Add(floorNumber);
        }
Example #7
0
        public PlayingState()
        {
            this.Add(new SpriteGameObject("spr_background"));

            thePlayer = new Player();
            this.Add(thePlayer);

            goalKeeper = new GoalKeeper();
            this.Add(goalKeeper);

            crowd = new GameObjectList();
            this.Add(crowd);

            nameScore          = new TextGameObject("GameFont");
            nameScore.Text     = "GOALS:";
            nameScore.Position = new Vector2(120, 0);
            this.Add(nameScore);

            score          = new TextGameObject("GameFont");
            score.Text     = "0";
            score.Position = new Vector2(300, 0);
            this.Add(score);

            nameLives          = new TextGameObject("GameFont");
            nameLives.Text     = "LIVES:";
            nameLives.Position = new Vector2(500, 0);
            this.Add(nameLives);

            numberOfLives          = new TextGameObject("GameFont");
            numberOfLives.Text     = "lives";
            numberOfLives.Position = new Vector2(630, 0);
            this.Add(numberOfLives);
        }
Example #8
0
    /// <summary>
    /// Adds game objects that show the level's general information: two text objects and a background image.
    /// </summary>
    /// <param name="title">The title of the level.</param>
    /// <param name="description">The one-line description of the level.</param>
    void AddLevelInfoObjects(string title, string description)
    {
        // - background box
        SpriteGameObject infoBackground = new SpriteGameObject("Sprites/spr_level_info");

        infoBackground.SetOriginToCenter();
        infoBackground.LocalPosition = new Vector2(600, 820);
        AddChild(infoBackground);

        // - title text
        TextGameObject titleText = new TextGameObject("Fonts/HelpFont", Color.Blue, TextGameObject.Alignment.Center);

        titleText.Text          = LevelIndex + " - " + title;
        titleText.LocalPosition = new Vector2(600, 786);
        AddChild(titleText);

        // - description text
        TextGameObject descriptionText = new TextGameObject("Fonts/HelpFont", Color.DarkBlue, TextGameObject.Alignment.Center);

        descriptionText.Text          = description;
        descriptionText.LocalPosition = new Vector2(600, 820);
        AddChild(descriptionText);

        // - number of pairs
        pairList = new PairList(targetNumberOfPairs);
        pairList.LocalPosition = new Vector2(20, 20);
        AddChild(pairList);
    }
    /// <summary>
    /// Creates a textbox that draws a (small) background box and text string above it. I has a build in streamReader that selects a line out of a txt file.
    /// </summary>
    /// <param name="path">.txt file that contains the text line(s)</param>
    /// <param name="textPlace">specific line that is in .txt file. if 0 is entered, the textbox selects a random line out of the file</param>
    /// <param name="overlay"> backgroundsprite</param>
    /// <param name="font">fond of the text</param>
    /// <param name="objPositionX">x position of the target object</param>
    /// <param name="objPositionY">y position of the target object</param>
    /// <param name="textPosition"> the text offset compared to the overlay</param>
    /// <param name="cameraSensitivity"> weather or not the textbox should be sensitive to camera movement</param>
    public TextBox(string path, int textPlace, string overlay, string font, float objPositionX, float objPositionY, Vector2 textPosition, int cameraSensitivity) : base(100, "")
    {
        visible = true;
        List <string> textLines  = new List <string>();
        StreamReader  fileReader = new StreamReader(path);
        string        line       = fileReader.ReadLine();
        int           width      = line.Length;

        while (line != null)
        {
            textLines.Add(line);
            line = fileReader.ReadLine();
        }

        if (textPlace == 0)
        {
            textPlace = r.Next(1, textLines.Count);
        }

        SpriteGameObject textFrame = new SpriteGameObject(overlay, 1, "", 0, cameraSensitivity, 1);

        Add(textFrame);

        objPosition = new Vector2(objPositionX, objPositionY);
        center      = new Vector2(textFrame.Width / 2, textFrame.Height);
        Position    = objPosition - center;

        TextGameObject text = new TextGameObject(font, cameraSensitivity: cameraSensitivity, layer: 2);

        text.Text     = textLines[textLines.Count - textPlace];
        text.Position = textPosition;
        text.Color    = Color.Black;
        Add(text);
    }
Example #10
0
 private void PlayerNameTitle()
 {
     playerNameTitle          = new TextGameObject("Arial26", 1, 0, "playerName" + guid.ToString());
     playerNameTitle.Text     = Id.Split('_')[1];
     playerNameTitle.Color    = Color.Red;
     playerNameTitle.Position = GlobalPosition - new Vector2((playerNameTitle.Size.X / 2), 64 + playerNameTitle.Size.Y);
 }
Example #11
0
        public WinState()
        {
            Add(new SpriteGameObject("MaliciousCompliance-temp"));

            Add(scoreText    = new TextGameObject("GameFont", 1));
            Add(confettiList = new GameObjectList());
            for (int i = 0; i < confettiCount; i++)
            {
                confettiList.Add(new RotatingSpriteGameObject("confetti" + GameEnvironment.Random.Next(6) + "-temp"));
            }
            foreach (RotatingSpriteGameObject confetti in confettiList.Children)
            {
                confetti.Origin   = confetti.Center;
                confetti.Degrees += GameEnvironment.Random.Next(-20, 20);
                confetti.Velocity = new Vector2(GameEnvironment.Random.Next(-10, 10), 20);
                confetti.Position = new Vector2(GameEnvironment.Random.Next(0, GameEnvironment.Screen.X), GameEnvironment.Random.Next(-50, -20));
                confettiQueue.Enqueue(confetti);
            }

            scoreText.Text     = "SCORE: " + PlayingState.finalScore.ToString();
            scoreText.Position = new Vector2(GameEnvironment.Screen.X / 2 - scoreText.Size.X / 2f, GameEnvironment.Screen.Y / 2);

            Add(tryAgainText = new TextGameObject("GameFont", 1));


            tryAgainText.Text     = "Press any key to continue.";
            tryAgainText.Position = new Vector2(GameEnvironment.Screen.X / 2 - scoreText.Size.X * 1.5f, scoreText.Position.Y + 200);
        }
Example #12
0
        private void AddLevelInfoObjects(string title, string description)
        {
            // Level info background sprite
            SpriteGameObject levelInfo = new SpriteGameObject("Sprites/spr_level_info");

            levelInfo.SetOriginToCenter();
            levelInfo.Position = new Vector2(600, 820);
            AddChild(levelInfo);

            TextGameObject titleObject = new TextGameObject("Fonts/HelpFont", Color.Blue, TextGameObject.Alignment.Center);

            titleObject.Text     = LevelIndex + " - " + title;
            titleObject.Position = new Vector2(600, 786);
            AddChild(titleObject);

            TextGameObject descriptionObject = new TextGameObject("Fonts/HelpFont", Color.Blue, TextGameObject.Alignment.Center);

            descriptionObject.Text     = description;
            descriptionObject.Position = new Vector2(600, 820);
            AddChild(descriptionObject);

            pairList          = new PairList(targetNuberOfPairs);
            pairList.Position = new Vector2(20, 20);
            AddChild(pairList);
        }
Example #13
0
        public StatusBar()
            : base()
        {
            clickableObjects = new GameObjectList();

            background = new SpriteGameObject("spr_bar");

            overHeadArrowsIcon = new ClickableSpriteGameObject("arrow_raining", IconType.OverheadArrowsIcon);
            rollingBoulderIcon = new ClickableSpriteGameObject("bolder_powerupp", IconType.RollingBoulderIcon);
            boilingOilIcon = new ClickableSpriteGameObject("spr_keuze_mage", IconType.BoilingOilIcon);

            moneyCount = new TextGameObject("GameFont");

            overHeadArrowsIcon.Position = new Vector2(975, 30);
            rollingBoulderIcon.Position = new Vector2(1075, 30);
            boilingOilIcon.Position = new Vector2(1175, 30);

            moneyCount.Position = new Vector2(800, 30);
            moneyCount.Text = "";

            clickableObjects.Add(overHeadArrowsIcon);
            clickableObjects.Add(rollingBoulderIcon);
            clickableObjects.Add(boilingOilIcon);

            Add(background);

            Add(overHeadArrowsIcon);
            Add(rollingBoulderIcon);
            Add(boilingOilIcon);
            Add(moneyCount);
        }
Example #14
0
 public GameOverGameState()
 {
     textObj          = new TextGameObject("GameFont");
     textObj.Text     = "Game over! Press any key to restart...";
     textObj.Position = new Vector2((Painter.Screen.X / 6), (Painter.Screen.Y / 2) - 10);
     this.Add(textObj);
 }
Example #15
0
        public Store()
        {
            overheadArrows = new BuyableGameObject(100f, UpgradeType.OverheadArrows, "arrow_raining", new Vector2(75, 440));
            rollingBoulder = new BuyableGameObject(100f, UpgradeType.RollingBoulder, "bolder_powerupp", new Vector2(75, 645));
            boilingOil = new BuyableGameObject(100f, UpgradeType.BoilingOil, "spr_keuze_babarian", new Vector2(75, 850));

            castleUpgrade = new BuyableGameObject(100f, UpgradeType.CastleUpgrade, "spr_keuze_mage", new Vector2(1300, 440));
            archerUpgrade = new BuyableGameObject(100f, UpgradeType.ArcherUpgrade, "spr_keuze_boog", new Vector2(1300, 645));
            catapultUpgrade = new BuyableGameObject(100f, UpgradeType.CatapultUpgrade, "catepult@1x1", new Vector2(1300, 850));

            upgradeText = new TextGameObject("GameFont");
            upgradeText.Position = new Vector2(60, 80);
            upgradeText.Text = "Spawn Arrows to rain\n on your enemies!";

            upgrades.Add(overheadArrows);
            upgrades.Add(rollingBoulder);
            upgrades.Add(boilingOil);
            upgrades.Add(castleUpgrade);
            upgrades.Add(archerUpgrade);
            upgrades.Add(catapultUpgrade);

            Add(new SpriteGameObject("store_background"));
            Add(overheadArrows);
            Add(rollingBoulder);
            Add(boilingOil);
            Add(castleUpgrade);
            Add(archerUpgrade);
            Add(catapultUpgrade);

            Add(upgradeText);
        }
 public GameOverGameState()
     : base()
 {
     gameOverText = new TextGameObject("GameFont");
     gameOverText.Text = "Game over dude! Game over!";
     gameOverText.Position = new Vector2(Painter.Screen.X / 2 - gameOverText.Size.X / 2, Painter.Screen.Y / 2 - gameOverText.Size.Y / 2);
     Add(gameOverText);
 }
 public CreditState()
 {
     credits = new TextGameObject("credits");
     credits.text = "Thank you for playing\n\n\n\n\n\nCoding\n\nAllard\nJelle\nOscar\nRik\nWouter\n\n\nModel Design\n\nAllard\n\n\nSprites\n\nAllard\nOscar\nRik\nJelle\nWouter\n\n\nMusic\n\nJelle\n\n\nSound Effects\n\nJelle\nWouter\n\n\n\nWe are Fancy Panda Softworks";
     credits.Position = new Vector2(100, GameEnvironment.Screen.Y*1.5f);
     timer = 0;
     creditVelocity = 16;
 }
Example #18
0
 public PlayingState()
 {
     this.Add(new SpriteGameObject("spr_background"));
     score = new TextGameObject(scorePos, Color.White);
     this.Add(score);
     bird = new Bird();
     this.Add(bird);
 }
Example #19
0
        public GameOverState()
        {
            this.text          = new TextGameObject("GameFont");
            this.text.Text     = "Game Over";
            this.text.Position = new Vector2((Centipede.Screen.X / 2) - (this.text.Size.X / 2), (Centipede.Screen.Y / 2) - (this.text.Size.Y / 2));

            this.Add(text);
        }
Example #20
0
 public CreditState()
 {
     credits          = new TextGameObject("credits");
     credits.text     = "Thank you for playing\n\n\n\n\n\nCoding\n\nAllard\nJelle\nOscar\nRik\nWouter\n\n\nModel Design\n\nAllard\n\n\nSprites\n\nAllard\nOscar\nRik\nJelle\nWouter\n\n\nMusic\n\nJelle\n\n\nSound Effects\n\nJelle\nWouter\n\n\n\nWe are Fancy Panda Softworks";
     credits.Position = new Vector2(100, GameEnvironment.Screen.Y * 1.5f);
     timer            = 0;
     creditVelocity   = 16;
 }
Example #21
0
 public StartScreen()
 {
     this.Add(new SpriteGameObject("startscreen_spr"));
     DonkeyKongBigDick          = new TextGameObject("gamefont");
     DonkeyKongBigDick.Text     = "Press SPACE to play \n Reach the top!";
     DonkeyKongBigDick.Position = new Vector2(140, 265);
     this.Add(DonkeyKongBigDick);
 }
 public override void Update(GameTime gameTime)
 {
     MusicPlayer.beatCount = 0;
     MusicPlayer.barCount = 0;
     MusicPlayer.dangerLevel = -1;
     text = new TextGameObject("text");
     text.text = "End.";
 }
Example #23
0
        public ThankYouForPlayingState()
        {
            Add(new SpriteGameObject("MaliciousCompliance-temp"));
            Add(thankYouForPlayingText = new TextGameObject("GameFont", 1));

            thankYouForPlayingText.Text     = "THANK YOU FOR PLAYING! :)";
            thankYouForPlayingText.Position = new Vector2(GameEnvironment.Screen.X / 2 - thankYouForPlayingText.Size.X / 2, GameEnvironment.Screen.Y / 2);
        }
Example #24
0
        public GameOverState()
        {
            TextGameObject GOText = new TextGameObject("GameFont");

            Add(GOText);
            GOText.Text     = "Game Over";
            GOText.Position = new Vector2(GameEnvironment.Screen.X * .5f - GOText.Size.X * .5f, GameEnvironment.Screen.Y * .5f);
        }
 public override void Update(GameTime gameTime)
 {
     MusicPlayer.beatCount   = 0;
     MusicPlayer.barCount    = 0;
     MusicPlayer.dangerLevel = -1;
     text      = new TextGameObject("text");
     text.text = "End.";
 }
Example #26
0
        public virtual void Init()
        {
            TextGameObject text = new TextGameObject("GameFont");

            text.Text  = "Press space to continue.";
            text.Color = Color.Black;
            this.Add(new SpriteGameObject("background"), text);
        }
Example #27
0
        public GameoverState()
        {
            this.text          = new TextGameObject("GameFont");
            this.text.Text     = "Game Over!";
            this.text.Position = new Microsoft.Xna.Framework.Vector2((Centipede.Screen.X / 2) - (this.text.Size.X / 2), (Centipede.Screen.Y / 2) - (this.text.Size.Y / 2));

            this.Add(text);
        }
Example #28
0
        public GameOver()
        {
            text = new TextGameObject("GameFont");
            this.Add(text);

            text.Text     = "Game over dude! Game over!";
            text.Position = new Vector2(200, Painter.Screen.Y / 2);
        }
Example #29
0
 public Endscreen()
 {
     this.Add(new SpriteGameObject("endscreen_spr"));
     DonkeyKongBigDick          = new TextGameObject("gamefont");
     DonkeyKongBigDick.Text     = "you ded bro \n(SPACE to restart) \nScore: " + DonkeyKong.self.score;
     DonkeyKongBigDick.Position = new Vector2(175, 200);
     this.Add(DonkeyKongBigDick);
 }
Example #30
0
        public GameOverGameState()
        {
            text          = new TextGameObject("GameFont");
            text.Text     = "Game Over!";
            text.Position = new Vector2(200, 200);

            this.Add(text);
        }
        public TitleScreenState()
        {
            this.text          = new TextGameObject("GameFont");
            this.text.Text     = "Press \"space\" to start the game";
            this.text.Position = new Vector2((SpaceInvaders.Screen.X / 2) - (this.text.Size.X / 2), (SpaceInvaders.Screen.Y / 2) - (this.text.Size.Y / 2));

            this.Add(text);
        }
            public LANTab()
            {
                Point      screen  = GameEnvironment.Screen;
                SpriteFont arial26 = GameEnvironment.AssetManager.GetFont("Arial26");

                //Create a text field for the ip address
                ipAddress          = new TextField(arial26, Color.Black);
                ipAddress.Position = new Vector2((screen.X - ipAddress.Width) / 2, 50);
                ipAddress.Editable = true;
                Add(ipAddress);
                TextGameObject ipAddressLabel = new TextGameObject("Arial26");

                ipAddressLabel.Text     = "IP address: ";
                ipAddressLabel.Position = new Vector2(ipAddress.Position.X - ipAddressLabel.Size.X - 10, ipAddress.Position.Y);
                ipAddressLabel.Color    = Color.Black;
                Add(ipAddressLabel);

                //Create a text field for the user name
                userName          = new TextField(arial26, Color.Black);
                userName.Position = new Vector2((screen.X - userName.Width) / 2, 125);
                userName.Editable = true;
                Add(userName);
                TextGameObject userNameLabel = new TextGameObject("Arial26");

                userNameLabel.Text     = "Username: "******"button", "Connect", arial26, Color.Black);
                connectButton.Action = () =>
                {
                    GameEnvironment.GameSettingsManager.SetValue("user_name", userName.Text);
                    GameEnvironment.GameSettingsManager.SetValue("server_ip_address", ipAddress.Text);
                    GameSetupState gss = GameEnvironment.GameStateManager.GetGameState("gameSetupState") as GameSetupState;
                    gss.InitializeGameMode(GameSetupState.GameMode.MultiplayerClient);
                    GameEnvironment.GameStateManager.SwitchTo("gameSetupState");
                };
                //Create a button to start hosting.
                hostButton        = new Button("button", "Host a Game", arial26, Color.Black);
                hostButton.Action = () =>
                {
                    GameEnvironment.GameSettingsManager.SetValue("user_name", userName.Text);
                    GameSetupState gss = GameEnvironment.GameStateManager.GetGameState("gameSetupState") as GameSetupState;
                    gss.InitializeGameMode(GameSetupState.GameMode.MultiplayerHost);
                    GameEnvironment.GameStateManager.SwitchTo("gameSetupState");
                };

                int x = (screen.X - hostButton.Width - connectButton.Width - 25) / 2;

                hostButton.Position = new Vector2(x + connectButton.Width + 25, 200);
                Add(hostButton);

                connectButton.Position = new Vector2(x, 200);
                Add(connectButton);
            }
Example #33
0
    public void LoadTiles(string path)
    {
        //Haalt de tekst uit tekstfile
        int width;
        List<string> textlines = new List<string>();
        StreamReader fileReader = new StreamReader(path);
        string line = fileReader.ReadLine();
        width = line.Length;
        while (line != null)
        {
            textlines.Add(line);
            line = fileReader.ReadLine();
        }

        //Tijdslimiet i wordt afgelezen uit tekstfile
        int i = int.Parse(textlines[textlines.Count - 1]);
        SpriteGameObject timerBackground = new SpriteGameObject("Sprites/spr_timer", 100, "timerBackground");
        timerBackground.Position = new Vector2(10, 10);
        this.Add(timerBackground);
        TimerGameObject timer = new TimerGameObject(i, 101, "timer");
        timer.Position = new Vector2(25, 30);
        this.Add(timer);

        int height = textlines.Count - 2;

        //Creƫert het speelveld
        TileField tiles = new TileField(textlines.Count - 2, width, 1, "tiles");

        //Plaatst de hintbutton
        GameObjectList hintfield = new GameObjectList(100, "hintfield");
        this.Add(hintfield);
        string hint = textlines[textlines.Count - 2];
        SpriteGameObject hint_frame = new SpriteGameObject("Overlays/spr_frame_hint", 1, "hint_frame");
        hintfield.Position = new Vector2((GameEnvironment.Screen.X - hint_frame.Width) / 2, 10);
        hintfield.Add(hint_frame);
        TextGameObject hintText = new TextGameObject("Fonts/HintFont", 2, "hintText");
        hintText.Text = hint;
        hintText.Position = new Vector2(120, 25);
        hintText.Color = Color.Black;
        hintfield.Add(hintText);
        VisibilityTimer hintTimer = new VisibilityTimer(hintfield, 1, "hintTimer");
        this.Add(hintTimer);

        //Vult het speelveld met de goede tiles
        this.Add(tiles);
        tiles.CellWidth = 72;
        tiles.CellHeight = 55;
        for (int x = 0; x < width; ++x)
            for (int y = 0; y < textlines.Count - 2; ++y)
            {
                Tile t = LoadTile(textlines[y][x], x, y);
                tiles.Add(t, x, y);
            }

        levelwidth = width * tiles.CellWidth;
        levelheight = height * tiles.CellHeight;
    }
Example #34
0
    public LevelButton(int levelIndex, string imageAsset, int layer = 0, string id = "")
        : base(imageAsset, layer, id)
    {
        this.levelIndex = levelIndex;

        text          = new TextGameObject("Fonts/Hud", 1);
        text.Text     = levelIndex.ToString();
        text.Position = new Vector2(sprite.Width - text.Size.X - 10, 5);
    }
Example #35
0
        public Player(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            exp             = info.GetInt32("exp");
            freeStatPoints  = info.GetInt32("freeStatPoints");
            playerNameTitle = info.GetValue("playerNameTitle", typeof(TextGameObject)) as TextGameObject;
            playerType      = (PlayerType)info.GetValue("playerType", typeof(PlayerType));

            mouseSlot = info.TryGUIDThenFull <MouseSlot>(context, "mouseSlot");
        }
Example #36
0
        public EndGameOverlay() : base()
        {
            background = new Switch("Sprites/Backgrounds/spr_game_over", Depth.OverlayBackground);
            AddChild(background);

            tagButton = new Switch("Sprites/Buttons/spr_btn_tag", Depth.OverlayButton);
            AddChild(tagButton);
            tagButton.SetOriginToLeftTop();
            tagButton.LocalPosition = new Vector2(20, 120);

            getBallButton = new Switch("Sprites/Buttons/spr_btn_getball", Depth.OverlayButton);
            AddChild(getBallButton);
            getBallButton.LocalPosition = new Vector2(400, 770);

            rankButton = new Switch("Sprites/Buttons/spr_btn_rank", Depth.OverlayButton);
            AddChild(rankButton);
            rankButton.SetOriginToLeftBottom();
            rankButton.LocalPosition = new Vector2(30, 1100);

            replayButton = new Switch("Sprites/Buttons/spr_btn_replay", Depth.OverlayButton);
            replayButton.SetOriginToCenterBottom();
            AddChild(replayButton);
            replayButton.LocalPosition = new Vector2(350, 1100);

            shareButton = new Switch("Sprites/Buttons/spr_btn_share", Depth.OverlayButton);
            AddChild(shareButton);
            shareButton.SetOriginToRightBottom();
            shareButton.LocalPosition = new Vector2(670, 1100);

            scoreText = new TextGameObject("Fonts/EndGameScore", Depth.OverlayButton, Color.White, TextGameObject.HorizontalAlignment.Center, TextGameObject.VerticalAlignment.Center);
            AddChild(scoreText);
            scoreText.LocalPosition = new Vector2(350, 252);

            highScoreText = new TextGameObject("Fonts/EndGameHighScore", Depth.OverlayButton, Color.White, TextGameObject.HorizontalAlignment.Center, TextGameObject.VerticalAlignment.Center);
            AddChild(highScoreText);
            highScoreText.LocalPosition = new Vector2(350, 400);

            additionMoneyText = new TextGameObject("Fonts/EndGameMoney", Depth.OverlayButton, Color.White, TextGameObject.HorizontalAlignment.Right, TextGameObject.VerticalAlignment.Center);
            AddChild(additionMoneyText);
            additionMoneyText.LocalPosition = new Vector2(640, 620);

            totalMoneyText = new TextGameObject("Fonts/EndGameMoney", Depth.OverlayButton, Color.White, TextGameObject.HorizontalAlignment.Left, TextGameObject.VerticalAlignment.Center);
            AddChild(totalMoneyText);
            totalMoneyText.LocalPosition = new Vector2(150, 620);

            getBallOverlay = new GetBallOverlay();
            AddChild(getBallOverlay);

            confirmOverlay = new ConfirmOverlay(getBallOverlay);
            AddChild(confirmOverlay);

            tagOverlay = new TagOverlay();
            AddChild(tagOverlay);

            warningOverlay = new WarningOverlay();
            AddChild(warningOverlay);
        }
Example #37
0
 public LevelButton(int levelIndex, LevelStatus startStatus)
     : base(levelIndex, startStatus)
 {
     // add a label that shows the level index
     label = new TextGameObject("Fonts/MainFont", 1, Color.White, TextGameObject.Alignment.Right);
     label.LocalPosition = new Vector2(sprite.Width - 15, 10);
     label.Parent        = this;
     label.Text          = levelIndex.ToString();
 }
Example #38
0
    public Level(Player player = null)
    {
        completed = false;
        if (player != null)
        {
            this.player = player;
        }

        exitText = new TextGameObject("text");
        noteText = new TextGameObject("text");
        noteText.text = "Press F to pick up the note";
    }
    /// <summary>Load the level.</summary>
    public void LoadTiles(string path)
    {
        this.path = path;
        List<string> textlines = new List<string>();
        StreamReader fileReader = new StreamReader(path);
        string line = fileReader.ReadLine(); // first row of the level
        width = line.Length; // calculated level width
        while (line != null)
        {
            // read all lines
            textlines.Add(line);
            line = fileReader.ReadLine();
        }
        height = textlines.Count - 2;

        // add the hint
        GameObjectList hintfield = new GameObjectList(100);
        Add(hintfield);
        SpriteGameObject hint_frame = new SpriteGameObject("Overlays/spr_frame_hint", 1); // hint background
        hintfield.Position = new Vector2((GameEnvironment.Screen.X - hint_frame.Width) / 2, 10);
        hintfield.Add(hint_frame);
        TextGameObject hintText = new TextGameObject("Fonts/HintFont", 2); // hint text
        hintText.Text = textlines[textlines.Count - 2]; // last line in the level descriptor
        hintText.Position = new Vector2(120, 25);
        hintText.Color = Color.Black;
        hintfield.Add(hintText);
        VisibilityTimer hintTimer = new VisibilityTimer(hintfield, 1, "hintTimer"); // timeout
        Add(hintTimer);

        TimerGameObject timer = new TimerGameObject(101, "timer");
        timer.Position = new Vector2(25, 30);
        timer.TimeLeft = TimeSpan.FromSeconds(double.Parse(textlines[textlines.Count - 1]));
        Add(timer);

        // construct the level
        TileField tiles = new TileField(height, width, 1, "tiles");
        Add(tiles);
        // tile dimentions
        tiles.CellWidth = 72;
        cellWidth = 72;

        tiles.CellHeight = 55;
        cellHeight = 55;
        
        for (int x = 0; x < width; ++x)
            for (int y = 0; y < height; ++y)
            {
                Tile t = LoadTile(textlines[y][x], x, y);
                tiles.Add(t, x, y);
            }
    }
    /// <summary>Create a level button.</summary>
    /// <param name="levelIndex">The index of the level.</param>
    /// <param name="level">The level to start.</param>
    public LevelButton(int levelIndex, Level level, int layer = 0, string id = "") : base(layer, id)
    {
        this.levelIndex = levelIndex;
        this.level = level;

        levels_solved = new SpriteGameObject("Sprites/spr_level_solved", 0, "", levelIndex - 1);
        levels_unsolved = new SpriteGameObject("Sprites/spr_level_unsolved");
        spr_lock = new SpriteGameObject("Sprites/spr_level_locked", 2);
        Add(levels_solved);
        Add(levels_unsolved);
        Add(spr_lock);

        text = new TextGameObject("Fonts/Hud", 1);
        text.Text = levelIndex.ToString();
        text.Position = new Vector2(spr_lock.Width - text.Size.X - 10, 5);
        Add(text);
    }
    public SpecialLevel(int roomNumber, string name, bool saved = false)
    {
        drawSaveText = saved;
        firstTime = true;

        //Adding the player and grid
        player = new Player(Vector3.Zero);
        player.Parent = this;
        tileGrid = LoadLevel(name);
        tileGrid.Parent = this;
        gameObjects.Add(tileGrid);
        player.LoadContent();
        gameObjects.Add(player);

        //Setting the roomcounter
        roomCounter = new TextGameObject("text");
        roomCounter.text = roomNumber.ToString();
        //Adding the hanging man
        if (roomCounter.text == "100")
        {
            BillBoard man = new BillBoard(new Vector3(700, 210, 200));
            man.Parent = this;
            gameObjects.Add(man);
        }

        if (drawSaveText)
        {
            saveText = new TextGameObject("text");
            saveText.text = "Progress Saved";
            saveText.Position = new Vector2((GameEnvironment.Screen.X - saveText.Size.X) / 2, 0);
        }
        if (name == "Content\\Special Levels\\Final.txt")
            exitText.text = "Press E to kill yourself";
        else
            exitText.text = "Press E to proceed";

        //Adding the roomcounter
        gameObjects.Add(roomCounter);

        //Adding stamina
        stamina = new Stamina();
        stamina.Parent = this;
        gameObjects.Add(stamina);
    }
    public MultipleExitLevel(int roomNumber = 1)
    {
        part = 0;
        CreateGrids();
        Add(grids[part]);
        Add(player);
        completed = false;
        firstTime = true;
        player.Grid = grids[part];
        stamina = new Stamina();
        stamina.Parent = this;
        gameObjects.Add(stamina);

        exitText.text = "Press E to proceed";

        roomCounter = new TextGameObject("text");
        roomCounter.text = roomNumber.ToString();
        gameObjects.Add(roomCounter);
    }
    public void LoadTiles(string path)
    {
        int width;
        List<string> textlines = new List<string>();
        StreamReader fileReader = new StreamReader(path);
        string line = fileReader.ReadLine();
        width = line.Length;
        while (line != null)
        {
            textlines.Add(line);
            line = fileReader.ReadLine();
        }
        TileField tiles = new TileField(textlines.Count - 2, width, 1, "tiles");

        GameObjectList hintfield = new GameObjectList(100);
        this.Add(hintfield);
        string hint = textlines[textlines.Count - 1];
        SpriteGameObject hint_frame = new SpriteGameObject("Overlays/spr_frame_hint", 1);
        hintfield.Position = new Vector2((GameEnvironment.Screen.X - hint_frame.Width) / 2, 10);
        hint_frame.Meebewegen();
        hintfield.Add(hint_frame);
        TextGameObject hintText = new TextGameObject("Fonts/HintFont", 2);
        hintText.Text = textlines[textlines.Count - 2];
        hintText.Position = new Vector2(120, 25);
        hintText.Color = Color.Black;
        hintfield.Add(hintText);
        VisibilityTimer hintTimer = new VisibilityTimer(hintfield, 1, "hintTimer");
        this.Add(hintTimer);

        GameObject.lvltimer = Convert.ToDouble(textlines[textlines.Count - 1]); // de laatste lijn in de textfile heeft de tijd

        this.Add(tiles);
        tiles.CellWidth = 72;
        tiles.CellHeight = 55;
        for (int x = 0; x < width; ++x)
            for (int y = 0; y < textlines.Count - 2; ++y)
            {
                Tile t = LoadTile(textlines[y][x], x, y);
                tiles.Add(t, x, y);
            }
    }
    /// <summary>
    /// Creating/generating the level itself
    /// </summary>
    /// <param name="roomNumber">The number of the room</param>
    /// <param name="tiles">The size the Mainpath should be, counted in tiles</param>
    /// <param name="chased">Whether or not the monster is chasing the player</param>
    public RandomLevel(int roomNumber, int tiles = 12, bool chased = false, int noteID = 0)
    {
        //Setting a boolean for the monster
        this.chased = chased;

        //Assining the variables
        tileList = new Dictionary<Point, Tile>();
        keyList = new List<Point>();

        random = GameEnvironment.Random;

        //Select the tiles to use
        int pathType = random.Next(4);
        if (pathType < 9)
            pathID = "0" + (pathType + 1);
        else
            pathID = "" + (pathType + 1);

        int wallType = random.Next(4);
        if (wallType < 9)
            wallID = "0" + (wallType + 1);
        else
            pathID = "" + (wallType + 1);
        newTile = new EntryTile(pathID);
        this.tiles = tiles;

        //Create the startpoint
        position = Point.Zero;
        tileList.Add(position, newTile);
        keyList.Add(position);

        //Creating the paths
        CreateMainPath();
        for (int i = random.Next(1, (int)Math.Pow(tiles,2/3)); i > 0; i--)
            CreateSidePath(random.Next(3, 15), chased);

        //making the tile grid
        TileGrid tileGrid = Grid;
        gameObjects.Add(tileGrid);

        //making the player
        player = new Player(Vector3.Zero);
        gameObjects.Add(player);
        player.Parent = this;
        player.LoadContent();

        foreach(GameObject obj in tileGrid.Objects)
        {
            if (obj != null)
                if(obj.ID == "EntryTile")
                {
                    player.Position = new Vector3(obj.Position.X, obj.Position.Y + GameObjectGrid.CellHeight, obj.Position.Z);
                    foreach(GameObject tile in tileGrid.Objects)
                    {
                        if (tile != null)
                        {
                            if (tile.Position.X == obj.Position.X + 200 && tile.Position.Z == obj.Position.Z && tile.ID == "PathTile")
                                player.viewAngleX = 0f;
                            if (tile.Position.X == obj.Position.X && tile.Position.Z == obj.Position.Z + 200 && tile.ID == "PathTile")
                                player.viewAngleX = (float)(Math.PI / 2);
                            if (tile.Position.X == obj.Position.X - 200 && tile.Position.Z == obj.Position.Z && tile.ID == "PathTile")
                                player.viewAngleX = (float)(Math.PI);
                            if (tile.Position.X == obj.Position.X && tile.Position.Z == obj.Position.Z - 200 && tile.ID == "PathTile")
                                player.viewAngleX = (float)(Math.PI * 1.5);
                        }
                    }
                }
        }

        //Adding decoration objects
        TileGrid grid = Find("TileGrid") as TileGrid;
        for (int x = 0; x < grid.Columns; x++)
            for (int y = 0; y < grid.Rows; y++)
                if (grid.Get(x, y) != null)
                {
                    if (grid.Get(x, y).ID == "WallTile" && GameEnvironment.Random.Next(15) == 0)
                    {
                        try
                        {
                            if (grid.Get(x + 1, y) != null && grid.Get(x + 1, y).ID == "PathTile" && grid.Get(x + 1, y).ID != "DecorationTile")
                            {
                                AddDecoration(grid.Get(x, y).Position, new Vector3(-1, 0, 0));
                                grid.Add(new DecorationTile(pathID), x + 1, y);
                            }
                            else if (grid.Get(x, y + 1) != null && grid.Get(x, y + 1).ID == "PathTile" && grid.Get(x, y + 1).ID != "DecorationTile")
                            {
                                AddDecoration(grid.Get(x, y).Position, new Vector3(0, 0, -1));
                                grid.Add(new DecorationTile(pathID), x, y + 1);
                            }
                            else if (grid.Get(x - 1, y) != null && grid.Get(x - 1, y).ID == "PathTile" && grid.Get(x - 1, y).ID != "DecorationTile")
                            {
                                AddDecoration(grid.Get(x, y).Position, new Vector3(1, 0, 0));
                                grid.Add(new DecorationTile(pathID), x - 1, y);
                            }
                            else if (grid.Get(x, y - 1) != null && grid.Get(x, y - 1).ID == "PathTile" && grid.Get(x, y - 1).ID != "DecorationTile")
                            {
                                AddDecoration(grid.Get(x, y).Position, new Vector3(0, 0, 1));
                                grid.Add(new DecorationTile(pathID), x, y - 1);
                            }
                        }
                        catch (IndexOutOfRangeException e) { Console.WriteLine(e.StackTrace); }
                    }
                }

        //Add the note
        if (noteID != 0)
        {
            NoteObject note = new NoteObject(noteID.ToString());
            note.Parent = this;
            CreateNote(note, tileGrid);
            gameObjects.Add(note);
        }

        //Making the monster
        if (chased)
        {
            monster = new Monster(Grid.Objects);
            monster.Parent = this;
            monster.LoadContent();
            gameObjects.Add(monster);
        }

        //Making the stamina bar
        stamina = new Stamina();
        gameObjects.Add(stamina);
        stamina.Parent = this;
        exitText.text = "Press E to proceed";

        //Making the room counter
        roomCounter = new TextGameObject("text");
        roomCounter.text = roomNumber.ToString();
        gameObjects.Add(roomCounter);
    }