コード例 #1
0
		/// <summary>
		/// Change the current action
		/// </summary>
		/// <param name="action">Action handle</param>
		void SetAction(ActionBase action)
		{
			// Dispose disposable controls
			foreach (var ctrl in ActionPropertiesBox.Controls)
			{
				if (ctrl is IDisposable)
					((IDisposable)ctrl).Dispose();
			}
			ActionPropertiesBox.Controls.Clear();



			if (Script == null)
				return;

			Script.Action = action;

			if (action == null)
				return;

			ActionBaseControl basectrl = null;

			if (action is EnableTarget)
			{
				basectrl = new EnableTargetControl(action as EnableTarget, Dungeon);
			}
			else if (action is DisableTarget)
			{
				basectrl = new DisableTargetControl(action as DisableTarget, Dungeon);
			}
			else if (action is ToggleTarget)
			{
				basectrl = new ToggleTargetControl(action as ToggleTarget, Dungeon);
			}
			else if (action is ActivateTarget)
			{
				basectrl = new ActivateTargetControl(action as ActivateTarget, Dungeon);
			}
			else if (action is DeactivateTarget)
			{
				basectrl = new DeactivateTargetControl(action as DeactivateTarget, Dungeon);
			}
			else if (action is Teleport)
			{
				basectrl = new TeleportControl(action as Teleport, Dungeon);
			}
			else if (action is ChangePicture)
			{
				basectrl = new ChangePictureControl(action as ChangePicture);
			}
			else if (action is ChangeText)
			{
				basectrl = new ChangeTextControl(action as ChangeText);
			}
			else if (action is DisableChoice)
			{
				basectrl = new DisableChoiceControl(action as DisableChoice);
			}
			else if (action is EnableChoice)
			{
				basectrl = new EnableChoiceControl(action as EnableChoice);
			}
			else if (action is EndChoice)
			{
				basectrl = new EndChoiceControl(action as EndChoice);
			}
			else if (action is EndDialog)
			{
				basectrl = new EndDialogControl(action as EndDialog);
			}
			else if (action is GiveExperience)
			{
				basectrl = new GiveExperienceControl(action as GiveExperience);
			}
			else if (action is GiveItem)
			{
				basectrl = new GiveItemControl(action as GiveItem);
			}
			else if (action is Healing)
			{
				basectrl = new HealingControl(action as Healing);
			}
			else if (action is JoinCharacter)
			{
				basectrl = new JoinCharacterControl(action as JoinCharacter);
			}
			else if (action is DisplayMessage)
			{
				basectrl = new DisplayMessageControl(action as DisplayMessage);
			}
			else if (action is SetTo)
			{
				basectrl = new SetToControl(action as SetTo, Dungeon);
			}
			else if (action is SpawnMonster)
			{
				basectrl = new SpawnMonsterControl(action as SpawnMonster, Dungeon);
			}
			else
			{
			}

			if (basectrl == null)
				return;

			basectrl.Dock = DockStyle.Fill;
			ActionPropertiesBox.Controls.Add(basectrl);


		}
コード例 #2
0
		/// <summary>
		/// Set the action
		/// </summary>
		/// <param name="script">Action handle</param>
		/// <returns>True on success</returns>
		public bool SetAction(ActionBase script)
		{
			ControlHandle = null;
			
			if (script is Teleport)
			{
				ActionListBox.SelectedItem = "Teleport";
				ControlHandle = new TeleportControl(script as Teleport, Dungeon);
			}

			else if (script is ActivateTarget)
			{
				ActionListBox.SelectedItem = "Activate";
				ControlHandle = new ActivateTargetControl(script as ActivateTarget, Dungeon);
			}

			else if (script is ChangePicture)
			{
				ActionListBox.SelectedItem = "Change Picture";
				ControlHandle = new ChangePictureControl(script as ChangePicture);
			}

			else if (script is PlaySound)
			{
				ActionListBox.SelectedItem = "Play Sound";
				ControlHandle = new PlaySoundControl(script as PlaySound);
			}

			else if (script is EndDialog)
			{
				ActionListBox.SelectedItem = "End Dialog";
				ControlHandle = new EndDialogControl(script as EndDialog);
			}

			else if (script is EndChoice)
			{
				ActionListBox.SelectedItem = "End Choice";
				ControlHandle = new EndChoiceControl(script as EndChoice);
			}

			else if (script is DeactivateTarget)
			{
				ActionListBox.SelectedItem = "Deactivate";
				ControlHandle = new DeactivateTargetControl(script as DeactivateTarget, Dungeon);
			}

			else if (script is EnableChoice)
			{
				ActionListBox.SelectedItem = "Enable Choice";
				ControlHandle = new EnableChoiceControl(script as EnableChoice);
			}

			else if (script is DisableChoice)
			{
				ActionListBox.SelectedItem = "Disable Choice";
				ControlHandle = new DisableChoiceControl(script as DisableChoice);
			}

			else if (script is ToggleTarget)
			{
				ActionListBox.SelectedItem = "Toggle";
				ControlHandle = new ToggleTargetControl(script as ToggleTarget, Dungeon);
			}

			else if (script is Healing)
			{
				ActionListBox.SelectedItem = "Healing";
				ControlHandle = new HealingControl(script as Healing);
			}

			else if (script is GiveExperience)
			{
				ActionListBox.SelectedItem = "Give Experience";
				ControlHandle = new GiveExperienceControl(script as GiveExperience);
			}

			else if (script is GiveItem)
			{
				ActionListBox.SelectedItem = "Give Item";
				ControlHandle = new GiveItemControl(script as GiveItem);
			}

			else if (script is ChangeText)
			{
				ActionListBox.SelectedItem = "Change Text";
				ControlHandle = new ChangeTextControl(script as ChangeText);
			}

			else if (script is JoinCharacter)
			{
				ActionListBox.SelectedItem = "Join Character";
				ControlHandle = new JoinCharacterControl(script as JoinCharacter);
			}


			if (ControlHandle == null)
				return false;


			ControlHandle.Dock = DockStyle.Fill;
			ActionControlBox.Controls.Clear();
			ActionControlBox.Controls.Add(ControlHandle);

			return true;
		}