// private Effect m_Shader; // private RenderTarget2D m_ShaderRenderTarget; // might not need this // private Texture2D m_ShaderTexture; // might not need this public GameScene() { Tankontroller game = (Tankontroller)Tankontroller.Instance(); m_TankBaseTexture = game.CM().Load <Texture2D>("Tank-B-05"); m_TankBrokenTexture = game.CM().Load <Texture2D>("BrokenTank"); m_TankRightTrackTexture = game.CM().Load <Texture2D>("Tank track B-R"); m_TankLeftTrackTexture = game.CM().Load <Texture2D>("Tank track B-L"); m_CannonTexture = game.CM().Load <Texture2D>("cannon"); m_CannonFireTexture = game.CM().Load <Texture2D>("cannonFire"); m_BulletTexture = game.CM().Load <Texture2D>("circle"); mPlayAreaTexture = game.CM().Load <Texture2D>("playArea"); mPixelTexture = game.CM().Load <Texture2D>("block"); TrackSystem.SetupStaticMembers(game.CM().Load <Texture2D>("track")); TeamGUI.SetupStaticTextures( game.CM().Load <Texture2D>("port1"), game.CM().Load <Texture2D>("port2"), game.CM().Load <Texture2D>("port3"), game.CM().Load <Texture2D>("port4"), game.CM().Load <Texture2D>("port5"), game.CM().Load <Texture2D>("port6"), game.CM().Load <Texture2D>("port7"), game.CM().Load <Texture2D>("port8")); JackIcon.SetupStaticTextures( game.CM().Load <Texture2D>("leftTrackForward"), game.CM().Load <Texture2D>("leftTrackBackwards"), game.CM().Load <Texture2D>("rightTrackForward"), game.CM().Load <Texture2D>("rightTrackBackwards"), game.CM().Load <Texture2D>("fire"), game.CM().Load <Texture2D>("charge"), game.CM().Load <Texture2D>("none"), game.CM().Load <Texture2D>("turretLeft"), game.CM().Load <Texture2D>("turretRight")); PowerBar.SetupStaticTextures(game.CM().Load <Texture2D>("powerBar_border"), game.CM().Load <Texture2D>("powerBar_power")); m_CircleTexture = game.CM().Load <Texture2D>("circle"); m_SpriteBatch = new SpriteBatch(game.GDM().GraphicsDevice); /*m_Shader = game.CM().Load<Effect>("shader"); * m_ShaderRenderTarget = new RenderTarget2D(game.GDM().GraphicsDevice, * game.GDM().GraphicsDevice.PresentationParameters.BackBufferWidth, * game.GDM().GraphicsDevice.PresentationParameters.BackBufferHeight); * m_ShaderTexture = new Texture2D(game.GDM().GraphicsDevice, * game.GDM().GraphicsDevice.PresentationParameters.BackBufferWidth, * game.GDM().GraphicsDevice.PresentationParameters.BackBufferHeight, false, m_ShaderRenderTarget.Format); */ mBackgroundTexture = game.CM().Load <Texture2D>("background_01"); mBackgroundRectangle = new Rectangle(0, 0, game.GDM().GraphicsDevice.Viewport.Width, game.GDM().GraphicsDevice.Viewport.Height); mPlayAreaRectangle = new Rectangle(game.GDM().GraphicsDevice.Viewport.Width * 2 / 100, game.GDM().GraphicsDevice.Viewport.Height * 25 / 100, game.GDM().GraphicsDevice.Viewport.Width * 96 / 100, game.GDM().GraphicsDevice.Viewport.Height * 73 / 100); mPlayAreaOutlineRectangle = new Rectangle(mPlayAreaRectangle.X - 5, mPlayAreaRectangle.Y - 5, mPlayAreaRectangle.Width + 10, mPlayAreaRectangle.Height + 10); introMusicInstance = game.ReplaceCurrentMusicInstance("Music/Music_intro", false); mController0 = Tankontroller.Instance().Controller0(); mController1 = Tankontroller.Instance().Controller1(); mController2 = Tankontroller.Instance().Controller2(); mController3 = Tankontroller.Instance().Controller3(); mController0.ResetJacks(); mController1.ResetJacks(); if (DGS.Instance.GetInt("NUM_PLAYERS") > 2) { mController2.ResetJacks(); if (DGS.Instance.GetInt("NUM_PLAYERS") > 3) { mController3.ResetJacks(); } } //loopMusicInstance = game.GetSoundManager().GetLoopableSoundEffectInstance("Music/Music_loopable"); // Put the name of your song here instead of "song_title" // game.ReplaceCurrentMusicInstance("Music/Music_loopable", true); tankMoveSound = game.GetSoundManager().GetLoopableSoundEffectInstance("Sounds/Tank_Tracks"); // Put the name of your song here instead of "song_title" if (DGS.Instance.GetInt("NUM_PLAYERS") < 4) { setupNot4Player(mPlayAreaRectangle); } else { setup4Player(mPlayAreaRectangle); } foreach (Player p in m_Teams) { m_World.AddTank(p.Tank); } }
public StartScene() { Tankontroller game = (Tankontroller)Tankontroller.Instance(); mControllers = new List <IController>(); mController0 = Tankontroller.Instance().Controller0(); if (mController0 != null) { mControllers.Add(mController0); } mController1 = Tankontroller.Instance().Controller1(); if (mController1 != null) { mControllers.Add(mController1); } mController2 = Tankontroller.Instance().Controller2(); if (mController2 != null) { mControllers.Add(mController2); } mController3 = Tankontroller.Instance().Controller3(); if (mController3 != null) { mControllers.Add(mController3); } mSpriteBatch = new SpriteBatch(game.GDM().GraphicsDevice); int screenWidth = game.GDM().GraphicsDevice.Viewport.Width; int screenHeight = game.GDM().GraphicsDevice.Viewport.Height; mBackgroundTexture = game.CM().Load <Texture2D>("background_01"); mBackgroundRectangle = new Rectangle(0, 0, screenWidth, screenHeight); mForgroundTexture = game.CM().Load <Texture2D>("menu_white"); mTitleTexture = game.CM().Load <Texture2D>("menu_title"); mTitleRectangle = new Rectangle((screenWidth / 2) - (644 / 2), (screenHeight / 2) - (128 / 2), 644, 128); mButtonList = new ButtonList(); Texture2D startGameButtonTexture = game.CM().Load <Texture2D>("menu_play_white"); Texture2D startGameButtonTexturePressed = game.CM().Load <Texture2D>("menu_play_dark"); Rectangle startGameButtonRectangle = new Rectangle( ((int)((screenWidth - startGameButtonTexture.Width) / 2) - (int)(startGameButtonTexture.Width * 0.75f)), (screenHeight) / 2 + startGameButtonTexture.Height, startGameButtonTexture.Width, startGameButtonTexture.Height); Button startGameButton = new Button(startGameButtonTexture, startGameButtonTexturePressed, startGameButtonRectangle, Color.Red, StartGame); startGameButton.Selected = true; mButtonList.Add(startGameButton); Texture2D exitGameButtonTexture = game.CM().Load <Texture2D>("menu_quit_white"); Texture2D exitGameButtonTexturePressed = game.CM().Load <Texture2D>("menu_quit_dark"); Rectangle exitGameButtonRectangle = new Rectangle((screenWidth - exitGameButtonTexture.Width) / 2 + (int)(startGameButtonTexture.Width * 0.75f), (screenHeight) / 2 + exitGameButtonTexture.Width, exitGameButtonTexture.Width, exitGameButtonTexture.Height); Button exitGameButton = new Button(exitGameButtonTexture, exitGameButtonTexturePressed, exitGameButtonRectangle, Color.Red, ExitGame); exitGameButton.Selected = false; mButtonList.Add(exitGameButton); mSecondsLeft = 0.1f; game.ReplaceCurrentMusicInstance("Music/Music_start", true); }
private void setupNot4Player(Rectangle pPlayArea) { Tankontroller game = (Tankontroller)Tankontroller.Instance(); int middleBlockHeight = pPlayArea.Height / 3; int outerBlockHeight = pPlayArea.Height / 5; int blockThickness = pPlayArea.Width / 50; int outerBlockXOffset = pPlayArea.Width / 8; List <RectWall> Walls = new List <RectWall>(); Walls.Add(new RectWall(Tankontroller.Instance().CM().Load <Texture2D>("block"), new Rectangle(pPlayArea.X + outerBlockXOffset, pPlayArea.Y + outerBlockHeight, blockThickness, outerBlockHeight))); Walls.Add(new RectWall(Tankontroller.Instance().CM().Load <Texture2D>("block"), new Rectangle(pPlayArea.X + outerBlockXOffset, pPlayArea.Y + outerBlockHeight, outerBlockHeight, blockThickness))); Walls.Add(new RectWall(Tankontroller.Instance().CM().Load <Texture2D>("block"), new Rectangle(pPlayArea.X + outerBlockXOffset, pPlayArea.Y + 3 * outerBlockHeight, blockThickness, outerBlockHeight))); Walls.Add(new RectWall(Tankontroller.Instance().CM().Load <Texture2D>("block"), new Rectangle(pPlayArea.X + outerBlockXOffset, pPlayArea.Y + 4 * outerBlockHeight - blockThickness, outerBlockHeight, blockThickness))); Walls.Add(new RectWall(Tankontroller.Instance().CM().Load <Texture2D>("block"), new Rectangle(pPlayArea.X + pPlayArea.Width - outerBlockXOffset - blockThickness, pPlayArea.Y + outerBlockHeight, blockThickness, outerBlockHeight))); Walls.Add(new RectWall(Tankontroller.Instance().CM().Load <Texture2D>("block"), new Rectangle(pPlayArea.X + pPlayArea.Width - outerBlockXOffset - outerBlockHeight, pPlayArea.Y + outerBlockHeight, outerBlockHeight, blockThickness))); Walls.Add(new RectWall(Tankontroller.Instance().CM().Load <Texture2D>("block"), new Rectangle(pPlayArea.X + pPlayArea.Width - outerBlockXOffset - blockThickness, pPlayArea.Y + 3 * outerBlockHeight, blockThickness, outerBlockHeight))); Walls.Add(new RectWall(Tankontroller.Instance().CM().Load <Texture2D>("block"), new Rectangle(pPlayArea.X + pPlayArea.Width - outerBlockXOffset - outerBlockHeight, pPlayArea.Y + 4 * outerBlockHeight - blockThickness, outerBlockHeight, blockThickness))); Walls.Add(new RectWall(Tankontroller.Instance().CM().Load <Texture2D>("block"), new Rectangle(pPlayArea.X + 3 * outerBlockXOffset - 2 * blockThickness, pPlayArea.Y + middleBlockHeight, blockThickness, middleBlockHeight))); Walls.Add(new RectWall(Tankontroller.Instance().CM().Load <Texture2D>("block"), new Rectangle(pPlayArea.X + pPlayArea.Width - 3 * outerBlockXOffset + blockThickness, pPlayArea.Y + middleBlockHeight, blockThickness, middleBlockHeight))); Walls.Add(new RectWall(Tankontroller.Instance().CM().Load <Texture2D>("block"), new Rectangle(pPlayArea.X + pPlayArea.Width - 3 * outerBlockXOffset + 2 * blockThickness, pPlayArea.Y + (pPlayArea.Height - blockThickness) / 2, outerBlockHeight, blockThickness))); Walls.Add(new RectWall(Tankontroller.Instance().CM().Load <Texture2D>("block"), new Rectangle(pPlayArea.X + 3 * outerBlockXOffset - outerBlockHeight - 2 * blockThickness, pPlayArea.Y + (pPlayArea.Height - blockThickness) / 2, outerBlockHeight, blockThickness))); Walls.Add(new RectWall(Tankontroller.Instance().CM().Load <Texture2D>("block"), new Rectangle(pPlayArea.X + (pPlayArea.Width - blockThickness) / 2, pPlayArea.Y, blockThickness, middleBlockHeight))); Walls.Add(new RectWall(Tankontroller.Instance().CM().Load <Texture2D>("block"), new Rectangle(pPlayArea.X + (pPlayArea.Width - blockThickness) / 2, pPlayArea.Y + pPlayArea.Height - middleBlockHeight, blockThickness, middleBlockHeight))); List <Vector2> tankPositions = new List <Vector2>(); List <float> tankRotations = new List <float>(); if (DGS.Instance.GetInt("NUM_PLAYERS") == 2) { float xPosition = pPlayArea.X + outerBlockXOffset; float yPosition = pPlayArea.Y + pPlayArea.Height / 2; Vector2 tankPosition = new Vector2(xPosition, yPosition); tankPositions.Add(tankPosition); tankRotations.Add(0); xPosition = pPlayArea.X + pPlayArea.Width - outerBlockXOffset; yPosition = pPlayArea.Y + pPlayArea.Height / 2; tankPosition = new Vector2(xPosition, yPosition); tankPositions.Add(tankPosition); tankRotations.Add((float)Math.PI); } else if (DGS.Instance.GetInt("NUM_PLAYERS") == 3) { float xPosition = pPlayArea.X + outerBlockXOffset; float yPosition = pPlayArea.Y + pPlayArea.Height / 2; Vector2 tankPosition = new Vector2(xPosition, yPosition); tankPositions.Add(tankPosition); tankRotations.Add(0); xPosition = pPlayArea.X + pPlayArea.Width - outerBlockXOffset; yPosition = pPlayArea.Y + pPlayArea.Height / 2; tankPosition = new Vector2(xPosition, yPosition); tankPositions.Add(tankPosition); tankRotations.Add((float)Math.PI); xPosition = pPlayArea.Width / 2 + 35; yPosition = pPlayArea.Y + pPlayArea.Height / 2; tankPosition = new Vector2(xPosition, yPosition); tankPositions.Add(tankPosition); tankRotations.Add((float)Math.PI / 2); } else if (DGS.Instance.GetInt("NUM_PLAYERS") == 4) { float xPosition = pPlayArea.X + outerBlockXOffset / 2; float yPosition = pPlayArea.Y + outerBlockXOffset / 2; Vector2 tankPosition = new Vector2(xPosition, yPosition); tankPositions.Add(tankPosition); tankRotations.Add((float)(-Math.PI + Math.PI / 4)); xPosition = pPlayArea.X + pPlayArea.Width - outerBlockXOffset / 2; yPosition = pPlayArea.Y + outerBlockXOffset / 2; tankPosition = new Vector2(xPosition, yPosition); tankPositions.Add(tankPosition); tankRotations.Add((float)-Math.PI / 4); xPosition = pPlayArea.X + outerBlockXOffset / 2; yPosition = pPlayArea.Y + pPlayArea.Height - outerBlockXOffset / 2; tankPosition = new Vector2(xPosition, yPosition); tankPositions.Add(tankPosition); tankRotations.Add((float)(Math.PI / 2 + Math.PI / 4)); xPosition = pPlayArea.X + pPlayArea.Width - outerBlockXOffset / 2; yPosition = pPlayArea.Y + pPlayArea.Height - outerBlockXOffset / 2; tankPosition = new Vector2(xPosition, yPosition); tankPositions.Add(tankPosition); tankRotations.Add((float)Math.PI / 4); } else if (DGS.Instance.GetInt("NUM_PLAYERS") == 5) { float xPosition = pPlayArea.X + pPlayArea.Width / 2 + 0 - outerBlockXOffset / 2; float yPosition = pPlayArea.Y + pPlayArea.Height / 2 - outerBlockXOffset / 2; Vector2 tankPosition = new Vector2(xPosition, yPosition); tankPositions.Add(tankPosition); tankRotations.Add((float)(-Math.PI + Math.PI / 4)); xPosition = pPlayArea.X + pPlayArea.Width / 2 + 0 + outerBlockXOffset / 2; yPosition = pPlayArea.Y + pPlayArea.Height / 2 - outerBlockXOffset / 2; tankPosition = new Vector2(xPosition, yPosition); tankPositions.Add(tankPosition); tankRotations.Add((float)-Math.PI / 4); xPosition = pPlayArea.X + pPlayArea.Width / 2 + 0 - outerBlockXOffset / 2; yPosition = pPlayArea.Y + pPlayArea.Height / 2 + outerBlockXOffset / 2; tankPosition = new Vector2(xPosition, yPosition); tankPositions.Add(tankPosition); tankRotations.Add((float)(Math.PI / 2 + Math.PI / 4)); xPosition = pPlayArea.X + pPlayArea.Width / 2 + 0 + outerBlockXOffset / 2; yPosition = pPlayArea.Y + pPlayArea.Height / 2 + outerBlockXOffset / 2; tankPosition = new Vector2(xPosition, yPosition); tankPositions.Add(tankPosition); tankRotations.Add((float)Math.PI / 4); } float tankXPosition = pPlayArea.X + outerBlockXOffset; float tankYPosition = pPlayArea.Y + pPlayArea.Height / 2; float tankRotation = 0; float tankScale = (float)pPlayArea.Width / (50 * 40); float textureHeightOverWidth = (float)254 / (float)540; int textureWidth = game.GDM().GraphicsDevice.Viewport.Width / 4; int textureHeight = (int)(textureWidth * textureHeightOverWidth); m_Teams.Add(new Player( DGS.Instance.GetColour("COLOUR_TANK1"), Tankontroller.Instance().Controller0(), tankPositions[0].X, tankPositions[0].Y, tankRotations[0], tankScale, game.CM().Load <Texture2D>("healthbar_winterjack_06"), game.CM().Load <Texture2D>("healthbar_winterjack_05"), game.CM().Load <Texture2D>("healthbar_winterjack_04"), game.CM().Load <Texture2D>("healthbar_winterjack_03"), game.CM().Load <Texture2D>("healthbar_winterjack_02"), game.CM().Load <Texture2D>("healthbar_winterjack_01"), new Rectangle(0, 0, textureWidth, textureHeight), true)); tankXPosition = pPlayArea.X + pPlayArea.Width - outerBlockXOffset; tankRotation = (float)Math.PI; m_Teams.Add(new Player( DGS.Instance.GetColour("COLOUR_TANK2"), Tankontroller.Instance().Controller1(), tankPositions[1].X, tankPositions[1].Y, tankRotations[1], tankScale, game.CM().Load <Texture2D>("healthbar_engineer_06"), game.CM().Load <Texture2D>("healthbar_engineer_05"), game.CM().Load <Texture2D>("healthbar_engineer_04"), game.CM().Load <Texture2D>("healthbar_engineer_03"), game.CM().Load <Texture2D>("healthbar_engineer_02"), game.CM().Load <Texture2D>("healthbar_engineer_01"), new Rectangle(game.GDM().GraphicsDevice.Viewport.Width - textureWidth, 0, textureWidth, textureHeight), false)); if (DGS.Instance.GetInt("NUM_PLAYERS") > 2) { tankRotation = (float)Math.PI; if (DGS.Instance.GetInt("NUM_PLAYERS") <= 3) { tankXPosition = pPlayArea.Width / 2 + 35; tankRotation = (float)Math.PI / 2; } m_Teams.Add(new Player( DGS.Instance.GetColour("COLOUR_TANK3"), Tankontroller.Instance().Controller2(), tankPositions[2].X, tankPositions[2].Y, tankRotations[2], tankScale, game.CM().Load <Texture2D>("healthbar_robo_06"), game.CM().Load <Texture2D>("healthbar_robo_05"), game.CM().Load <Texture2D>("healthbar_robo_04"), game.CM().Load <Texture2D>("healthbar_robo_03"), game.CM().Load <Texture2D>("healthbar_robo_02"), game.CM().Load <Texture2D>("healthbar_robo_01"), new Rectangle(0 + textureWidth, 0, textureWidth, textureHeight), true)); tankXPosition = pPlayArea.X + outerBlockXOffset; tankRotation = 0; if (DGS.Instance.GetInt("NUM_PLAYERS") > 3) { tankYPosition = pPlayArea.Y + pPlayArea.Height / 2 + 50; m_Teams.Add(new Player( DGS.Instance.GetColour("COLOUR_TANK4"), Tankontroller.Instance().Controller3(), tankPositions[3].X, tankPositions[3].Y, tankRotations[3], tankScale, game.CM().Load <Texture2D>("healthbar_yeti_06"), game.CM().Load <Texture2D>("healthbar_yeti_05"), game.CM().Load <Texture2D>("healthbar_yeti_04"), game.CM().Load <Texture2D>("healthbar_yeti_03"), game.CM().Load <Texture2D>("healthbar_yeti_02"), game.CM().Load <Texture2D>("healthbar_yeti_01"), new Rectangle(game.GDM().GraphicsDevice.Viewport.Width - textureWidth * 2, 0, textureWidth, textureHeight), false)); } } m_World = new TheWorld(pPlayArea, Walls); }