Exemple #1
0
		static void Main() {
			Console.WriteLine("Welcome to the arena!");
			
			Player pc = new Player();
			Enemy enemy;
			
			while(pc.isAlive()) {
				enemy = new Enemy();
				Console.WriteLine("You face: " + enemy.name + ", which seems to have " + enemy.health + " HP.");
				Console.WriteLine("You have " + pc.health + " HP -- Do you wish to attack? Y/N");
				string willAttack = Console.ReadLine();
				
				if(willAttack == "Y") {
					while(enemy.isAlive()) {
						pc.attack(enemy);
						if(enemy.isAlive()) {
							Console.WriteLine(enemy.name + " retaliates!");
							enemy.attack(pc);
						}
					}
					Console.WriteLine("The enemy has fallen! Another adventure begins...");
					
					//pc.exp += 
				}
			}
			
			Console.WriteLine(pc.name + " is dead! RIP. Game over!");
		}
Exemple #2
0
 public override void Draw(GameTime gameTime, Renderer renderer, Player localPlayer, Vector2 offset)
 {
     base.Draw(gameTime, renderer, localPlayer, offset);
     Context g = renderer.Context;
     Shape.Draw(renderer, GetPosition(renderer, offset), Direction, (Unit.Team == Teams.Home ? Arena.Config.HomeColor1 : Arena.Config.AwayColor1), (Unit.Team == Teams.Home ? Arena.Config.HomeColor2 : Arena.Config.AwayColor2), renderer.GetUnitSize((double)Arena.Config.ActorSize / 2));
     foreach (Ability a in Unit.Abilities)
         a.Draw(gameTime, g);
 }
Exemple #3
0
        public void DrawUIBelow(GameTime gameTime, Renderer renderer, Player localPlayer, Vector2 offset)
        {
            Vector2 position = GetPosition(renderer, offset);
            Context g = renderer.Context;
            if (Unit.Health < 1)
                return;
            double percent = (double)Unit.Health / (double)Unit.MaxHealth;
            double size = renderer.GetUnitSize((double)Arena.Config.ActorSize / 2) * 1.25;
            Vector2 start = position + new Vector2(0, (float)-size);
            g.MoveTo(start.X, start.Y);
            g.ArcNegative(position.X, position.Y, size, 3 * MathHelper.PiOver2, 3 * MathHelper.PiOver2 - (MathHelper.TwoPi * percent));
            if (percent < 1) {
                g.LineTo(position.X, position.Y);
                g.LineTo(start.X, start.Y);
            }
            renderer.SetColor(Unit.Team == localPlayer.Team ? Arena.Config.HealthColor1 : Arena.Config.EnemyHealthColor1);
            g.FillPreserve();
            renderer.SetColor(Unit.Team == localPlayer.Team ? Arena.Config.HealthColor2 : Arena.Config.EnemyHealthColor2);

            double unit = MathHelper.TwoPi / Unit.MaxHealth;
            for (int i = 0; i < Unit.Health; i++) {
                Vector2 dest = position + new Vector2((float)(Math.Cos(3 * MathHelper.PiOver2 - unit * i) * size), (float)(Math.Sin(3 * MathHelper.PiOver2 - unit * i) * size));
                g.MoveTo(position.X, position.Y);
                g.LineTo(dest.X, dest.Y);
                renderer.SetColor(Unit.Team == localPlayer.Team ? Arena.Config.HealthColor2 : Arena.Config.EnemyHealthColor2);
                g.Stroke();
            }

            if (Unit.Energy < 1 || Unit.Team != localPlayer.Team)
                return;
            double ePercent = (double)Unit.Energy / (double)Unit.MaxEnergy;
            g.MoveTo(position.X, position.Y - size);
            double energy = 3 * MathHelper.PiOver2 - (MathHelper.TwoPi * ePercent);
            double energySize = size / 7;
            g.ArcNegative(position.X, position.Y, size, 3 * MathHelper.PiOver2, energy);
            g.LineTo(position.X + Math.Cos(energy) * (energySize + size), position.Y + Math.Sin(energy) * (size + energySize));
            g.Arc(position.X, position.Y, size + energySize, energy, 3 * MathHelper.PiOver2);
            g.ClosePath();
            renderer.SetColor(Arena.Config.EnergyColor1);
            g.FillPreserve();
            renderer.SetColor(Arena.Config.EnergyColor2);
            g.Stroke();

            unit = MathHelper.TwoPi / Unit.MaxEnergy;
            for (int i = 0; i < Unit.Energy; i++) {
                Vector2 src = position + new Vector2((float)(Math.Cos(3 * MathHelper.PiOver2 - unit * i) * size), (float)(Math.Sin(3 * MathHelper.PiOver2 - unit * i) * size));
                Vector2 dest = position + new Vector2((float)(Math.Cos(3 * MathHelper.PiOver2 - unit * i) * (size + energySize)), (float)(Math.Sin(3 * MathHelper.PiOver2 - unit * i) * (size + energySize)));
                g.MoveTo(src.X, src.Y);
                g.LineTo(dest.X, dest.Y);
                renderer.SetColor(Arena.Config.EnergyColor2);
                g.Stroke();
            }
        }
