private void NewProjectForm_Load(object sender, EventArgs e) { // Load all defined editing layers IEnvironmentContainer ec = EnvironmentContainer.Current; layerComboBox.DataSource = ec.Layers; }
public override int ResolveCollision(Direction direction) { IEnvironmentContainer environment = _owner.Environment; int offset = 0; var expectedSpec = GetExpectedSpecs(_owner, direction, _owner.Stats.StepLength); var collided = environment.Instances.FirstOrDefault(instance => instance != null && Collider.Colliding(new CollisionModel(instance.Actor.Stats.Size, instance.Actor.Position.X, instance.Actor.Position.Y), expectedSpec) && _owner != instance.Actor && _creator != instance.Actor && !(instance is Projectile) && !(instance is MovableObjectBehavior)); if (collided == null) { switch (direction) { case Direction.Down: case Direction.Up: offset = expectedSpec.Y - _owner.Position.Y; break; case Direction.Right: case Direction.Left: offset = expectedSpec.X - _owner.Position.X; break; } _owner.Position = new Stats.Point(expectedSpec.X, expectedSpec.Y); } else { var behavior = environment.Instances.FirstOrDefault(x => x.Actor == _owner); environment.RemoveInstance(behavior); collided.Actor.HandleAttack(_owner.Stats); } return(Math.Abs(offset)); }
/// <summary> /// Generates an index that cross-references each entity type with its corresponding /// ID group. /// </summary> /// <param name="groups">The ID groups to index</param> /// <returns>Index of the ID groups for each entity type. The key is the ID of the entity type, /// the values are elements in the <paramref name="groups"/> array.</returns> Dictionary <int, IdGroup> GetEntityGroups(IdGroup[] groups) { IEnvironmentContainer ec = EnvironmentContainer.Current; if (ec == null) { return(new Dictionary <int, IdGroup>()); } IEntity[] ents = ec.EntityTypes; Dictionary <int, IdGroup> result = new Dictionary <int, IdGroup>(ents.Length); foreach (IEntity e in ents) { IIdGroup idg = e.IdGroup; if (idg != null && idg.Id > 0) { int gid = idg.Id; IdGroup entGroup = Array.Find <IdGroup>(groups, g => g.Id == gid); Debug.Assert(entGroup != null); result.Add(e.Id, entGroup); } } return(result); }
public Knife(Point initialPosition, IActor creator, IEnvironmentContainer environmentContainer) : base(null, initialPosition, environmentContainer) { Stats = new DefaultStats(Common.Settings.ActorSettings.DefaultSize, 1, 9, Common.Settings.ActorSettings.DaggerStepLength); _collisionResolver = new ProjectileCollisionResolver(creator, this); _animation = new KnifeAnimation(); }
public DungeonStoneWall(Point initialPosition, IEnvironmentContainer environmentContainer) : base(null, initialPosition, environmentContainer) { Stats = new DefaultStats(Common.Settings.ActorSettings.DefaultSize, 0, 0, 0); _animation = new DungeonStoneWallAnimation(); _collisionResolver = new IgnoringCollisionResolver(this); }
public BrokenHeart(Point initialPosition, IEnvironmentContainer environmentContainer) : base(null, initialPosition, environmentContainer) { Stats = new DefaultStats(Common.Settings.ActorSettings.DefaultSize, 1, 3, Common.Settings.ActorSettings.BrokenHeartStepLength); _animation = new HeartAnimation(); _collisionResolver = new IgnoringCollisionResolver(this); }
private void AddLayerToThemeForm_Shown(object sender, EventArgs e) { IEnvironmentContainer ec = EnvironmentContainer.Current; ILayer[] layers = ec.Layers; listBox.Items.AddRange(layers); }
void LoadTableList() { IEnvironmentContainer ec = EnvironmentContainer.Current; string[] tableNames = new TableFactory().GetUserTables(); List <string> exclude = new List <string>(); if (excludeDomainTablesCheckBox.Checked) { IDomainTable[] domainTables = ec.DomainTables; foreach (IDomainTable t in domainTables) { exclude.Add(t.TableName); } } if (excludeAlreadyAddedCheckBox.Checked) { ITable[] tables = ec.Tables; foreach (ITable t in tables) { exclude.Add(t.TableName); } } if (exclude.Count > 0) { tableNames = Array.FindAll <string>(tableNames, delegate(string s) { return(!exclude.Contains(s)); }); } tableList.Items.Clear(); tableList.Items.AddRange(tableNames); }
public Sceleton(IWeaponItem weapon, Point initialPostion, IEnvironmentContainer environmentContainer) : base(weapon, initialPostion, environmentContainer) { Stats = new DefaultStats(Common.Settings.ActorSettings.DefaultSize, 3000, 1, Common.Settings.ActorSettings.SkeletonStepLength); _animation = new SceletonAnimation(); _collisionResolver = new DefaultCollisionResolver(this); _isInteractive = true; }
public virtual void HandleAttack(IStats attackerStats) { _owner.Stats.AddLives(-attackerStats.Damage); IEnvironmentContainer environment = _owner.Environment; //environment.AddInstance(DamageAnimationFactory.GetHeart(_owner)); if (_owner.Stats.HealthPercentage <= 0) { var ownerInstance = environment.Instances.FirstOrDefault(x => x.Actor == _owner); if (ownerInstance != null) { environment.RemoveInstance(ownerInstance); } } }
private void entitiesButton_Click(object sender, EventArgs e) { IEnvironmentContainer ec = EnvironmentContainer.Current; IEntity[] entities = ec.EntityTypes; IEntity[] selection = GetEntityTypes(); ChecklistForm <IEntity> dial = new ChecklistForm <IEntity>(entities, selection); if (dial.ShowDialog() == DialogResult.OK) { m_EntityTypes = dial.Selection; } dial.Dispose(); }
private void LayerForm_Shown(object sender, EventArgs e) { nameTextBox.Text = m_Edit.Name; IEnvironmentContainer ec = EnvironmentContainer.Current; IEntity[] all = ec.EntityTypes; pointComboBox.Items.AddRange(EnvironmentContainer.Filter(all, SpatialType.Point)); lineComboBox.Items.AddRange(EnvironmentContainer.Filter(all, SpatialType.Line)); textComboBox.Items.AddRange(EnvironmentContainer.Filter(all, SpatialType.Text)); polygonComboBox.Items.AddRange(EnvironmentContainer.Filter(all, SpatialType.Polygon)); if (m_Edit.DefaultPointType != null) { pointComboBox.SelectedItem = m_Edit.DefaultPointType; } if (m_Edit.DefaultLineType != null) { lineComboBox.SelectedItem = m_Edit.DefaultLineType; } if (m_Edit.DefaultTextType != null) { textComboBox.SelectedItem = m_Edit.DefaultTextType; } if (m_Edit.DefaultPolygonType != null) { polygonComboBox.SelectedItem = m_Edit.DefaultPolygonType; } ITheme theme = m_Edit.Theme; if (theme != null) { themeLabel.Visible = true; themeTextBox.Visible = true; themeTextBox.Text = theme.Name; } }
private void EntityForm_Shown(object sender, EventArgs e) { IEnvironmentContainer ec = EnvironmentContainer.Current; idGroupComboBox.Items.AddRange(ec.IdGroups); layerComboBox.Items.AddRange(ec.Layers); fontComboBox.Items.AddRange(ec.Fonts); IIdGroup g = m_Edit.IdGroup; if (g != null) { idGroupComboBox.SelectedItem = g; } ILayer layer = m_Edit.Layer; if (layer != null) { layerComboBox.SelectedItem = layer; } IFont font = m_Edit.Font; if (font != null) { fontComboBox.SelectedItem = font; } entityNameTextBox.Text = m_Edit.Name; pointCheckbox.Checked = m_Edit.IsPointValid; lineCheckbox.Checked = m_Edit.IsLineValid; boundaryCheckbox.Checked = m_Edit.IsPolygonBoundaryValid; textCheckbox.Checked = m_Edit.IsTextValid; labelCheckbox.Checked = m_Edit.IsPolygonValid; labelCheckbox.Enabled = textCheckbox.Checked; boundaryCheckbox.Enabled = lineCheckbox.Checked; }
private void tablesButton_Click(object sender, EventArgs e) { // If this is the first time the button has been clicked, load up current associations if (m_DefaultTables == null) { m_DefaultTables = m_Edit.DefaultTables; } // Grab the complete table list IEnvironmentContainer ec = EnvironmentContainer.Current; ITable[] tables = ec.Tables; ChecklistForm <ITable> dial = new ChecklistForm <ITable>(tables, m_DefaultTables); if (dial.ShowDialog() == DialogResult.OK) { m_DefaultTables = dial.Selection; } dial.Dispose(); }
private void TableForm_Load(object sender, EventArgs e) { // Load tables that have already been associated with Backsight IEnvironmentContainer ec = EnvironmentContainer.Current; m_Tables = ec.Tables; // If we're adding a new table, list the database tables. Otherwise // skip to the page that lists column names if (String.IsNullOrEmpty(m_Edit.TableName)) { LoadTableList(); } else { wizard.Pages.Remove(tablesPage); wizard.NextTo(columnsPage); } // Display available domains domainsListBox.DataSource = ec.DomainTables; }
/// <summary> /// Loads all the ID groups known to the database. /// </summary> IdGroup[] GetGroups() { IEnvironmentContainer ec = EnvironmentContainer.Current; if (ec == null) { return(new IdGroup[0]); } IIdGroup[] groups = ec.IdGroups; List <IdGroup> result = new List <IdGroup>(groups.Length); foreach (IIdGroup group in groups) { if (group.Id != 0) { IdGroup idg = new IdGroup(group); result.Add(idg); } } return(result.ToArray()); }
public EditorLevel(int screenWidth, int screenHeight) { _environment = new EnvironmentContainer(); LevelWidth = Common.Settings.GlobalSettings.LevelWidth; LevelHeight = Common.Settings.GlobalSettings.LevelHeight; PickableObjects = new ObservableCollection <IInstancePrototype>(); ActivePrototypes = new ObservableCollection <IInstancePrototype>(); ((ObservableCollection <IInstancePrototype>)ActivePrototypes).Insert(0, ActivePrototype); ///// TODO: Replace it with special editor environment container LevelObjects = new ViewModelCollection <IInstance>(); //LevelItems = EnvironmentContainer.Items; // Add Terrain 4 test var wall1 = new StaticObjectBehavior(new DungeonStoneWall(new Point(2400, 2600), _environment)); var wall2 = new StaticObjectBehavior(new DungeonStoneWall(new Point(2900, 2900), _environment)); LevelObjects.Add(wall1); LevelObjects.Add(wall2); //Replace with invisible actor with ignoring collision resolver Player = new Player(new BrokenHeart(new Point(2700, 2700), _environment), null); ViewPort = new ViewPort(screenWidth, screenHeight, (IInstance)Player); // Load available pickable objects foreach (Type t in System.Reflection.Assembly.GetAssembly(typeof(IInstancePrototype)).GetTypes() .Where(x => x.GetInterface(typeof(IInstancePrototype).Name) != null && !x.IsInterface && !x.IsAbstract)) { ((ObservableCollection <IInstancePrototype>)PickableObjects).Insert(0, (IInstancePrototype)Activator.CreateInstance(t)); } _environment.AddInstance((IInstance)Player); _environment.Run(); }
public Sanctuary(int screenWidth, int screenHeight) : base(screenWidth, screenHeight) { if (Container == null) { IEnvironmentContainer environment = new EnvironmentContainer(); Container = environment; LevelWidth = Common.Settings.GlobalSettings.LevelWidth; LevelHeight = Common.Settings.GlobalSettings.LevelHeight; environment.Instances = LevelObjects; LevelItems = environment.Items; // Add Terrain var wall1 = new StaticObjectBehavior(new DungeonStoneWall(new Point(2400, 2600), environment)); var wall2 = new StaticObjectBehavior(new DungeonStoneWall(new Point(2900, 2900), environment)); // Add Items var CopperKey = new CopperKeyItem(new Point(2500, 2500)); var CopperKey3 = new CopperKeyItem(new Point(2560, 2500)); var Knife = new KnifeWeaponItem(new Point(3000, 2500)); // Add NPC var GuideChar = new GuideBehavior(new Sceleton(new KnifeWeaponItem(null), new Point(3000, 2600), environment)); var TestEnemy1 = new TestEnemyBehavior(new Sceleton(new KnifeWeaponItem(null), new Point(3000, 2800), environment)); var TestEnemy2 = new TestEnemyBehavior(new Sceleton(new KnifeWeaponItem(null), new Point(2500, 2400), environment)); var TestEnemy3 = new TestEnemyBehavior(new Sceleton(new KnifeWeaponItem(null), new Point(2700, 2800), environment)); var TestEnemy4 = new TestEnemyBehavior(new Sceleton(new KnifeWeaponItem(null), new Point(2500, 3100), environment)); // Init Player var playerActor = new Thief(new KnifeWeaponItem(null), new Point(2700, 2700), environment); Player = new Player(playerActor); //Player = new Player(playerActor, new InteractionHandler(new Messenger())); ViewPort = new ViewPort(screenWidth, screenHeight, (IInstance)Player); // Load all obstacles environment.AddInstance(wall1); environment.AddInstance(wall2); environment.AddInstance(GuideChar); environment.AddInstance(TestEnemy1); environment.AddInstance(TestEnemy2); environment.AddInstance(TestEnemy3); environment.AddInstance(TestEnemy4); for (var i = 3000; i < 3500; i += 50) { environment.AddInstance(new GuideBehavior(new Sceleton(new KnifeWeaponItem(null), new Point(i, i), environment))); } for (var i = 32; i < 6000; i += 32) { environment.AddInstance(new StaticObjectBehavior(new DungeonStoneWall(new Point(i, 3000), environment))); } environment.AddInstance((IInstance)Player); // Load all items environment.Items.Add(CopperKey); environment.Items.Add(CopperKey3); environment.Items.Add(Knife); } else { IEnvironmentContainer environment = Container; LevelWidth = Common.Settings.GlobalSettings.LevelWidth; LevelHeight = Common.Settings.GlobalSettings.LevelHeight; LevelObjects = environment.Instances; LevelItems = environment.Items; // Init Player var playerActor = new Thief(new KnifeWeaponItem(null), new Point(2600, 2700), environment); Player = new Player(playerActor); //Player = new Player(playerActor, new InteractionHandler(new Messenger())); ViewPort = new ViewPort(screenWidth, screenHeight, (IInstance)Player); environment.AddInstance((IInstance)Player); } SubscribeOnEvents(); }
public IInstance CreateInstance(Point initialPosition, IEnvironmentContainer environmentContainer) { return(new StaticObjectBehavior(new DungeonStoneWall(initialPosition, environmentContainer))); }
public IInstance CreateInstance(Point initialPosition, IEnvironmentContainer environmentContainer) { return(new TestEnemyBehavior(new Sceleton(new KnifeWeaponItem(null), initialPosition, environmentContainer))); }
private void TemplateForm_Shown(object sender, EventArgs e) { // Load the schema combo (without the <none> item). Note that // this will end up calling tableComboBox_SelectedValueChanged, // which will set m_Table to be the first table in the array. IEnvironmentContainer ec = EnvironmentContainer.Current; ITable[] tables = ec.Tables; tableComboBox.DataSource = tables; // Attempt to locate a table that refers to the template (while the // database structure makes it possible to relate a template to // more than one table, the UI works under the assumption that a // template will apply to no more than one table - if this proves // ok in the longer run, the database structure should be revised // to match). m_Table = m_Edit.Schema; if (m_Table == null) { fieldsListBox.Enabled = false; formatTextBox.Enabled = false; } // Return if we're creating a new template if (m_Edit.IsNew) { if (tables.Length > 0) { tableComboBox.SelectedItem = tables[0]; } nameTextBox.Focus(); return; } // Define alternate title for the dialog window this.Text = "Update Text Template"; // Display the name of the item. nameTextBox.Text = m_Edit.Name; // If the schema is defined (it should be), select it. Then // load the list of fields, and select those that the template // already uses. if (m_Table != null) { //MessageBox.Show(m_Table.TableName); tableComboBox.SelectedItem = m_Table; ListFields(); } else { MessageBox.Show("Template does not have an associated table"); } // Display the current format. formatTextBox.Text = m_Edit.Format; // Set focus on the OK button. okButton.Focus(); }
private void EnvironmentStructureForm_Shown(object sender, EventArgs e) { // Hide the color label, since it only applies when an entity type is selected colorLabel.Visible = false; IEnvironmentContainer ec = EnvironmentContainer.Current; TreeNode root = new TreeNode(ec.Name); root.ImageKey = root.SelectedImageKey = "AttributeContainer"; tree.Nodes.Add(root); // Themes and layers ITheme[] themes = ec.Themes; if (themes.Length > 0) { for (int i = 0; i < themes.Length; i++) { // Ignore the blank theme ITheme theme = themes[i]; if (theme.Id == 0) { continue; } TreeNode themeNode = new TreeNode(theme.Name); themeNode.ImageKey = themeNode.SelectedImageKey = "Theme"; themeNode.Tag = theme; ILayer[] layers = theme.Layers; for (int j = 0; j < layers.Length; j++) { ILayer layer = layers[j]; TreeNode layerNode = new TreeNode(layer.Name); layerNode.ImageKey = layerNode.SelectedImageKey = "Layer"; layerNode.Tag = layer; themeNode.Nodes.Add(layerNode); } root.Nodes.Add(themeNode); } } // Now any layers that aren't associated with a theme ILayer[] allLayers = ec.Layers; foreach (ILayer layer in allLayers) { if (layer.Theme == null) { TreeNode layerNode = new TreeNode(layer.Name); layerNode.ImageKey = layerNode.SelectedImageKey = "Layer"; layerNode.Tag = layer; root.Nodes.Add(layerNode); } } // Entity types IEntity[] ents = ec.EntityTypes; foreach (IEntity ent in ents) { if (ent.Id != 0) { TreeNode entNode = new TreeNode(ent.Name); entNode.ImageKey = entNode.SelectedImageKey = "Body"; entNode.Tag = ent; root.Nodes.Add(entNode); } } }