void handleStats(SyncDictionary <StatType, float> .Operation op, StatType stat, float value) { // equipment changed, perhaps update the gameobject //Debug.Log(op + " - " + stat); runRefresh(); }
public void CurlyBracesConstructor() { SyncDictionary <int, string> dict = new SyncDictionary <int, string> { { 1, "1" }, { 2, "2" }, { 3, "3" } }; Assert.That(dict.Count, Is.EqualTo(3)); }
public void UpdateWins(SyncDictionary <NetworkIdentity, MatchPlayerData> .Operation op, NetworkIdentity key, MatchPlayerData matchPlayerData) { if (key.gameObject.GetComponent <NetworkIdentity>().isLocalPlayer) { winCountLocal.text = $"Player {matchPlayerData.playerIndex}\n{matchPlayerData.wins}"; } else { winCountOpponent.text = $"Player {matchPlayerData.playerIndex}\n{matchPlayerData.wins}"; } }
public Appliaction(JsonValue config) { this.configRoot = config["ConfigRoot"].AsString(); this.port = config["Port"].AsInt(); this.ServicePort = config["LoginServerProt"].AsInt(); this.ServiceHost = config["LoginServerHost"].AsString(); ServerHost = config["ServiceHost"].AsString(); MaxBattleCount = config["MaxBattle"].AsInt(); NetProtoTool.EnableLog = config["Log"].AsBoolean(); Current = this; MonitorPool.Singleton.Init(this.GetType().Assembly); GateServerClients = new SyncDictionary <int, RequestClient>(); }
public void ObjectCanBeReusedAfterReset() { clientSyncDictionary.Reset(); // make old client the host SyncDictionary <int, string> hostList = clientSyncDictionary; SyncDictionary <int, string> clientList2 = new SyncDictionary <int, string>(); Assert.That(hostList.IsReadOnly, Is.False); // Check Add and Sync without errors hostList.Add(30, "hello"); hostList.Add(35, "world"); SerializeDeltaTo(hostList, clientList2); }
private bool PerformCooldownAction(PlantBehavior plant, SyncDictionary <NetworkIdentity, double> cooldowns, double cooldownDuration, CooldownActionDelegate action, ref int counter) { var netid = plant.gameObject.GetComponent <NetworkIdentity>() as NetworkIdentity; var time = NetworkTime.time; var cooldownEnd = time - cooldownDuration; // If we haven't watered this plant yet, pretend the cooldown just elapsed. cooldowns.TryGetValue(netid, out cooldownEnd); if (time + NetworkTime.timeStandardDeviation >= cooldownEnd) // Give some wiggle room for comparison to account for time variation { action(plant); cooldowns[netid] = time + cooldownDuration; counter++; return(true); } return(false); }
void modifyStatsStream(SyncDictionary <StatType, float> newStats) { foreach (StatType t in newStats.Keys) { //Debug.Log(t + " - " + newStats[t]+ " - "+(int)StatType.currentAttacks ); if (stats.ContainsKey(t)) { stats[t] += newStats[t]; } else { stats[t] = newStats[t]; } } refreshDownstream(); }
void OnHandGraphChange(SyncDictionary <int, HandGraph> .Operation op, int itemIndex, HandGraph newItem) { if (op == SyncDictionary <int, HandGraph> .Operation.OP_SET || op == SyncDictionary <int, HandGraph> .Operation.OP_ADD) { if (!isLocalPlayer) { if (SubscribedSyncHands.ContainsKey(newItem.HandID)) { SubscribedSyncHands[newItem.HandID].UpdateHand(newItem); } else { Debug.LogError("Couldn't find Hand ID: " + newItem.HandID); } } } }
void OnGraphChange(SyncDictionary <int, Node> .Operation op, int itemIndex, Node newItem) { if (op == SyncDictionary <int, Node> .Operation.OP_SET || op == SyncDictionary <int, Node> .Operation.OP_ADD) { if (!isLocalPlayer) { Debug.Log("Updating Scene Graph for node"); if (SubscribedObjects.ContainsKey(newItem.ObjectID)) { SubscribedObjects[newItem.ObjectID].UpdatePose(newItem.transform.localPosition, newItem.transform.localRotation); } else { Debug.LogError("Couldn't find ID: " + newItem.ObjectID); } } } }
public void SetUp() { serverSyncDictionary = new SyncDictionary <int, string>(); clientSyncDictionary = new SyncDictionary <int, string>(); // add some data to the list serverSyncDictionary.Add(0, "Hello"); serverSyncDictionary.Add(1, "World"); serverSyncDictionary.Add(2, "!"); SerializeAllTo(serverSyncDictionary, clientSyncDictionary); // set up dirty callbacks for testing. // AFTER adding the example data. we already know we added that data. serverSyncDictionaryDirtyCalled = 0; clientSyncDictionaryDirtyCalled = 0; serverSyncDictionary.OnDirty = () => ++ serverSyncDictionaryDirtyCalled; clientSyncDictionary.OnDirty = () => ++ clientSyncDictionaryDirtyCalled; }
public static Dictionary <StatType, float> sumStats(SyncDictionary <StatType, float> a, SyncDictionary <StatType, float> b) { Dictionary <StatType, float> statsBasic = new Dictionary <StatType, float>(); foreach (StatType s in a.Keys) { statsBasic[s] = a[s]; } foreach (StatType s in b.Keys) { if (statsBasic.ContainsKey(s)) { statsBasic[s] += b[s]; } else { statsBasic[s] = b[s]; } } return(statsBasic); }
public ServerWorldSimluater(int levelId, int index, List <BattlePlayer> battlePlayers) { LevelID = levelId; Index = index; IsCompleted = false; LevelData = ExcelToJSONConfigManager.Current.GetConfigByID <BattleLevelData>(levelId); MapConfig = ExcelToJSONConfigManager.Current.GetConfigByID <MapData>(LevelData.MapID); var mapGridName = MapConfig.LevelName + ".bin"; var data = ResourcesLoader.Singleton.GetMapGridByLevel(mapGridName); Grid = new Astar.GridBase(); Grid.maxX = data.MaxX; Grid.maxY = data.MaxY; Grid.maxZ = data.MaxZ; Grid.offsetX = data.Offset.x; Grid.offsetY = data.Offset.y; Grid.offsetZ = data.Offset.z; Grid.sizeX = data.Size.x; Grid.sizeY = data.Size.y; Grid.sizeZ = data.Size.z; Grid.grid = new Node[Grid.maxX, Grid.maxY, Grid.maxZ]; Data = data; foreach (var i in data.Nodes) { Grid.grid[i.X, i.Y, i.Z] = new Astar.Node() { x = i.X, isWalkable = i.IsWalkable, y = i.Y, z = i.Z }; } BattlePlayers = new SyncDictionary <long, BattlePlayer>(); foreach (var i in battlePlayers) { BattlePlayers.Add(i.User.UserID, i); } //this.Runner = new Thread(RunProcess); }
public BattleManager() { _servers = new SyncDictionary <long, UserServerInfo>(1024); }
public ServerManager() { Servers = new SyncDictionary <int, ServerMapping>(); BattleServers = new SyncDictionary <int, ServerMapping>(); }
public void LoadAllConfig(string configRoot) { this.ConfigRoot = configRoot.StartsWith("" + Path.DirectorySeparatorChar, StringComparison.Ordinal) ? configRoot : Path.Combine(AppDomain.CurrentDomain.BaseDirectory, configRoot); _magicData = new SyncDictionary <string, MagicData>(); _timeLines = new SyncDictionary <string, TimeLine>(); _aiTree = new SyncDictionary <string, TreeNode>(); _levels = new SyncDictionary <string, MapGridData>(); var magics = Directory.GetFiles(Path.Combine(ConfigRoot, "Magics"), "*.xml"); foreach (var i in magics) { var xml = File.ReadAllText(i, XmlParser.UTF8); var m = XmlParser.DeSerialize <Layout.MagicData>(xml); _magicData.Add(m.key, m); } var timeLines = Directory.GetFiles(Path.Combine(ConfigRoot, "Layouts"), "*.xml"); foreach (var i in timeLines) { var xml = File.ReadAllText(i, XmlParser.UTF8); var line = XmlParser.DeSerialize <TimeLine>(xml); _timeLines.Add("Layouts/" + Path.GetFileName(i), line); } var aitrees = Directory.GetFiles(Path.Combine(ConfigRoot, "AI"), "*.xml"); foreach (var i in aitrees) { var xml = File.ReadAllText(i, XmlParser.UTF8); var note = XmlParser.DeSerialize <TreeNode>(xml); _aiTree.Add("AI/" + Path.GetFileName(i), note); } var mapFiles = Directory.GetFiles(Path.Combine(ConfigRoot, "LevelGrids"), "*.bin"); foreach (var i in mapFiles) { var bytes = File.ReadAllBytes(i); var mapdata = new Proto.MapGridData(); using (var mem = new MemoryStream(bytes)) { using (var br = new BinaryReader(mem)) { mapdata.ParseFormBinary(br); } } _levels.Add(Path.GetFileName(i), mapdata); } var Manager = new ExcelToJSONConfigManager(this); var assemblyTypes = Manager.GetType().Assembly.GetTypes(); var mothed = Manager.GetType().GetMethod("GetConfigByID"); foreach (var i in assemblyTypes) { if (i.IsSubclassOf(typeof(JSONConfigBase))) { var m = mothed.MakeGenericMethod(i); m.Invoke(Manager, new object[] { 0 }); } } }
void OnScoreChange(SyncDictionary <NetworkIdentity, int> .Operation op, NetworkIdentity key, int item) { RefreshScoreboard(); }
private void OnPlayerListChange(SyncDictionary <int, Player> .Operation op, int key, Player player) { // equipment changed, perhaps update the gameobject Debug.Log(op + " - " + key + " - " + player); }