static void YCalc(NoduleDatabase nodules) { if (nodules.sideList.Count == 0) { return; } float noduleYSize = 0; foreach (BaseNodule nodule in nodules.sideList) { noduleYSize += nodule.Position.size.y + nodules.noduleSpacing; } //Debug.Log (nodules.mainNode.name + ", " + nodules.mainNode.Position + ", " + noduleYSize); while (noduleYSize > nodules.mainNode.Position.height) { nodules.noduleSpacing--; foreach (BaseNodule nodule in nodules.sideList) { noduleYSize += nodule.Position.size.y + nodules.noduleSpacing; } } float curY = -noduleYSize / 2; foreach (BaseNodule nodule in nodules.sideList) { nodule.offSet.y = curY; curY += nodule.Position.size.y + nodules.noduleSpacing; } nodules.noduleSpacing = 5; }
public static NoduleDatabase CreateNew(NodeObject mainObject) { NoduleDatabase DB = CreateInstance <NoduleDatabase> (); DB.name = mainObject.name + " - " + DB.GetType().Name; if (mainObject is BaseNode) { DB.mainNode = mainObject as BaseNode; DB.mainNodule = null; } else if (mainObject is BaseNodule) { DB.mainNode = null; DB.mainNodule = mainObject as BaseNodule; } else { throw new UnityException(); } if (!DB) { throw new UnityException(); } DB.Construct(); return(DB); }
static void ReCalcYPos(NoduleDatabase nodules) { nodules.sideList = nodules.FindAll(n => n.side == NoduleSide.Left); YCalc(nodules); nodules.sideList = nodules.FindAll(n => n.side == NoduleSide.Right); YCalc(nodules); }
public override void UpdateAllPosition(Vector2 delta) { if (options.Count == 0) { base.UpdateAllPosition(delta); } else { Vector2 canvasSize = DialogueEditorGUI.States.curState.canvasSize; Rect optionRect = options.Get(options.Count - 1).Position; Vector2 pos = position.position + delta; if (pos.x < 0 || (pos + position.size).x > canvasSize.x) { delta.x = 0; } if (pos.y < 0 || (optionRect.position + optionRect.size).y > canvasSize.y) { delta.y = 0; } position.position += delta; NoduleDatabase.ReCalcAllNodulePos(this); } options.UpdateAllPosition(delta); }
protected override void Construct() { name = "Start Node"; position = new Rect(CanvasGUI.CanvasToScreenPosition(CanvasGUI.CanvasRect.center), ResourceManager.START_NODE_SIZE); nodules = NoduleDatabase.CreateNew(this); nodules.Add(BaseNodule.Create <OutputNodule> (this)); DialogueEditorGUI.Cache.SaveNewObject(this, false); }
protected virtual void Construct(string nodeTitle, Vector2 nodePos, string nodeTextArea, Actor nodeActor) { name = nodeTitle; position.position = nodePos; textArea = nodeTextArea; actor = nodeActor; nodules = NoduleDatabase.CreateNew(this); DialogueEditorGUI.Cache.SaveNewObject(this); }
protected void Construct(string nodeTitle, string nodeTextArea, MainNode main) { name = nodeTitle; textArea = nodeTextArea; mainNode = main; actor = DialogueEditorGUI.Cache.Actors.Get(0); nodules = NoduleDatabase.CreateNew(this); DialogueEditorGUI.Cache.SaveNewObject(this, mainNode); }
public override void Init() { if (!nodules) { Debug.LogError(""); nodules = NoduleDatabase.CreateNew(this); } nodules.Init(); }
protected virtual void Construct(string _name, BaseNode _mainNode) { name = _name; mainNode = (NoduleTypes.CheckCompatibility(_mainNode, this)) ? _mainNode : null; nodules = NoduleDatabase.CreateNew(this); if (mainNode) { DialogueEditorGUI.Cache.SaveNewObject(this, mainNode); } }
public override void UpdateAllPosition(Vector2 delta) { if (!mainNode) { base.UpdateAllPosition(delta); } else { position.position += delta; NoduleDatabase.ReCalcAllNodulePos(this); } }
public virtual void UpdateAllPosition(Vector2 delta) { if ((position.position + delta).x < 0 || (position.position + delta + position.size).x > DialogueEditorGUI.States.curState.canvasSize.x) { delta.x = 0; } if ((position.position + delta).y < 0 || (position.position + delta + position.size).y > DialogueEditorGUI.States.curState.canvasSize.y) { delta.y = 0; } position.position += delta; NoduleDatabase.ReCalcAllNodulePos(this); }
public override void Init() { if (!mainNode) { Debug.LogError(""); Delete(); } if (nodules == null) { Debug.LogError(""); nodules = NoduleDatabase.CreateNew(this); } foreach (BaseNodule connectedNodule in nodules) { if (!connectedNodule.nodules.Contains(this)) { Debug.LogError(""); connectedNodule.nodules.Add(connectedNodule); } } }
public override void ReplaceAllReferences(Func <ScriptableObject, ScriptableObject> ReplacedSO) { nodules = (NoduleDatabase)ReplacedSO(nodules); }