public void OnConnect(NetworkMessage msg) { LobbyPlayer lobbyPlayer = new LobbyPlayer() { id = msg.conn.connectionId, charName = REX.Choice(DB.CharNames) }; lobbyPlayers.Add(lobbyPlayer); GameMsg.MsgPlayerLobbyUpdate playerLobbyUpdate = new GameMsg.MsgPlayerLobbyUpdate() { lobbyPlayer = lobbyPlayer }; for (int i = 0; i < NetworkServer.connections.Count; i++) { if (i == msg.conn.connectionId) { LobbyPlayer[] clients = lobbyPlayers.ToArray(); GameMsg.MsgPlayerLobbyList lobbyList = new GameMsg.MsgPlayerLobbyList() { lobbyPlayerList = clients, clientId = i }; NetworkServer.connections[i].Send(GameMsg.PlayerLobbyList, lobbyList); } else { NetworkServer.connections[i].Send(GameMsg.PlayerLobbyUpdate, playerLobbyUpdate); } } }
public override PlayerPawn Create(LobbyClientHandler.LobbyPlayer lobbyPlayer) { PlayerPawn player = new PlayerPawn(lobbyPlayer.charName, maxHp); player.SetId(lobbyPlayer.id); int[] affinityCounts = new int[Element.Count]; Spell[] spellsToLearn = REX.Choice(DB.BuyableSpells, 4); for (int i = 0; i < spellsToLearn.Length; i++) { ElementDisplay[] d = spellsToLearn[i].GetElementDisplays(RollContext.Null); for (int j = 0; j < d.Length; j++) { affinityCounts[d[j].element.GetId()]++; } } foreach (Spell spell in spellsToLearn) { player.AddSpell(spell); } for (int i = 0; i < Element.Count; i++) { if (affinityCounts[i] > 0) { player.Affinities[i].AddModifier(new AttributeModifier(GetName(), AttributeModifier.Operation.AddBase, affinityCounts[i])); } } return(player); }
public override void Open() { base.Open(); int shopAmount = 1; for (int i = 0; i < pawns.Length; i++) { List <string> buyableSpells = DB.BuyableSpells.Select(spell => spell.GetId()).ToList(); buyableSpells.RemoveAll(pawns[i].DoesKnowSpell); string[] shop = REX.Choice(buyableSpells, shopAmount); NetworkServer.SendToClient(i, GameMsg.ShopList, new GameMsg.MsgStringArray(shop)); } }
private void CastSpell(ServerBattle battle) { Spell spell = REX.Choice(GetSpells()); string spellId = spell.GetId(); int targetId = -1; if (spell.DoesRequireTarget()) { List <int> possibleTargets = new List <int>(); for (int i = 0; i < battle.allies.Length; i++) { if (battle.allies[i].IsAlive()) { possibleTargets.Add(battle.allies[i].GetId()); } } targetId = REX.Choice(possibleTargets); } battle.CastSpell(spellId, targetId); }