Exemple #4
0
        public void DrawUIAbove(GameTime gameTime, Renderer renderer, Player localPlayer, Vector2 offset)
        {
            Context g = renderer.Context;
            Vector2 position = GetPosition(renderer, offset);

            renderer.DrawText(position, ((Player)Unit.Owner).Number.ToString(), renderer.GetUnitSize((double)Arena.Config.ActorSize / 2) * 0.7, TextAlign.Center, TextAlign.Middle, ColorPresets.White, (Unit.Team == Teams.Home ? Arena.Config.HomeColor2 : Arena.Config.AwayColor2), null, 0, "chunky_aa");

            g.Save();

            double rangeRadius = renderer.GetUnitSize() * Unit.AttackRange;
            double rangeCircum = 2 * MathHelper.Pi * rangeRadius;
            double start = gameTime.TotalGameTime.TotalSeconds / MathHelper.TwoPi * 1;
            double[] dash = new double[] { rangeCircum / 80, rangeCircum / 120 };
            g.SetDash(dash, 0);
            g.LineWidth = 2;
            g.Arc(position.X, position.Y, rangeRadius, start, start + MathHelper.TwoPi);
            g.SetSourceRGBA(0, 0, 0, 0.1);
            g.Stroke();
            g.Restore();
        }
Exemple #5
0
 public virtual void Draw(GameTime gameTime, Renderer renderer, Player localPlayer, Vector2 offset)
 {
     zoom = renderer.Zoom;
 }
Exemple #6
0
 public void ReceiveNewPlayer(int index, string name, int number, byte team, byte role)
 {
     Game.Cmd.Console.WriteLine("Recieving new player: " + name + " | " + number + " | " + (Teams)team + " | " + (Roles)role);
     Messages.Add(new Message(string.Format("{0} has connected.", name)));
     if (Players.ContainsKey(index))
         Players.Remove(index);
     Players.Add(index, new Player(name, number, (Teams)team, (Roles)role));
     if (Players.Count == 1) {
         Game.Cmd.Console.WriteLine("I didn't have any other players, so this new player is the local player.");
         LocalPlayer = Players[index];
     }
     Game.Cmd.Console.WriteLine("I now have " + Players.Count + " players.");
 }
Exemple #7
0
 public void SendTeamChat(Player player, string message)
 {
     if (Server.Local.IsLocalServer) {
         Client.Local.ReceiveTeamChat(Server.Local.GetPlayerID(player), message);
     }
     else {
         NetOutgoingMessage msg = Server.Local.server.CreateMessage();
         msg.Write((byte)NetConnectionStatus.Connected);
         msg.Write((byte)PacketType.TeamChat);
         msg.Write((byte)Server.Local.GetPlayerID(player));
         msg.Write(message);
         Server.Local.server.SendMessage(msg, Connection, NetDeliveryMethod.ReliableOrdered, 0);
     }
 }
Exemple #8
0
        public Unit MakePlayerUnit(Player player, Vector2 position)
        {
            Console.WriteLine("[S] Making new player unit for " + player.Name + " at (" + position.X + ", " + position.Y + ")");
            Unit u = new Unit(player, Role.List[player.Role].Health, Role.List[player.Role].Energy);
            u.Owner = player;
            u.Team = player.Team;
            u.JumpTo(position);
            Role.SetUpUnit(ref u, player.Role);
            player.ControlledUnits.Add(u);
            player.PlayerUnit = u;

            Units.Add(++unitIndex, u);
            foreach (RemoteClient r in AllClients())
                r.SendNewPlayerUnit(unitIndex, GetPlayerID(player));
            return u;
        }
