private void GateActivated(Gate gate) { if (gate.isActivated) { return; } gate.isActivated = true; //Debug.Log(string.Format("Activated door: {0}",gate.name)); this.currentActivationOrder [numberOfGatesActivated] = gate.getId (); this.numberOfGatesActivated++; // If he stepped on every gate at least once if (numberOfGatesActivated == this.currentActivationOrder.Length) { bool wasCorrectOrder = true; for (int i = 0; i < this.Gates.Length; i++) { //if the activation order is not the same as the order he pressed if (this.currentActivationOrder [i] != this.GateOrder [i]) { wasCorrectOrder = false; } this.Gates [i].isActivated = false; } // we have to reset everything because it failed this.currentActivationOrder = new int[Gates.Length]; this.numberOfGatesActivated = 0; if (wasCorrectOrder) { ActivateDoors (); //Debug.Log("Activated!"); } else { foreach (Gate gateToDeactivate in this.Gates) { gateToDeactivate.DeactivateGate (); } //Debug.Log("Not ACtivated"); } } }
override protected void _setOpen(Gate gate, bool open, bool notify) { AndroidJNI.PushLocalFrame(100); using(AndroidJavaClass jniGateStorage = new AndroidJavaClass("com.soomla.levelup.data.GateStorage")) { jniGateStorage.CallStatic("setOpen", gate.ID, open, notify); } AndroidJNI.PopLocalFrame(IntPtr.Zero); }
protected override IEnumerator PlayAttackGateMotion(Gate gate) { yield return new WaitForSeconds(3.5f); if (gate != null) { gate.gameObject.SendMessage("Damage", 10); } }
public ChangeUserText(Gate g, string oldtext, string newtext, SetName snf) { this.g = g; this.oldtext = oldtext; this.newtext = newtext; this.snf = snf; }
void DamageGate(int troopAttackValue, GameElement attackElement, Troop _troop, Gate gateToDamage) { if(gateToDamage.CanDamageGate) { gateToDamage.TakeDamage(troopAttackValue, attackElement); KillTroop(_troop); } }
private static void AttachFromGate(string target, Gate gate) { var wire = Wires.FirstOrDefault(x => x.Name == target); if (wire != null) wire.Input = gate; else Wires.Add(new Wire{ Name = target, Input = gate }); }
override protected bool _isOpen(Gate gate) { bool open = false; AndroidJNI.PushLocalFrame(100); using(AndroidJavaClass jniGateStorage = new AndroidJavaClass("com.soomla.levelup.data.GateStorage")) { open = jniGateStorage.CallStatic<bool>("isOpen", gate.ID); } AndroidJNI.PopLocalFrame(IntPtr.Zero); return open; }
public void OpenClose() { var gate = new Gate (); Assert.IsTrue (!gate.IsOpened); for (int i = 0; i < 3; i++) { gate.Open (); gate.Close (); } Assert.IsTrue (!gate.IsOpened); }
public void LoadParameters(Gate g) { linkTool.enabled = false; SetGate(g); foreach (EditableParameter item in g.Parameters.Values) { item.Init(this); } }
public override GridObject CreateGridObject() { ParkingSpot new_parking_spot_component = (ParkingSpot) base.CreateGridObject(); gate = (Gate) buildingSnap.GetSnapObject(); gate.AddParkingSpot(new_parking_spot_component); new_parking_spot_component.gate = gate; return new_parking_spot_component; }
public Channel(string baseAddress) { _baseAddress = baseAddress; Config = new Config(_baseAddress); Preamp = new Preamp(_baseAddress); Gate = new Gate(_baseAddress); Dyn = new Dyn(_baseAddress); Eq = new Eq4(_baseAddress); Mix = new Mix(_baseAddress); Grp = new Grp(_baseAddress); Automix = new Automix(_baseAddress); }
public void Entered(Gate gate) { if (GateEntered != null) GateEntered(gate); var remaining = Gates.Count(g => !g.HasBeenEntered); World.GameCanvas.SetNumGatesRemaining(remaining); if (remaining > 0) return; World.Game.EndGame(); }
/** Unity-Editor Functions **/ /// <summary> /// Sets the given <c>Gate</c> as open if <c>open</c> is <c>true.</c> /// Otherwise sets as closed. /// </summary> /// <param name="gate">The <c>Gate</c> to open/close.</param> /// <param name="open">If set to <c>true</c> set the <c>Gate</c> to open;</param> /// <param name="notify">If set to <c>true</c> trigger event.</param> protected virtual void _setOpen(Gate gate, bool open, bool notify) { #if UNITY_EDITOR string key = keyGateOpen(gate.ID); if (open) { PlayerPrefs.SetString(key, "yes"); if (notify) { LevelUpEvents.OnGateOpened(gate); } } else { PlayerPrefs.DeleteKey(key); } #endif }
public IEnumerator Intro (Gate gateSpawn) { // Start fx = GameObject.FindObjectOfType<FX>(); voice = GameObject.FindObjectOfType<Voice>(); voice.Cough(); yield return new WaitForSeconds(1f); fx.Match(); yield return new WaitForSeconds(3f); // Update float timeElapsed = 0f; float timeRatio = 0f; float duration = 2f; while (timeElapsed < duration) { timeRatio = timeElapsed / duration; materialTitle.SetFloat("_Alpha", timeRatio); timeElapsed += Time.deltaTime; yield return 0; } yield return new WaitForSeconds(1f); timeElapsed = 0f; while (timeElapsed < duration) { timeRatio = timeElapsed / duration; materialTitle.SetFloat("_Alpha", 1f - timeRatio); timeElapsed += Time.deltaTime; yield return 0; } fx.BookFall(); yield return new WaitForSeconds(1f); StartCoroutine(Goto(gateSpawn)); player.started = true; }
public Flight(Gate _gate, ParkingSpot parking_spot, Runway _runway, int delayBeforeExit, int seperation, int variation, int _minutesToBoarding, int _minutesBoarding, FlightController _flightController) { gate = _gate; parkingSpot = parking_spot; runway = _runway; secondsDelayBeforeExit = delayBeforeExit; secondsSeparation = seperation; secondsVariation = variation; minutesToBoarding = _minutesToBoarding; minutesBoarding = _minutesBoarding; flightController = _flightController; origin = "Sydney"; // need to pull from some sort of database state = STATE_START; }
private static void AttachToGate(IEnumerable<string> wireNames, Gate gate) { foreach (var wireName in wireNames) { if (Wires.Count(x => x.Name == wireName) > 0) gate.Wires.Add(Wires.First(x => x.Name == wireName)); else { ushort hardValue; if (ushort.TryParse(wireName, out hardValue)) { var wire = new EndWire(hardValue); Wires.Add(wire); gate.Wires.Add(wire); } else if (!string.IsNullOrEmpty(wireName)) { var wire = new Wire {Name = wireName}; Wires.Add(wire); gate.Wires.Add(wire); } } } }
/// <summary> /// Constructor. /// </summary> /// <param name="id">ID.</param> /// <param name="gate">Gate to open this <c>Level</c>.</param> /// <param name="innerWorlds">Inner <c>Level</c>s of this <c>Level</c>.</param> /// <param name="scores">Scores of this <c>Level</c>.</param> /// <param name="missions">Missions of this <c>Level</c>.</param> public Level(string id, Gate gate, Dictionary<string, World> innerWorlds, Dictionary<string, Score> scores, List<Mission> missions) : base(id, gate, innerWorlds, scores, missions) { }
/* * Setup passenger after creating a new passenger */ public void SetupPassenger(Flight _flight, Gate _gate) { flight = _flight; gate = _gate; }
private void cancel_connection() { Destroy(dangling_connection.gameObject); dangling_connection = null; selected_gate = null; }
public override ConsoleControl FindControlByAddress(string address) { if (Fader.Address == address) { return(Fader); } else if (Mute.Address == address) { return(Mute); } else if (Link.Address == address) { return(Link); } else if (Pan.Address == address) { return(Pan); } else if (MonoSend.Address == address) { return(MonoSend); } else if (MonoFader.Address == address) { return(MonoFader); } else if (Eq.Address == address) { return(Eq); } else { ConsoleControl c; c = Comp.FindControlByAddress(address); if (c == null) { c = Insert.FindControlByAddress(address); if (c == null) { c = Gate.FindControlByAddress(address); if (c == null) { c = Pre.FindControlByAddress(address); if (c == null) { c = null; // Delay.FindControlByAddress(address); if (c == null) { c = Config.FindControlByAddress(address); if (c == null) { c = Dca.FindControlByAddress(address); if (c == null) { } else { return(c); } } else { return(Config.FindControlByAddress(address)); } } else { return(c); } } else { return(c); } } else { return(c); } } else { return(c); } } else { return(c); } } foreach (var Buss in MixBuss) { if (Buss.Address == address) { return(Buss); } } return(null); }
private long BetWithBanker(long sessionId, long accountId, string accountName, long amount, Gate gate, long banker, string bankerName, out long gateSumary, bool skipDAO = false) { gateSumary = 0; long sumaryBanker = _bankerLocks.Sum(x => x.betAmount); long requireNextLock = amount * GetWinnerMulti(gate); long oddLock = _bets[1].Logs.Sum(x => x.betAmount) * GetWinnerMulti(Gate.Odd) + _bets[2].Logs.Sum(x => x.betAmount) * GetWinnerMulti(Gate.ThreeUp) + _bets[3].Logs.Sum(x => x.betAmount) * GetWinnerMulti(Gate.ThreeDown); long evenLock = _bets[4].Logs.Sum(x => x.betAmount) * GetWinnerMulti(Gate.Even) + _bets[5].Logs.Sum(x => x.betAmount) * GetWinnerMulti(Gate.FourUp) + _bets[6].Logs.Sum(x => x.betAmount) * GetWinnerMulti(Gate.FourDown); if (gate >= Gate.Odd && gate <= Gate.ThreeDown) { oddLock += requireNextLock; } else { evenLock += requireNextLock; } long lockAmount = oddLock > evenLock ? oddLock - sumaryBanker : evenLock - sumaryBanker; long betResult = -99; string money = _moneyType == MoneyType.GOLD ? "Vàng" : "Xu"; if (!skipDAO) { betResult = GameDAO.BetWithBanker(sessionId, accountId, accountName, $"Đặt cửa: {gate.ToString()}, {amount} {money}", amount, (int)_moneyType, banker, lockAmount, bankerName, $"Tạm giữ bổ sung nhà cái: {gate.ToString()}, {amount} {money}"); } else { betResult = 1; } if (betResult >= 0) { _bets[(int)gate].Logs.Add(new BetLog { accountId = accountId, accountName = accountName, betAmount = amount, betGate = gate }); _bankerLocks.Add(new BetLog { accountId = banker, accountName = bankerName, betAmount = lockAmount, betGate = gate }); gateSumary = _bets[(int)gate].Logs.Sum(x => x.betAmount); } return(betResult); }
public override void OnSelectGate(Gate selectedGate) { context.CurrentState = new PutGate(context, selectedGate); }
public void parseLevelFromXML(string fileName) { float worldscale = WorldController.DEFAULT_SCALE; var xml = XDocument.Load(fileName); var height = xml.Root.Element("levelheight").Value; var width = xml.Root.Element("levelwidth").Value; levelHeight = Convert.ToInt32(height); levelWidth = Convert.ToInt32(width); var dragons = from d in xml.Root.Descendants("dragon") select new { X = d.Element("x").Value, Y = d.Element("y").Value }; int temp = 0; foreach (var dragon in dragons) { if (temp == 0) { Dragon playerDragon = new Dragon(dragonTexture, new Vector2((Convert.ToInt32(dragon.X) / worldscale), Convert.ToInt32(dragon.Y) / worldscale), new Vector2(dragonTexture.Width / worldscale, dragonTexture.Height / worldscale), fireBreath); playerDragon.OnFireTexture = dragonOnFireTexture; playerDragon.TurningTexture = dragonTurningTexture; racerList.Add(playerDragon); temp++; } else if (temp == 1) { Dragon playerDragon = new Dragon(enemyTexture1, new Vector2((Convert.ToInt32(dragon.X) / worldscale), Convert.ToInt32(dragon.Y) / worldscale), new Vector2(dragonTexture.Width / worldscale, dragonTexture.Height / worldscale), fireBreath); playerDragon.OnFireTexture = enemy1OnFireTexture; playerDragon.TurningTexture = enemy1TurningTexture; racerList.Add(playerDragon); temp++; } else if (temp == 2) { Dragon playerDragon = new Dragon(enemyTexture2, new Vector2((Convert.ToInt32(dragon.X) / worldscale), Convert.ToInt32(dragon.Y) / worldscale), new Vector2(dragonTexture.Width / worldscale, dragonTexture.Height / worldscale), fireBreath); playerDragon.OnFireTexture = enemy2OnFireTexture; playerDragon.TurningTexture = enemy2TurningTexture; racerList.Add(playerDragon); temp++; } else { Dragon playerDragon = new Dragon(enemyTexture3, new Vector2((Convert.ToInt32(dragon.X) / worldscale), Convert.ToInt32(dragon.Y) / worldscale), new Vector2(dragonTexture.Width / worldscale, dragonTexture.Height / worldscale), fireBreath); playerDragon.OnFireTexture = enemy3OnFireTexture; playerDragon.TurningTexture = enemy3TurningTexture; racerList.Add(playerDragon); temp++; } } var planets = from p in xml.Root.Descendants("planet") select new { Type = p.Element("type").Value, Radius = p.Element("radius").Value, X = p.Element("x").Value, Y = p.Element("y").Value }; foreach (var planet in planets) { PlanetaryObject newPlanet; Vector2 pos = new Vector2(Convert.ToInt32(planet.X) / WorldController.DEFAULT_SCALE, Convert.ToInt32(planet.Y) / WorldController.DEFAULT_SCALE); float radius = Convert.ToSingle(planet.Radius) / WorldController.DEFAULT_SCALE; if (planet.Type == "regular") { newPlanet = new RegularPlanet(regularPlanetTexture, pos, radius); } else if (planet.Type == "gaseous") { newPlanet = new GaseousPlanet(gaseousTexture, pos, radius, flamingTexture, igniteTexture); } else if (planet.Type == "lava") { newPlanet = new LavaPlanet(lavaPlanetTexture, pos, radius); } else { newPlanet = null; } planetList.Add(newPlanet); } var gates = from g in xml.Root.Descendants("gate") select new { Planet1 = g.Element("planet1").Value, Planet2 = g.Element("planet2").Value }; foreach (var gate in gates) { Gate newGate = new Gate(gateTexture, planetList[Convert.ToInt32(gate.Planet1)], planetList[Convert.ToInt32(gate.Planet2)]); gateList.Add(newGate); } IEnumerable <XElement> ais = xml.Root.Descendants("ai"); foreach (XElement ai in ais) { //Debug.Print("ai"); List <Vector2> newAI = new List <Vector2>(); var waypoints = from wp in ai.Descendants("waypoint") select new { x = wp.Element("x").Value, y = wp.Element("y").Value }; foreach (var waypoint in waypoints) { newAI.Add(new Vector2(Convert.ToInt32(waypoint.x), Convert.ToInt32(waypoint.y))); } newAI.Reverse(); aiList.Add(newAI); } var textMessages = from t in xml.Root.Descendants("text") select new { Content = t.Element("content").Value, Start = t.Element("start").Value, End = t.Element("end").Value }; foreach (var textMessage in textMessages) { FloatingText t = new FloatingText(textMessage.Content, Convert.ToInt32(textMessage.Start) / (int)worldscale, Convert.ToInt32(textMessage.End) / (int)worldscale); textList.Add(t); } }
public void ClearCell(CellCoordinates _coordinates, bool _isSwap) { GridObject gridObject = gridManager.GetCell(_coordinates); List <CellCoordinates> neighboursToInformOfDeath = new List <CellCoordinates>(); //Clear Wires if (gridObject != null && gridObject.ObjectType == GridObjectType.Gate) { foreach (CellCoordinates cell in gridObject.Coordinates) { Gate gate = (Gate)gridManager.GetCell(cell); foreach (CellCoordinates inputCoords in gate.Inputs) { GridObject input = gridManager.GetCell(inputCoords); if (input != null) { if (input.ObjectType == GridObjectType.Wire) { Wire wire = (Wire)input; for (uint i = 0; i < gridObject.Coordinates.Length; ++i) { if (gridObject.Coordinates[i] == wire.Exit) { // This wire actually connects to us, destroy it wireVisualManager.ClearWire(inputCoords); break; } } } neighboursToInformOfDeath.Add(inputCoords); } } foreach (CellCoordinates outputCoords in gate.Outputs) { GridObject output = gridManager.GetCell(outputCoords); if (output != null) { if (output.ObjectType == GridObjectType.Wire) { Wire wire = (Wire)output; for (uint i = 0; i < gridObject.Coordinates.Length; ++i) { if (gridObject.Coordinates[i] == wire.Entry) { // This wire actually connects to us, destroy it wireVisualManager.ClearWire(outputCoords); break; } } } else { wireVisualManager.ClearWire(outputCoords); } neighboursToInformOfDeath.Add(outputCoords); } } } } if (gridObject != null) { if (gridObject.ObjectType != GridObjectType.Wire) { if (!_isSwap) { Destroy(placedGridObjects[gridObject]); placedGridObjects.Remove(gridObject); } } wireVisualManager.ClearWire(_coordinates); } gridManager.ClearCell(_coordinates); foreach (CellCoordinates cell in neighboursToInformOfDeath) { UpdateGiblets(cell, false); } }
public void AddGate(GateType _type, CellCoordinates _coordinates, ObjectOrientation _orientation, GameObject _selfGameObject, int _value = 0, bool _isSwap = false) { //Check if an object is already there GridObject gridObject = gridManager.GetCell(_coordinates); if (gridObject != null) { ClearCell(_coordinates, _isSwap); gridObject = null; } switch (_type) { case GateType.Add: { gridObject = new AddGate(_coordinates, _orientation); break; } case GateType.Subtract: { gridObject = new SubtractGate(_coordinates, _orientation); break; } case GateType.Multiply: { gridObject = new MultiplyGate(_coordinates, _orientation); break; } case GateType.Divide: { gridObject = new DivideGate(_coordinates, _orientation); break; } case GateType.IncrementDecrement: { gridObject = new IncrementDecrementGate(_coordinates, _orientation, _value); break; } case GateType.Cross: { gridObject = new CrossGate(_coordinates, _orientation); break; } case GateType.Replicate: { gridObject = new ReplicateGate(_coordinates, _orientation); break; } } gridManager.InsertObject(gridObject); placedGridObjects.Add(gridObject, _selfGameObject); //Create Visual Wire Gate gate = (Gate)gridObject; uint index = 0; foreach (CellCoordinates inputCoords in gate.Inputs) { GridObject inputGridObject = gridManager.GetCell(inputCoords); if (inputGridObject != null) { if (inputGridObject.ObjectType != GridObjectType.Wire) { if (IsConnected(false, inputCoords, gridObject)) { wireVisualManager.CreateWireAndLink(inputCoords, gate.GetCoordinateForInput(index)); } } } index++; } index = 0; foreach (CellCoordinates outputCoords in gate.Outputs) { GridObject outputGridObject = gridManager.GetCell(outputCoords); if (outputGridObject != null) { if (outputGridObject.ObjectType != GridObjectType.Wire) { if (IsConnected(true, outputCoords, gridObject)) { wireVisualManager.CreateWireAndLink(_coordinates, outputCoords); } } } index++; } UpdateGiblets(_coordinates, true); }
public override void OnSelectGate(Gate selectedGate) { context.currentCircuit.PutGate(_row, _col, selectedGate); context.CurrentState = _previousState; }
public bool contains(Gate g) { return(indexOf(g) >= 0); }
public long Bet(long sessionId, long accountId, string accountName, long amount, Gate gate, out long gateSumary, long banker = -1, string bankerName = "", bool skipDAO = false) { if (_roomType == RoomType.FIFTY) { return(BetNornal(sessionId, accountId, accountName, amount, gate, out gateSumary, skipDAO)); } else { return(BetWithBanker(sessionId, accountId, accountName, amount, gate, banker, bankerName, out gateSumary, skipDAO)); } }
private long BetNornal(long sessionId, long accountId, string accountName, long amount, Gate gate, out long gateSumary, bool skipDAO = false) { gateSumary = 0; string money = _moneyType == MoneyType.GOLD ? "Vàng" : "Xu"; long betResult = -99; if (!skipDAO) { betResult = GameDAO.Bet(sessionId, accountId, accountName, $"Đặt cửa: {gate.ToString()}, {amount} {money}", amount, (int)_moneyType); } else { betResult = 1; } if (betResult >= 0) { _bets[(int)gate].Logs.Add(new BetLog { accountId = accountId, accountName = accountName, betAmount = amount, betGate = gate }); gateSumary = _bets[(int)gate].Logs.Sum(x => x.betAmount); } return(betResult); }
public Route(Gate entry) : this(entry, null) { }
public int FindGate(Gate g) { return(g.X + g.Y * W); }
public override string ToString() { this.Init__jsonIgnore(); string json = string.Concat( __jsonIgnore.ContainsKey("Id") ? string.Empty : string.Format(", Id : {0}", Id == null ? "null" : Id.ToString()), __jsonIgnore.ContainsKey("Activeid") ? string.Empty : string.Format(", Activeid : {0}", Activeid == null ? "null" : string.Format("'{0}'", Activeid.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))), __jsonIgnore.ContainsKey("Gate") ? string.Empty : string.Format(", Gate : {0}", Gate == null ? "null" : string.Format("'{0}'", Gate.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))), __jsonIgnore.ContainsKey("Rewarditem") ? string.Empty : string.Format(", Rewarditem : {0}", Rewarditem == null ? "null" : Rewarditem.ToString()), __jsonIgnore.ContainsKey("State") ? string.Empty : string.Format(", State : {0}", State == null ? "null" : State.ToString()), __jsonIgnore.ContainsKey("Tel") ? string.Empty : string.Format(", Tel : {0}", Tel == null ? "null" : string.Format("'{0}'", Tel.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))), __jsonIgnore.ContainsKey("Time") ? string.Empty : string.Format(", Time : {0}", Time == null ? "null" : Time.Value.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds.ToString()), " }"); return(string.Concat("{", json.Substring(1))); }
void Update() { // Reset variables childRigidbody = GetComponentsInChildren <Rigidbody2D>(); furthestBlock = 0; // Check objects for updated position foreach (Rigidbody2D blockade in childRigidbody) { blockade.velocity = new Vector2(0.0f, -speed); if (blockade.position.y > furthestBlock) { furthestBlock = blockade.position.y; } } // Add block if enough space if (furthestBlock <= lastBlockade) { // Ensures two blockades of the same type do not repeat do { tempSelector = Random.Range(0, blockades.Length); } while (tempSelector == blockadeSelector); blockadeSelector = tempSelector; // Adds gate if Blockade is type sides if (blockadeSelector == 1) { int genGate = Random.Range(0, 10); if (genGate <= 3) { // Generate Gate GameObject newGate = Instantiate(gates[genGate], generationPoint, Quaternion.identity, parentObject); newGate.AddComponent <Gate>(); Gate tempGate = newGate.GetComponent <Gate>(); switch (genGate) { case 0: gateKeyShape = "triangle"; break; case 1: gateKeyShape = "square"; break; case 2: gateKeyShape = "hexagon"; break; case 3: gateKeyShape = "circle"; break; } tempGate.SetGateKey(gateKeyShape); // Generate Platform GameObject newPlatform = Instantiate(blockades[blockadeSelector], generationPoint, Quaternion.identity, parentObject); newPlatform.AddComponent <BlockController>(); newPlatform.tag = "block"; } else { // Generate Platform GameObject newPlatform = Instantiate(blockades[blockadeSelector], generationPoint, Quaternion.identity, parentObject); newPlatform.AddComponent <BlockController>(); newPlatform.tag = "block"; } } else { // Generate Platform GameObject newPlatform = Instantiate(blockades[blockadeSelector], generationPoint, Quaternion.identity, parentObject); newPlatform.AddComponent <BlockController>(); newPlatform.tag = "block"; } } // Update speed variable if (speed <= MAX_SPEED && gameIsRunning == true) { speed += speedIncrement; } if (lastBlockade >= minBlockadeGenPoint) { lastBlockade -= bloackadeGenPtIncrement; } }
public XorGate(GateContext context, Gate leftInputGate, Gate rightInputGate) : base(context) { _leftInputGate = leftInputGate; _rightInputGate = rightInputGate; }
private void PassThroughCell(CellCoordinates _cell) { if (m_passedThrough.Peek() != _cell) { CellCoordinates head = m_passedThrough.Pop(); if (_cell != head && IsAdjacentTo(_cell, head)) { // Wait till we move, and only consider if it is adjacent if (m_passedThrough.Count >= 1) { CellCoordinates prev = m_passedThrough.Pop(); if (_cell == prev) { // Early out if we went backwards Log("WireManager: Going backwards to " + _cell.ToString()); m_passedThrough.Push(prev); return; } m_passedThrough.Push(prev); } else { // This is the first move, assert that we head onto a valid OUTPUT of our starting gate GridObject gridObject = m_gridManager.GetCell(head); switch (gridObject.ObjectType) { case GridObjectType.Input: { InputCell input = (InputCell)gridObject; if (input.Exit != _cell) { m_passedThrough.Push(head); // Put the head back on and early out, this is not the exit cell return; } break; } case GridObjectType.Gate: { Gate gate = (Gate)gridObject; bool isValid = false; foreach (CellCoordinates output in gate.Outputs) { if (output == _cell) { isValid = true; } } if (!isValid) { m_passedThrough.Push(head); // We are not over any valid output cell, put the head back on and early out return; } break; } default: { Debug.LogError("WireManager: PassThrough found starting position that wasn't a Gate or Input."); m_passedThrough.Push(head); // Put the head back on and early out return; } } } m_passedThrough.Push(head); // Put the head back on, moving forwards GridObject headObject = m_gridManager.GetCell(head); if ((m_passedThrough.Count == 1 || headObject == null || (headObject.ObjectType != GridObjectType.Gate && headObject.ObjectType != GridObjectType.Output)) && !m_passedThrough.Contains(_cell)) { // Check we haven't been here before on this path, and that we haven't already arrived at a destination GridObject cellObject = m_gridManager.GetCell(_cell); if (cellObject == null) { // Cell is unoccupied, add it Log("WireManager: Passing through " + _cell.ToString()); m_passedThrough.Push(_cell); } else { // Need to check it's a valid goal and we arrived in an acceptable way switch (cellObject.ObjectType) { case GridObjectType.Gate: { Gate gate = (Gate)cellObject; bool isValid = false; foreach (CellCoordinates input in gate.Inputs) { if (input == head) { isValid = true; break; } } if (isValid) { // Head lines up with an input for this gate so add Gate as end point Log("WireManager: Passing through " + _cell.ToString()); m_passedThrough.Push(_cell); } else { return; } break; } case GridObjectType.Output: { OutputCell output = (OutputCell)cellObject; if (output.Entry == head) { // Entry of Output lines up with head, so add Output as end point Log("WireManager: Passing through " + _cell.ToString()); m_passedThrough.Push(_cell); } else { ; return; } break; } default: { return; } } } } return; } m_passedThrough.Push(head); // Put the head back on, no new additions } }
public WithGateSpriteBody(ActorInitializer init, WithGateSpriteBodyInfo info) : base(init, info, () => 0) { gateInfo = info; gate = init.Self.Trait <Gate>(); }
private CodeLabel AddCodeLabel(int stage, IGate g, bool makelabels) { CodeLabel label; var e = g; var labelkey = GetCodeLabelIdentifier(stage, g); if (makelabels) { e = MakeCodeLabels(stage, e); e = Gate.Simplify(e); } if (!_labels.ContainsKey(labelkey)) { // not found in table ... if (null != OnBeforeAddLabel) { // client may do something about it var r = OnBeforeAddLabel(stage, e); if (r != e) { if (_gatemap.TryGetValue(r.ID, out label)) { return(label); } else { throw new Exception("unexpected, gate not found."); } } } } if (!_labels.TryGetValue(labelkey, out label)) { if (null == label) { // construct a new label var labelindex = _lseed++; //var name = "u_" + stage + "_" + labelindex; var name = "_c" + labelindex; var newlabel = new CodeLabel(this, stage, labelindex, name, e); // Gate.TraceLabel(g, newlabel.Gate, stage + " create {0} ...", newlabel); // look for a reduced label. var r = newlabel.Gate; var lg = newlabel.Gate as LabelGate; if (null == lg) { var derivedkey = GetCodeLabelIdentifier(stage, r); if (!_labels.TryGetValue(derivedkey, out label)) { _labels[derivedkey] = newlabel; Gate.TraceLabel(g, newlabel.Gate, stage + " insert <" + derivedkey + ">"); AddToGateMap(r, label); } else { // forget newlabel = null; } } else { } if (null != newlabel) { label = newlabel; _labels[labelkey] = label; AddToGateMap(label.Gate, label); Gate.TraceLabel(g, newlabel.Gate, stage + " insert <" + labelkey + ">"); } AddToGateMap(e, label); } } AddToGateMap(g, label); return(label); }
override protected bool _isOpen(Gate gate) { return gateStorage_IsOpen(gate.ID); }
public void Add(Gate gate) { gate.Manager = this; gates.Add(gate); }
static Gate fetchGate(string gateId, Gate targetGate) { if (targetGate == null) { return null; } if ((targetGate != null) && (targetGate.ID == gateId)) { return targetGate; } Gate result = null; GatesList gatesList = targetGate as GatesList; if (gatesList != null) { for (int i = 0; i < gatesList.Count; i++) { result = fetchGate(gateId, gatesList[i]); if (result != null) { return result; } } } return result; }
/// <summary> /// Removes the given gate from this gateslist. /// </summary> /// <param name="gate">Gate to remove.</param> public void Remove(Gate gate) { Gates.Remove(gate); gate.OnDetached(); }
public Route(Gate entry, Gate exit) : base() { this.Entry = entry; this.Exit = exit; }
public void UpdateGiblets(CellCoordinates _coordinates, bool _updateNeighbour = false) { GridObject gridObject = gridManager.GetCell(_coordinates); if (gridObject != null && gridObject.ObjectType == GridObjectType.Gate) { foreach (CellCoordinates coords in gridObject.Coordinates) { Gate gate = (Gate)gridManager.GetCell(coords); int count = 1; foreach (CellCoordinates inputCoords in gate.Inputs) { if (IsConnected(false, inputCoords, gridObject)) { //Hide Giblets placedGridObjects[gridObject].transform.Find("InConnector_" + count).gameObject.SetActive(false); if (_updateNeighbour) { // Neighbour is gate so update their giblets too UpdateGiblets(inputCoords); } } else { // Show giblets placedGridObjects[gridObject].transform.Find("InConnector_" + count).gameObject.SetActive(true); } count++; } count = 1; foreach (CellCoordinates outputCoords in gate.Outputs) { if (IsConnected(true, outputCoords, gridObject)) { //Hide Giblets placedGridObjects[gridObject].transform.Find("OutConnector_" + count).gameObject.SetActive(false); if (_updateNeighbour) { // Neighbour is gate so update their giblets too UpdateGiblets(outputCoords); } } else { placedGridObjects[gridObject].transform.Find("OutConnector_" + count).gameObject.SetActive(true); } count++; } } //Create Visual Wire { Gate gate = (Gate)gridObject; uint index = 0; foreach (CellCoordinates inputCoords in gate.Inputs) { GridObject inputGridObject = gridManager.GetCell(inputCoords); if (inputGridObject != null) { if (inputGridObject.ObjectType != GridObjectType.Wire) { if (IsConnected(false, inputCoords, gridObject)) { wireVisualManager.CreateWireAndLink(inputCoords, gate.GetCoordinateForInput(index)); } } } index++; } index = 0; foreach (CellCoordinates outputCoords in gate.Outputs) { GridObject outputGridObject = gridManager.GetCell(outputCoords); if (outputGridObject != null) { if (outputGridObject.ObjectType != GridObjectType.Wire) { if (IsConnected(true, outputCoords, gridObject)) { wireVisualManager.CreateWireAndLink(_coordinates, outputCoords); } } } index++; } } } }
/// <summary> /// Constructor for GatesList with one gate. /// </summary> /// <param name="id">ID.</param> /// <param name="singleGate">Single gate in this gateslist.</param> public GatesList(string id, Gate singleGate) : base(id) { Add(singleGate); }
public AddGate(GateInkCanvas gc, Gate gate) : base(gate, gc) { }
private bool IsConnected(bool _isOutput, CellCoordinates _coords, GridObject _startObject) { //Check Us GridObject gridObject = gridManager.GetCell(_coords); if (gridObject != null) { switch (gridObject.ObjectType) { case GridObjectType.Wire: { Wire wire = (Wire)gridObject; for (uint i = 0; i < _startObject.Coordinates.Length; ++i) { CellCoordinates toCompare = _isOutput ? wire.Entry : wire.Exit; if (_startObject.Coordinates[i] == toCompare) { return(true); } } break; } case GridObjectType.Input: { InputCell cell = (InputCell)gridObject; for (uint i = 0; i < _startObject.Coordinates.Length; ++i) { if (_startObject.Coordinates[i] == cell.Exit) { if (_startObject.ObjectType == GridObjectType.Gate) { Gate usAsGate = (Gate)gridManager.GetCell(_startObject.Coordinates[i]); foreach (CellCoordinates input in usAsGate.Inputs) { if (input == _coords) { return(true); } } } else { return(true); } } } break; } case GridObjectType.Output: { OutputCell cell = (OutputCell)gridObject; for (uint i = 0; i < _startObject.Coordinates.Length; ++i) { if (_startObject.Coordinates[i] == cell.Entry) { if (_startObject.ObjectType == GridObjectType.Gate) { Gate usAsGate = (Gate)gridManager.GetCell(_startObject.Coordinates[i]); foreach (CellCoordinates output in usAsGate.Outputs) { if (output == _coords) { return(true); } } } else { return(true); } } } break; } case GridObjectType.Gate: { Gate gateCell = (Gate)gridObject; for (uint i = 0; i < _startObject.Coordinates.Length; ++i) { for (uint j = 0; j < (_isOutput? gateCell.Inputs.Length : gateCell.Outputs.Length); ++j) { CellCoordinates[] toCompare = _isOutput ? gateCell.Inputs : gateCell.Outputs; if (_startObject.Coordinates[i] == toCompare[j]) { return(true); } } } break; } } } return(false); }
/// <summary> /// Adds the given gate to this gateslist. /// </summary> /// <param name="gate">Gate to add.</param> public void Add(Gate gate) { gate.OnAttached(); Gates.Add(gate); }
public void Construct(Builder builder, Level level, Vector3 root, Gate gate) { builder.BuildLevel(level, root, gate); }
/// <summary> /// Opens this gateslist if the gate-opened event causes the GatesList composite criteria to be met. /// </summary> /// <param name="gate">Gate that was opened.</param> private void onGateOpened(Gate gate) { if(Gates.Contains(gate)) { if (CanOpen()) { ForceOpen(true); } } }
public void Init(Gate targetGate, Character player) { TargetGate = targetGate; TargetSlote = targetGate.GetSlote(); _player = player; }
override protected void _setOpen(Gate gate, bool open, bool notify) { gateStorage_SetOpen(gate.ID, open, notify); }
protected GateState(Gate gate) { Gate = gate; }
//obstacleSprites[Random.Range(0, obstacleSprites.Length)] //Mini game parameters void Awake() { if (controller == null) { controller = this; DontDestroyOnLoad(gameObject); } else if (controller != this) { Destroy(gameObject); } Day = 1; CurrentWaterLevel = 2; TotalWaterLevel = STARTING_WATER_LEVEL; Population = STARTING_POPULATION; waterSlider = torchWaterPanel.GetComponentInChildren<Slider>(); waterSlider.gameObject.SetActive(false); torchPanel = torchWaterPanel.GetComponentInChildren<HorizontalLayoutGroup>().gameObject; player = GameObject.FindGameObjectWithTag("Player").GetComponent<Player>(); gate = GameObject.FindGameObjectWithTag("Gate").GetComponent<Gate>(); monkeys = new List<Enemy>(); obstacles = new List<Obstacle>(); GameObject monkeyPrefab = Resources.Load<GameObject>("Prefabs/Enemy"); for (int i = 0; i < spawnLocations.Length; i++) { monkeys.Add((Instantiate(monkeyPrefab, spawnLocations[i].position, Quaternion.identity) as GameObject).GetComponent<Enemy>()); monkeys[i].gameObject.SetActive(false); monkeys[i].gameObject.name = "Monkey" + i; //monkeys[i].transform.SetParent(transform); } obstacleSprites = Resources.LoadAll<Sprite>("Sprites/Obstacles"); GameObject obstaclePrefab = Resources.Load<GameObject>("Prefabs/Obstacle"); for (int i = 0; i < obstacleSpawnLocations.Length; i++) { obstacles.Add((Instantiate(obstaclePrefab, obstacleSpawnLocations[i].position, Quaternion.identity) as GameObject).GetComponent<Obstacle>()); obstacles[i].gameObject.SetActive(false); obstacles[i].gameObject.name = "Obstacle" + i; } SpawnMonkeys(); SpawnObstacles(); }
private int getGateIdByName(string prm_gateName) { Gate gate = db.Gates.Where(gt => gt.Name == prm_gateName).First(); return(gate.Id); }
/* * Set gate to exit gate, then leave airplane through airplane exit path */ public void ExitAirplane(Vector2[] exitPath, Gate _gate) { Setup(); gate = _gate; steering.Visit(exitPath); finalDestination = steering.GetFinalDestination(); state = STATE_AIRPLANE_EXITING; }
public void CreateGate(Gate gate) { _gateRepository.Add(gate); SaveGate(); }
// ----------------------------------- outgoing ----------------------------------- /* * Create flight connection and wait until Flight tell spassenger to leave airplane */ public void SpawnAndWait(Flight _flight, Gate _gate) { SetupPassenger(_flight, _gate); state = STATE_AIRPLANE_WAITING; }
public void UpdateGate(Gate gate) { _gateRepository.Update(gate); SaveGate(); }
public override void Visit(Gate pred) { Visit(pred.Match); }
/// <summary> /// Computes each source and propogates down wires from sources (breadth-first search), /// computing all gates found along the way. /// </summary> public static void PropagateBits(BoardState state, Queue <Gate> sources) { //Debug.WriteLine("propogated"); //Copy sources into currentGates Queue <Gate> gateQueue = new Queue <Gate>(sources); #if DEBUG gateQueue.Enqueue(null); #endif //All gates which have been visited at least once HashSet <Gate> visitedGates = new HashSet <Gate>(); //All wires which have been visited at least once HashSet <WireLine> visitedWires = new HashSet <WireLine>(); //All input gatePins which have been visited at least once HashSet <GatePin> visitedInputs = new HashSet <GatePin>(); //Stores the last 25% of circuit objects which have been visited //This is used if there is an overflow and the propogator is stuck oscillating //All objects contained here will have their values set to ERROR WrappingArray <DrawableObject> updatedObjects = new WrappingArray <DrawableObject>(GlobalSettings.PropogationRepetitionOverflow / 4); //Each iteration represents one propogation for (int i = 0; gateQueue.Count != 0; i++) { Gate currentGate = gateQueue.Dequeue(); #if DEBUG if (currentGate == null) { DebugStep?.Invoke(); if (!(gateQueue.Count == 0)) { gateQueue.Enqueue(null); } continue; } #endif currentGate.ComputeGate(); visitedGates.Add(currentGate); foreach (GatePin output in currentGate.Outputs) { PropagateDownWire(output.StartPoint, output.Values, state, gateQueue, visitedInputs, visitedWires, updatedObjects); } //infinite oscillation catch: if (i > GlobalSettings.PropogationRepetitionOverflow) { foreach (DrawableObject boardObject in updatedObjects) { if (boardObject is WireLine wire) { wire.Values = wire.Values.Select((_) => BitValue.Error); } } Debug.WriteLine("Infinite oscillation caught!"); break; } } //Set unvisited wires to Nothing foreach (WireLine wire in state.Wires.Where((wire) => !visitedWires.Contains(wire))) { wire.Values = wire.Values.Select((_) => BitValue.Nothing); } //Sets unvisited pins to Nothing foreach (GatePin pin in state.Gates.SelectMany((gate) => gate.Inputs).Where((pin) => !visitedInputs.Contains(pin))) { pin.Values = pin.Values.Select((_) => BitValue.Nothing); } }