protected Ability(Unit unit, string name, string description, AbilityActivationType activationType, int levels) { Unit = unit; Name = name; Description = description; ActivationType = activationType; Levels = levels; Level = 0; }
public Actor(Unit unit, VGame.Shape shape) { Unit = unit; Shape = shape; }
public void SendAttackOrder(Unit unit) { LocalPlayer.CurrentUnit.AttackTarget = unit; if (IsLocalServer) { Server.Local.ReceiveAttackOrder(Units.FirstOrDefault(x => x.Value == LocalPlayer.CurrentUnit).Key, Units.FirstOrDefault(x => x.Value == unit).Key); } else { Game.Cmd.Console.WriteLine("Sending attack order: " + LocalPlayer.Name + " -> " + unit.Owner.Name); NetOutgoingMessage msg = client.CreateMessage(); msg.Write((byte)PacketType.AttackOrder); msg.Write(GetUnitID(LocalPlayer.CurrentUnit)); msg.Write(GetUnitID(unit)); client.SendMessage(msg, NetDeliveryMethod.ReliableOrdered, 0); } }
public void ReceiveNewPlayerUnit(int unitIndex, int playerIndex, float x, float y, double direction) { Game.Cmd.Console.WriteLine("Recieving new player unit for " + Players[playerIndex].Name + " at (" + x + ", " + y + ")"); Player player = Players[playerIndex]; Unit u = new Unit(player, Role.List[player.Role].Health, Role.List[player.Role].Energy); u.Owner = player; u.Team = player.Team; u.JumpTo(new Vector2(x, y)); Role.SetUpUnit(ref u, player.Role); player.PlayerUnit = u; VGame.Shape shape = Role.MakeShape(player.Role); u.Actor = new Actor(u, shape); u.Actor.Unit = u; Actors.Add(u.Actor); Units.Add(unitIndex, u); player.ControlledUnits.Add(u); if (player.ControlledUnits.Count == 0) { player.PlayerUnit = u; player.CurrentUnit = u; } }
public int GetUnitID(Unit unit) { return Units.FirstOrDefault(x => x.Value == unit).Key; }
public void SendUseAbility(Unit unit, int ability, float? val1, float? val2) { if (Server.Local.IsLocalServer) { Client.Local.ReceiveUseAbility(Server.Local.GetUnitID(unit), ability, val1, val2); } else { NetOutgoingMessage msg = Server.Local.server.CreateMessage(); msg.Write((byte)NetConnectionStatus.Connected); msg.Write((byte)PacketType.UseAbility); msg.Write(Server.Local.GetUnitID(unit)); msg.Write((byte)ability); if (val1.HasValue) msg.Write((float)val1); if (val2.HasValue) msg.Write((float)val2); Server.Local.server.SendMessage(msg, Connection, NetDeliveryMethod.ReliableOrdered, 0); } }
public void SendMoveOrder(Unit unit, Vector2 position) { if (Server.Local.IsLocalServer) { Client.Local.ReceiveMoveOrder(Server.Local.GetUnitID(unit), position.X, position.Y); } else { NetOutgoingMessage msg = Server.Local.server.CreateMessage(); msg.Write((byte)NetConnectionStatus.Connected); msg.Write((byte)PacketType.MoveOrder); msg.Write(Server.Local.GetUnitID(unit)); msg.Write(unit.IntendedPosition.X); msg.Write(unit.IntendedPosition.Y); Server.Local.server.SendMessage(msg, Connection, NetDeliveryMethod.ReliableOrdered, 0); } }
public void SendLevelUp(Unit unit, int ability) { if (Server.Local.IsLocalServer) { Client.Local.ReceiveLevelUp(Server.Local.GetUnitID(unit), ability); } else { NetOutgoingMessage msg = Server.Local.server.CreateMessage(); msg.Write((byte)NetConnectionStatus.Connected); msg.Write((byte)PacketType.LevelUp); msg.Write(Server.Local.GetUnitID(unit)); msg.Write((byte)ability); Server.Local.server.SendMessage(msg, Connection, NetDeliveryMethod.ReliableOrdered, 0); } }
public void SendAttackOrder(Unit attacker, Unit victim) { if (Server.Local.IsLocalServer) { Client.Local.ReceiveAttackOrder(Server.Local.GetUnitID(attacker), Server.Local.GetUnitID(victim)); } else { NetOutgoingMessage msg = Server.Local.server.CreateMessage(); msg.Write((byte)NetConnectionStatus.Connected); msg.Write((byte)PacketType.AttackOrder); msg.Write(Server.Local.GetUnitID(attacker)); msg.Write(Server.Local.GetUnitID(victim)); Server.Local.server.SendMessage(msg, Connection, NetDeliveryMethod.ReliableOrdered, 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; }
protected void SendAttackOrder(Unit u) { if (CurrentUnit.AttackTarget != u) Server.Local.ReceiveAttackOrder(Server.Local.Units.FirstOrDefault(x => x.Value == CurrentUnit).Key, Server.Local.Units.FirstOrDefault(x => x.Value == u).Key); }
public static void SetUpUnit(ref Unit unit, Roles role) { unit.MoveSpeed = Arena.Role.List[role].MoveSpeed; unit.TurnSpeed = Arena.Role.List[role].TurnSpeed; unit.AttackRange = Arena.Role.List[role].AttackRange; unit.AttackDamage = Arena.Role.List[role].AttackDamage; unit.BaseAttackTime = Arena.Role.List[role].BaseAttackTime; unit.HealthRegen = Arena.Role.List[role].HealthRegen; unit.EnergyRegen = Arena.Role.List[role].EnergyRegen; foreach (System.Type t in Arena.Role.List[role].Abilities) { unit.Abilities.Add((Ability)Activator.CreateInstance(t, unit)); } }