/// <summary> /// /// </summary> /// <param name="script"></param> /// <param name="dungeon"></param> public PressurePlateScriptForm(PressurePlateScript script, Dungeon dungeon) { InitializeComponent(); if (script == null) { Script = new PressurePlateScript(); } else { Script = script; } ActionBox.Dungeon = dungeon; ActionBox.Script = Script; SetCondition(Script.Condition); }
/// <summary> /// /// </summary> /// <param name="node"></param> /// <returns></returns> public override bool Load(XmlNode xml) { if (xml == null || xml.Name != Tag) { return(false); } IsHidden = xml.Attributes["hidden"] != null?bool.Parse(xml.Attributes["hidden"].Value) : false; Reusable = xml.Attributes["reusable"] != null?bool.Parse(xml.Attributes["reusable"].Value) : false; WasUsed = xml.Attributes["used"] != null?bool.Parse(xml.Attributes["used"].Value) : false; DecorationPrimary = xml.Attributes["primary"] != null?int.Parse(xml.Attributes["primary"].Value) : -1; DecorationSecondary = xml.Attributes["secondary"] != null?int.Parse(xml.Attributes["secondary"].Value) : -1; foreach (XmlNode node in xml) { switch (node.Name.ToLower()) { case "scripts": { foreach (XmlNode sub in node) { PressurePlateScript script = new PressurePlateScript(); script.Load(sub); Scripts.Add(script); } } break; default: { base.Load(node); } break; } } return(true); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MoveUpBox_Click(object sender, EventArgs e) { if (Scripts == null) { return; } int id = ScriptListBox.SelectedIndex; if (id <= 0) { return; } PressurePlateScript script = Scripts[id]; Scripts.RemoveAt(id); Scripts.Insert(id - 1, script); UpdateUI(); ScriptListBox.SelectedIndex = id - 1; }
void Update() { for (int iComponent = 0; iComponent < transform.childCount; iComponent++) { Transform component = transform.GetChild(iComponent); //checks if plates that need to be activated are active if (component.name.Contains("Plate")) { puzzelFinished = true; //if one trap is not activated correctly it will deactivate for (int iPlate = 0; iPlate < component.childCount; iPlate++) { Transform plate = component.GetChild(iPlate); PressurePlateScript script = plate.GetComponent <PressurePlateScript>(); if (script.activationNeeded != script.activated) { puzzelFinished = false; } } } else if (component.name.Contains("Door")) { if (puzzelFinished) { for (int iDoor = 0; iDoor < component.childCount; iDoor++) { Transform door = component.GetChild(iDoor); door.GetComponent <Rigidbody>().isKinematic = false; door.GetComponent <Collider>().enabled = false; } } } if (puzzelFinished) { Debug.Log("YAY!!!"); } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MoveDownBox_Click(object sender, EventArgs e) { if (Scripts == null) { return; } int id = ScriptListBox.SelectedIndex; if (id >= Scripts.Count - 1) { return; } PressurePlateScript action = Scripts[id]; Scripts.RemoveAt(id); Scripts.Insert(id + 1, action); UpdateUI(); ScriptListBox.SelectedIndex = id + 1; }