public bool Draw(FNode <T> root, string rootLabel = "Tree") { if (root == null) { GUILayout.BeginVertical("box"); { GUILayout.Label(rootLabel); GUILayout.Label("Root FNode is NULL"); } GUILayout.EndVertical(); return(false); } if (active == null) { active = root; } removeKey = null; changeKey = null; currentPath = "/"; //changeTarget = null; visited.Clear(); history.Clear(); history.Push(currentPath); treeScroll = GUILayout.BeginScrollView(treeScroll, false, true); { GUILayout.BeginVertical("box"); { DrawNode("root", root); } GUILayout.EndVertical(); } GUILayout.EndScrollView(); return(removeKey != null || changeKey != null); }
public void AddFadingNode(FNode node, float showDuration) { NodeInfo info = new NodeInfo (); info.node = node; info.showDuration = showDuration; infos.Add (info); }
public static void TransitionFadeOut(FNode node,float delay) { GoTweenConfig config=new GoTweenConfig().floatProp("alpha",0f).onComplete(FSpeechBubbleManager.Instance.RemoveFromContainer); config.easeType=GoEaseType.ExpoOut; config.delay=delay; Go.to (node,0.5f,config); }
public bool Process(char[] chs, int offset, ref int result) { FNode nextNode = null; result = -1; int index = offset; while (index < chs.Length) { ushort key = (ushort)chs[index++]; if (nextNode == null) { nextNode = FTreeHelper.BinarySearch(key, childs); } else { nextNode = nextNode.BinarySearch(key); } if (nextNode == null) { break; } if (nextNode.terminated) { result = index; } } return(result != -1); }
public Vector2 GetPositionRelativeToAncestor(FContainer ancestor) { FNode target = this; Vector2 position = new Vector2(0, 0); FContainer container; while (true) { position += target.GetPosition(); container = target.container; if (container == null) { break; } if (container == ancestor) { break; } target = container; } return(position); }
//sorts array in DESCENDING order because the higher y values should be earlier (aka further back) private static int CompareY(FNode a, FNode b) { float delta = b.y-a.y; if(delta < 0) return -1; if(delta > 0) return 1; return 0; }
public void InsertWord(string word) { if (string.IsNullOrEmpty(word)) { return; } char[] chs = word.ToCharArray(); int index = 0; FNode nextNode = null; while (index < chs.Length) { ushort key = (ushort)chs[index++]; if (nextNode == null) { nextNode = FTreeHelper.BinaryInsert(key, childs); } else { nextNode = nextNode.InsertChild(key); } } nextNode.terminated = true; }
public void AddChild(FNode node) { int nodeIndex = _childNodes.IndexOf(node); if (nodeIndex == -1) //add it if it's not a child { node.HandleAddedToContainer(this); _childNodes.Add(node); if (_isOnStage) { node.stage = _stage; node.HandleAddedToStage(); } } else if (nodeIndex != _childNodes.Count - 1) //if node is already a child, put it at the top of the children if it's not already { _childNodes.RemoveAt(nodeIndex); _childNodes.Add(node); if (_isOnStage) { _stage.HandleFacetsChanged(); } } }
virtual protected FNode createObjectLayer(XMLNode node) { // add objects to FContainers FContainer objectGroup = new FContainer(); foreach (XMLNode fObject in node.children) { if (fObject.tagName == "object") { if (fObject.attributes.ContainsKey("gid")) { // create FSprite (override that function for specific class changes) objectGroup.AddChild(this.createTileObject(fObject)); } else { FNode newObject = this.createObject(fObject); if (newObject != null) { objectGroup.AddChild(newObject); } } } } // remember name _layerNames.Add(node.attributes["name"]); // add to self return(objectGroup); }
static public void RemoveFromContainer(this FNode node) { if (node != null && node.container != null) { node.container.RemoveChild(node); } }
public FNode(Schedule _data, float _key) { right = this; left = this; data = _data; key = _key; }
public FNode ShowButtonHighlight(FNode node, Vector2 offset, float width, float height, Color color, bool shouldPlaySound) { if (shouldPlaySound) { FXPlayer.NormalButtonTap (); } FSliceSprite highlight = new FSliceSprite ("UI/ButtonHighlight", width, height, 8, 8, 8, 8); AddChild (highlight); highlight.SetPosition (this.OtherToLocal (node, offset)); highlight.shader = FShader.Additive; highlight.scale = 1.0f; highlight.alpha = 0.35f; highlight.color = color + new Color (0.5f, 0.5f, 0.5f);//brighten the color //uniform scaling float growSize = 8.0f; float growScaleX = (width + growSize) / width; float growScaleY = (height + growSize) / height; Go.to (highlight, 0.15f, new GoTweenConfig ().floatProp ("scaleX", growScaleX).floatProp ("scaleY", growScaleY).floatProp ("alpha", 0.0f).setEaseType (GoEaseType.Linear).removeWhenComplete ()); return highlight; }
public void setClipNode(FNode clipNode) { foreach (FTilemap f in tilemaps) { f.clipNode = clipNode; } }
public static void Create(FNode content, int lifespan, FContainer parent, float xOff, float yOff, float scaleX = 1f, float scaleY = 1f, bool beam = false, float xVelocity = 0f, float yVelocity = 0f) { TemporalSprite temp = new TemporalSprite(content, lifespan, parent, xOff, yOff, scaleX, scaleY, beam, new Vector2(xVelocity, yVelocity)); ScreenManager.StartCoroutine(temp.LiveOutAndDie()); }
private void UpdateFollow() { if (_followTarget != null) { if (_followTarget.stage == null) //the target MUST be on the same stage { _followTarget = null; return; } if (_shouldFollowScale) { this.scale = 1.0f / _followTarget.concatenatedMatrix.GetScaleX(); } if (_shouldFollowRotation) { this.rotation = _followTarget.concatenatedMatrix.GetRotation() * RXMath.RTOD; } _followMatrix.SetScaleThenRotate(0, 0, _scaleX, _scaleY, _rotation * -RXMath.DTOR); Vector2 pos = _followMatrix.GetNewTransformedVector(new Vector2(_followTarget.concatenatedMatrix.tx, _followTarget.concatenatedMatrix.ty)); this.x = -pos.x; this.y = -pos.y; } }
public FNode ShowButtonHighlight(FNode node, Vector2 offset, float width, float height, Color color, bool shouldPlaySound) { if (shouldPlaySound) { FXPlayer.NormalButtonTap(); } FSliceSprite highlight = new FSliceSprite("UI/ButtonHighlight", width, height, 8, 8, 8, 8); AddChild(highlight); highlight.SetPosition(this.OtherToLocal(node, offset)); highlight.shader = FShader.Additive; highlight.scale = 1.0f; highlight.alpha = 0.35f; highlight.color = color + new Color(0.5f, 0.5f, 0.5f); //brighten the color //uniform scaling float growSize = 8.0f; float growScaleX = (width + growSize) / width; float growScaleY = (height + growSize) / height; Go.to(highlight, 0.15f, new TweenConfig().floatProp("scaleX", growScaleX).floatProp("scaleY", growScaleY).floatProp("alpha", 0.0f).setEaseType(EaseType.Linear).removeWhenComplete()); return(highlight); }
public void Test2() { var four = new FNode(4); four.Head = new FNode(5); four.Head.Next = new FNode(6); var one = new FNode(1); one.Head = new FNode(3); one.Head.Next = new FNode(7); var nine = new FNode(9); nine.Head = new FNode(11); nine.Head.Next = new FNode(13); four.Next = one; one.Next = nine; var expected = new int[] { 1, 3, 4, 5, 6, 7, 9, 11, 13 }; var fl = new FlattenLists(); var result = fl.Flatten(four); var actual = AlgoUtilities.Utilities.ToList(result); var equal = actual.SequenceEqual(expected); Assert.That(equal, Is.True); }
public void Init(FContainer container, uint color, bool shouldUpdateColliders) { _container = container; _container.AddChild(_drawHolder = new FContainer()); _color = RXUtils.GetColorFromHex(color); this.shouldUpdateColliders = shouldUpdateColliders; Collider[] colliders = gameObject.GetComponents <Collider>(); int colliderCount = colliders.Length; for (int c = 0; c < colliderCount; c++) { Collider collider = colliders[c]; FNode newNode = null; if (collider is BoxCollider) { FSprite sprite = new FSprite("Debug/Square"); sprite.color = _color; newNode = sprite; } else if (collider is SphereCollider) { FSprite sprite = new FSprite("Debug/Circle"); sprite.color = _color; newNode = sprite; } if (newNode != null) { _drawHolder.AddChild(newNode); _nodes.Add(newNode); } } FPPolygonalCollider mesh2D = gameObject.GetComponent <FPPolygonalCollider>(); if (mesh2D != null) { FPDebugPolygonColliderView debugView = new FPDebugPolygonColliderView("Debug/Triangle", mesh2D); debugView.color = _color; _drawHolder.AddChild(debugView); _nodes.Add(debugView); } Update(); if (!shouldUpdateColliders) { UpdateColliders(); //always update the colliders the first time } }
public static void Cancel(FNode node) { BlinkUtil obj=null; pendings.TryGetValue(node, out obj); if (obj!=null) { obj.Stop(); } }
public void Add(Schedule _schedule) { if(_schedule.nextScheduleItem != null){ FNode _fNode = new FNode(_schedule, _schedule.nextScheduleItem.time); _schedule.fNode = _fNode; Add(_fNode); } }
public SRNodeView(NodeView parentNodeView, INode2 node, NodeFilter filter, int depth) : base(parentNodeView, node, filter, depth, false) { FChannelPin = FNode.FindPin(ChannelPinName); FChannelPin.Changed += HandleChannelPinChanged; FSRChannel = FChannelPin[0]; }
public Action_MoveCamera(float x, float y, float time) : base() { this.target = new FNode(); this.target.x = x; this.target.y = y; this.time = time; }
public FNodeEnablerForSmartTouch(FNode node) { smartTouchable = node as FSmartTouchableInterface; if (smartTouchable == null) { throw new FutileException("Trying to enable single touch on a node that doesn't implement FSmartTouchableInterface"); } }
public void AddFadingNode(FNode node, float showDuration) { NodeInfo info = new NodeInfo(); info.node = node; info.showDuration = showDuration; infos.Add(info); }
public void InitializeHierarchy() { RootNode = new FNode(-1, null, null); var Untagged = new FAllocationTag("Untagged"); UntaggedNode = new FNode(Untagged.TagNameIndex, RootNode, Untagged); }
public FNodeEnablerForSingleTouch(FNode node) { singleTouchable = node as FSingleTouchableInterface; if(singleTouchable == null) { throw new FutileException("Trying to enable single touch on a node that doesn't implement FSingleTouchableInterface"); } }
public Tweener(FNode node) { this.node = node; int n = values.Length; for (int i = 0; i < n; ++i) { values[i].style = Style.INACTIVE; values[i].fn = IntSqrt; } }
public FNodeEnablerForMultiTouch(FNode node) { multiTouchable = node as FMultiTouchableInterface; if (multiTouchable == null) { throw new FutileException("Trying to enable multi touch on a node that doesn't implement FMultiTouchableInterface"); } }
protected void Stop() { if (node!=null) { Futile.instance.SignalUpdate-=HandleUpdate; node.SetPosition(oPosition); _pendings.Remove(node); node=null; } }
private void DrawNode(string name, FNode <T> node) { bool expanded = IsExpanded(currentPath); GUILayout.BeginHorizontal(); { // Delete Button if (!node.isRoot) { // RemoveButton(node.parent, name); GUILayout.Button("x", SMALL_BUTTON); } GUILayout.Label(name, FIXED_WIDTH); // Select Button if (GUILayout.Button(active == node ? "()" : "", SMALL_BUTTON)) { active = node; } GUILayout.Label(": {", FIXED_WIDTH); if (!expanded) { if (GUILayout.Button("...")) { Toggle(currentPath); } GUILayout.Label("}"); GUILayout.FlexibleSpace(); } else { if (GUILayout.Button("---", SMALL_BUTTON)) { Toggle(currentPath); } } } GUILayout.EndHorizontal(); if (expanded) { GUI.color = ModColor(visited.Count); GUILayout.BeginVertical("box"); { GUI.color = Color.white; var childrens = node.childrenNames; foreach (var childName in childrens) { var child = node.GetChild(childName); Push(node, child); DrawNode(childName, child); Pop(); } FieldControls(node); } GUILayout.EndVertical(); } }
protected void Stop() { if (node != null) { Futile.instance.SignalUpdate -= HandleUpdate; node.SetPosition(oPosition); _pendings.Remove(node); node = null; } }
static public void Cancel(FNode node) { ShakeUtil obj = null; _pendings.TryGetValue(node, out obj); if (obj != null) { obj.Stop(); } }
private FNode <JsonObject> tempData() { var root = FNode <JsonObject> .NewRoot(); root.AddChild("yeet"); root.AddChild("yeah"); root.AddChild("deep").AddChild("nested").AddChild("goodness"); return(root); }
public FNode EnsureChildNode(int InChildNameIndex) { FNode ChildNode; if (!ChildNodesByNameMap.TryGetValue(InChildNameIndex, out ChildNode)) { ChildNode = new FNode(InChildNameIndex, this, null); } return(ChildNode); }
void OnGUI() { GUILayout.BeginArea(new Rect(0, 0, position.width * .25f, position.height)); { treeView.Draw(root, "data"); } GUILayout.EndArea(); if (treeView.selected != active) { active = treeView.selected; if (active != null) { serialized = active.data.ToString(); } } Rect rest = new Rect(position.width * .25f, 0, position.width * .75f, position.height); GUILayout.BeginArea(rest); { dataScroll = GUILayout.BeginScrollView(dataScroll, false, true); { if (active != null) { if (GUILayout.Button("Unfocus")) { JsonFNodeTreeViewUtil.Unfocus(); } // EditorGUILayout.TextField("Clear", ""); var lastSerialized = serialized; serialized = EditorGUILayout.DelayedTextField(serialized, GUILayout.Height(96)); if (serialized.Length != lastSerialized.Length || serialized != lastSerialized) { try { JsonObject jobj = Json.Parse <JsonObject>(serialized); active.data.Clear(); active.data.SetRecursively(jobj); } catch (Exception e) { Debug.LogWarning("Failed to parse copy/pasted JSON." + e + "\n" + e.StackTrace); serialized = lastSerialized; } } bool changed = JsonDrawer.DrawSolo(active.data, "Data"); if (changed) { serialized = active.data.ToString(); } } else { GUI.Label(rest, "Nothing to draw."); } } GUILayout.EndScrollView(); } GUILayout.EndArea(); }
public void Unfollow(FNode targetToUnfollow, bool shouldResetPosition) //if null is passed, it'll remove the current target no matter what it is { if (targetToUnfollow == null || _followTarget == targetToUnfollow) { _followTarget = null; if (shouldResetPosition) { ResetPosition(); } } }
public override void HandleRemovedFromStage() { // reset to zero _followObject = null; _worldBounds.width = 0; _worldBounds.height = 0; x = 0; y = 0; base.HandleRemovedFromStage(); }
public static void ClearChildren(FNode n) { FContainer c = n as FContainer; if (c != null) { while (c.GetChildCount() > 0) { FNode s = c.GetChildAt(0); ClearChildren(s); s.RemoveFromContainer(); } } }
public static Vector2 GetGlobalBottomRightRectPoint(Rect rect, FNode node) { if (node.isOnStage) { return(node.LocalToGlobal(new Vector2(rect.xMax, rect.yMin))); } else { return(new Vector2(-1, -1)); } }
//Helper method for the GetNodes method private static void AddNode(FNode node, List <ANode> nodes, Stack <FElem> parents) { if (parents.Count > 0) { parents.Peek().add(node); } else { nodes.Add(node); } }
public static Vector2 GetGlobalTopLeftRectPoint(Rect rect, FNode node) { if (node.isOnStage) { return(node.LocalToGlobal(new Vector2(rect.xMin, rect.yMax))); } else { return(new Vector2(-1, -1)); } }
public FNodeFollower(FNode follower,FNode following) { _follower=follower; _following=following; Vector2 globalPos=_following.LocalToGlobal(Vector2.zero); Vector2 localPos=_follower.container.GlobalToLocal(globalPos); _offset=_follower.GetPosition()-localPos; ((IFNodeWatcher)this).Watch(_following); }
public void RemoveChild(FNode node) { node.HandleRemovedFromContainer(); if (_isOnStage) { node.HandleRemovedFromStage(); } _childNodes.Remove(node); }
public static void TransitionPop(FNode node) { node.scaleX=0; node.scaleY=0.1f; GoTweenConfig config0=new GoTweenConfig().floatProp("scaleX",1f); config0.easeType=GoEaseType.ElasticOut; Go.to(node,0.2f,config0); GoTweenConfig config1=new GoTweenConfig().floatProp("scaleY",1f); config1.easeType=GoEaseType.ElasticOut; //config1.delay=0.15f; Go.to(node,0.4f,config1); }
public void go(FNode node_, float duration_, float amplitude_) { Cancel(node_); oPosition = node_.GetPosition(); curDuration = duration = duration_; curAmplitude = amplitude = amplitude_; _pendings.Add(node_, this); if (node == null) { Futile.instance.SignalUpdate += HandleUpdate; } node = node_; }
public MagicOrb(FNode owner, World world) : base(new RXRect(0, 0, 5, 5), world) { this.useActualMaxVel = true; maxVel = 2; this.bounceiness = 1f; this.owner = owner; handleStateCount = true; collidesWithWater = false; sprite = new FAnimatedSprite("Magic Orb/magic_orb"); sprite.addAnimation(new FAnimation("idle", new int[] { 1, 2 }, 150, true)); sprite.play("idle"); this.AddChild(sprite); this.xVel = RXRandom.Float() * .5f - .25f; this.yVel = RXRandom.Float() * .5f - .25f; FSoundManager.PlaySound("orbShoot"); }
public void Add(FNode _fNode) { if (_minNode != null){ _fNode.left = _minNode; _fNode.right = _minNode.right; _minNode.right = _fNode; _fNode.right.left = _fNode; if (_fNode.key < _minNode.key){ _minNode = _fNode; } } else{ _minNode = _fNode; } _nNodes++; }
public void ShowParticleBox(FNode baseNode, Rect rect) { Vector2 offset = this.OtherToLocal (baseNode, Vector2.zero); float cx = offset.x + rect.x + rect.width / 2; float cy = offset.y + rect.y + rect.height / 2; ; // FSprite sprite = new FSprite("Box"); // sprite.SetPosition(cx,cy); // sprite.width = rect.width; // sprite.height = rect.height; // // AddChild(sprite); int count = 50; float halfWidth = rect.width / 2; float halfHeight = rect.height / 2; FParticleDefinition pd = new FParticleDefinition ("Extra/Particle_Noise"); pd.startScale = 0.3f; pd.endScale = 0.7f; float speed = 30.0f; for (int c = 0; c<count; c++) { pd.lifetime = RXRandom.Range (0.9f, 1.3f); //pd.delay = RXRandom.Range(0.0f,0.1f); pd.x = cx + RXRandom.Range (-halfWidth, halfWidth); pd.y = cy + RXRandom.Range (-halfHeight, halfHeight); pd.speedX = RXRandom.Range (-speed, speed); pd.speedY = RXRandom.Range (-speed, speed); pd.startColor = new Color (1, 1, 0.8f, 0.7f); pd.endColor = new Color (1, 1, 0.8f, 0.0f); pd.startRotation = RXRandom.Range (0, 360.0f); pd.endRotation = pd.startRotation + RXRandom.Range (-180.0f, 180.0f); particleSystem.AddParticle (pd); } }
public void addObject(FNode objectToAdd) { if (objectToAdd is Knight || objectToAdd is Arrow || objectToAdd is Heart || objectToAdd is MagicOrb || objectToAdd is Ghost || objectToAdd is SoulPickup) damageObjects.Add((FutilePlatformerBaseObject)objectToAdd); else if (objectToAdd is FutilePlatformerBaseObject) collisionObjects.Add((FutilePlatformerBaseObject)objectToAdd); if (objectToAdd is Sign) signs.Add((Sign)objectToAdd); if (objectToAdd is Villager) villagers.Add((Villager)objectToAdd); if (objectToAdd is HitSwitch) hitSwitches.Add((HitSwitch)objectToAdd); if (objectToAdd is PushBlock || objectToAdd is Switch) background.AddChild(objectToAdd); else playerLayer.AddChild(objectToAdd); }
public void go(FNode node_,float duration_,float period_,float visibleRatio_) { Cancel(node_); oVisible=node_.isVisible; //Debug.Log("oPosition="+oPosition); curDuration=duration=duration_; period=period_; visibleRatio=visibleRatio_; if (oVisible) { nextToggle=period*visibleRatio; } else { nextToggle=period*(1f-visibleRatio); } pendings.Add(node_,this); if (node==null) { Futile.instance.SignalUpdate+=HandleUpdate; } node=node_; }
public void AddChild(FNode node) { int nodeIndex = _childNodes.IndexOf(node); if(nodeIndex == -1) //add it if it's not a child { node.HandleAddedToContainer(this); _childNodes.Add(node); if(_isOnStage) { node.HandleAddedToStage(); } } else if(nodeIndex != _childNodes.Count-1) //if node is already a child, put it at the top of the children if it's not already { _childNodes.RemoveAt(nodeIndex); _childNodes.Add(node); if(_isOnStage) _stage.HandleQuadsChanged(); } }
public void AddChildAtIndex(FNode node, int newIndex) { int nodeIndex = _childNodes.IndexOf(node); if(newIndex > _childNodes.Count) //if it's past the end, make it at the end { newIndex = _childNodes.Count; } if(nodeIndex == newIndex) return; //if it's already at the right index, just leave it there if(nodeIndex == -1) //add it if it's not a child { node.HandleAddedToContainer(this); _childNodes.Insert(newIndex, node); if(_isOnStage) { node.stage = _stage; node.HandleAddedToStage(); } } else //if node is already a child, move it to the desired index { _childNodes.RemoveAt(nodeIndex); if(nodeIndex < newIndex) { _childNodes.Insert(newIndex-1, node); //gotta subtract 1 to account for it moving in the order } else { _childNodes.Insert(newIndex, node); } if(_isOnStage) _stage.HandleFacetsChanged(); } }
public static void Watch(this IFNodeWatcher watcher, FNode watched) { FNodeWatcherManager.Instance.Subscribe(watcher,watched); }
public void Unsubscribe(IFNodeWatcher watcher,FNode watched) { if (_watchedFNodes.Contains(watched)) { List<IFNodeWatcher> watchers=_watchersByFNode[watched]; watchers.Remove(watcher); if (watchers.Count==0) { _watchersByFNode.Remove(watched); _watchedFNodes.Remove(watched); } } }
public void Subscribe(IFNodeWatcher watcher,FNode watched) { if (!_watchedFNodes.Contains(watched)) { _watchedFNodes.Add(watched); List<IFNodeWatcher> watchers=new List<IFNodeWatcher>(); watchers.Add(watcher); _watchersByFNode.Add(watched,watchers); } else { _watchersByFNode[watched].Add(watcher); } }
// move to an FNode object public void moveTo(FNode givenObject, float time=0.0f) { if (_followObject != null) { _followObject = null; } if (time == 0.0f) { // jump right to the given object x = givenObject.x; y = givenObject.y; } else { // tween to the given point Go.to(this, time, new TweenConfig().floatProp("x", givenObject.x).floatProp("y", givenObject.y).setEaseType(EaseType.QuadInOut)); } }
public void follow(FNode givenObject) { _followObject = givenObject; }
//takes a point in another node and converts it to a point in this node public Vector2 OtherToLocal(FNode otherNode, Vector2 otherVector) { return GlobalToLocal(otherNode.LocalToGlobal(otherVector)); }
private static int ZComparison(FNode a, FNode b) { float delta = a.sortZ - b.sortZ; if(delta < 0) return -1; if(delta > 0) return 1; return 0; }
public void RemoveChild(FNode node) { if(node.container != this) return; //I ain't your daddy node.HandleRemovedFromContainer(); if(_isOnStage) { node.HandleRemovedFromStage(); node.stage = null; } _childNodes.Remove(node); }