Exemple #9
0
 private static void DrawAbility(GameTime gameTime, Renderer renderer, Player player, int ability)
 {
     Context g = renderer.Context;
     DrawBox(renderer, Ability[ability], new Cairo.Color(0, 0, 0), null);
     if (player.CurrentUnit.Abilities[ability].Ready || player.CurrentUnit.Abilities[ability].ActivationType == AbilityActivationType.Passive) {
         if (player.CurrentUnit.Abilities[ability].Level > 0)
             if (player.CurrentUnit.Energy >= player.CurrentUnit.Abilities[ability].EnergyCost && player.CurrentUnit.Abilities[ability].ActivationType != AbilityActivationType.Passive)
                 DrawBox(renderer, Ability[ability], new Cairo.Color(0, 0.9, 0), null);
             else
                 DrawBox(renderer, Ability[ability], new Cairo.Color(0.25, 0.5, 0.25), null);
         else
             DrawBox(renderer, Ability[ability], new Cairo.Color(0.1, 0.2, 0.1), null);
     }
     else {
         DrawBox(renderer, Ability[ability], new Cairo.Color(0, 0, 0.9), null);
         Vector2 timerCenter = Ability[ability][0] + new Vector2((float)AbilitySize / 2);
         g.MoveTo(timerCenter.ToPointD());
         double angle = Math.Max(0, MathHelper.TwoPi - (player.CurrentUnit.Abilities[ability].ReadyTime - gameTime.TotalGameTime).TotalMilliseconds / player.CurrentUnit.Abilities[ability].Cooldown / 25 / MathHelper.TwoPi);
         double adjustedAngle = angle - MathHelper.PiOver2;
         double flip = angle % MathHelper.PiOver2;
         if (flip > MathHelper.PiOver4) {
             flip -= MathHelper.PiOver2;
             flip = Math.Abs(flip);
         }
         g.LineTo(timerCenter.AddLengthDir(AbilitySize / 2 / Math.Cos(flip), adjustedAngle).ToPointD());
         if (angle > 7 * MathHelper.PiOver4)
             g.LineTo(Ability[ability][0].ToPointD());
         if (angle > 5 * MathHelper.PiOver4)
             g.LineTo(Ability[ability][3].ToPointD());
         if (angle > 3 * MathHelper.PiOver4)
             g.LineTo(Ability[ability][2].ToPointD());
         if (angle > 1 * MathHelper.PiOver4)
             g.LineTo(Ability[ability][1].ToPointD());
         g.LineTo(timerCenter.AddLengthDir(AbilitySize / 2, 3 * MathHelper.PiOver2).ToPointD());
         //g.LineTo(timerCenter.AddLengthDir(AbilitySize / 2, 3 * MathHelper.PiOver2).ToPointD());
         g.ClosePath();
         if (player.CurrentUnit.Energy >= player.CurrentUnit.Abilities[ability].EnergyCost)
             renderer.StrokeAndFill(new Cairo.Color(0, 0.5, 0), null);
         else
             renderer.StrokeAndFill(new Cairo.Color(0.25, 0.4, 0.25), null);
     }
     renderer.DrawText(Ability[ability][0] + new Vector2(Padding, Padding), player.CurrentUnit.Abilities[ability].Name.ToUpper(), 14, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, AbilityNameBackground, 0, "chunky");
     if (player.CurrentUnit.Abilities[ability].ActivationType != AbilityActivationType.Passive) {
         renderer.DrawText(Ability[ability][1] + new Vector2(-Padding, Padding), TemporaryKeyList[ability], 19, TextAlign.Right, TextAlign.Top, MainTextFill, MainTextStroke, AbilityKeyBackground, 0, "chunky");
         renderer.DrawText(Ability[ability][2] + new Vector2(-Padding, -Padding), player.CurrentUnit.Abilities[ability].Cooldown.ToString(), 14, TextAlign.Right, TextAlign.Bottom, MainTextFill, MainTextStroke, AbilityCooldownBackground, 0, "chunky");
         renderer.DrawText(Ability[ability][3] + new Vector2(Padding, -Padding), player.CurrentUnit.Abilities[ability].EnergyCost.ToString(), 14, TextAlign.Left, TextAlign.Bottom, MainTextFill, MainTextStroke, AbilityEnergyBackground, 0, "chunky");
     }
     if (!player.CurrentUnit.Abilities[ability].Ready && player.CurrentUnit.Abilities[ability].ActivationType != AbilityActivationType.Passive) {
         string str = Math.Round(((double)(player.CurrentUnit.Abilities[ability].ReadyTime - gameTime.TotalGameTime).TotalMilliseconds) / (double)1000, 1).ToString().MakeDecimal();
         renderer.DrawText(Ability[ability][0] + new Vector2((float)(AbilitySize / 2), (float)(AbilitySize / 2)), str, 32, TextAlign.Center, TextAlign.Middle, MainTextFill, MainTextStroke, null, 0, "chunky");
     }
     Vector2 levelOrigin = Ability[ability][1] + new Vector2(-Padding - LevelBoxSize, (float)((AbilitySize / 2) - (LevelBoxSize * player.CurrentUnit.Abilities[ability].Levels) / 2 - (LevelBoxPadding * (player.CurrentUnit.Abilities[ability].Levels) / 2) + LevelBoxPadding / 2));
     for (var i = 0; i < player.CurrentUnit.Abilities[ability].Levels; i++) {
         DrawBox(renderer, new List<Vector2>() {
             levelOrigin + new Vector2(0, LevelBoxSize * i + LevelBoxPadding * i),
             levelOrigin + new Vector2(LevelBoxSize, LevelBoxSize * i + LevelBoxPadding * i),
             levelOrigin + new Vector2(LevelBoxSize, LevelBoxSize * i + LevelBoxSize + LevelBoxPadding * i),
             levelOrigin + new Vector2(0, LevelBoxSize * i + LevelBoxSize + LevelBoxPadding * i)
         }, (player.CurrentUnit.Abilities[ability].Level >= i + 1 ? new Cairo.Color(1, 1, 1) : new Cairo.Color(0, 0, 0)), new Cairo.Color(1, 1, 1));
     }
 }
