public Encounter DeepCopy() { Encounter copy = new Encounter(); copy = (Encounter)this.MemberwiseClone(); copy.encounterTiles = new List <TileEnc>(); foreach (TileEnc s in this.encounterTiles) { TileEnc newTileEnc = new TileEnc(); newTileEnc.Layer1Filename = s.Layer1Filename; newTileEnc.Layer2Filename = s.Layer2Filename; newTileEnc.Layer3Filename = s.Layer3Filename; newTileEnc.LoSBlocked = s.LoSBlocked; newTileEnc.Walkable = s.Walkable; copy.encounterTiles.Add(newTileEnc); } copy.encounterCreatureRefsList = new List <CreatureRefs>(); foreach (CreatureRefs s in this.encounterCreatureRefsList) { CreatureRefs newCrtRef = new CreatureRefs(); newCrtRef.creatureResRef = s.creatureResRef; newCrtRef.creatureTag = s.creatureTag; newCrtRef.creatureStartLocationX = s.creatureStartLocationX; newCrtRef.creatureStartLocationY = s.creatureStartLocationY; copy.encounterCreatureRefsList.Add(newCrtRef); } copy.encounterCreatureList = new List <string>(); foreach (string s in this.encounterCreatureList) { copy.encounterCreatureList.Add(s); } copy.Triggers = new List <Trigger>(); foreach (Trigger t in this.Triggers) { copy.Triggers.Add(t); } copy.propsList = new List <Prop>(); foreach (Prop p in this.propsList) { copy.propsList.Add(p); } copy.encounterInventoryRefsList = new List <ItemRefs>(); foreach (ItemRefs s in this.encounterInventoryRefsList) { ItemRefs newItRef = new ItemRefs(); newItRef = s.DeepCopy(); copy.encounterInventoryRefsList.Add(newItRef); } copy.encounterPcStartLocations = new List <Coordinate>(); foreach (Coordinate s in this.encounterPcStartLocations) { Coordinate newCoor = new Coordinate(); newCoor.X = s.X; newCoor.Y = s.Y; copy.encounterPcStartLocations.Add(newCoor); } return(copy); }
public CreatureRefs DeepCopy() { CreatureRefs other = (CreatureRefs)this.MemberwiseClone(); return(other); }
private void panelView_MouseDown(object sender, MouseEventArgs e) { int col = e.X / sqr; int row = e.Y / sqr; if (tileSelected) { prntForm.encountersList[_selectedLbxEncounterIndex].encounterMapLayout[row, col] = currentTile; if (radioButton1.Checked) { prntForm.encountersList[_selectedLbxEncounterIndex].encounterTiles[row * 7 + col].Layer1Filename = currentTileFilename; } else if (radioButton2.Checked) { prntForm.encountersList[_selectedLbxEncounterIndex].encounterTiles[row * 7 + col].Layer2Filename = currentTileFilename; } } else if (PcSelected) { if (prntForm.encountersList[_selectedLbxEncounterIndex].encounterPcStartLocations.Count < 6) { prntForm.encountersList[_selectedLbxEncounterIndex].encounterPcStartLocations.Add(new Coordinate(col, row)); } } else if (CrtSelected) { CreatureRefs crtRef = new CreatureRefs(); crtRef.creatureResRef = prntForm.creaturesList[_selectedLbxCreatureIndex].cr_resref; crtRef.creatureTag = prntForm.creaturesList[_selectedLbxCreatureIndex].cr_tag + "_" + prntForm.mod.nextIdNumber; crtRef.creatureStartLocationX = col; crtRef.creatureStartLocationY = row; prntForm.encountersList[_selectedLbxEncounterIndex].encounterCreatureRefsList.Add(crtRef); } else if (rbtnInfo.Checked) { foreach (CreatureRefs crt in prntForm.encountersList[_selectedLbxEncounterIndex].encounterCreatureRefsList) { if ((crt.creatureStartLocationX == col) && (crt.creatureStartLocationY == row)) { //lastSelectedObjectResRef = crt.CreatureResRef; this.propertyGrid1.SelectedObject = crt; } } } else if (rbtnWalkable.Checked) { if (prntForm.encountersList[_selectedLbxEncounterIndex].encounterTiles[row * 7 + col].Walkable == true) { prntForm.encountersList[_selectedLbxEncounterIndex].encounterTiles[row * 7 + col].Walkable = false; } else { prntForm.encountersList[_selectedLbxEncounterIndex].encounterTiles[row * 7 + col].Walkable = true; } refreshMap(); } else if (rbtnLoS.Checked) { if (prntForm.encountersList[_selectedLbxEncounterIndex].encounterTiles[row * 7 + col].LoSBlocked == true) { prntForm.encountersList[_selectedLbxEncounterIndex].encounterTiles[row * 7 + col].LoSBlocked = false; } else { prntForm.encountersList[_selectedLbxEncounterIndex].encounterTiles[row * 7 + col].LoSBlocked = true; } refreshMap(); } refreshMap(); }
private void clickDrawArea(MouseEventArgs e) { switch (e.Button) { #region Left Button case MouseButtons.Left: refreshLeftPanelInfo(); prntForm.currentSelectedTrigger = null; gridX = e.X / sqr; gridY = e.Y / sqr; lastSquareClicked.X = currentSquareClicked.X; lastSquareClicked.Y = currentSquareClicked.Y; currentSquareClicked.X = gridX; currentSquareClicked.Y = gridY; #region PC Selected if (PcSelected) { if (prntForm.encountersList[prntForm._selectedLbxEncounterIndex].encounterPcStartLocations.Count < 6) { prntForm.encountersList[prntForm._selectedLbxEncounterIndex].encounterPcStartLocations.Add(new Coordinate(gridX, gridY)); } refreshMap(true); } #endregion #region Creature Selected else if (CrtSelected) { CreatureRefs crtRef = new CreatureRefs(); string _nodeTag = prntForm.frmBlueprints.tvCreatures.SelectedNode.Name; crtRef.creatureResRef = prntForm.creaturesList[prntForm.frmBlueprints.GetCreatureIndex(_nodeTag)].cr_resref; crtRef.creatureTag = prntForm.creaturesList[prntForm.frmBlueprints.GetCreatureIndex(_nodeTag)].cr_tag + "_" + prntForm.mod.nextIdNumber; crtRef.creatureStartLocationX = gridX; crtRef.creatureStartLocationY = gridY; prntForm.encountersList[prntForm._selectedLbxEncounterIndex].encounterCreatureRefsList.Add(crtRef); refreshMap(true); } #endregion #region Tile Selected else if (rbtnPaintTile.Checked) { //gridX = e.X / sqr; //gridY = e.Y / sqr; selectedTile.index = gridY * thisEnc.MapSizeX + gridX; prntForm.logText("gridx = " + gridX.ToString() + "gridy = " + gridY.ToString()); prntForm.logText(Environment.NewLine); if (radioButton1.Checked) { thisEnc.encounterTiles[selectedTile.index].Layer1Filename = currentTileFilename; //if shift key is down, draw all between here and lastclickedsquare if (Control.ModifierKeys == Keys.Shift) { Point cSqr = new Point(currentSquareClicked.X, currentSquareClicked.Y); Point lSqr = new Point(lastSquareClicked.X, lastSquareClicked.Y); int startX = lSqr.X; int startY = lSqr.Y; int endX = cSqr.X; int endY = cSqr.Y; if (lSqr.X >= cSqr.X) { startX = cSqr.X; endX = lSqr.X; } if (lSqr.Y >= cSqr.Y) { startY = cSqr.Y; endY = lSqr.Y; } for (int x = startX; x <= endX; x++) { for (int y = startY; y <= endY; y++) { thisEnc.encounterTiles[y * thisEnc.MapSizeX + x].Layer1Filename = currentTileFilename; currentSquareClicked = new Point(x, y); refreshMap(false); } } /*if (cSqr.X == lSqr.X) { if (cSqr.Y > lSqr.Y) { for (int i = lSqr.Y; i <= cSqr.Y; i++) { area.Tiles[i * area.MapSizeX + cSqr.X].Layer1Filename = currentTileFilename; currentSquareClicked = new Point(cSqr.X, i); refreshMap(false); } } else { for (int i = cSqr.Y; i <= lSqr.Y; i++) { area.Tiles[i * area.MapSizeX + cSqr.X].Layer1Filename = currentTileFilename; currentSquareClicked = new Point(cSqr.X, i); refreshMap(false); } } } else if (cSqr.Y == lSqr.Y) { if (cSqr.X > lSqr.X) { for (int i = lSqr.X; i <= cSqr.X; i++) { area.Tiles[cSqr.Y * area.MapSizeX + i].Layer1Filename = currentTileFilename; currentSquareClicked = new Point(i, cSqr.Y); refreshMap(false); } } else { for (int i = cSqr.X; i <= lSqr.X; i++) { area.Tiles[cSqr.Y * area.MapSizeX + i].Layer1Filename = currentTileFilename; currentSquareClicked = new Point(i, cSqr.Y); refreshMap(false); } } } else { int startX = lSqr.X; int startY = lSqr.Y; int endX = cSqr.X; int endY = cSqr.Y; if (lSqr.X >= cSqr.X) { startX = cSqr.X; endX = lSqr.X; } if (lSqr.Y >= cSqr.Y) { startY = cSqr.Y; endY = lSqr.Y; } for (int x = startX; x <= endX; x++) { for (int y = startY; y <= endY; y++) { area.Tiles[y * area.MapSizeX + x].Layer1Filename = currentTileFilename; currentSquareClicked = new Point(x, y); refreshMap(false); } } prntForm.logText("Shift key down for line painting but last click must be a straight line to this click"); prntForm.logText(Environment.NewLine); }*/ } } else if (radioButton2.Checked) { thisEnc.encounterTiles[selectedTile.index].Layer2Filename = currentTileFilename; if (Control.ModifierKeys == Keys.Shift) { Point cSqr = new Point(currentSquareClicked.X, currentSquareClicked.Y); Point lSqr = new Point(lastSquareClicked.X, lastSquareClicked.Y); int startX = lSqr.X; int startY = lSqr.Y; int endX = cSqr.X; int endY = cSqr.Y; if (lSqr.X >= cSqr.X) { startX = cSqr.X; endX = lSqr.X; } if (lSqr.Y >= cSqr.Y) { startY = cSqr.Y; endY = lSqr.Y; } for (int x = startX; x <= endX; x++) { for (int y = startY; y <= endY; y++) { thisEnc.encounterTiles[y * thisEnc.MapSizeX + x].Layer2Filename = currentTileFilename; currentSquareClicked = new Point(x, y); refreshMap(false); } } } } refreshMap(false); } #endregion #region Prop Selected else if (prntForm.PropSelected) { /*TODO still need to add props to encounters string selectedProp = prntForm.selectedLevelMapPropTag; prntForm.logText(selectedProp); prntForm.logText(Environment.NewLine); //gridX = e.X / sqr; //gridY = e.Y / sqr; prntForm.logText("gridx = " + gridX.ToString() + "gridy = " + gridY.ToString()); prntForm.logText(Environment.NewLine); // verify that there is no creature, blocked, or PC already on this location // add to a List<> a new item with the x,y coordinates if (le_selectedProp.ImageFileName == "blank") { return; } Prop newProp = new Prop(); newProp = le_selectedProp.DeepCopy(); newProp.PropTag = le_selectedProp.PropTag + "_" + prntForm.mod.nextIdNumber; newProp.LocationX = gridX; newProp.LocationY = gridY; thisEnc.Props.Add(newProp); // show the item on the map if (mod.moduleName != "NewModule") { Bitmap newBitmap = new Bitmap(prntForm._mainDirectory + "\\modules\\" + mod.moduleName + "\\graphics\\" + le_selectedProp.ImageFileName + ".png"); propBitmapList.Add(newBitmap); } else { //do nothing if default module } refreshMap(false); */ } #endregion #region Paint New Trigger Selected else if (rbtnPaintTrigger.Checked) { /*TODO stil need to add triggers to encounters string selectedTrigger = prntForm.selectedLevelMapTriggerTag; prntForm.logText(selectedTrigger); prntForm.logText(Environment.NewLine); //gridX = e.X / sqr; //gridY = e.Y / sqr; prntForm.logText("gridx = " + gridX.ToString() + "gridy = " + gridY.ToString()); prntForm.logText(Environment.NewLine); Point newPoint = new Point(gridX, gridY); //add the selected square to the squareList if doesn't already exist try { //check: if click square already exists, then erase from list Trigger newTrigger = thisEnc.getTriggerByTag(selectedTrigger); bool exists = false; foreach (Coordinate p in newTrigger.TriggerSquaresList) { if ((p.X == newPoint.X) && (p.Y == newPoint.Y)) { //already exists, erase newTrigger.TriggerSquaresList.Remove(p); exists = true; break; } } if (!exists) //doesn't exist so is a new point, add to list { Coordinate newCoor = new Coordinate(); newCoor.X = newPoint.X; newCoor.Y = newPoint.Y; newTrigger.TriggerSquaresList.Add(newCoor); } } catch { MessageBox.Show("The tag of the selected Trigger was not found in the area's trigger list"); } //update the map to show colored squares refreshMap(false); */ } #endregion #region Edit Trigger Selected else if (rbtnEditTrigger.Checked) { /*TODO add triggers to encounters if (prntForm.selectedLevelMapTriggerTag != null) { string selectedTrigger = prntForm.selectedLevelMapTriggerTag; prntForm.logText(selectedTrigger); prntForm.logText(Environment.NewLine); //gridX = e.X / sqr; //gridY = e.Y / sqr; prntForm.logText("gridx = " + gridX.ToString() + "gridy = " + gridY.ToString()); prntForm.logText(Environment.NewLine); Point newPoint = new Point(gridX, gridY); try { //check: if click square already exists, then erase from list Trigger newTrigger = thisEnc.getTriggerByTag(selectedTrigger); if (newTrigger == null) { MessageBox.Show("error: make sure to select a trigger to edit first (click info button then click on trigger)"); } bool exists = false; foreach (Coordinate p in newTrigger.TriggerSquaresList) { if ((p.X == newPoint.X) && (p.Y == newPoint.Y)) { //already exists, erase newTrigger.TriggerSquaresList.Remove(p); exists = true; break; } } if (!exists) //doesn't exist so is a new point, add to list { Coordinate newCoor = new Coordinate(); newCoor.X = newPoint.X; newCoor.Y = newPoint.Y; newTrigger.TriggerSquaresList.Add(newCoor); //newTrigger.TriggerSquaresList.Add(newPoint); } } catch { MessageBox.Show("The tag of the selected Trigger was not found in the area's trigger list"); } //update the map to show colored squares refreshMap(false); } */ } #endregion #region Walkmesh Toggle Selected else if (rbtnWalkable.Checked) { //gridX = e.X / sqr; //gridY = e.Y / sqr; selectedTile.index = gridY * thisEnc.MapSizeX + gridX; prntForm.logText("gridx = " + gridX.ToString() + "gridy = " + gridY.ToString()); prntForm.logText(Environment.NewLine); if (thisEnc.encounterTiles[selectedTile.index].Walkable == true) { thisEnc.encounterTiles[selectedTile.index].Walkable = false; } else { thisEnc.encounterTiles[selectedTile.index].Walkable = true; } refreshMap(false); } #endregion #region LoS mesh Toggle Selected else if (rbtnLoS.Checked) { //gridX = e.X / sqr; //gridY = e.Y / sqr; selectedTile.index = gridY * thisEnc.MapSizeX + gridX; prntForm.logText("gridx = " + gridX.ToString() + "gridy = " + gridY.ToString()); prntForm.logText(Environment.NewLine); if (thisEnc.encounterTiles[selectedTile.index].LoSBlocked == true) { thisEnc.encounterTiles[selectedTile.index].LoSBlocked = false; } else { thisEnc.encounterTiles[selectedTile.index].LoSBlocked = true; } refreshMap(false); } #endregion #region None Selected else // not placing, just getting info and possibly deleteing icon { contextMenuStrip1.Items.Clear(); //when left click, get location //gridX = e.X / sqr; //gridY = e.Y / sqr; Point newPoint = new Point(gridX, gridY); EventHandler handler = new EventHandler(HandleContextMenuClick); //loop through all the objects //if has that location, add the tag to the list //draw selection box refreshMap(false); drawSelectionBox(gridX, gridY); txtSelectedIconInfo.Text = ""; /*TODOforeach (Prop prp in thisEnc.Props) { if ((prp.LocationX == newPoint.X) && (prp.LocationY == newPoint.Y)) { // if so then give details about that icon (name, tag, etc.) txtSelectedIconInfo.Text = "name: " + prp.ImageFileName + Environment.NewLine + "tag: " + prp.PropTag + Environment.NewLine; lastSelectedObjectTag = prp.PropTag; //prntForm.selectedLevelMapPropTag = prp.PropTag; panelView.ContextMenuStrip.Items.Add(prp.PropTag, null, handler); //string, image, handler prntForm.frmIceBlinkProperties.propertyGrid1.SelectedObject = prp; } }*/ /*TODOforeach (Trigger t in thisEnc.Triggers) { foreach (Coordinate p in t.TriggerSquaresList) { if ((p.X == newPoint.X) && (p.Y == newPoint.Y)) { txtSelectedIconInfo.Text = "Trigger Tag: " + Environment.NewLine + t.TriggerTag; lastSelectedObjectTag = t.TriggerTag; prntForm.currentSelectedTrigger = t; prntForm.frmTriggerEvents.refreshTriggers(); panelView.ContextMenuStrip.Items.Add(t.TriggerTag, null, handler); //string, image, handler //prntForm.frmIceBlinkProperties.propertyGrid1.SelectedObject = t; } } }*/ //if the list is less than 2, do nothing if (panelView.ContextMenuStrip.Items.Count > 1) { contextMenuStrip1.Show(panelView, e.Location); } prntForm.frmTriggerEvents.refreshTriggers(); } #endregion break; #endregion #region Right Button case MouseButtons.Right: // exit by right click or ESC prntForm.logText("entered right-click"); prntForm.logText(Environment.NewLine); prntForm.selectedLevelMapCreatureTag = ""; prntForm.selectedLevelMapPropTag = ""; prntForm.CreatureSelected = false; prntForm.PropSelected = false; prntForm.currentSelectedTrigger = null; refreshMap(true); UpdatePB(); rbtnInfo.Checked = true; break; #endregion } }
public Encounter DeepCopy() { Encounter copy = new Encounter(); copy = (Encounter)this.MemberwiseClone(); copy.encounterTiles = new List<TileEnc>(); foreach (TileEnc s in this.encounterTiles) { TileEnc newTileEnc = new TileEnc(); newTileEnc.Layer1Filename = s.Layer1Filename; newTileEnc.Layer2Filename = s.Layer2Filename; newTileEnc.LoSBlocked = s.LoSBlocked; newTileEnc.Walkable = s.Walkable; copy.encounterTiles.Add(newTileEnc); } copy.encounterCreatureRefsList = new List<CreatureRefs>(); foreach (CreatureRefs s in this.encounterCreatureRefsList) { CreatureRefs newCrtRef = new CreatureRefs(); newCrtRef.creatureResRef = s.creatureResRef; newCrtRef.creatureTag = s.creatureTag; newCrtRef.creatureStartLocationX = s.creatureStartLocationX; newCrtRef.creatureStartLocationY = s.creatureStartLocationY; copy.encounterCreatureRefsList.Add(newCrtRef); } copy.encounterCreatureList = new List<string>(); foreach (string s in this.encounterCreatureList) { copy.encounterCreatureList.Add(s); } copy.encounterInventoryRefsList = new List<ItemRefs>(); foreach (ItemRefs s in this.encounterInventoryRefsList) { ItemRefs newItRef = new ItemRefs(); newItRef = s.DeepCopy(); copy.encounterInventoryRefsList.Add(newItRef); } copy.encounterPcStartLocations = new List<Coordinate>(); foreach (Coordinate s in this.encounterPcStartLocations) { Coordinate newCoor = new Coordinate(); newCoor.X = s.X; newCoor.Y = s.Y; copy.encounterPcStartLocations.Add(newCoor); } return copy; }