コード例 #1
0
ファイル: XmlAdd.cs プロジェクト: Crome696/ServUO
		public override void OnResponse( NetState state, RelayInfo info )
		{
			if(info == null || state == null || state.Mobile == null) return;

			int radiostate = -1;
			if(info.Switches.Length > 0)
			{
				radiostate = info.Switches[0];
			}
			// read the text entries for default values
			XmlSpawnerDefaults.DefaultEntry defs = XmlSpawnerDefaults.GetDefaults(state.Account.ToString(), state.Mobile.Name);
			if (defs.IgnoreUpdate)
			{
				return;
			}

			TextRelay tr = info.GetTextEntry( 100 );        // mindelay
			if(tr != null && tr.Text != null && tr.Text.Length > 0)
			{
				try{defs.MinDelay = TimeSpan.FromMinutes(double.Parse(tr.Text));} 
				catch{}
			}
			tr = info.GetTextEntry( 101 );        // maxdelay info
			if(tr != null && tr.Text != null && tr.Text.Length > 0)
			{
				try{defs.MaxDelay = TimeSpan.FromMinutes(double.Parse(tr.Text));} 
				catch{}
			}

			tr = info.GetTextEntry( 102 );        // min refractory
			if(tr != null && tr.Text != null && tr.Text.Length > 0)
			{
				try{defs.RefractMin = TimeSpan.FromMinutes(double.Parse(tr.Text));} 
				catch{}
			}

			tr = info.GetTextEntry( 103 );        // max refractory
			if(tr != null && tr.Text != null && tr.Text.Length > 0)
			{
				try{defs.RefractMax = TimeSpan.FromMinutes(double.Parse(tr.Text));} 
				catch{}
			}

			tr = info.GetTextEntry( 104 );        // TOD start
			if(tr != null && tr.Text != null && tr.Text.Length > 0)
			{
				try{defs.TODStart = TimeSpan.FromHours(double.Parse(tr.Text));} 
				catch{}
			}

			tr = info.GetTextEntry( 105 );        // TOD end
			if(tr != null && tr.Text != null && tr.Text.Length > 0)
			{
				try{defs.TODEnd = TimeSpan.FromHours(double.Parse(tr.Text));} 
				catch{}
			}

			tr = info.GetTextEntry( 106 );        // Speech trigger
			if (tr != null)
			{
				string txt = tr.Text;
				if (txt != null && txt.Length == 0) txt = null;
				defs.SpeechTrigger = txt;
			}
            


			tr = info.GetTextEntry( 107 );        // HomeRange
			if(tr != null && tr.Text != null && tr.Text.Length > 0)
			{
				try{defs.HomeRange = int.Parse(tr.Text);} 
				catch{}
			}

			tr = info.GetTextEntry( 108 );        // SpawnRange
			if(tr != null && tr.Text != null && tr.Text.Length > 0)
			{
				try{defs.SpawnRange = int.Parse(tr.Text);} 
				catch{}
			}

			tr = info.GetTextEntry( 109 );        // ProximityRange
			if(tr != null && tr.Text != null && tr.Text.Length > 0)
			{
				try{defs.ProximityRange = int.Parse(tr.Text);} 
				catch{}
			}

			tr = info.GetTextEntry( 110 );        // Team
			if(tr != null && tr.Text != null && tr.Text.Length > 0)
			{
				try{defs.Team = int.Parse(tr.Text);} 
				catch{}
			}

			tr = info.GetTextEntry( 111 );        // Duration
			if(tr != null && tr.Text != null && tr.Text.Length > 0)
			{
				try{defs.Duration = TimeSpan.FromMinutes(double.Parse(tr.Text));} 
				catch{}
			}

			tr = info.GetTextEntry( 112 );        // ProximitySound
			if(tr != null && tr.Text != null && tr.Text.Length > 0)
			{
				try{defs.ProximitySound = int.Parse(tr.Text);} 
				catch{}
			}

			tr = info.GetTextEntry( 113 );        // Kill reset
			if(tr != null && tr.Text != null && tr.Text.Length > 0)
			{
				try{defs.KillReset = int.Parse(tr.Text);} 
				catch{}
			}

			tr = info.GetTextEntry( 114 );        // Spawner name
			if(tr != null)
				defs.SpawnerName = tr.Text;

			// DefsExt entry
			tr = info.GetTextEntry( 115 );        // save def str
			if(tr != null)
				defs.DefsExt = tr.Text;

			tr = info.GetTextEntry( 117 );        // trigger on carried
			if (tr != null)
			{
				string txt = tr.Text;
				if (txt != null && txt.Length == 0) txt = null;
				defs.TriggerOnCarried = txt;
			}

			tr = info.GetTextEntry( 118 );        // no trigger on carried
			if (tr != null)
			{
				string txt = tr.Text;
				if (txt != null && txt.Length == 0) txt = null;
				defs.NoTriggerOnCarried = txt;
			}

			tr = info.GetTextEntry( 119 );        // proximity message
			if (tr != null)
			{
				string txt = tr.Text;
				if (txt != null && txt.Length == 0) txt = null;
				defs.ProximityMsg = txt;
			}

			tr = info.GetTextEntry( 120 );        // player trig prop
			if (tr != null)
			{
				string txt = tr.Text;
				if (txt != null && txt.Length == 0) txt = null;
				defs.PlayerTriggerProp = txt;
			}

			tr = info.GetTextEntry( 121 );        // Trigger probability
			if(tr != null && tr.Text != null && tr.Text.Length > 0)
			{
				try{defs.TriggerProbability = double.Parse(tr.Text);} 
				catch{}
			}

			tr = info.GetTextEntry( 122 );        // trig object prop
			if (tr != null)
			{
				string txt = tr.Text;
				if (txt != null && txt.Length == 0) txt = null;
				defs.TriggerObjectProp = txt;
			}

			tr = info.GetTextEntry( 123 );        // DespawnTime
			if(tr != null && tr.Text != null && tr.Text.Length > 0)
			{
				try{defs.DespawnTime = TimeSpan.FromHours(double.Parse(tr.Text));} 
				catch{}
			}

			tr = info.GetTextEntry( 124 );        // Skill trigger
			if (tr != null)
			{
				string txt = tr.Text;
				if (txt != null && txt.Length == 0) txt = null;
				defs.SkillTrigger = txt;
			}
            
			tr = info.GetTextEntry( 125 );        // AutoNumberValue
			if(tr != null && tr.Text != null && tr.Text.Length > 0)
			{
				try{defs.AutoNumberValue = int.Parse(tr.Text);} 
				catch{}
			}


			// fill the NameList from the text entries
			if(defs.ShowExtension)
				for(int i=0;i<MaxEntries;i++)
				{
					tr = info.GetTextEntry( 1000+i );
					if(defs.NameList != null && i < defs.NameList.Length && tr != null)
					{
						defs.NameList[i] = tr.Text;
					}
				}

			defs.Group = info.IsSwitched(304);
			defs.HomeRangeIsRelative = info.IsSwitched(305);
			defs.AutoNumber = info.IsSwitched(306);
			defs.SequentialSpawn = (info.IsSwitched(307) ? 0 : -1);
			defs.ExternalTriggering = info.IsSwitched(308);
			defs.AllowGhostTrig = info.IsSwitched(309);
			defs.SpawnOnTrigger = info.IsSwitched(311);
			defs.SmartSpawning = info.IsSwitched(310);
			defs.AllowNPCTrig = info.IsSwitched(312);

			switch ( info.ButtonID )
			{

				case 0: // Close
				{
					return;
				}
				case 100: // Add spawner
				{
					state.Mobile.Target = new PlaceSpawnerTarget(state);

					break;
				}
				case 115: // SaveDefs
				{
					string filename;
					if(defs.DefsExt != null && defs.DefsExt.Length > 0)
					{
						filename = String.Format("{0}-{1}-{2}",defs.AccountName, defs.PlayerName, defs.DefsExt);
					} 
					else 
					{
						filename = String.Format("{0}-{1}",defs.AccountName, defs.PlayerName);
					}
					DoSaveDefs(state.Mobile,filename);
					break;
				}
				case 116: // LoadDefs
				{
					string filename;
					if(defs.DefsExt != null && defs.DefsExt.Length > 0)
					{
						filename = String.Format("{0}-{1}-{2}",defs.AccountName, defs.PlayerName, defs.DefsExt);
					} 
					else 
					{
						filename = String.Format("{0}-{1}",defs.AccountName, defs.PlayerName);
					}
					DoLoadDefs(state.Mobile,filename);
					break;
				}
				case 117: // Restore Defaults
				{
					state.Mobile.SendMessage(String.Format("Restoring defaults"));
					XmlSpawnerDefaults.RestoreDefs(defs);
					break;
				}
				case 155: // Return the player to the starting loc
				{
					m_From.Location = defs.StartingLoc;
					m_From.Map = defs.StartingMap;
					break;
				}
				case 156: // Delete last spawner
				{
					if(defs.LastSpawner == null || defs.LastSpawner.Deleted) break;
					Refresh(state.Mobile);
					state.Mobile.SendGump( new XmlAddConfirmDeleteGump(state.Mobile, defs.LastSpawner) );
					return;
				}
				case 157: // Reset last spawner
				{
					if(defs.LastSpawner != null && !defs.LastSpawner.Deleted)
						defs.LastSpawner.DoReset = true;
					break;
				}
				case 158: // Respawn last spawner
				{
					if(defs.LastSpawner != null && !defs.LastSpawner.Deleted)
						defs.LastSpawner.DoRespawn = true;
					break;
				}
				case 180: // Set Options
				{
					Refresh(state.Mobile);
					state.Mobile.SendGump( new XmlAddOptionsGump(state.Mobile, defs.LastSpawner) );
					return;
				}
				case 200: // gump extension
				{
					defs.ShowExtension = !defs.ShowExtension;
					break;
				}
				case 306:  // TOD mode
				{
					if(defs.TODMode == XmlSpawner.TODModeType.Realtime)
						defs.TODMode = XmlSpawner.TODModeType.Gametime;
					else
						defs.TODMode = XmlSpawner.TODModeType.Realtime;
					break;
				}
				case 1000:  // GoTo
				{
					// then go to it
					DoGoTo(defs.LastSpawner);
					break;
				}
				case 1001:  // Show Gump
				{
					Refresh(state.Mobile);
					DoShowGump(state.Mobile, defs.LastSpawner);
					break;
				}
				case 1002:  // Show Props
				{
					Refresh(state.Mobile);
					DoShowProps(defs.LastSpawner);
					break;
				}
				case 3999: // clear selections
				{
					// clear the selections
					if(defs.SelectionList != null) Array.Clear(defs.SelectionList,0,defs.SelectionList.Length);
					break;
				}
				case 9998:  // refresh the gump
				{
					break;
				}
				default:
				{
					if(info.ButtonID >= 4000 && info.ButtonID < 4000+ MaxEntries)
					{
						int i = info.ButtonID - 4000;
						if(defs.SelectionList != null && i >= 0  && i < defs.SelectionList.Length)
						{
							defs.SelectionList[i] = !defs.SelectionList[i];
						}
					}
					if(info.ButtonID >= 5000 && info.ButtonID < 5000+ MaxEntries)
					{
						int i = info.ButtonID - 5000;
						/*
						string match = null;
						if(defs.NameList[i] != null)
						{
							match = defs.NameList[i].Trim();
						}
						*/

						defs.CategorySelectionIndex = i;
						XmlAddGump newg = new XmlAddGump(state.Mobile, defs.StartingLoc, defs.StartingMap, false, defs.ShowExtension, 0,0);

						state.Mobile.SendGump( newg );
                        
						if(defs.NameList[i] == null || defs.NameList[i].Length == 0)
						{

							// if no string has been entered then just use the full categorized add gump
							state.Mobile.CloseGump( typeof(Server.Gumps.XmlCategorizedAddGump));
							state.Mobile.SendGump( new Server.Gumps.XmlCategorizedAddGump( state.Mobile, defs.CurrentCategory, defs.CurrentCategoryPage,i, newg ) );
						} 
						else
						{
							// use the XmlPartialCategorizedAddGump
							state.Mobile.CloseGump( typeof(Server.Gumps.XmlPartialCategorizedAddGump));

							//Type [] types = (Type[])XmlPartialCategorizedAddGump.Match( defs.NameList[i] ).ToArray( typeof( Type ) );
							ArrayList types = XmlPartialCategorizedAddGump.Match( defs.NameList[i] );
							state.Mobile.SendGump( new XmlPartialCategorizedAddGump( state.Mobile, defs.NameList[i], 0, types, true, i, newg ) );
						}
						return;
						/*
						if(match == null || match.Length == 0)
						{
							state.Mobile.SendGump( new Server.Gumps.XmlCategorizedAddGump( state.Mobile, i, this ) );
						} else
						{
							state.Mobile.SendGump( new Server.Gumps.XmlLookupCategorizedAddGump( state.Mobile, match, 0,
							(Type[])Server.Gumps.AddGump.Match( match ).ToArray( typeof( Type ) ), true ) );
						}
						*/


					}
					break;
				}
			}
			// Create a new gump
			//m_Spawner.OnDoubleClick( state.Mobile);
			Refresh(state.Mobile);
		}
コード例 #2
0
ファイル: XmlAdd.cs プロジェクト: cynricthehun/UOLegends
 public PlaceSpawnerTarget(XmlAddGump addgump, NetState state)
     : base(30, true, TargetFlags.None)
 {
     m_addgump = addgump;
     defs = m_addgump.defs;
     m_state = state;
 }