Ejemplo n.º 1
0
 /// <summary>
 /// Consturctor
 /// </summary>
 public TdMobSprite()
     : base(TPEngine.Get().TextureManager.LoadTexture(@"art/TowerDefense/mob"))
 {
     m_Texture   = TPEngine.Get().TextureManager.LoadTexture(@"art/TowerDefense/mob");
     greenHealth = TPEngine.Get().TextureManager.LoadTexture(@"art/TowerDefense/greenhealth");
     redHealth   = TPEngine.Get().TextureManager.LoadTexture(@"art/TowerDefense/redhealth");
 }
Ejemplo n.º 2
0
 protected override void Load()
 {
     base.Load();
     ScreenSize = TPEngine.Get().ScreenSize;
     m_ScreenBufferRenderTarget = new RenderTarget2D(m_GDevice,
                                                     ScreenSize.Width, ScreenSize.Height, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8, 1, RenderTargetUsage.PreserveContents);
 }
Ejemplo n.º 3
0
 public TPOptionList(int offsetY = 75)
 {
     m_Font          = TPEngine.Get().FontManager.LoadFont(@"fonts\testfont");
     OffsetY         = offsetY;
     this.Position.X = 220;
     this.Position.Y = 170;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Unlocks a class of towers
        /// </summary>
        /// <param name="towerName">name of the tower class</param>
        public static void UnlockTowerButton(string towerName)
        {
            switch (towerName)
            {
            case "fast":
                if (!FastTower.Unlocked && FastTower.UnlockTowerClass())
                {
                    BottomBar.addButton(TPEngine.Get().TextureManager.LoadTexture(@"art/TowerDefense/Bot_FastTower"),
                                        "fast",
                                        TowerBuilder.TowerBuildingClicked);
                }
                break;

            case "strong":
                if (!StrongTower.Unlocked && StrongTower.UnlockTowerClass())
                {
                    BottomBar.addButton(TPEngine.Get().TextureManager.LoadTexture(@"art/TowerDefense/Bot_StrongTower"),
                                        "strong",
                                        TowerBuilder.TowerBuildingClicked);
                }
                break;

            case "spray":
                if (!SprayTower.Unlocked && SprayTower.UnlockTowerClass())
                {
                    BottomBar.addButton(TPEngine.Get().TextureManager.LoadTexture(@"art/TowerDefense/Bot_SprayTower"),
                                        "spray",
                                        TowerBuilder.TowerBuildingClicked);
                }
                break;
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Quits the TowerDefense game
 /// </summary>
 /// <param name="name">variable passed through by the button</param>
 public void quitGame(string name)
 {
     if (!dead)
     {
         dead = true;
         TPEngine.Get().GameRef.Exit();
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// LoadContent will be called once per game and is the place to load
 /// all of your content.
 /// </summary>
 protected override void LoadContent()
 {
     // Create a new SpriteBatch, which can be used to draw textures.
     base.LoadContent();
     anim1 = Content.Load <GifAnimation.GifAnimation>("chip4");
     anim2 = Content.Load <GifAnimation.GifAnimation>("mob1");
     TPEngine.Get().State.PushState(new TDBaseState(), true);
 }
Ejemplo n.º 7
0
 protected override void Load()
 {
     base.Load();
     if (UseRenderTarget)
     {
         m_RenderTarget = new RenderTarget2D(TPEngine.Get().GameRef.GraphicsDevice,
                                             viewportBounds.Width, viewportBounds.Height, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8, 1, RenderTargetUsage.DiscardContents);
     }
 }
Ejemplo n.º 8
0
 public override void Update(GameTime gameTime)
 {
     base.Update(gameTime);
     //if the Esc key is pressed, return to the main game
     if (Keyboard.GetState().IsKeyDown(Keys.Escape))
     {
         TPEngine.Get().State.PopState();
     }
 }
Ejemplo n.º 9
0
 public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
 {
     base.Update(gameTime);
     if (Keyboard.GetState().IsKeyDown(Keys.X) && prevState.IsKeyUp(Keys.X))
     {
         TPEngine.Get().State.PopState();
     }
     prevState = Keyboard.GetState();
 }
Ejemplo n.º 10
0
        public TPState()
        {
            //set default viewport to entire window
            viewportBounds = TPEngine.Get().GameRef.GraphicsDevice.Viewport;

            layers = new TPLayerList();

            m_DefaultLayer = new TPLayer(layers);
            //m_DrawLayer = new TPLayer(layers);
            UseRenderTarget = false;
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Starts the TDGame state
 /// </summary>
 /// <param name="name">variable passed from button</param>
 public void startGame(string name)
 {
     if (!dead)
     {
         Tower.ResetTowerLocks();
         TDPlayerStats.ResetStats();
         TPEngine.Get().State.PopState();
         TPEngine.Get().State.PushState(new TDState(), true);
         dead = true;
     }
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Draws the score screen.
        /// </summary>
        /// <param name="batch"></param>
        public override void Draw(SpriteBatch batch)
        {
            base.Draw(batch);
            batch.Begin();
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Score:           " + TDPlayerStats.Grade + "/100");
            sb.AppendLine("Virus' Killed:       " + TDPlayerStats.KillCount);
            sb.AppendLine("Remaining Money:     " + TDPlayerStats.Money);
            batch.DrawString(Font, sb.ToString(), new Vector2(TPEngine.Get().ScreenSize.Width / 2 - 100, 200), new Color(0, 240, 240));
            sb = null;
            batch.End();
        }
Ejemplo n.º 13
0
        public void AddItem(string label, TPRollingTextOnSelect callback)
        {
            TPRollingTextMenuItem item = new TPRollingTextMenuItem(label, callback);

            item.Position.X = this.Position.X + TPEngine.Get().FontManager.LoadFont(@"fonts\testfont").MeasureString(item.ToString()).X / 4;
            item.Position.Y = this.Position.Y;
            m_MenuItemSet.Add(item);
            if (m_MenuItemSet.Count == 1)
            {
                m_Index = 0;
            }
            SetTargets();
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Creates the buy menu
        /// </summary>
        private static void CreateBuyWindow()
        {
            BuyMenu = new Window(740, 100, false, TPEngine.Get().TextureManager.LoadTexture(@"art/TowerDefense/BuyMenu"));

            BuyMenu.addButton(TPEngine.Get().TextureManager.LoadTexture(@"art/TowerDefense/Bot_FastTower"),
                              "fast",
                              UnlockTowerButton);
            BuyMenu.addButton(TPEngine.Get().TextureManager.LoadTexture(@"art/TowerDefense/Bot_StrongTower"),
                              "strong",
                              UnlockTowerButton);
            BuyMenu.addButton(TPEngine.Get().TextureManager.LoadTexture(@"art/TowerDefense/Bot_SprayTower"),
                              "spray",
                              UnlockTowerButton);
        }
Ejemplo n.º 15
0
 private void SetTargets()
 {
     for (int i = 0; i < m_MenuItemSet.Count; i++)
     {
         if (i < m_Index - 2)
         {
             m_MenuItemSet[i].PositionTarget.Y = this.Position.Y + OFFSETS[0];
             m_MenuItemSet[i].AlphaTarget      = ALPHAS[0];
             m_MenuItemSet[i].ScaleTarget      = SCALE_MINUTE;
         }
         if (i == m_Index - 2)
         {
             m_MenuItemSet[i].PositionTarget.Y = this.Position.Y + OFFSETS[1];
             m_MenuItemSet[i].AlphaTarget      = ALPHAS[1];
             m_MenuItemSet[i].ScaleTarget      = SCALE_SMALL;
         }
         if (i == m_Index - 1)
         {
             m_MenuItemSet[i].PositionTarget.Y = this.Position.Y + OFFSETS[2];
             m_MenuItemSet[i].AlphaTarget      = ALPHAS[2];
             m_MenuItemSet[i].ScaleTarget      = SCALE_MEDIUM;
         }
         if (i == m_Index)
         {
             m_MenuItemSet[i].PositionTarget.Y = this.Position.Y + OFFSETS[3];
             m_MenuItemSet[i].AlphaTarget      = ALPHAS[3];
             m_MenuItemSet[i].ScaleTarget      = SCALE_LARGE;
             //m_MenuItemSet[i].RenderColor = Color.White;
         }
         if (i == m_Index + 1)
         {
             m_MenuItemSet[i].PositionTarget.Y = this.Position.Y + OFFSETS[4];
             m_MenuItemSet[i].AlphaTarget      = ALPHAS[2];
             m_MenuItemSet[i].ScaleTarget      = SCALE_MEDIUM;
         }
         if (i == m_Index + 2)
         {
             m_MenuItemSet[i].PositionTarget.Y = this.Position.Y + OFFSETS[5];
             m_MenuItemSet[i].AlphaTarget      = ALPHAS[1];
             m_MenuItemSet[i].ScaleTarget      = SCALE_SMALL;
         }
         if (i > m_Index + 2)
         {
             m_MenuItemSet[i].PositionTarget.Y = this.Position.Y + OFFSETS[6];
             m_MenuItemSet[i].AlphaTarget      = ALPHAS[0];
             m_MenuItemSet[i].ScaleTarget      = SCALE_MINUTE;
         }
         m_MenuItemSet[i].PositionTarget.X = this.Position.X + TPEngine.Get().FontManager.LoadFont(@"fonts\testfont").MeasureString(m_MenuItemSet[i].ToString()).X / 4;
     }
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Everything included with building the bottom menu bar should go here.
        /// </summary>
        private static void CreateBottomBar()
        {
            BottomBar = new Window(0, 620, true, TPEngine.Get().TextureManager.LoadTexture(@"art/TowerDefense/BotBar"));


            BottomBar.addButton(TPEngine.Get().TextureManager.LoadTexture(@"art/TowerDefense/BuyButton"),
                                "BuyButton",
                                MakeBuyWindowVisible);

            BottomBar.addButton(TPEngine.Get().TextureManager.LoadTexture(@"art/TowerDefense/Bot_NormalTower"),
                                "normal",
                                TowerBuilder.TowerBuildingClicked);

            NormalTower.UnlockTowerClass();
        }
Ejemplo n.º 17
0
        /// <summary>
        /// This is where all the Tower defense update calls should be placed so that it is easy to transfer our
        /// project over to the main one without having to add a lot of code to the main program.
        /// </summary>
        /// <param name="gametime">current game time</param>
        /// <param name="keyboard">keyboard state</param>
        /// <param name="mouse">mouse state</param>
        public static void Update(GameTime gametime, KeyboardState keyboard, MouseState mouse)
        {
            Random random = new Random();

            if (LastWaveUpdate == TimeSpan.Zero)
            {
                LastWaveUpdate = gametime.TotalGameTime;
            }

            if (currentWave != null && !currentWave.complete)
            {
                currentWave.update(gametime);
                LastWaveUpdate = gametime.TotalGameTime;
            }
            else if ((gametime.TotalGameTime - LastWaveUpdate) > SpawnNextWaveIn)
            {
                if (TDPlayerStats.currentWave == TDPlayerStats.maxWaves)
                {
                    TPEngine.Get().State.PopState();
                    TPEngine.Get().State.PushState(new TDScoreScreenState());
                }

                TDPlayerStats.Money += 5;
                TDPlayerStats.currentWave++;
                currentWave = new EnemyWave(random.Next(8, 12), 1);

                //LastWaveUpdate = gametime.TotalGameTime;
            }

            if (TDPlayerStats.Grade <= 0)
            {
                TPEngine.Get().State.PopState();
                TPEngine.Get().State.PushState(new TDScoreScreenState());
            }

            if (Keyboard.GetState().IsKeyDown(Keys.X) && !clicked)
            {
                TDPlayerStats.Grade = 0;
                TPEngine.Get().State.PopState();
                TPEngine.Get().State.PushState(new TDScoreScreenState());
                clicked = true;
            }
            TowerBuilder.UpdateKeyboardInput(keyboard, mouse);
            Enemy.Update(gametime);
            Tower.Update(gametime);
            Projectile.UpdateProjectiles(gametime);
            Window.Update(gametime, keyboard, mouse);
        }
Ejemplo n.º 18
0
 public override void Draw(SpriteBatch batch)
 {
     //Reset the viewport in case it has been altered and not fixed by another state.
     TPEngine.Get().GameRef.GraphicsDevice.Viewport = ScreenSize;
     m_GDevice.SetRenderTarget(m_ScreenBufferRenderTarget);
     m_GDevice.Clear(Color.Black);
     for (int counter = 0; counter < stateStack.Count; counter++)
     {
         stateStack[counter].Draw(batch);
     }
     m_GDevice.SetRenderTarget(null);
     batch.Begin();
     batch.Draw(m_ScreenBufferRenderTarget, Vector2.Zero, Color.White);
     batch.End();
     base.Draw(batch);
 }
Ejemplo n.º 19
0
        protected override void Load()
        {
            base.Load();
            myLayers = new TPLayer[NumLayers];
            for (int x = 0; x < NumLayers; x++)
            {
                myLayers[x] = new TPLayer(this.layers);
            }

            mySprite = new Bullseye(new Vector2(200, 200));
            myLayers[2].AddEntity(mySprite);

            backgroundTexture          = new TPSprite(TPEngine.Get().TextureManager.LoadTexture(@"art/minigame/emaildetail"));
            backgroundTexture.Position = new Vector2(backgroundTexture.Position.X, backgroundTexture.Position.Y);
            myLayers[0].AddEntity(backgroundTexture);

            myLayers[2].AddEntity(bulletHole);
            myLayers[2].AddEntity(explosion);

            from.Position.X  = 240;
            from.Position.Y  = 165;
            from.RenderColor = Color.Black;

            subject.Position.X  = 240 + from.HalfSize.X;
            subject.Position.Y  = 250;
            subject.RenderColor = Color.Black;

            body.Position.X  = 300;
            body.Position.Y  = 400;
            body.RenderColor = Color.Black;

            myLayers[1].AddEntity(from);
            myLayers[1].AddEntity(subject);
            myLayers[1].AddEntity(body);

            if (FirstRunDetail)
            {
                TPEngine.Get().SpriteDictionary.Add("bulletHoleDetail", bulletHole);
                TPEngine.Get().SpriteDictionary.Add("explosionDetail", explosion);
                TPEngine.Get().SpriteDictionary.Add("MinigameMySpriteDetail", mySprite);
                TPEngine.Get().StringDictionary.Add("fromDetail", from);
                TPEngine.Get().StringDictionary.Add("subjectDetail", subject);
                TPEngine.Get().StringDictionary.Add("bodyDetail", body);
                FirstRunDetail = false;
            }
            //TPEngine.Get().StringDictionary.Add("MinigameLevel", level);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Constructor of the TDStartState
        /// </summary>
        public TDStartState()
        {
            tdMouse  = new TDPointer(new Vector2(200, 200));
            TDLayers = new TPLayer[numLayers];
            for (int i = 0; i < numLayers; i++)
            {
                TDLayers[i] = new TPLayer(layers);
            }
            background = new TPSprite(TPEngine.Get().TextureManager.LoadTexture(@"art/TowerDefense/StartScreenBackground"));
            TDLayers[0].AddEntity(background);
            TDLayers[numLayers - 1].AddEntity(tdMouse);
            TowerDefenseManager.setLayers(TDLayers);

            menuwindow = new Window(menuxpos, menuypos, true, TPEngine.Get().TextureManager.LoadTexture(@"art/TowerDefense/startscreenWindow"));
            menuwindow.addButton(TPEngine.Get().TextureManager.LoadTexture(@"art/TowerDefense/StartButton"), "start", startGame);
            menuwindow.addButton(TPEngine.Get().TextureManager.LoadTexture(@"art/TowerDefense/ExitButton"), "exit", quitGame);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Loads the resources used by this state
        /// </summary>
        protected override void Load()
        {
            base.Load();

            tdMouse  = new TDPointer(new Vector2(200, 200));
            TDLayers = new TPLayer[numLayers];
            for (int i = 0; i < numLayers; i++)
            {
                TDLayers[i] = new TPLayer(layers);
            }
            backgroundTexture = new TPSprite(TPEngine.Get().TextureManager.LoadTexture(@"art/TowerDefense/CurrentMap"));

            //backgroundTexture = new TPSprite(TPEngine.Get().TextureManager.LoadTexture(@"art/TowerDefense/mob"));
            TDLayers[0].AddEntity(backgroundTexture);
            TDLayers[5].AddEntity(tdMouse);

            map = new Map(1280, 720);
            TowerBuilder.Load(map);
            mp = new MapCreator(map);
            TowerDefenseManager.numLayers = numLayers;
            TowerDefenseManager.Start(map, TDLayers);
            Font = TPEngine.Get().FontManager.LoadFont(@"fonts/testfont");
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Ctor. This uses a default XNA font.
 /// </summary>
 /// <param name="inString">String we wish to display.</param>
 /// <param name="color">Color of the string.</param>
 public TPString(string inString, Color color) : this(inString, TPEngine.Get().FontManager.LoadFont(@"fonts\testfont"), color)
 {
 }
Ejemplo n.º 23
0
 /// <summary>
 /// pushes the starting state of the tower defense game on
 /// </summary>
 protected override void Load()
 {
     base.Load();
     TPEngine.Get().State.PushState(new TDStartState(), true);
 }
Ejemplo n.º 24
0
 public GameSprite(Vector2 pos)
     : base(TPEngine.Get().TextureManager.LoadTexture(@"art /[TPEngine]/[mytexturename]"))
 {
     Position = pos;
 }
Ejemplo n.º 25
0
 public TPOptionListItem(string str, TPOptionListCallback callback)
     : base(str, TPEngine.Get().FontManager.LoadFont(@"fonts\testfont"))
 {
     m_Callback = callback;
 }
Ejemplo n.º 26
0
 /// <summary>
 /// static initalization, loads the texture used by towers
 /// </summary>
 static TDNormalTowerSprite()
 {
     NormalTowerTexture = TPEngine.Get().TextureManager.LoadTexture(@"art/TowerDefense/Tower");
 }
Ejemplo n.º 27
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="pos">current position vector</param>
 public TDPointer(Vector2 pos)
     : base(TPEngine.Get().TextureManager.LoadTexture(@"art/alpha/tdpointer"))
 {
     Position = pos;
 }
Ejemplo n.º 28
0
 public TPSprite(string pathToTex)
     : this(TPEngine.Get().TextureManager.LoadTexture(pathToTex))
 {
 }
Ejemplo n.º 29
0
 public TPRollingTextMenuItem(string label, TPRollingTextOnSelect callback)
     : base(label, TPEngine.Get().FontManager.LoadFont(@"fonts\testfont_large"))
 {
     m_cbOnselect = callback;
 }
Ejemplo n.º 30
0
 /// <summary>
 /// consturctor
 /// </summary>
 public TDProjectileSprite()
     : base(TPEngine.Get().TextureManager.LoadTexture(@"art/TowerDefense/bolt"))
 {
 }