Exemple #10
0
 public void ReceiveReady(Player player, bool ready)
 {
     if (player.Team == Teams.Neutral)
         return;
     // TODO: IF IN LOBBY
     player.Ready = ready;
     Console.WriteLine("[S] {0}'s READY is now {1}", player.Name, ready);
     foreach (RemoteClient r in AllClientsButOne(GetPlayerID(player))) {
         r.SendReady(player, ready);
     }
 }
Exemple #11
0
 public void ReceiveLoadingPercent(Player player, float percent)
 {
     player.LoadingPercent = percent;
     foreach (RemoteClient r in AllClientsButOne(GetPlayerID(player))) {
         r.SendLoadingPercent(player, percent);
     }
 }
Exemple #12
0
 public void ReceiveLoaded(Player player)
 {
     player.Loaded = true;
 }
Exemple #13
0
 public void ReceiveChangeTeam(Player player, Teams team)
 {
     if (player.Team == team || player.Ready)
         return;
     player.Team = team;
     Console.WriteLine("[S] {0} moving to {1}", player.Name, team);
     foreach (RemoteClient r in AllClients()) {
         r.SendChangeTeam(player, team);
     }
 }
Exemple #14
0
 public void ReceiveChangeRole(Player player, Roles role)
 {
     if (player.Role == role || (player.Team != Teams.Home && player.Team != Teams.Away) || player.Ready)
         return;
     player.Role = role;
     Console.WriteLine("[S] {0} is now a {1}", player.Name, role);
     foreach (RemoteClient r in AllClients()) {
         r.SendChangeRole(player, role);
     }
 }
Exemple #15
0
 public void ReceiveAllChat(Player player, string message)
 {
     if (message.Length == 0)
         return;
     Console.WriteLine("[S] {0}: {1}", player.Name, message.Trim());
     foreach (RemoteClient r in AllClients())
         r.SendAllChat(player, message.Trim());
 }
Exemple #16
0
 public void ReceiveTeamChat(Player player, string message)
 {
     if (message.Length == 0)
         return;
     Console.WriteLine("[S] {0} ({1}): {2}", player.Name, player.Team, message.Trim());
     foreach (RemoteClient r in AllClients())
         if (Players[r.PlayerID].Team == player.Team)
             r.SendTeamChat(player, message.Trim());
 }
