void GameManagerInterface.Start(GameTuple startAndEndPoint) { recreateGraphRepresentation(); base.InitializeRun(startAndEndPoint); RouterScript currentRouter = activeRouter.GetComponent <RouterScript>(); currentRouter.SetPriority(0); neighboursOfActiveRouter = ExpandNode(currentRouter); prioQueue = new PriorityQueue <RouterScript>(); for (int i = 0; i < neighboursOfActiveRouter.Count; i++) { PathScript pathToNeighbor = graphRepresentation2[currentRouter.GetRouterIndex(), neighboursOfActiveRouter[i].GetRouterIndex()]; neighboursOfActiveRouter[i].SetPriority(pathToNeighbor.GetPathCosts()); prioQueue.Enqueue(neighboursOfActiveRouter[i]); if (isLogEnabled) { Debug.Log(string.Format("Added router {0} to prio queue with path costs {1}.", neighboursOfActiveRouter[i], pathToNeighbor.GetPathCosts())); } } }
/// <summary> /// </summary> /// <param name="client"> /// </param> /// <param name="list"> /// </param> /// <param name="statId"> /// </param> private static void AddStat3232(Client client, IList <GameTuple <int, uint> > list, int statId) { var tuple = new GameTuple <int, uint> { Value1 = statId, Value2 = client.Character.Stats[statId].BaseValue }; list.Add(tuple); }
/// <summary> /// Starts a new run of the greedy algorithm. The reference path /// for the given tuple of start and end router is calculated. /// </summary> /// <param name="startAndEndPoint">The start and end router for this run.</param> public void Start(GameTuple startAndEndPoint) { base.recreateGraphRepresentation(); base.InitializeRun(startAndEndPoint); UpdateGreedyHeuristics( startAndEndPoint.source.GetComponent <RouterScript>(), startAndEndPoint.destination.GetComponent <RouterScript>()); neighboursOfActiveRouter = ExpandNode(activeRouter.GetComponent <RouterScript>()); }
/// <summary> /// Initializes the basic parameters for the new run. /// </summary> /// <param name="startAndEndPoint">Start and end point of the run.</param> protected void InitializeRun(GameTuple startAndEndPoint) { currentRun = startAndEndPoint; currentPath = new List <RouterScript>(); currentPath.Add(startAndEndPoint.source.GetComponent <RouterScript>()); activeRouter = startAndEndPoint.source; if (isLogEnabled) { Debug.Log("The current player position is: " + activeRouter); } }
/// <summary> /// </summary> /// <param name="client"> /// </param> /// <param name="statsToUpdate"> /// </param> public static void SendBulk(IZoneClient client, Dictionary <int, uint> statsToUpdate) { if (statsToUpdate.Count == 0) { return; } var toPlayfieldIds = new List <int>(); foreach (KeyValuePair <int, uint> keyValuePair in statsToUpdate) { if (client.Controller.Character.Stats[keyValuePair.Key].AnnounceToPlayfield) { toPlayfieldIds.Add(keyValuePair.Key); } } var toPlayfield = new List <GameTuple <CharacterStat, uint> >(); var toClient = new List <GameTuple <CharacterStat, uint> >(); foreach (KeyValuePair <int, uint> keyValuePair in statsToUpdate) { var statValue = new GameTuple <CharacterStat, uint> { Value1 = (CharacterStat)keyValuePair.Key, Value2 = keyValuePair.Value }; toClient.Add(statValue); if (toPlayfieldIds.Contains(keyValuePair.Key)) { toPlayfield.Add(statValue); } } var message = new StatMessage { Identity = client.Controller.Character.Identity, Stats = toClient.ToArray() }; client.SendCompressed(message); /* announce to playfield? */ if (toPlayfieldIds.Count > 0) { message.Stats = toPlayfield.ToArray(); client.Controller.Character.Playfield.AnnounceOthers(message, client.Controller.Character.Identity); } }
void GameManagerInterface.Start(GameTuple startAndEndPoint) { if (isLogEnabled) { Debug.Log("Source: " + startAndEndPoint.source.name + " , Destination: " + startAndEndPoint.destination.name); } base.recreateGraphRepresentation(); // Find paths from start to end point. optimalPath = base.findOptimalHopCountPath(startAndEndPoint.source, startAndEndPoint.destination); base.InitializeRun(startAndEndPoint); }
/// <summary> /// </summary> /// <param name="client"> /// </param> /// <param name="list"> /// </param> /// <param name="statId"> /// </param> private static void AddStat88(Client client, IList <GameTuple <byte, byte> > list, int statId) { if (statId > 255) { Console.WriteLine("AddStat88 statId(" + statId + ") > 255"); } var tuple = new GameTuple <byte, byte> { Value1 = (byte)statId, Value2 = (byte)client.Character.Stats[statId].BaseValue }; list.Add(tuple); }
/// <summary> /// </summary> /// <param name="client"> /// </param> /// <param name="list"> /// </param> /// <param name="statId"> /// </param> private static void AddStat816(IZoneClient client, IList <GameTuple <byte, short> > list, int statId) { if (statId > 255) { Console.WriteLine("AddStat816 statId(" + statId + ") > 255"); } var tuple = new GameTuple <byte, short> { Value1 = (byte)statId, Value2 = (short)client.Controller.Character.Stats[statId].BaseValue }; list.Add(tuple); }
/// <summary> /// </summary> /// <param name="character"> /// </param> /// <param name="statsToClient"> /// </param> /// <returns> /// </returns> private MessageDataFiller FillerBulk(ICharacter character, Dictionary <int, uint> statsToClient) { return(x => { GameTuple <CharacterStat, uint>[] temp = new GameTuple <CharacterStat, uint> [statsToClient.Count]; int cnt = 0; foreach (KeyValuePair <int, uint> kv in statsToClient) { temp[cnt] = new GameTuple <CharacterStat, uint>() { Value1 = (CharacterStat)kv.Key, Value2 = kv.Value }; cnt++; } x.Identity = character.Identity; x.Stats = temp; }); }
/// <summary> /// </summary> /// <param name="client"> /// </param> /// <param name="list"> /// </param> /// <param name="statId"> /// </param> private static void AddStat88(IZoneClient client, IList<GameTuple<byte, byte>> list, int statId) { if (statId > 255) { Console.WriteLine("AddStat88 statId(" + statId + ") > 255"); } var tuple = new GameTuple<byte, byte> { Value1 = (byte)statId, Value2 = (byte)client.Character.Stats[statId].BaseValue }; list.Add(tuple); }
/// <summary> /// </summary> /// <param name="client"> /// </param> /// <param name="list"> /// </param> /// <param name="statId"> /// </param> private static void AddStat3232(IZoneClient client, IList<GameTuple<int, uint>> list, int statId) { var tuple = new GameTuple<int, uint> { Value1 = statId, Value2 = client.Character.Stats[statId].BaseValue }; list.Add(tuple); }
/// <summary> /// </summary> /// <param name="client"> /// </param> /// <param name="statsToUpdate"> /// </param> public static void SendBulk(IZoneClient client, Dictionary<int, uint> statsToUpdate) { if (statsToUpdate.Count == 0) { return; } var toPlayfieldIds = new List<int>(); foreach (KeyValuePair<int, uint> keyValuePair in statsToUpdate) { if (client.Character.Stats[keyValuePair.Key].AnnounceToPlayfield) { toPlayfieldIds.Add(keyValuePair.Key); } } var toPlayfield = new List<GameTuple<CharacterStat, uint>>(); var toClient = new List<GameTuple<CharacterStat, uint>>(); foreach (KeyValuePair<int, uint> keyValuePair in statsToUpdate) { var statValue = new GameTuple<CharacterStat, uint> { Value1 = (CharacterStat)keyValuePair.Key, Value2 = keyValuePair.Value }; toClient.Add(statValue); if (toPlayfieldIds.Contains(keyValuePair.Key)) { toPlayfield.Add(statValue); } } var message = new StatMessage { Identity = client.Character.Identity, Stats = toClient.ToArray() }; client.SendCompressed(message); /* announce to playfield? */ if (toPlayfieldIds.Count > 0) { message.Stats = toPlayfield.ToArray(); client.Character.Playfield.AnnounceOthers(message, client.Character.Identity); } }
public object Deserialize( StreamReader streamReader, SerializationContext serializationContext, PropertyMetaData propertyMetaData = null) { VendingMachineFullUpdateMessage message = new VendingMachineFullUpdateMessage(); message.N3MessageType = (N3MessageType)streamReader.ReadInt32(); message.Identity = streamReader.ReadIdentity(); message.Unknown = streamReader.ReadByte(); message.TypeIdentifier = streamReader.ReadInt32(); var identityType = (IdentityType)streamReader.ReadInt32(); int identityInstance = streamReader.ReadInt32(); message.NpcIdentity = new Identity() { Type = identityType, Instance = identityInstance }; if (message.NpcIdentity.Instance == 0) { message.Coordinates = new Vector3(); message.Coordinates.X = streamReader.ReadSingle(); message.Coordinates.Y = streamReader.ReadSingle(); message.Coordinates.Z = streamReader.ReadSingle(); message.Heading = new Quaternion(); message.Heading.X = streamReader.ReadSingle(); message.Heading.Y = streamReader.ReadSingle(); message.Heading.Z = streamReader.ReadSingle(); message.Heading.W = streamReader.ReadSingle(); } message.PlayfieldId = streamReader.ReadInt32(); message.Unknown4 = streamReader.ReadInt32(); message.Unknown5 = streamReader.ReadInt32(); message.Unknown6 = streamReader.ReadInt16(); int x3f1 = streamReader.ReadInt32(); x3f1 = x3f1 / 0x03f1; List<GameTuple<CharacterStat, uint>> temp = new List<GameTuple<CharacterStat, uint>>(); while (x3f1 > 1) { var temptuple = new GameTuple<CharacterStat, uint>(); temptuple.Value1 = (CharacterStat)streamReader.ReadInt32(); temptuple.Value2 = streamReader.ReadUInt32(); temp.Add(temptuple); x3f1--; } message.Stats = temp.ToArray(); message.Unknown7 = streamReader.ReadString(streamReader.ReadInt32()).Replace("\0", ""); /*int templen = streamReader.ReadInt32(); // String length!! message.Unknown7 = ""; while (templen > 0) { message.Unknown7 += (char)streamReader.ReadByte(); templen--; } message.Unknown7 = message.Unknown7.TrimEnd('\0');*/ message.Unknown8 = streamReader.ReadInt32(); if (message.Unknown8 == 2) { message.Unknown9 = streamReader.ReadInt32(); x3f1 = streamReader.ReadInt32(); x3f1 = x3f1 / 0x03f1; List<Identity> tempids = new List<Identity>(); while (x3f1 > 1) { identityType = (IdentityType)streamReader.ReadInt32(); identityInstance = streamReader.ReadInt32(); tempids.Add(new Identity() { Type = identityType, Instance = identityInstance }); x3f1--; } message.Unknown10 = tempids.ToArray(); } message.Unknown11 = streamReader.ReadInt32(); return message; }
/// <summary> /// </summary> /// <param name="skillMessage"> /// </param> /// <param name="client"> /// </param> protected override void Read(SkillMessage skillMessage, IZoneClient client) { uint baseIp = 0; uint characterLevel = client.Controller.Character.Stats[StatIds.level].BaseValue; // Calculate base IP value for character level if (characterLevel > 204) { baseIp += (characterLevel - 204) * 600000; characterLevel = 204; } if (characterLevel > 189) { baseIp += (characterLevel - 189) * 150000; characterLevel = 189; } if (characterLevel > 149) { baseIp += (characterLevel - 149) * 80000; characterLevel = 149; } if (characterLevel > 99) { baseIp += (characterLevel - 99) * 40000; characterLevel = 99; } if (characterLevel > 49) { baseIp += (characterLevel - 49) * 20000; characterLevel = 49; } if (characterLevel > 14) { baseIp += (characterLevel - 14) * 10000; // Change 99 => 14 by Wizard characterLevel = 14; } baseIp += 1500 + ((characterLevel - 1) * 4000); int count = skillMessage.Skills.Length; var statlist = new List <int>(); while (count > 0) { count--; GameTuple <CharacterStat, uint> stat = skillMessage.Skills[count]; client.Controller.Character.Stats[(int)stat.Value1].Value = (int)stat.Value2; statlist.Add((int)stat.Value1); } statlist.Add(53); // IP uint usedIp = baseIp - (uint)Math.Floor(SkillUpdate.CalculateIP(client.Controller.Character.Stats)); client.Controller.Character.Stats[StatIds.ip].BaseValue = usedIp; // Send the changed stats back to the client count = 0; var newStats = new List <GameTuple <CharacterStat, uint> >(); while (count < statlist.Count) { int stat = statlist[count]; uint statval = client.Controller.Character.Stats[stat].BaseValue; newStats.Add(new GameTuple <CharacterStat, uint> { Value1 = (CharacterStat)stat, Value2 = statval }); count++; } var reply = new SkillMessage { Identity = skillMessage.Identity, Unknown = 0x00, Skills = newStats.ToArray() }; client.Controller.Character.Playfield.Publish( new IMSendAOtomationMessageBodyToClient { client = client, Body = reply }); // and save the changes to the statsdb client.Controller.Character.WriteStats(); }
public object Deserialize( StreamReader streamReader, SerializationContext serializationContext, PropertyMetaData propertyMetaData = null) { VendingMachineFullUpdateMessage message = new VendingMachineFullUpdateMessage(); message.N3MessageType = (N3MessageType)streamReader.ReadInt32(); message.Identity = streamReader.ReadIdentity(); message.Unknown = streamReader.ReadByte(); message.TypeIdentifier = streamReader.ReadInt32(); var identityType = (IdentityType)streamReader.ReadInt32(); int identityInstance = streamReader.ReadInt32(); message.NpcIdentity = new Identity() { Type = identityType, Instance = identityInstance }; if (message.NpcIdentity.Instance == 0) { message.Coordinates = new Vector3(); message.Coordinates.X = streamReader.ReadSingle(); message.Coordinates.Y = streamReader.ReadSingle(); message.Coordinates.Z = streamReader.ReadSingle(); message.Heading = new Quaternion(); message.Heading.X = streamReader.ReadSingle(); message.Heading.Y = streamReader.ReadSingle(); message.Heading.Z = streamReader.ReadSingle(); message.Heading.W = streamReader.ReadSingle(); } message.PlayfieldId = streamReader.ReadInt32(); message.Unknown4 = streamReader.ReadInt32(); message.Unknown5 = streamReader.ReadInt32(); message.Unknown6 = streamReader.ReadInt16(); int x3f1 = streamReader.ReadInt32(); x3f1 = x3f1 / 0x03f1; List <GameTuple <CharacterStat, uint> > temp = new List <GameTuple <CharacterStat, uint> >(); while (x3f1 > 1) { var temptuple = new GameTuple <CharacterStat, uint>(); temptuple.Value1 = (CharacterStat)streamReader.ReadInt32(); temptuple.Value2 = streamReader.ReadUInt32(); temp.Add(temptuple); x3f1--; } message.Stats = temp.ToArray(); message.Unknown7 = streamReader.ReadString(streamReader.ReadInt32()).Replace("\0", ""); /*int templen = streamReader.ReadInt32(); // String length!! * message.Unknown7 = ""; * while (templen > 0) * { * message.Unknown7 += (char)streamReader.ReadByte(); * templen--; * } * message.Unknown7 = message.Unknown7.TrimEnd('\0');*/ message.Unknown8 = streamReader.ReadInt32(); if (message.Unknown8 == 2) { message.Unknown9 = streamReader.ReadInt32(); x3f1 = streamReader.ReadInt32(); x3f1 = x3f1 / 0x03f1; List <Identity> tempids = new List <Identity>(); while (x3f1 > 1) { identityType = (IdentityType)streamReader.ReadInt32(); identityInstance = streamReader.ReadInt32(); tempids.Add(new Identity() { Type = identityType, Instance = identityInstance }); x3f1--; } message.Unknown10 = tempids.ToArray(); } message.Unknown11 = streamReader.ReadInt32(); return(message); }