/// <summary> /// Dessine le slots de consommables. /// </summary> /// <param name="batch"></param> /// <param name="time"></param> void DrawConsummableSlots(SpriteBatch batch, GameTime time) { int spellCount = m_hero.Spells.Count; int y = (int)Ressources.ScreenSize.Y - spellIconSize - 5; int xBase = ((int)Ressources.ScreenSize.X - ((spellIconSize + padding) * spellCount)) / 2; int size = spellIconSize / 2; xBase -= (size + padding) * m_hero.Consummables.Length; for (int i = 0; i < m_hero.Consummables.Length; i++) { Color col = m_hero.Consummables[i].UsingStarted ? Color.Gray : Color.White; // Dessine le slot du consommable. batch.Draw(Ressources.GetSpellTexture(m_hero.Consummables[i].Model.ConsummableType.ToString()), new Rectangle(xBase, y, size, size), null, Color.White, 0.0f, Vector2.Zero, SpriteEffects.None, ZLayer.HeroControler); // Affiche le nombre de consommables. if (m_hero.Consummables[i].Count >= 1) { batch.DrawString(Ressources.Font, "x" + m_hero.Consummables[i].Count, new Vector2(xBase + size - 12, y + size - 12), Color.Black, 0.0f, Vector2.Zero, 0.5f, SpriteEffects.None, ZLayer.HeroControler + ZLayer.FrontStep); } // Dessine le cooldown. if (m_hero.Consummables[i].UsingStarted) { string cooldown; if (m_hero.Consummables[i].RemainingTime <= 1) { cooldown = (m_hero.Consummables[i].RemainingTime).ToString("f1"); } else { cooldown = (m_hero.Consummables[i].RemainingTime).ToString("f0"); } Vector2 stringW = Ressources.Font.MeasureString(cooldown); int offsetX = (size - (int)stringW.X) / 2; int offsetY = (size - (int)stringW.Y) / 2; batch.DrawString(Ressources.Font, cooldown, new Vector2(xBase + offsetX, y + offsetY), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, ZLayer.HeroControler + ZLayer.FrontStep); } xBase += size + padding; } }
/// <summary> /// Dessine les slots des équipements (armures, armes, bottes). /// </summary> /// <param name="batch"></param> /// <param name="time"></param> void DrawEquipmentSlots(SpriteBatch batch, GameTime time) { int y = (int)Ressources.ScreenSize.Y - spellIconSize / 2 - 5; int xBase = ((int)Ressources.ScreenSize.X - ((spellIconSize + padding) * m_hero.Spells.Count)) / 2; int size = spellIconSize / 2; xBase -= (size + padding) * m_hero.Consummables.Length; for (int i = 0; i < m_hero.Consummables.Length; i++) { Color col = m_hero.Consummables[i].UsingStarted ? Color.Gray : Color.White; // Dessine le slot du consommable. batch.Draw(Ressources.GetSpellTexture(m_hero.Consummables[i].Model.Name), new Rectangle(xBase, y, size, size), null, Color.White, 0.0f, Vector2.Zero, SpriteEffects.None, ZLayer.HeroControler); xBase += size + padding; } }
/// <summary> /// Dessine le slot du héros donné à la position donnée. /// </summary> /// <param name="rect"></param> /// <param name="hero"></param> void DrawHero(SpriteBatch batch, Rectangle rect, Server.Entities.EntityHero hero) { float layerDepth = 0.5f; const int iconSize = 16; const int spellSize = 32; var ctrl = m_sceneRenderer.GameServer.GetSrvScene().PickControler; var scene = m_sceneRenderer.GameServer.GetSrvScene(); var texture = ctrl.IsMyTurn(hero.ID) ? Ressources.MenuItemHover : Ressources.MenuItem; EnhancedGui.Drawing.DrawRectBox(batch, texture, rect, Color.White, layerDepth + 0.1f); int x = rect.X + 20; int y = rect.Y + 20; // Dessine l'icone du rôle du héros batch.Draw(GetIcon((Views.EntityHeroRole)hero.Role), new Rectangle(x, y, iconSize, iconSize), null, Color.White, 0.0f, Vector2.Zero, SpriteEffects.None, layerDepth); x += iconSize + 10; // Dessine le nom du héros. batch.DrawString(Ressources.CourrierFont, scene.GetControlerByHeroId(hero.ID).HeroName, new Vector2(x, y), Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, layerDepth); y += 25; x = rect.X + 20; // Dessine les sorts du héros. for (int i = 0; i < hero.Spells.Count; i++) { Rectangle iconRect = new Rectangle(x, y, spellSize, spellSize); batch.Draw( Ressources.GetSpellTexture(hero.Spells[i].Name), iconRect, null, Color.White, 0.0f, Vector2.Zero, SpriteEffects.None, layerDepth); x += spellSize + 4; } }
/// <summary> /// Dessine les icones des spells. /// </summary> void DrawSpellIcons(SpriteBatch batch, GameTime time) { int spellCount = m_hero.Spells.Count; int y = (int)Ressources.ScreenSize.Y - spellIconSize - 5; int xBase = ((int)Ressources.ScreenSize.X - ((spellIconSize + padding) * spellCount)) / 2; for (int i = 0; i < spellCount; i++) { bool isOnCooldown = m_hero.Spells[i].CurrentCooldown > 0; int x = xBase + i * (spellIconSize + padding); // Dessine l'icone du sort Color col = isOnCooldown ? Color.Gray : Color.White; batch.Draw(Ressources.GetSpellTexture(m_hero.Spells[i].Name), new Rectangle(x, y, spellIconSize, spellIconSize), null, col, 0.0f, Vector2.Zero, SpriteEffects.None, ZLayer.HeroControler); // Dessine le cooldown du sort. if (isOnCooldown) { string cooldown; if (m_hero.Spells[i].CurrentCooldown <= 1) { cooldown = (m_hero.Spells[i].CurrentCooldown).ToString("f1"); } else { cooldown = (m_hero.Spells[i].CurrentCooldown).ToString("f0"); } Vector2 stringW = Ressources.Font.MeasureString(cooldown); int offsetX = (spellIconSize - (int)stringW.X) / 2; int offsetY = (spellIconSize - (int)stringW.Y) / 2; batch.DrawString(Ressources.Font, cooldown, new Vector2(x + offsetX, y + offsetY), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, ZLayer.HeroControler + ZLayer.FrontStep); } } }
/// <summary> /// Dessine le lobby en ayant une connexion mémoire directe avec le serveur. /// </summary> /// <param name="time"></param> /// <param name="batch"></param> void DrawDirect(GameTime time, SpriteBatch batch) { int w = (int)Ressources.ScreenSize.X; int h = (int)Ressources.ScreenSize.Y; var ctrl = m_sceneRenderer.GameServer.GetSrvScene().PickControler; batch.Begin(); batch.GraphicsDevice.Clear(Color.LightGray); // Dessine les héros. int x = 5; int y; for (int team = 0; team <= 1; team++) { y = 20; foreach (var hero in ctrl.GetHeroes()[team]) { DrawHero(batch, new Rectangle(x, y, w / 2 - 10, 100), hero); y += 110; } x += w / 2; } // Dessine les diverses informations sur l'état de la phase de picks. if (!ctrl.IsReadyToGo()) { // Dessine le temps restant. y = h - 300; string s = ((int)(ctrl.GetCurrentTimeoutSeconds() - (DateTime.Now - ctrl.LastControlerUpdate).TotalSeconds)).ToString(); float scale = 4.0f; Vector2 sz = Ressources.CourrierFont.MeasureString(s) * scale; x = (w - (int)sz.X) / 2; batch.DrawString(Ressources.CourrierFont, s, new Vector2(x, y), Color.Black, 0.0f, Vector2.Zero, scale, SpriteEffects.None, 0.5f); y += 70; // Dessine les messages. x = 5; scale = 1.0f; var controler = m_sceneRenderer.GameServer.GetSrvScene().GetControlerByHeroId(ctrl.GetPickingHeroId()); string heroName = controler == null ? "<none>" : controler.HeroName; string msg = heroName + " : choisissez une compétence " + (ctrl.IsPickingActive() ? "active" : "passive") + "."; sz = Ressources.CourrierFont.MeasureString(msg) * scale; x = (w - (int)sz.X) / 2; batch.DrawString(Ressources.CourrierFont, msg, new Vector2(x, y), Color.Black, 0.0f, Vector2.Zero, scale, SpriteEffects.None, 0.5f); x = 5; y += 100; batch.DrawString(Ressources.CourrierFont, ctrl.CurrentMessage, new Vector2(x, y), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f); } // Dessine les icones des compétences proposées. if (ctrl.IsReadyToGo()) { string str = "Appuyez sur entrée pour démarer le jeu."; Vector2 size = Ressources.CourrierFont.MeasureString(str); y = h - 50; x = (w - (int)size.X) / 2; batch.DrawString(Ressources.CourrierFont, str, new Vector2(x, y), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f); } else { x = 5; const int spellSize = 64; if (ctrl.IsPickingActive()) { foreach (Server.Spells.SpellModel spell in ctrl.GetActiveSpellModels()) { y = h - spellSize - 4; Rectangle dstRect = new Rectangle(x, y, spellSize, spellSize); // Effet de surbrillance si un sort est survollé. Color color = Color.White; var ms = Input.GetMouseState(); if (dstRect.Contains(new Point((int)ms.X, (int)ms.Y))) { color = Color.Red; } batch.Draw(Ressources.GetSpellTexture(spell.Name), dstRect, null, color, 0.0f, Vector2.Zero, SpriteEffects.None, 0.5f); x += spellSize + 4; } } else { foreach (Server.Entities.EntityUniquePassives spell in ctrl.GetPassiveSpells()) { y = h - spellSize - 4; Rectangle dstRect = new Rectangle(x, y, spellSize, spellSize); // Effet de surbrillance si un sort est survollé. Color color = Color.White; var ms = Input.GetMouseState(); if (dstRect.Contains(new Point((int)ms.X, (int)ms.Y))) { color = Color.Red; } batch.Draw(Ressources.GetSpellTexture(spell.ToString()), dstRect, null, color, 0.0f, Vector2.Zero, SpriteEffects.None, 0.5f); x += spellSize + 4; } } } batch.End(); }