Ejemplo n.º 1
0
 private void CurrentClicked(JobSelectButton sender)
 {
     NetOutgoingMessage playerJobSpawnMsg = NetworkManager.CreateMessage();
     var picked = (JobDefinition) sender.UserData;
     playerJobSpawnMsg.Write((byte) NetMessage.RequestJob); //Request job.
     playerJobSpawnMsg.Write(picked.Name);
     NetworkManager.SendMessage(playerJobSpawnMsg, NetDeliveryMethod.ReliableOrdered);
 }
Ejemplo n.º 2
0
        private void HandleJobList(NetIncomingMessage msg)
        {
            int byteNum = msg.ReadInt32();
            byte[] compressedXml = msg.ReadBytes(byteNum);

            string jobListXml = ZipString.UnZipStr(compressedXml);

            JobHandler.Singleton.LoadDefinitionsFromString(jobListXml);
            int pos = 5;
            _jobButtonContainer.components.Clear(); //Properly dispose old buttons !!!!!!!
            foreach (JobDefinition definition in JobHandler.Singleton.JobSettings.JobDefinitions)
            {
                var current = new JobSelectButton(definition.Name, definition.JobIcon, definition.Description,
                                                  ResourceManager)
                                  {
                                      Available = definition.Available,
                                      Position = new Point(5, pos)
                                  };

                current.Clicked += CurrentClicked;
                current.UserData = definition;
                _jobButtonContainer.components.Add(current);
                pos += current.ClientArea.Height + 20;
            }
        }