public AgentCharacter GetAgent(string characterName) { if (agentControl == null) { Initialise(); } if (agentControl == null) { return(null); } ICharacterEvents characterEvents; if (events.TryGetValue(characterName, out characterEvents) && characterEvents is AgentCharacter) { return(characterEvents as AgentCharacter); } agentControl.Characters.Load(characterName, characterName + ".acs"); var character = agentControl.Characters.Character(characterName); // Will only be null with TestHarness if (settingsStore != null) { var settings = settingsStore.GetSettings(); character.SoundEffectsEnabled = settings.SoundEffects; } var agent = new AgentCharacter(lifetime, character, this, mainWindow, settingsStore); events.Add(characterName, agent); return(agent); }
void ICharacterEvents.OnClick(short button, bool shiftKey, short x, short y) { // 1 for left, 2 for right, 4 for middle. Presumably flags? if (button == 1) { AgentClicked.Fire(); } if (button == 2) { var menuStrip = new ContextMenuStrip(); menuStrip.Items.Add("Hide", null, (_, __) => Hide()); menuStrip.Items.Add("Animate", null, (_, __) => PlayRandom()); menuStrip.Items.Add("-"); var soundEffectsMenuItem = new ToolStripMenuItem { CheckOnClick = true, Checked = Character.SoundEffectsEnabled, Text = "Sound Effects" }; soundEffectsMenuItem.Click += (sender, args) => Character.SoundEffectsEnabled = soundEffectsMenuItem.Checked; menuStrip.Items.Add(soundEffectsMenuItem); menuStrip.Show(x, y); menuStrip.Closed += (sender, args) => { var settings = settingsStore.GetSettings(); settings.SoundEffects = soundEffectsMenuItem.Checked; settingsStore.SetSettings(settings); }; } }