Exemple #17
0
 public void SendChangeRole(Player player, Roles role)
 {
     if (Server.Local.IsLocalServer) {
         Client.Local.ReceiveChangeRole(Server.Local.GetPlayerID(player), role);
     }
     else {
         NetOutgoingMessage msg = Server.Local.server.CreateMessage();
         msg.Write((byte)NetConnectionStatus.Connected);
         msg.Write((byte)PacketType.ChangeRole);
         msg.Write((byte)Server.Local.GetPlayerID(player));
         msg.Write((byte)role);
         Server.Local.server.SendMessage(msg, Connection, NetDeliveryMethod.ReliableOrdered, 0);
     }
 }
Exemple #18
0
 public override void Draw(GameTime gameTime, Renderer renderer, Player localPlayer, Vector2 offset)
 {
     Context g = renderer.Context;
     Shape.Draw(renderer, WorldPosition + offset, Direction, FillColor, StrokeColor, renderer.GetUnitSize());
 }
Exemple #19
0
 public void SendLoadingPercent(Player player, float percent)
 {
     if (Server.Local.IsLocalServer) {
         Client.Local.ReceiveLoadingPercent(Server.Local.GetPlayerID(player), percent);
     }
     else {
         NetOutgoingMessage msg = Server.Local.server.CreateMessage();
         msg.Write((byte)NetConnectionStatus.Connected);
         msg.Write((byte)PacketType.LoadingPercent);
         msg.Write((byte)Server.Local.GetPlayerID(player));
         msg.Write(percent);
         Server.Local.server.SendMessage(msg, Connection, NetDeliveryMethod.ReliableOrdered, 0);
     }
 }
Exemple #20
0
 public static void Update(GameTime gameTime, Player player)
 {
     if (Client.Local.IsShowingScoreboard)
         ScoreboardScale = Math.Min(ScoreboardScale + 0.1, 1);
     else
         ScoreboardScale = Math.Max(ScoreboardScale - 0.025, 0);
 }
Exemple #21
0
 public void SendReady(Player player, bool ready)
 {
     if (Server.Local.IsLocalServer) {
         Client.Local.ReceiveReady(Server.Local.GetPlayerID(player), ready);
     }
     else {
         NetOutgoingMessage msg = Server.Local.server.CreateMessage();
         msg.Write((byte)NetConnectionStatus.Connected);
         msg.Write((byte)PacketType.Ready);
         msg.Write((byte)Server.Local.GetPlayerID(player));
         msg.Write((byte)(ready ? 1 : 0));
         Server.Local.server.SendMessage(msg, Connection, NetDeliveryMethod.ReliableOrdered, 0);
     }
 }
