public void Render(GraphicsDevice graphicsDevice) { // If we don't have _P, grab it from the current gameInstance. // We can't do this in the constructor because we are created in the property bag's constructor! if (_P == null) _P = gameInstance.propertyBag; foreach (Player p in _P.playerList.Values) { if (p.Alive && p.ID != _P.playerMyId) { p.SpriteModel.Draw(_P.playerCamera.ViewMatrix, _P.playerCamera.ProjectionMatrix, _P.playerCamera.Position, _P.playerCamera.GetLookVector(), p.Position - Vector3.UnitY * 1.5f, p.Heading, 2); } } foreach (KeyValuePair<string, Item> i in _P.itemList)// if (bPair.Value.Team == _P.playerTeam)//doesnt care which team { i.Value.SpriteModel.Draw(_P.playerCamera.ViewMatrix, _P.playerCamera.ProjectionMatrix, _P.playerCamera.Position, _P.playerCamera.GetLookVector(), i.Value.Position - Vector3.UnitY * 1.5f,//* 1.5f probably not helpful i.Value.Heading, 2); } }
public void Render(GraphicsDevice graphicsDevice) { // If we don't have _P, grab it from the current gameInstance. // We can't do this in the constructor because we are created in the property bag's constructor! if (_P == null) _P = gameInstance.propertyBag; // Draw the skybox. Matrix viewMatrix = _P.playerCamera.ViewMatrix; Matrix projectionMatrix = _P.playerCamera.ProjectionMatrix; effect.CurrentTechnique = effect.Techniques["Skyplane"]; effect.Parameters["xWorld"].SetValue(Matrix.Identity); effect.Parameters["xView"].SetValue(viewMatrix); effect.Parameters["xProjection"].SetValue(projectionMatrix); effect.Parameters["xTexture"].SetValue(texNoise); effect.Parameters["xTime"].SetValue(effectTime); effect.Begin(); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Begin(); graphicsDevice.SamplerStates[0].MagFilter = TextureFilter.Point; graphicsDevice.RenderState.CullMode = CullMode.None; graphicsDevice.RenderState.DepthBufferEnable = false; graphicsDevice.VertexDeclaration = vertexDeclaration; graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, vertices.Length / 3); graphicsDevice.RenderState.DepthBufferEnable = true; pass.End(); } effect.End(); }
public void RenderPlayerNames(GraphicsDevice graphicsDevice) { // If we don't have _P, grab it from the current gameInstance. // We can't do this in the constructor because we are created in the property bag's constructor! if (_P == null) _P = gameInstance.propertyBag; foreach (Player p in _P.playerList.Values) { if (p.Alive && p.ID != _P.playerMyId) { // Figure out what text we should draw on the player - only for teammates and nearby enemies string playerText = ""; bool continueDraw=false; if (p.ID != _P.playerMyId && p.Team == _P.playerTeam) continueDraw = true; else { Vector3 diff = (p.Position -_P.playerPosition); float len = diff.Length(); diff.Normalize(); if (len<=15){ Vector3 hit = Vector3.Zero; Vector3 build = Vector3.Zero; gameInstance.propertyBag.blockEngine.RayCollision(_P.playerPosition + new Vector3(0f, 0.1f, 0f), diff, len, 25, ref hit, ref build); if (hit == Vector3.Zero) //Why is this reversed? continueDraw = true; } } if (continueDraw)//p.ID != _P.playerMyId && p.Team == _P.playerTeam) { playerText = p.Handle; if (p.Ping > 0) playerText = "*** " + playerText + " ***"; p.SpriteModel.DrawText(_P.playerCamera.ViewMatrix, _P.playerCamera.ProjectionMatrix, p.Position - Vector3.UnitY * 1.5f, playerText, p.Team == PlayerTeam.Blue ? _P.blue : _P.red);//Defines.IM_BLUE : Defines.IM_RED); } } } }
public void Render(GraphicsDevice graphicsDevice) { // If we don't have _P, grab it from the current gameInstance. // We can't do this in the constructor because we are created in the property bag's constructor! if (_P == null) _P = gameInstance.propertyBag; foreach (Player p in _P.playerList.Values) { if (p.Alive && p.ID != _P.playerMyId) { p.SpriteModel.Draw(_P.playerCamera.ViewMatrix, _P.playerCamera.ProjectionMatrix, _P.playerCamera.Position, _P.playerCamera.GetLookVector(), p.Position - Vector3.UnitY * 1.5f, p.Heading, 2); } } }
public InterfaceTextInput(Infiniminer.InfiniminerGame gameInstance, Infiniminer.PropertyBag pb) { uiFont = gameInstance.Content.Load <SpriteFont>("font_04b08"); _P = pb; //keyMap = new Infiniminer.KeyMap(); }
public void Render(GraphicsDevice graphicsDevice) { // If we don't have _P, grab it from the current gameInstance. // We can't do this in the constructor because we are created in the property bag's constructor! if (_P == null) _P = gameInstance.propertyBag; foreach (Particle p in particleList) { Matrix worldMatrix = Matrix.CreateScale(p.Size / 2) * Matrix.CreateTranslation(p.Position); particleEffect.Parameters["xWorld"].SetValue(worldMatrix); particleEffect.Parameters["xView"].SetValue(_P.playerCamera.ViewMatrix); particleEffect.Parameters["xProjection"].SetValue(_P.playerCamera.ProjectionMatrix); particleEffect.Parameters["xColor"].SetValue(p.Color.ToVector4()); particleEffect.Begin(); particleEffect.Techniques[0].Passes[0].Begin(); graphicsDevice.RenderState.CullMode = CullMode.None; graphicsDevice.VertexDeclaration = vertexDeclaration; graphicsDevice.Vertices[0].SetSource(vertexBuffer, 0, VertexPositionTextureShade.SizeInBytes); graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, vertexBuffer.SizeInBytes / VertexPositionTextureShade.SizeInBytes / 3); particleEffect.Techniques[0].Passes[0].End(); particleEffect.End(); } }
public void Render(GraphicsDevice graphicsDevice) { // If we don't have _P, grab it from the current gameInstance. // We can't do this in the constructor because we are created in the property bag's constructor! if (_P == null) _P = gameInstance.propertyBag; // Draw the UI. spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.SaveState); // Draw the crosshair. spriteBatch.Draw(texCrosshairs, new Rectangle(graphicsDevice.Viewport.Width / 2 - texCrosshairs.Width / 2, graphicsDevice.Viewport.Height / 2 - texCrosshairs.Height / 2, texCrosshairs.Width, texCrosshairs.Height), Color.White); switch (_P.playerClass) { case PlayerClass.Miner: if (_P.Content[5] > 0) { BlockType held = (BlockType)(byte)(_P.Content[5]); int screenWidth = graphicsDevice.Viewport.Width; int screenHeight = graphicsDevice.Viewport.Height; graphicsDevice.SamplerStates[0].MagFilter = TextureFilter.Point; int drawX = screenWidth / 2 + 61 * 3; int drawY = screenHeight - 91 * 3; spriteBatch.Draw(blockIcons[held], new Rectangle(drawX + 37 * 3, drawY + 50 * 3, 117, 63), Color.White); } break; } // If equipped, draw the tool. switch (_P.playerTools[_P.playerToolSelected]) { case PlayerTools.Detonator: RenderDetonator(graphicsDevice, spriteBatch); break; case PlayerTools.Remote: RenderRemote(graphicsDevice, spriteBatch); break; case PlayerTools.ProspectingRadar: RenderProspectron(graphicsDevice, spriteBatch); break; case PlayerTools.ConstructionGun: RenderConstructionGun(graphicsDevice, spriteBatch, _P.playerBlocks[_P.playerBlockSelected]); break; case PlayerTools.DeconstructionGun: RenderConstructionGun(graphicsDevice, spriteBatch, BlockType.None); break; default: { // Draw info about what we have equipped. PlayerTools currentTool = _P.playerTools[_P.playerToolSelected]; BlockType currentBlock = _P.playerBlocks[_P.playerBlockSelected]; string equipment = currentTool.ToString(); if (currentTool == PlayerTools.ConstructionGun) equipment += " - " + currentBlock.ToString() + " (" + BlockInformation.GetCost(currentBlock) + ")"; RenderMessageCenter(spriteBatch, equipment, new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height - 20), Color.White, Color.Black); } break; } if (gameInstance.DrawFrameRate) RenderMessageCenter(spriteBatch, String.Format("FPS: {0:000}", gameInstance.FrameRate), new Vector2(60, graphicsDevice.Viewport.Height - 20), Color.Gray, Color.Black); if (!_P.playerDead && _P.Content[10] > 0) RenderMessageCenter(spriteBatch, ArtifactInformation.GetName(_P.Content[10]), new Vector2(240 + (ArtifactInformation.GetName(_P.Content[10])).Length * 2, graphicsDevice.Viewport.Height - 20), Color.Lerp(Color.White, Color.Gold, _P.colorPulse), Color.Black); // Show the altimeter. int altitude = (int)(_P.playerPosition.Y - 64 + Defines.GROUND_LEVEL); RenderMessageCenter(spriteBatch, String.Format("ALTITUDE: {0:00}", altitude), new Vector2(graphicsDevice.Viewport.Width - 90, graphicsDevice.Viewport.Height - 20), altitude >= 0 ? Color.Gray : Defines.IM_RED, Color.Black); string interact = _P.strInteract(); if (interact != "")//interact with stuffs { RenderMessageCenter(spriteBatch, interact, new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height / 2 + 60), Color.White, Color.Black); } //if (_P.AtBankTerminal()) // RenderMessageCenter(spriteBatch, "8: DEPOSIT 50 ORE 9: WITHDRAW 50 ORE", new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height / 2 + 60), Color.White, Color.Black); //if (_P.AtGenerator()) // RenderMessageCenter(spriteBatch, "8: Generator On 9: Generator Off", new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height / 2 + 60), Color.White, Color.Black); //if (_P.AtPipe()) // RenderMessageCenter(spriteBatch, "8: Rotate Left 9: Rotate Right", new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height / 2 + 60), Color.White, Color.Black); // Are they trying to change class when they cannot? //if (Keyboard.GetState().IsKeyDown(Keys.M) && _P.playerPosition.Y <= 64 - Defines.GROUND_LEVEL && _P.chatMode == ChatMessageType.None) // RenderMessageCenter(spriteBatch, "YOU CANNOT CHANGE YOUR CLASS BELOW THE SURFACE", new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height / 2 + 90), Color.White, Color.Black); // Draw the text-based information panel. int textStart = (graphicsDevice.Viewport.Width - 1024) / 2; spriteBatch.Draw(texBlank, new Rectangle(0, 0, graphicsDevice.Viewport.Width, 20), Color.Black); spriteBatch.DrawString(uiFont, "ORE: " + _P.playerOre + "/" + _P.playerOreMax, new Vector2(textStart + 3, 2), Color.White); spriteBatch.DrawString(uiFont, "LOOT: $" + _P.playerCash, new Vector2(textStart + 170, 2), Color.White); RenderMessageCenter(spriteBatch, String.Format("Health: {0:000}", _P.playerHealth) + "/" + String.Format("{0:000}", _P.playerHealthMax), new Vector2(graphicsDevice.Viewport.Width - 300, graphicsDevice.Viewport.Height - 20), _P.playerHealth >= _P.playerHealthMax / 4 ? _P.playerHealth >= _P.playerHealthMax * 0.8f ? Color.Green : Color.Gray : Defines.IM_RED, Color.Black); //spriteBatch.DrawString(uiFont, "HEALTH: " + _P.playerHealth + "/" + _P.playerHealthMax, new Vector2(textStart + 170, 2), Color.White); spriteBatch.DrawString(uiFont, "WEIGHT: " + _P.playerWeight + "/" + _P.playerWeightMax, new Vector2(textStart + 320, 2), Color.White); spriteBatch.DrawString(uiFont, "TEAM ORE: " + _P.teamOre, new Vector2(textStart + 515, 2), Color.White); spriteBatch.DrawString(uiFont, _P.redName + ": $" + _P.teamRedCash, new Vector2(textStart + 700, 2), _P.red);// Defines.IM_RED); spriteBatch.DrawString(uiFont, _P.blueName + ": $" + _P.teamBlueCash, new Vector2(textStart + 860, 2), _P.blue);// Defines.IM_BLUE); spriteBatch.DrawString(uiFont, _P.teamArtifactsRed + "/" +_P.winningCashAmount, new Vector2(textStart + 700, 22), _P.red); spriteBatch.DrawString(uiFont, _P.teamArtifactsBlue + "/" + _P.winningCashAmount, new Vector2(textStart + 860, 22), _P.blue); spriteBatch.DrawString(uiFont, "Artifacts", new Vector2(textStart + 700, 42), _P.red); spriteBatch.DrawString(uiFont, "Artifacts", new Vector2(textStart + 860, 42), _P.blue); // Draw player information. if ((Keyboard.GetState().IsKeyDown(Keys.Tab) && _P.screenEffect == ScreenEffect.None) || _P.teamWinners != PlayerTeam.None) { spriteBatch.Draw(texBlank, new Rectangle(0, 0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height), new Color(Color.Black, 0.7f)); //Server name RenderMessageCenter(spriteBatch, _P.serverName, new Vector2(graphicsDevice.Viewport.Width / 2, 32), _P.playerTeam == PlayerTeam.Blue ? _P.blue : _P.red, Color.Black);//Defines.IM_BLUE : Defines.IM_RED, Color.Black); if (_P.teamWinners != PlayerTeam.None) { string teamName = _P.teamWinners == PlayerTeam.Red ? "RED" : "BLUE"; Color teamColor = _P.teamWinners == PlayerTeam.Red ? _P.red : _P.blue;//Defines.IM_RED : Defines.IM_BLUE; string gameOverMessage = "GAME OVER - " + teamName + " TEAM WINS!"; RenderMessageCenter(spriteBatch, gameOverMessage, new Vector2(graphicsDevice.Viewport.Width / 2, 150), teamColor, new Color(0, 0, 0, 0)); } int drawY = 200; foreach (Player p in _P.playerList.Values) { if (p.Team != PlayerTeam.Red) continue; RenderMessageCenter(spriteBatch, p.Handle + " ( $" + p.Score + " )", new Vector2(graphicsDevice.Viewport.Width / 4, drawY), _P.red, new Color(0, 0, 0, 0));//Defines.IM_RED drawY += 35; } drawY = 200; foreach (Player p in _P.playerList.Values) { if (p.Team != PlayerTeam.Blue) continue; RenderMessageCenter(spriteBatch, p.Handle + " ( $" + p.Score + " )", new Vector2(graphicsDevice.Viewport.Width * 3 / 4, drawY), _P.blue, new Color(0, 0, 0, 0)); //Defines.IM_BLUE drawY += 35; } } // Draw the chat buffer. if (_P.chatMode == ChatMessageType.SayAll) { spriteBatch.DrawString(uiFont, "ALL> " + _P.chatEntryBuffer, new Vector2(22, graphicsDevice.Viewport.Height - 98), Color.Black); spriteBatch.DrawString(uiFont, "ALL> " + _P.chatEntryBuffer, new Vector2(20, graphicsDevice.Viewport.Height - 100), Color.White); } else if (_P.chatMode == ChatMessageType.SayBlueTeam || _P.chatMode == ChatMessageType.SayRedTeam) { spriteBatch.DrawString(uiFont, "TEAM> " + _P.chatEntryBuffer, new Vector2(22, graphicsDevice.Viewport.Height - 98), Color.Black); spriteBatch.DrawString(uiFont, "TEAM> " + _P.chatEntryBuffer, new Vector2(20, graphicsDevice.Viewport.Height - 100), Color.White); } if (_P.chatMode != ChatMessageType.None) { drawChat(_P.chatFullBuffer,graphicsDevice); /*for (int i = 0; i < _P.chatFullBuffer.Count; i++) { Color chatColor = Color.White; chatColor = _P.chatFullBuffer[i].type == ChatMessageType.SayAll ? Color.White : _P.chatFullBuffer[i].type == ChatMessageType.SayRedTeam ? InfiniminerGame.IM_RED : InfiniminerGame.IM_BLUE; spriteBatch.DrawString(uiFont, _P.chatFullBuffer[i].message, new Vector2(22, graphicsDevice.Viewport.Height - 114 - 16 * i), Color.Black); spriteBatch.DrawString(uiFont, _P.chatFullBuffer[i].message, new Vector2(20, graphicsDevice.Viewport.Height - 116 - 16 * i), chatColor); }*/ } else { drawChat(_P.chatBuffer,graphicsDevice); } // Draw the player radar. spriteBatch.Draw(texRadarBackground, new Vector2(10, 30), Color.White); foreach (Player p in _P.playerList.Values) { if (p.Team == _P.playerTeam && p.Alive || p.Content[1] == 1)//within radar RenderRadarBlip(spriteBatch, p.ID == _P.playerMyId ? _P.playerPosition : p.Position, p.Team == PlayerTeam.Red ? _P.red : _P.blue, p.Ping > 0, ""); //Defines.IM_RED : Defines.IM_BLUE, p.Ping > 0, ""); } foreach (KeyValuePair<Vector3, Beacon> bPair in _P.beaconList) if (bPair.Value.Team == _P.playerTeam) RenderRadarBlip(spriteBatch, bPair.Key, Color.White, false, bPair.Value.ID); RenderRadarBlip(spriteBatch, new Vector3(100000, 0, 32), Color.White, false, "NORTH"); // foreach (KeyValuePair<string, Item> bPair in _P.itemList)// if (bPair.Value.Team == _P.playerTeam)//doesnt care which team // RenderRadarBlip(spriteBatch, bPair.Value.Position, Color.Magenta, false, bPair.Value.ID); spriteBatch.Draw(texRadarForeground, new Vector2(10, 30), Color.White); // Draw escape message. if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { RenderMessageCenter(spriteBatch, "PRESS Y TO CONFIRM THAT YOU WANT TO QUIT.", new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height / 2 + 30), Color.White, Color.Black); RenderMessageCenter(spriteBatch, "PRESS K TO SUICIDE.", new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height / 2 + 80), Color.White, Color.Black); } // Draw the current screen effect. if (_P.screenEffect == ScreenEffect.Death) { Color drawColor = new Color(1 - (float)_P.screenEffectCounter * 0.5f, 0f, 0f); spriteBatch.Draw(texBlank, new Rectangle(0, 0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height), drawColor); if (_P.screenEffectCounter >= 2) RenderMessageCenter(spriteBatch, "You may now respawn.", new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height / 2), Color.White, Color.Black); } else if (_P.screenEffect == ScreenEffect.Teleport || _P.screenEffect == ScreenEffect.Explosion) { Color drawColor = new Color(1, 1, 1, 1 - (float)_P.screenEffectCounter * 0.5f); spriteBatch.Draw(texBlank, new Rectangle(0, 0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height), drawColor); if (_P.screenEffectCounter > 2) _P.screenEffect = ScreenEffect.None; } else if (_P.screenEffect == ScreenEffect.Earthquake) { //Color drawColor = new Color(1, 1, 1, 1 - (float)_P.screenEffectCounter * 0.5f); //spriteBatch.Draw(texBlank, new Rectangle(0, 0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height), drawColor); if (_P.screenEffectCounter > 2) _P.screenEffect = ScreenEffect.None; } else if (_P.screenEffect == ScreenEffect.Fall) { Color drawColor = new Color(1, 0, 0, 1 - (float)_P.screenEffectCounter * 0.5f); spriteBatch.Draw(texBlank, new Rectangle(0, 0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height), drawColor); if (_P.screenEffectCounter > 2) _P.screenEffect = ScreenEffect.None; } else if (_P.screenEffect == ScreenEffect.Water) { Color drawColor = new Color(0, 0, 1, 1 - (float)_P.screenEffectCounter); spriteBatch.Draw(texBlank, new Rectangle(0, 0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height), drawColor); if (_P.screenEffectCounter > 2) _P.screenEffect = ScreenEffect.None; } else if (_P.screenEffect == ScreenEffect.Drown) { Color drawColor = new Color(0.5f, 0, 0.8f, 0.25f + (float)_P.screenEffectCounter*0.2f); spriteBatch.Draw(texBlank, new Rectangle(0, 0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height), drawColor); if (_P.screenEffectCounter > 2) { _P.screenEffect = ScreenEffect.Water; _P.screenEffectCounter = 1; } } // Draw the help screen. if (Keyboard.GetState().IsKeyDown(Keys.F1)) { spriteBatch.Draw(texBlank, new Rectangle(0, 0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height), Color.Black); spriteBatch.Draw(texHelp, drawRect, Color.White); } spriteBatch.End(); }
public InterfaceElement(Infiniminer.InfiniminerGame gameInstance, Infiniminer.PropertyBag pb) { uiFont = gameInstance.Content.Load<SpriteFont>("font_04b08"); _P = pb; }
public void Render(GraphicsDevice graphicsDevice) { // If we don't have _P, grab it from the current gameInstance. // We can't do this in the constructor because we are created in the property bag's constructor! if (_P == null) _P = gameInstance.propertyBag; // Draw the UI. spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.SaveState); // Draw the crosshair. spriteBatch.Draw(texCrosshairs, new Rectangle(graphicsDevice.Viewport.Width / 2 - texCrosshairs.Width / 2, graphicsDevice.Viewport.Height / 2 - texCrosshairs.Height / 2, texCrosshairs.Width, texCrosshairs.Height), Color.White); // If equipped, draw the detonator. switch (_P.playerTools[_P.playerToolSelected]) { case PlayerTools.Detonator: RenderDetonator(graphicsDevice, spriteBatch); break; case PlayerTools.ProspectingRadar: RenderProspectron(graphicsDevice, spriteBatch); break; case PlayerTools.ConstructionGun: RenderConstructionGun(graphicsDevice, spriteBatch, _P.playerBlocks[_P.playerBlockSelected]); break; case PlayerTools.DeconstructionGun: RenderConstructionGun(graphicsDevice, spriteBatch, BlockType.None); break; default: { // Draw info about what we have equipped. PlayerTools currentTool = _P.playerTools[_P.playerToolSelected]; BlockType currentBlock = _P.playerBlocks[_P.playerBlockSelected]; string equipment = currentTool.ToString(); if (currentTool == PlayerTools.ConstructionGun) equipment += " - " + currentBlock.ToString() + " (" + BlockInformation.GetCost(currentBlock) + ")"; RenderMessageCenter(spriteBatch, equipment, new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height - 20), Color.White, Color.Black); } break; } if (gameInstance.DrawFrameRate) RenderMessageCenter(spriteBatch, String.Format("FPS: {0:000}", gameInstance.FrameRate), new Vector2(60, graphicsDevice.Viewport.Height - 20), Color.Gray, Color.Black); // Show the altimeter. int altitude = (int)(_P.playerPosition.Y - 64 + InfiniminerGame.GROUND_LEVEL); RenderMessageCenter(spriteBatch, String.Format("ALTITUDE: {0:00}", altitude), new Vector2(graphicsDevice.Viewport.Width - 90, graphicsDevice.Viewport.Height - 20), altitude >= 0 ? Color.Gray : InfiniminerGame.IM_RED, Color.Black); // Draw bank instructions. if (_P.AtBankTerminal()) RenderMessageCenter(spriteBatch, "1: DEPOSIT 50 ORE 2: WITHDRAW 50 ORE", new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height / 2 + 60), Color.White, Color.Black); // Are they trying to change class when they cannot? if (Keyboard.GetState().IsKeyDown(Keys.M) && _P.playerPosition.Y <= 64 - InfiniminerGame.GROUND_LEVEL && _P.chatMode == ChatMessageType.None) RenderMessageCenter(spriteBatch, "YOU CANNOT CHANGE YOUR CLASS BELOW THE SURFACE", new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height / 2 + 90), Color.White, Color.Black); // Draw the text-based information panel. int textStart = (graphicsDevice.Viewport.Width - 1024)/2; spriteBatch.Draw(texBlank, new Rectangle(0, 0, graphicsDevice.Viewport.Width, 20), Color.Black); spriteBatch.DrawString(uiFont, "ORE: " + _P.playerOre + "/" + _P.playerOreMax, new Vector2(textStart+3, 2), Color.White); spriteBatch.DrawString(uiFont, "LOOT: $" + _P.playerCash, new Vector2(textStart + 170, 2), Color.White); spriteBatch.DrawString(uiFont, "WEIGHT: " + _P.playerWeight + "/" + _P.playerWeightMax, new Vector2(textStart + 340, 2), Color.White); spriteBatch.DrawString(uiFont, "TEAM ORE: " + _P.teamOre, new Vector2(textStart + 515, 2), Color.White); spriteBatch.DrawString(uiFont, "RED: $" + _P.teamRedCash, new Vector2(textStart + 700, 2), InfiniminerGame.IM_RED); spriteBatch.DrawString(uiFont, "BLUE: $" + _P.teamBlueCash, new Vector2(textStart + 860, 2), InfiniminerGame.IM_BLUE); // Draw player information. if ((Keyboard.GetState().IsKeyDown(Keys.Tab) && _P.screenEffect == ScreenEffect.None) || _P.teamWinners != PlayerTeam.None) { spriteBatch.Draw(texBlank, new Rectangle(0, 0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height), new Color(Color.Black, 0.7f)); if (_P.teamWinners != PlayerTeam.None) { string teamName = _P.teamWinners == PlayerTeam.Red ? "RED" : "BLUE"; Color teamColor = _P.teamWinners == PlayerTeam.Red ? InfiniminerGame.IM_RED : InfiniminerGame.IM_BLUE; string gameOverMessage = "GAME OVER - " + teamName + " TEAM WINS!"; RenderMessageCenter(spriteBatch, gameOverMessage, new Vector2(graphicsDevice.Viewport.Width / 2, 150), teamColor, new Color(0, 0, 0, 0)); } int drawY = 200; foreach (Player p in _P.playerList.Values) { if (p.Team != PlayerTeam.Red) continue; RenderMessageCenter(spriteBatch, p.Handle + " ( $" + p.Score + " )", new Vector2(graphicsDevice.Viewport.Width/4, drawY), InfiniminerGame.IM_RED, new Color(0, 0, 0, 0)); drawY += 35; } drawY = 200; foreach (Player p in _P.playerList.Values) { if (p.Team != PlayerTeam.Blue) continue; RenderMessageCenter(spriteBatch, p.Handle + " ( $" + p.Score + " )", new Vector2(graphicsDevice.Viewport.Width * 3 / 4, drawY), InfiniminerGame.IM_BLUE, new Color(0, 0, 0, 0)); drawY += 35; } } // Draw the chat buffer. if (_P.chatMode == ChatMessageType.SayAll) { spriteBatch.DrawString(uiFont, "ALL> " + _P.chatEntryBuffer, new Vector2(22, graphicsDevice.Viewport.Height - 98), Color.Black); spriteBatch.DrawString(uiFont, "ALL> " + _P.chatEntryBuffer, new Vector2(20, graphicsDevice.Viewport.Height - 100), Color.White); } else if (_P.chatMode == ChatMessageType.SayBlueTeam || _P.chatMode == ChatMessageType.SayRedTeam) { spriteBatch.DrawString(uiFont, "TEAM> " + _P.chatEntryBuffer, new Vector2(22, graphicsDevice.Viewport.Height - 98), Color.Black); spriteBatch.DrawString(uiFont, "TEAM> " + _P.chatEntryBuffer, new Vector2(20, graphicsDevice.Viewport.Height - 100), Color.White); } for (int i = 0; i < _P.chatBuffer.Count; i++) { Color chatColor = Color.White; if (_P.chatBuffer[i].type == ChatMessageType.SayRedTeam) chatColor = InfiniminerGame.IM_RED; if (_P.chatBuffer[i].type == ChatMessageType.SayBlueTeam) chatColor = InfiniminerGame.IM_BLUE; spriteBatch.DrawString(uiFont, _P.chatBuffer[i].message, new Vector2(22, graphicsDevice.Viewport.Height - 114 - 16 * i), Color.Black); spriteBatch.DrawString(uiFont, _P.chatBuffer[i].message, new Vector2(20, graphicsDevice.Viewport.Height - 116 - 16 * i), chatColor); } // Draw the player radar. spriteBatch.Draw(texRadarBackground, new Vector2(10, 30), Color.White); foreach (Player p in _P.playerList.Values) if (p.Team == _P.playerTeam && p.Alive) RenderRadarBlip(spriteBatch, p.ID == _P.playerMyId ? _P.playerPosition : p.Position, p.Team == PlayerTeam.Red ? InfiniminerGame.IM_RED : InfiniminerGame.IM_BLUE, p.Ping > 0, ""); foreach (KeyValuePair<Vector3, Beacon> bPair in _P.beaconList) if (bPair.Value.Team == _P.playerTeam) RenderRadarBlip(spriteBatch, bPair.Key, Color.White, false, bPair.Value.ID); RenderRadarBlip(spriteBatch, new Vector3(100000, 0, 32), Color.White, false, "NORTH"); spriteBatch.Draw(texRadarForeground, new Vector2(10, 30), Color.White); // Draw escape message. if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { RenderMessageCenter(spriteBatch, "PRESS Y TO CONFIRM THAT YOU WANT TO QUIT.", new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height / 2 + 30), Color.White, Color.Black); RenderMessageCenter(spriteBatch, "PRESS K TO COMMIT PIXELCIDE.", new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height / 2 + 80), Color.White, Color.Black); } // Draw the current screen effect. if (_P.screenEffect == ScreenEffect.Death) { Color drawColor = new Color(1 - (float)_P.screenEffectCounter * 0.5f, 0f, 0f); spriteBatch.Draw(texBlank, new Rectangle(0, 0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height), drawColor); if (_P.screenEffectCounter >= 2) RenderMessageCenter(spriteBatch, "You have died. Click to respawn.", new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height/2), Color.White, Color.Black); } if (_P.screenEffect == ScreenEffect.Teleport || _P.screenEffect == ScreenEffect.Explosion) { Color drawColor = new Color(1, 1, 1, 1 - (float)_P.screenEffectCounter * 0.5f); spriteBatch.Draw(texBlank, new Rectangle(0, 0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height), drawColor); if (_P.screenEffectCounter > 2) _P.screenEffect = ScreenEffect.None; } if (_P.screenEffect == ScreenEffect.Fall) { Color drawColor = new Color(1, 0, 0, 1 - (float)_P.screenEffectCounter * 0.5f); spriteBatch.Draw(texBlank, new Rectangle(0, 0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height), drawColor); if (_P.screenEffectCounter > 2) _P.screenEffect = ScreenEffect.None; } // Draw the help screen. if (Keyboard.GetState().IsKeyDown(Keys.F1)) { spriteBatch.Draw(texBlank, new Rectangle(0, 0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height), Color.Black); spriteBatch.Draw(texHelp, drawRect, Color.White); } spriteBatch.End(); }
public InterfaceElement(Infiniminer.InfiniminerGame gameInstance, Infiniminer.PropertyBag pb) { uiFont = gameInstance.Content.Load <SpriteFont>("font_04b08"); _P = pb; }