public Sequence(Sequence unit, BComponent newParent = null) { this.parent = newParent; behaviors = unit.CopyChildren(this); index = 0; this.behaviorManager = unit.behaviorManager; }
public WinAction(BComponent unit) : base(unit) { actionUnit = unit as AAction; imgOptions = Resources.Load <Texture>("opcje"); imgDelete = Resources.Load <Texture>("usun"); if (unit is ActionBool) { txtType = "Bool"; imgActionType = Resources.Load <Texture>("ActionBollean"); } else if (unit is ActionEnumerator) { txtType = "Enumerator"; imgActionType = Resources.Load <Texture>("ActionEnumerator"); } else if (unit is ActionProperty) { txtType = "Property"; imgActionType = Resources.Load <Texture>("ActionProperty"); } else if (unit is ActionVoid) { txtType = "Void"; imgActionType = Resources.Load <Texture>("ActionVoid"); } }
protected void HideAdd() { isAddedUsed = false; unitToAdd = null; showAddsButons = false; widnowsAddSize = 0f; }
public Selector(BComponent parent, Behaviors behaviorManager, XmlNode xmlDoc) { this.behaviors = GetComponents(this, behaviorManager, xmlDoc); this.parent = parent; this.behaviorManager = behaviorManager; index = 0; }
public BComponent AddComponent(Type type, params object[] args) { BComponent t = (BComponent)Activator.CreateInstance(type, args); components.Add(type, t); return(t); }
public Selector(Selector select, BComponent newParent = null) { this.parent = newParent; behaviors = select.CopyChildren(this); index = 0; this.behaviorManager = select.behaviorManager; }
public ActionBool(ActionBool actionBool, BComponent newParent = null) { this.parent = newParent; this.actionName = actionBool.actionName; this.componentName = actionBool.componentName; this.action = actionBool.action; this.behaviorManager = actionBool.behaviorManager; }
public UnitArrang(BComponent units, IEditWindow window) { this.window = window; rows.Add(new List <BComponent>()); BuildArrangMap(units, 0); currentRowId = findLongestRow; }
public ActionProperty(ActionProperty actionProp, BComponent newParent = null) { this.parent = newParent; this.actionName = actionProp.actionName; this.componentName = actionProp.componentName; this.action = actionProp.action; this.behaviorManager = actionProp.behaviorManager; }
public ActionProperty(BComponent parent, System.Func <bool> action, string aName, string cName, Behaviors behaviorManager) { this.action = action; this.actionName = aName; this.componentName = cName; this.parent = parent; this.behaviorManager = behaviorManager; }
public ActionVoid(BComponent parent, System.Action action, string aName, string cName, Behaviors behaviorManager) { this.action = action; this.actionName = aName; this.componentName = cName; this.parent = parent; this.behaviorManager = behaviorManager; }
public ActionVoid(ActionVoid actionVoid, BComponent newParent = null) { this.parent = newParent; this.actionName = actionVoid.actionName; this.componentName = actionVoid.componentName; this.action = actionVoid.action; this.behaviorManager = actionVoid.behaviorManager; }
protected void ShowAdd(BComponent u) { unitToAdd = u; showAddsButons = true; isAddedUsed = true; StarAtnimAddPasteButtons(); }
public ActionEnumerator(ActionEnumerator actionEnum, BComponent newParent = null) { this.parent = newParent; this.actionName = actionEnum.actionName; this.componentName = actionEnum.componentName; this.action = actionEnum.action; this.enumerator = this.action(); this.behaviorManager = actionEnum.behaviorManager; }
protected void ShowPaste() { unitToAdd = unit.behaviorManager.clipboard; unit.behaviorManager.clipboard = unitToAdd.Copy(); showAddsButons = true; isAddedUsed = true; StarAtnimAddPasteButtons(); }
public static BComponent BuildComponent(XmlNode xmlDoc, BComponent parent, Behaviors behavior) { string name = xmlDoc.Name; if (ActionBool.NAME == name) { return(ActionBool.Build(xmlDoc, parent, behavior)); } else if (ActionProperty.NAME == name) { return(ActionProperty.Build(xmlDoc, parent, behavior)); } else if (ActionVoid.NAME == name) { return(ActionVoid.Build(xmlDoc, parent, behavior)); } else if (ActionEnumerator.NAME == name) { return(ActionEnumerator.Build(xmlDoc, parent, behavior)); } else if (RandomSelector.NAME == name) { return(RandomSelector.Build(xmlDoc, parent, behavior)); } else if (RootSelector.NAME == name) { return(RootSelector.Build(xmlDoc, parent, behavior)); } else if (Selector.NAME == name) { return(Selector.Build(xmlDoc, parent, behavior)); } else if (Sequence.NAME == name) { return(Sequence.Build(xmlDoc, parent, behavior)); } else if (Inverter.NAME == name) { return(Inverter.Build(xmlDoc, parent, behavior)); } else if (UntilTrue.NAME == name) { return(UntilTrue.Build(xmlDoc, parent, behavior)); } else if (UntilFalse.NAME == name) { return(UntilFalse.Build(xmlDoc, parent, behavior)); } else { Debug.LogErrorFormat("I did not find the item: {0}", name); return(null); } }
public RandomSelector(BComponent parent, Behaviors behaviorManager, XmlNode xmlDoc) { this.parent = parent; this.behaviors = GetComponents(this, behaviorManager, xmlDoc); this.behaviorManager = behaviorManager; currentIndex = 0; currentTime = 0f; FindAttributesTime(xmlDoc, out timeMin, out timeMax); FirstSeed(); }
public UnitWindow(BComponent unit) { this.skin = Resources.Load <GUISkin>("Window"); this.unit = unit; this.rect = new Rect(new Vector2(-1f, -1f), new Vector2(-1f, -1f)); idWindow = windowsCount; windowsCount += 1; isAddedUsed = false; imgAddNext = Resources.Load <Texture>("add new"); visibleScale = 0f; }
public RandomSelector(RandomSelector random, BComponent newParent = null) { parent = newParent; currentIndex = 0; currentTime = 0f; behaviors = random.CopyChildren(this); behaviorManager = random.behaviorManager; timeMin = random.timeMin; timeMax = random.timeMax; FirstSeed(); }
public ActionEnumerator(BComponent parent, System.Func <IEnumerator <bool> > action, string aName, string cName, Behaviors behaviorManager) { this.parent = parent; this.action = action; this.actionName = aName; this.componentName = cName; this.behaviorManager = behaviorManager; if (action != null) { enumerator = action(); } }
public static DialogInputHoldRandom Show(BComponent unit, System.Action <object> evt) { DialogInputHoldRandom result = EditorWindow.GetWindowWithRect <DialogInputHoldRandom>( new Rect(0f, 0f, 300f, 100f), true, "Set new time values on random selected"); result.unitRandom = unit as Components.Composites.RandomSelector; result.skin = Resources.Load <GUISkin>("dialog"); result.evt = evt; result.ShowPopup(); return(result); }
/// <summary> /// Wyszukujemy konkretny komponent ze wskazanej lokacji /// </summary> /// <param name="location">Location.</param> public BComponent Find(Location location) { BComponent result = null; if (location.row < rows.Count) { List <BComponent> row = rows[location.row]; if (location.coll < row.Count) { result = row[location.coll]; } } return(result); }
public Behaviors(TextAsset txt, GameObject obj, float waitTime, bool updateAllTree, Window.UnitArrang arrang = null) { if (txt == null || txt.text == null || txt.text.Length < 1) { Debug.LogWarningFormat("No xml tree [{0}]", obj.name); return; } XmlDocument xmlDoc = new XmlDocument(); if (arrang != null) { string path = arrang.window.GetAssetTextPath(txt); using (TextReader tr = new StreamReader(path)) { xmlDoc.Load(tr); } } else { using (StringReader sr = new StringReader(txt.text)) { xmlDoc.Load(sr); } } XmlNodeList xmlNodes = xmlDoc.SelectNodes("root"); BComponent root = null; components = FindComponents(obj); xmlAI = txt; foreach (XmlNode xmlNode in xmlNodes) { root = BuildComponent(xmlNode, null, this); } this.root = root as RootSelector; if (this.root == null) { throw new NullReferenceException(string.Format("Behaviors: xml is invalid - has no root element [{0}]", txt.name)); } this.root.updateAllTree = updateAllTree; this.waitTime = waitTime; }
protected Vector2 CheckOverlapCurrent(Vector2 position) { Vector2 result = position; Location location = unit.locationArrang; if (location.coll > 0) { BComponent find = UnitArrang.arrang.Find(new Location(location.row, location.coll - 1)); if (find != null) { Vector2 findPos = find.window.rect.position; result = position + OverlapsWindows(position, findPos); } } return(result); }
public static BComponent Build(XmlNode xmlDoc, BComponent parent, Behaviors behaviorManager) { System.Func <bool> action = null; string actionName; string componentName; bool isError = false; string messageError = ""; FindAttributes(xmlDoc, out actionName, out componentName); if (actionName == null) { isError = true; messageError = "ActionProperty: don't have action attribute"; throw new NullReferenceException(messageError); } else { MonoBehaviour mono = GetRightMono(componentName, behaviorManager.components); if (mono != null) { action = FindProperty <System.Func <bool> >(actionName, mono); if (action == null) { isError = true; messageError = string.Format("ActionProperty: I can't find property [{0}]", actionName); } } else { isError = true; messageError = string.Format("ActionProperty: wrong component name [{1}] for menthod: [{0}]", actionName, componentName); Debug.LogError(messageError); } } ActionProperty result = new ActionProperty(parent, action, actionName, componentName, behaviorManager); result.isError = isError; result.messageError = messageError; return(result); }
public void MenuMoreComponentRandom(System.Action <object> evt, BComponent unit) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Copy"), false, (obj) => { evt(obj); }, "Copy-Unit"); menu.AddItem(new GUIContent("Cut"), false, (obj) => { evt(obj); }, "Cut-Unit"); menu.AddSeparator(""); menu.AddItem(new GUIContent("Hold Time on Random Selection"), false, (obj) => { DialogInputHoldRandom.Show(unit, evt); }, "Hold" ); menu.ShowAsContext(); }
protected void BuildArrangMap(BComponent unit, int currentId) { if (unit == null) { return; } rows[currentId].Add(unit); unit.locationArrang = new Location(currentId, rows[currentId].Count - 1); if ((rows.Count - 1) < (currentId + 1)) { rows.Add(new List <BComponent>()); } if (unit.childrenComponents != null) { foreach (BComponent u in unit.childrenComponents) { BuildArrangMap(u, currentId + 1); } } }
protected Vector2 CheckOverlapChildren(Vector2 position) { Vector2 result = position; if (unit.childrenComponents != null && unit.childrenComponents.Length > 0) { BComponent unitChild = unit.childrenComponents[0]; if (unitChild != null) { Location location = unitChild.locationArrang; if (location.coll > 0) { BComponent find = UnitArrang.arrang.Find(new Location(location.row, location.coll - 1)); if (find != null) { Vector2 unitChildPosition = position + GetChildOffsetPosition(0); Vector2 findPos = find.window.rect.position; result = position + OverlapsWindows(unitChildPosition, findPos); } } } } return(result); }
public bool CenterBetweenTwoChildren(Vector2 position) { if (unit.childrenComponents != null && unit.childrenComponents.Length > 0) { BComponent unitLeft = unit.childrenComponents[0]; BComponent unitRight = unit.childrenComponents[unit.childrenComponents.Length - 1]; if (unitLeft == null || unitRight == null) { return(false); } Vector2 leftPosition = unitLeft.window.rect.position; Vector2 rightPosition = unitRight.window.rect.position; position = new Vector2(Vector2.Lerp(leftPosition, rightPosition, 0.5f).x, position.y); this.rect = new Rect(position, WINDOW_BEHAVIOR_UNIT_SIZE); return(true); } else { return(false); } }
public void Components() { var context = new Context(); // init var e = context.CreateEntity("e"); Assert.IsFalse(e.Contains <AComponent>()); Assert.IsFalse(e.Contains(typeof(AComponent))); // add var aComponent = new AComponent("a1"); e.Add(aComponent); Assert.IsTrue(e.Contains <AComponent>()); Assert.IsTrue(e.Contains(typeof(AComponent))); Assert.AreSame(aComponent, e.Get <AComponent>()); var bComponent = new BComponent(); Assert.IsFalse(e.Contains <BComponent>()); e.Add(bComponent); Assert.AreSame(bComponent, e.Get <BComponent>()); Assert.AreSame(aComponent, e.Get <AComponent>()); // replace var aComponent2 = new AComponent("a2"); Assert.AreNotSame(aComponent2, e.Get <AComponent>()); e.Add(aComponent2); Assert.AreSame(aComponent2, e.Get <AComponent>()); // remove e.Remove <AComponent>(); Assert.IsFalse(e.Contains <AComponent>()); Assert.IsNull(e.Get <AComponent>()); }