Exemple #22
0
        public static void Draw(GameTime gameTime, Renderer renderer, Player player)
        {
            Context g = renderer.Context;
            if (player == null)
                return;

            // SCOREBOARD
            int sbTop = 3;
            if (ScoreboardScale > 0) {
                renderer.DrawText(new Vector2(BoxWidth + Margin - 400 + (float)(400 * ScoreboardScale), Margin + sbTop * 22), "HOME", 20, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, Config.HomeColor2, 0, "chunky");
                sbTop++;
                foreach (KeyValuePair<int, Player> kvp in Client.Local.Players) {
                    if (kvp.Value.Team == Teams.Home) {
                        renderer.DrawText(new Vector2(BoxWidth + Margin - 400 + (float)(400 * ScoreboardScale), Margin + sbTop * 22), kvp.Value.Name.ToUpper(), 20, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, null, 0, "chunky");
                        sbTop++;
                    }
                }
                renderer.DrawText(new Vector2(BoxWidth + Margin - 400 + (float)(400 * ScoreboardScale), Margin + sbTop * 22), "AWAY", 20, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, Config.AwayColor2, 0, "chunky");
                sbTop++;
                foreach (KeyValuePair<int, Player> kvp in Client.Local.Players) {
                    if (kvp.Value.Team == Teams.Away) {
                        renderer.DrawText(new Vector2(BoxWidth + Margin - 400 + (float)(400 * ScoreboardScale), Margin + sbTop * 22), kvp.Value.Name.ToUpper(), 20, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, null, 0, "chunky");
                        sbTop++;
                    }
                }
            }

            // LEFT
            DrawBox(renderer, LeftBox, Arena.Config.HUDBackground, null);

            // health background
            g.MoveTo(new Vector2(0 + Margin, 0 + Margin * 2 + (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2((float)(0 + Margin + BarWidth), 0 + Margin * 2 + (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2((float)(0 + Margin + BarWidth), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2(0 + Margin, renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
            g.ClosePath();
            renderer.StrokeAndFill(new Cairo.Color(0, 0, 0), null);

            // health foreground
            if (player.CurrentUnit != null) {
                g.MoveTo(new Vector2(0 + Margin, renderer.Height - Margin * 2 - (float)MinimapSize - (float)(BarHeight * player.CurrentUnit.GetHealthPercent())).ToPointD());
                g.LineTo(new Vector2((float)(0 + Margin + BarWidth), renderer.Height - Margin * 2 - (float)MinimapSize - (float)(BarHeight * player.CurrentUnit.GetHealthPercent())).ToPointD());
                g.LineTo(new Vector2((float)(0 + Margin + BarWidth), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
                g.LineTo(new Vector2(0 + Margin, renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
                g.ClosePath();
                renderer.StrokeAndFill(new Cairo.Color(0, 128, 0), null);
            }

            // energy background
            g.MoveTo(new Vector2((float)(0 + Margin * 2 + BarWidth), 0 + Margin * 2 + (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2((float)(0 + Margin * 2 + BarWidth * 2), 0 + Margin * 2 + (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2((float)(0 + Margin * 2 + BarWidth * 2), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2((float)(0 + Margin * 2 + BarWidth), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
            g.ClosePath();
            renderer.StrokeAndFill(new Cairo.Color(0, 0, 0), null);

            // energy foreground
            if (player.CurrentUnit != null) {
                g.MoveTo(new Vector2((float)(0 + Margin * 2 + BarWidth), renderer.Height - Margin * 2 - (float)MinimapSize - (float)(BarHeight * player.CurrentUnit.GetEnergyPercent())).ToPointD());
                g.LineTo(new Vector2((float)(0 + Margin * 2 + BarWidth * 2), renderer.Height - Margin * 2 - (float)MinimapSize - (float)(BarHeight * player.CurrentUnit.GetEnergyPercent())).ToPointD());
                g.LineTo(new Vector2((float)(0 + Margin * 2 + BarWidth * 2), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
                g.LineTo(new Vector2((float)(0 + Margin * 2 + BarWidth), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
                g.ClosePath();
                renderer.StrokeAndFill(new Cairo.Color(0, 0, 128), null);
            }

            // experience background
            g.MoveTo(new Vector2((float)(0 + Margin * 3 + BarWidth * 2), 0 + Margin * 2 + (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2((float)(0 + Margin * 3 + BarWidth * 3), 0 + Margin * 2 + (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2((float)(0 + Margin * 3 + BarWidth * 3), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2((float)(0 + Margin * 3 + BarWidth * 2), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
            g.ClosePath();
            renderer.StrokeAndFill(new Cairo.Color(0, 0, 0), null);

            // experience foreground
            if (player.CurrentUnit != null) {
                g.MoveTo(new Vector2((float)(0 + Margin * 3 + BarWidth * 2), renderer.Height - Margin * 2 - (float)MinimapSize - (float)(BarHeight * player.CurrentUnit.GetExperiencePercent())).ToPointD());
                g.LineTo(new Vector2((float)(0 + Margin * 3 + BarWidth * 3), renderer.Height - Margin * 2 - (float)MinimapSize - (float)(BarHeight * player.CurrentUnit.GetExperiencePercent())).ToPointD());
                g.LineTo(new Vector2((float)(0 + Margin * 3 + BarWidth * 3), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
                g.LineTo(new Vector2((float)(0 + Margin * 3 + BarWidth * 2), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
                g.ClosePath();
                renderer.StrokeAndFill(new Cairo.Color(0, 128, 128), null);
            }

            // minimap
            DrawBox(renderer, MinimapBackground, new Cairo.Color(0, 0, 0), null);
            renderer.DrawText(MinimapBackground[0] + new Vector2((float)(MinimapSize / 2), (float)(MinimapSize / 2)), "MINIMAP", 14, TextAlign.Center, TextAlign.Middle, MainTextFill, MainTextStroke, null, 0, "chunky");

            // RIGHT
            DrawBox(renderer, RightBox, Arena.Config.HUDBackground, null);

            if (player.CurrentUnit != null) {
                DrawAbility(gameTime, renderer, player, 0);
                DrawAbility(gameTime, renderer, player, 2);
                DrawAbility(gameTime, renderer, player, 1);
                DrawAbility(gameTime, renderer, player, 3);
            }

            if (player.CurrentUnit != null) {
                renderer.DrawText(new Vector2(Margin, Margin), "MOVE SPEED: " + player.CurrentUnit.MoveSpeed.ToString(), 14, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, null, 0, "chunky");
                renderer.DrawText(new Vector2(Margin, Margin + 14), "TURN SPEED: " + player.CurrentUnit.TurnSpeed.ToString(), 14, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, null, 0, "chunky");
                renderer.DrawText(new Vector2(Margin, Margin + 28), "ATTACK SPEED: " + player.CurrentUnit.AttackSpeed.ToString(), 14, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, null, 0, "chunky");
                renderer.DrawText(new Vector2(Margin, Margin + 42), "ATTACK RANGE: " + player.CurrentUnit.AttackRange.ToString(), 14, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, null, 0, "chunky");

                Client.Local.DrawChat(renderer, new Vector2(BoxWidth + Margin, renderer.Height - Margin), 10);

                for (int i = 0; i < player.CurrentUnit.Buffs.Count; i++) {
                    if (!player.CurrentUnit.Buffs[i].Hidden) {
                        string str = (player.CurrentUnit.Buffs[i].Permanent ? "" : "  " + Math.Round(((double)(player.CurrentUnit.Buffs[i].ExpirationTime - gameTime.TotalGameTime).TotalMilliseconds) / (double)1000, 1).ToString().MakeDecimal());
                        renderer.DrawText(new Vector2(renderer.Width - BoxWidth - Margin, renderer.Height -Margin - 20 * i), player.CurrentUnit.Buffs[i].Name + str, 14, TextAlign.Right, TextAlign.Bottom, MainTextFill, MainTextStroke, (player.CurrentUnit.Buffs[i].Type == BuffAlignment.Positive ? new Cairo.Color(0, 0.5, 0) : new Cairo.Color(0, 0, 0.5)), 0, "chunky");
                    }
                }
            }
            //Renderer.DrawText(new Vector2(0 + BoxWidth + Margin, 0 + Margin), Renderer.FPS.ToString(), 20, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, null, 0, null);
            //DrawText(g, new Vector2(0 + BoxWidth + Margin, 0 + Margin + 20), "P " + Client.Local.Players.Count.ToString(), 20, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, null, 0, null);
            //DrawText(g, new Vector2(0 + BoxWidth + Margin, 0 + Margin + 40), "U " + Client.Local.Units.Count.ToString(), 20, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, null, 0, null);
            //DrawText(g, new Vector2(0 + BoxWidth + Margin, 0 + Margin + 60), "A " + Client.Local.Actors.Count.ToString(), 20, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, null, 0, null);
        }
Exemple #23
0
 public void AddPlayer(Player player)
 {
     Console.WriteLine("[S] Adding new player: " + player.Name + " | " + player.Number + " | " + player.Team + " | " + player.Role);
     RemoteClient rc = null;
     if (!(player is Bot)) {
         rc = new RemoteClient(playerIndex, IsLocalServer ? null : incoming.SenderConnection);
         RemoteClients.Add(playerIndex, rc);
     }
     Players.Add(playerIndex, player);
     foreach (RemoteClient r in AllClients())
         r.SendNewPlayer(playerIndex);
     if (!(player is Bot))
         foreach (KeyValuePair<int, Player> kvp in Players)
             if (kvp.Key != playerIndex)
                 rc.SendNewPlayer(kvp.Key);
     /*Unit u = MakePlayerUnit(player, new Vector2(100, 100).AddLengthDir(100, Arena.Config.Random.NextDouble() * MathHelper.TwoPi));
         if (!(player is Bot))
         foreach (KeyValuePair<int, Unit> kvp in Units)
             if (kvp.Key != GetUnitID(u))
                 rc.SendNewPlayerUnit(GetUnitID(kvp.Value), GetPlayerID(kvp.Value.Owner));*/
     playerIndex++;
 }