public override void OnInspectorGUI() { DrawDefaultInspector(); FlatChunk c = (FlatChunk)target; DrawSettingsEditor(c.chunk_set, c.onChunkSetChange, ref chunk_foldout, ref chunk_editor); DrawSettingsEditor(c.noise_set, c.onNoiseSetChange, ref noise_foldout, ref noise_editor); }
void CloneButton_Click(object sender, EventArgs e) { if (mSubject == null) { MessageBox.Show("Can't do that -- mSubject is null!"); return; } //======================================================================= // Serialise the current Flat to XML, then deserialise - simple method // of creating a deep clone of the Flat. //======================================================================= XmlSerializer lSerializer = new XmlSerializer(mSubject.GetType()); StringWriter lStringWriter = new StringWriter(); lSerializer.Serialize(lStringWriter, mSubject); StringReader lStringReader = new StringReader(lStringWriter.ToString()); FlatChunk lDest = (FlatChunk)lSerializer.Deserialize(lStringReader); //======================================================================= // Add the new Flat to the SHET //======================================================================= lDest.DeclaredName = "NewFlat1"; Level lLevel = mMainForm.CurrentLevel; short lMaxIdx = 0; foreach (FlatChunk lExistingFlat in lLevel.SHET.Flats) { if (lExistingFlat.DeclaredIdx > lMaxIdx) { lMaxIdx = lExistingFlat.DeclaredIdx; } } lDest.DeclaredIdx = (short)(1 + lMaxIdx); int lSizeIncrease = lLevel.SHET.AddFlat(lDest); lLevel.SHET.TrailingZeroByteCount -= lSizeIncrease; //======================================================================= // Refresh the tree view //======================================================================= mMainForm.RootChunk = mMainForm.RootChunk; MessageBox.Show("Flat cloned successfully. " + (lLevel.SHET.TrailingZeroByteCount < 0 ? string.Format("Note that you have run out of space in your level file - you will need to free up {0} bytes before you can save your changes.", -lLevel.SHET.TrailingZeroByteCount) : "")); }
override protected void init() { Debug.Log("host init"); if (chunks == null || chunks.Length == 0) { Debug.Log("create chunks array"); chunks = new GameObject[chunk_host_set.length * chunk_host_set.width]; } if (chunks.Length != chunk_host_set.length * chunk_host_set.width) { Debug.Log("resizing chunk array"); resizeChunksArr(); } GameObject obj; for (int i = 0; i < chunk_host_set.length; i++) { for (int j = 0; j < chunk_host_set.width; j++) { obj = getChunkObj(i, j); if (obj == null) { obj = new GameObject(); obj.transform.parent = transform; FlatChunk fc = obj.AddComponent <FlatChunk>(); INoiseGenerator ng = getNoiseGen(i, j); fc.createdByParent(ng, chunk_set, getPos(i, j)); setChunkObj(i, j, obj); } else { obj.GetComponent <FlatChunk>().createdByParent( getNoiseGen(i, j), chunk_set, Vector3.Scale(getPos(i, j), transform.localScale) ); } } } }
private string GetImageNameForFlat(string xiDirname, FlatChunk xiFlat) { string lName = string.Format("Flat-{0}-{1}.png", xiFlat.DeclaredIdx, xiFlat.DeclaredName); lName.Replace('\\', '_'); lName.Replace('/', '_'); lName.Replace(':', '_'); lName.Replace('*', '_'); lName.Replace('?', '_'); lName.Replace('"', '_'); lName.Replace('<', '_'); lName.Replace('>', '_'); lName.Replace('|', '_'); return(string.Format("{0}{1}{2}", xiDirname, Path.DirectorySeparatorChar, lName)); }
void Start() { fc = GetComponent <FlatChunk>(); }
public override void SetSubject(Chunk xiChunk) { mSubject = xiChunk as FlatChunk; if (mSubject != null) { Level lLevel = mMainForm.CurrentLevel; Panel.SuspendLayout(); Panel.WeaponsTable.SuspendLayout(); Panel.ObjectsTable.SuspendLayout(); //===================================================================== // Set the general Flat properties //===================================================================== Panel.IdTextBox.Text = mSubject.DeclaredIdx.ToString(); Panel.NameTextBox.Text = mSubject.DeclaredName; Panel.OriginXTextBox.Text = mSubject.OriginPosition.X.ToString(); Panel.OriginYTextBox.Text = mSubject.OriginPosition.Y.ToString(); Panel.OriginZTextBox.Text = mSubject.OriginPosition.Z.ToString(); Panel.RotationXTextBox.Text = mSubject.RotationVector.X.ToString(); Panel.RotationYTextBox.Text = mSubject.RotationVector.Y.ToString(); Panel.RotationZTextBox.Text = mSubject.RotationVector.Z.ToString(); Panel.WidthTextBox.Text = mSubject.Width.ToString(); Panel.HeightTextBox.Text = mSubject.Height.ToString(); Panel.ScaleXTextBox.Text = mSubject.ScaleX.ToString(); Panel.ScaleYTextBox.Text = mSubject.ScaleY.ToString(); Panel.HasMetaDataCheckBox.Checked = mSubject.HasMetaData; Panel.FlagBCheckBox.Checked = mSubject.FlgB; Panel.FlagCCheckBox.Checked = mSubject.FlgC; Panel.VisibleCheckBox.Checked = mSubject.Visible; Panel.FlagECheckBox.Checked = mSubject.FlgE; Panel.NextNTextBox.Text = ArrayToString(mSubject.NextN); Panel.ByteSizeLabel.Text = string.Format("{0} bytes ({1} bytes free)", mSubject.ByteSize, lLevel.SHET.TrailingZeroByteCount); //===================================================================== // Set up the Weapons section //===================================================================== while (Panel.WeaponsTable.RowStyles.Count > 1) { Panel.WeaponsTable.RowStyles.RemoveAt(1); for (int ii = 0; ii < 6; ii++) { Panel.WeaponsTable.Controls.RemoveAt(6); } } if (mSubject.Weapons != null) { foreach (FlatChunk.WeaponEntry lWeapon in mSubject.Weapons) { AddWeaponToTable(lWeapon); } } //===================================================================== // Set up the Objects section //===================================================================== while (Panel.ObjectsTable.RowStyles.Count > 1) { Panel.ObjectsTable.RowStyles.RemoveAt(1); for (int ii = 0; ii < 11; ii++) { Panel.ObjectsTable.Controls.RemoveAt(11); } } if (mSubject.Objects != null) { foreach (FlatChunk.ObjectEntry lObject in mSubject.Objects) { AddObjectToTable(lObject); } } Panel.ObjectsTable.ResumeLayout(); Panel.WeaponsTable.ResumeLayout(); Panel.ResumeLayout(); } }