public void queueText(HelpText text) { dialogues.Push(text); if (!inUpdate) { updateText(); } }
protected void RopeRotationPointUpdate() { Hook.SetCastTo(GetLocalRotationPoint()); Hook.ForceRaycastUpdate(); if (Hook.IsColliding()) { //add a rotation point float difference = (Hook.GetCollisionPoint() - RotationPoints.Peek()).Length(); if (difference > 1) { Vector2 norm = (Hook.GetGlobalPosition() - Hook.GetCollisionPoint()).Normalized(); norm = new Vector2(norm.y, -norm.x); if (norm.Dot(Hook.GetCollisionNormal()) < 0) { norm *= -1; } RopeNorms.Push(norm); RotationPoints.Push(Hook.GetCollisionPoint()); } } if (RotationPoints.Count > 1 && RopeNorms.Count > 0) { //remove a rotation point if (RopeNorms.Peek().Dot(GetLocalRotationPoint()) < 0) { RotationPoints.Pop(); RopeNorms.Pop(); } } //Update rotation point and rope feedback Hook.SetCastTo(GetLocalRotationPoint()); Hook.ForceRaycastUpdate(); for (int i = 0; i < RotationPoints.Count; i++) { Vector2[] temp = new Vector2[RotationPoints.Count]; RotationPoints.CopyTo(temp, 0); if (Rope.GetPointCount() <= i + 1) { Rope.AddPoint(temp[i] - Hook.GetGlobalPosition()); } else { Rope.SetPointPosition(i + 1, temp[i] - Hook.GetGlobalPosition()); } } for (int i = RotationPoints.Count + 1; i < Rope.GetPointCount(); i++) { Rope.RemovePoint(i); } }
static int Push(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); System.Collections.Generic.Stack <FairyGUI.GComponent> obj = (System.Collections.Generic.Stack <FairyGUI.GComponent>)ToLua.CheckObject <System.Collections.Generic.Stack <FairyGUI.GComponent> >(L, 1); FairyGUI.GComponent arg0 = (FairyGUI.GComponent)ToLua.CheckObject <FairyGUI.GComponent>(L, 2); obj.Push(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public static System.Collections.Generic.Stack <string> Info(System.Collections.Generic.Stack <string> aStack, string newItem, string search) { int sizeStack = aStack.Count; bool containSearch = false; int indexSearch = 0; Console.WriteLine("Number of items: {0}", sizeStack); if (sizeStack == 0) { Console.WriteLine("Stack is empty"); } else { Console.WriteLine("Top item: {0}", aStack.Peek()); } foreach (string item in aStack) { if (item == search) { containSearch = true; break; } indexSearch++; } Console.WriteLine("Stack contains \"{0}\": {1}", search, containSearch? "True": "False"); if (containSearch) { for (var i = 0; i <= indexSearch; i++) { aStack.Pop(); } } aStack.Push(newItem); return(aStack); }
private void Teleport(StateMachine st) { //Get a random starting spot. Location jumpPos = new Location(Random.Range(0, level.Map.GetLength(0)), Random.Range(0, level.Map.GetLength(1))); //Find the nearest free spot. Use depth-first level traversal. System.Collections.Generic.Stack <Location> searchSpace = new System.Collections.Generic.Stack <Location>(); searchSpace.Push(jumpPos); System.Collections.Generic.Dictionary <Location, bool> searchedYet = new System.Collections.Generic.Dictionary <Location, bool>(); searchedYet.Add(jumpPos, true); while (level.Map[jumpPos.X, jumpPos.Y]) { //Use depth-first traversal. jumpPos = searchSpace.Pop(); if (!level.Map[jumpPos.X, jumpPos.Y]) { break; } else { //Add the four adjacent sides in random order. int start = Random.Range(0, 4); Location loc = new Location(); for (int i = 0; i < 4; ++i) { int index = (start + i) % 4; switch (index) { case 0: loc.X = jumpPos.X + 1; loc.Y = jumpPos.Y; break; case 1: loc.X = jumpPos.X - 1; loc.Y = jumpPos.Y; break; case 2: loc.X = jumpPos.X; loc.Y = jumpPos.Y + 1; break; case 3: loc.X = jumpPos.X; loc.Y = jumpPos.Y - 1; break; default: throw new System.NotImplementedException(); } if (loc.X >= 0 && loc.X < level.Map.GetLength(0) && loc.Y >= 0 && loc.Y < level.Map.GetLength(1) && !searchedYet.ContainsKey(loc)) { searchSpace.Push(loc); searchedYet[loc] = true; } } } continue; } st.transform.position = new Vector3(jumpPos.X, jumpPos.Y, st.transform.position.z); }